	var timeout    = 500;
	var closetimer = 0;
	var ddmenuitem = 0;

	function ddmenu_open(){
		ddmenu_canceltimer();
		   ddmenu_close();
		   ddmenuitem = $(this).find('ul').css('visibility', 'visible');
	}

	function ddmenu_close(){
		if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');
	}

	function ddmenu_timer(){
		closetimer = window.setTimeout(ddmenu_close, timeout);
	}

	function ddmenu_canceltimer(){
		if(closetimer){
			window.clearTimeout(closetimer);
		        closetimer = null;
	}}


	 
	
	$(document).ready(function(){
		
		if($("#flag_select").length > 0) {
			$("#flag_select").msDropDown();
		}
		
		$("#latest_news").jCarouselLite({  
			 vertical: true,  
			 visible: 3,
			 auto:500,  
			 speed:4000
		}); 
		
		
		
		$("#footer_content ul").liScroll(); 

		
		$('#latest_news li').css('height','auto');
		$('#footer_content').css('width','960px');
		$('#rss_reader li').css('width','auto');
		
		
		
		
		Cufon.replace('.main_headline_link');
		Cufon.replace('.find_us_link');
		Cufon.replace('#bridgend_tel');
		Cufon.replace('h1');
		Cufon.replace('.contactDetailslink');
		Cufon.replace('.next_page_link');
		
		
		
		
		$('#main_banner').crossSlide({
			  sleep: 8,
			  fade: 1
			}, [
			  { src: '/assets/templates/images/header_images/CorillaGroup_header_1.jpg' },
			  { src: '/assets/templates/images/header_images/CorillaGroup_header_2.jpg'   },
			  { src: '/assets/templates/images/header_images/CorillaGroup_header_3.jpg'  }
			]);

		
		
		
		$('#main_logo_container').pngFix(); 
		$('.main_nav').pngFix();
		$('.main_nav ul li').pngFix();
		$('#footer_content').pngFix();
		//$('#product_nav li a:hover').pngFix();
		$('#title').pngFix();
		$('#find_us_link').pngFix();
		$('#sign_up_title').pngFix();
		

		
		$('.main_nav > li').bind('mouseover', ddmenu_open);
		$('.main_nav > li').bind('mouseout',  ddmenu_timer);
		
		$(".product_details").colorbox({iframe:true, innerWidth:695, innerHeight:517, opacity:0});

		$("#why_corilla_read_more").colorbox({iframe:true, innerWidth:695, innerHeight:517, opacity:0});

		
		$(".enquiry_form").colorbox({iframe:true, innerWidth:695, innerHeight:517, opacity:0});
		
		
		$("#video_still").colorbox({iframe:true, width:"700px", height:"670px", opacity:0});
		
		
		// hide all read more content on pageload , in case JScript is disabled
		$('.read_more_content').hide();
		
		
		$(".read_more_link").click(function() {
			
			var s = $(this).attr("id");
			id = s.replace("read_more_" , "");
			
			$("#read_more_content_" + id).show("blind", { direction: "vertical" }, 750);
			$(this).hide();
		
			return false;
		
		});
		
		$(".close_link").click(function() {
		
			var s = $(this).attr("id");
			id = s.replace("close_link_" , "");
		
			$("#read_more_content_" + id).hide("blind", { direction: "vertical" }, 750);
			setInterval($("#read_more_" + id).show(),750);
		
			return false;
		
		});

		
		
		
		
		
		
		$("#email").keypress(function(event) {
			if (event.keyCode == '13') {
			
				 email = $("#email").val();
				 
				 if(email.length > 0 ) {
			
					//event.preventDefault();

					 $.post('newsletter_append.html', {email:email}, function(data){
					// hide the container DIV for the row we have just deleted
					alert('Thanks , your now on our list to receive our newsletter.');
					});
					
				} else {
				
					alert('Please enter your email address then re-save by hitting the enter key.');
					
				}
				 
				 
			}

		});


		
		$("#products_list a[title]").tooltip({tip:'#show-tooltip-text',offset: [225, 62]}); 
		
		
		$(".main_headline_link").click(function() {
			
			var s = $(this).attr("id");
			id = s.replace("main_headline_link_" , "");
			
			$(".main_headline").hide();
			$("#main_headline" + id).show();
			// remove all classes associated with the container
			$(".main_headline_container").hide();
			$("#main_headline_container_chunk" + id).show();
			
			// hide all other main_content Divs
			$(".main_content_container").hide();
			// reveal the relevant content for the link clicked
			$("#main_content_" + id).show();
			
		});
		
		
		
		
		/*
		$(".main_headline_link").click(function() { 
				
				// set all our links and li's to be unselected
			
			    $(".main_headline_link").css('background-image','');
			    $("#product_nav li").css('border','1px solid #FFFFFF');
			    $("#product_nav li").css('border-right','0');
			    $("#product_nav li").css('width','224px');
			    $("#product_nav li").css('background-color','#FFFFFF');
			
				$(this).css('background-image','url(/assets/templates/images/product_nav_links/product_nav_selected.png)');	
				$(this).css('background-repeat','no-repeat');
				$(this).css('background-position','225px 14px');
				$(this).css('position','absolute');
				$(this).css('width','300px');
				$(this).css('border','0');
				$(this).css('z-index','70');

				$(this).parent().css('border', '1px solid #CCCCCC');
				$(this).parent().css('border-right', '0');
				$(this).parent().css('background-color', '#f2f2f1');
				
				
				
		
		});
		
		*/
		
		
		$('.read_more_link').click(function(){
		
			
		
			var s = $(this).attr("id");
			id = s.replace("read_more_link_" , "");
			
			$(this).hide();
			$("#industries_text_readmore_" + id).show("blind", { direction: "vertical" }, 400);
			
		
			return false;

		
		
		});
		
		
		$('.close_more_link').click(function() {
			
			var s = $(this).attr("id");
			id = s.replace("close_more_link_" , "");
			
			$("#industries_text_readmore_" + id).hide("blind", { direction: "vertical" }, 400);
			$('#read_more_link_' + id).show();
			
			return false;

		});
		
		
		
	});

	document.onclick = ddmenu_close;

