// JavaScript Document

$(document).ready(function() {
	
	//external links
	$('a[rel=external]').attr('target', '_blank');
	$('a[rel=external nofollow]').attr('target', '_blank');
													 
	$('.block .full').hide();
	$('.block p.more span').text('Read more');
	$('.block p.more span').click(function() {
			$(this).parent().parent().find('.full').toggle(); // First click should toggle to 'show'
			$(this).text($(this).text() == 'Read more' ? 'Hide' : 'Read more');
      return false;
	});
	
	$('#productListing a.contactbutton').click(function() {
			if ($(this).attr('href').indexOf('?product='+$(this).parent().parent().find('.productListing-data h3.itemTitle').text().replace('\"', '')) < 1) {
					$(this).attr('href',$(this).attr('href') + '?product='+$(this).parent().parent().find('.productListing-data h3.itemTitle').text().replace('\"', ''));
			};
	});
	
	$('#productGeneral a.contactbutton').click(function() {																
			if ($(this).attr('href').indexOf('?product='+$(this).parents('.column-center-background').find('.title_box h1#productName').text().replace('\"', '')) < 1) {
					$(this).attr('href',$(this).attr('href') + '?product='+$(this).parents('.column-center-background').find('.title_box h1#productName').text().replace('\"', ''));
			};
	});
	
	$('#productMainImage a').colorbox({opacity:0.8});
	$('.contactbutton').colorbox({iframe:true, innerWidth:440, innerHeight:430, opacity:0.8});

	$('.user_menu ul li.drop').hover(
		function() { $('ul', this).css('display', 'block'); },
		function() { $('ul', this).css('display', 'none'); }
	);
	
	$('#diagram .hover').hover(
		function() { $('span.desc', this).css('display', 'block'); },
		function() { $('span.desc', this).css('display', 'none'); }
	);
	
	$('#demo-van ul li').hover(
		function () {
			$('#demo-van div.' + $(this).attr('class')).css('display', 'block');
			$('#demo-van #demo-mask').css('height', $('#demo-van #vans').css('height')).css('display', 'block');
			$('#demo-van ul li').css('display', 'none');
			$(this).css('display', 'block');
		},
		function () {
			$('#demo-van div.' + $(this).attr('class')).css('display', 'none');
			$('#demo-van #demo-mask').css('display', 'none');
			$('#demo-van ul li').css('display', 'block');
		}
	);
	
});


