var hovertop = 0;
var hoverleft = 0;
var dropcount = 1;
var catcount = 1;
var newsletter_up = 0;

function sideimageset(id){
  imgname = '#leftmenu_'+id;
  hovertop = id;
  mL = $(imgname).css('margin-left');

 if(mL == 0+'px' || mL == 'auto'){
 	 $(imgname).animate({"margin-left": "+=10px"}, 100, function() {});
  }
}


$(document).ready(function(){
	$(".chrismenu1").mouseover(function(event){
		
		menuid = $(this).attr('id')
		menuname = '#' +  $(this).attr('id');
		
		menusplit = menuid.split('_');
		cid = menusplit[1];
		
		dropname = '#dropdown_'+cid;
		
		pos1 = $(menuname).offset();
		pos1_width = $(dropname).width();
		
		rightpos = pos1.left + pos1_width;
		cutoffpoint = $(window).width() + $(window).scrollLeft()
		newpos = cutoffpoint - pos1_width - 20;
		
  		if (rightpos > cutoffpoint)
  		{
			
			$('.dropdown').css({ 'margin-left':'0px','display':'none' });
			$(dropname).css({ 'margin-left':newpos+'px'}).css({'display':'block'});	
		
		}
		else
		{
		
			$('.dropdown').css({ 'margin-left':'0px','display':'none' });
			$(dropname).css({ 'margin-left':pos1.left+'px'}).css({'display':'block'});	
		
		}
		
		//$(dropname).css({ 'margin-left':pos1.left+'px'}).fadeIn('slow', function() {});
	});
});

$(document).ready(function(){
	$(".chrismenu1").mouseout(function(event){
		$('.dropdown').mouseenter(function(){}).mouseleave( function(){$('.dropdown').css({ 'margin-left':'0px','display':'none' });});	
		//$('.dropdown').mouseenter(function(){}).mouseleave( function(){$('.dropdown').css({ 'margin-left':'0px' }).fadeOut('slow', function() {});;});	
	});

	$('.topmenu4').mouseover(function(event){
		$('.dropdown').css({ 'margin-left':'0px','display':'none' });
		//$('.dropdown').fadeOut('slow', function() {});
	});
	
	$('.topmenu3').mouseover(function(event){
		$('.dropdown').css({ 'margin-left':'0px','display':'none' });
		//$('.dropdown').fadeOut('slow', function() {});
	});
	
	$('.logoholder').mouseover(function(event){
		$('.dropdown').css({ 'margin-left':'0px','display':'none' });
		//$('.dropdown').fadeOut('slow', function() {});
	});
	
});



function sideimageon(id){

  imgname = '#leftmenu_'+id;
  
  if(hovertop != id){
  	$(imgname).animate({"margin-left": "+=10px"}, 100, function() {});
  }
}

function sideimageoff(id){
    imgname = '#leftmenu_'+id;	
  	if(hovertop != id){
  		$(imgname).animate({"margin-left": "-=10px"}, 200, function() {});
  	}
}

function footerimageover(id){
  imgname = '#img_footer'+id;
  fL = $(imgname).css('margin-top');
 	if(fL >= 45+'px' || fL == 'auto'){
 	 $(imgname).animate({"margin-top": "38px"}, 100, function() {});
  	}	
}

function footerimageout(id){
  imgname = '#img_footer'+id;
 
  fL = $(imgname).css('margin-top');

	if(newsletter_up != 1 || id != 2){
		
		if(fL <= 38+'px' || fL == 'auto'){
	 	 $(imgname).animate({"margin-top": "45px"}, 100, function() {});
	 	}
 	}
}


$(document).ready(function(){
	$(".topmenu2").click(function(event){
		if(!$('#searchbar').is(':visible')){
			$('#searchbar').show("slide", { direction: "up" }, 1000);
			$('.topmenu2').css({'background-image':'url(/images/newimages/search_over.jpg)'  });
			
		}
		else{
			$('#searchbar').hide("slide", { direction: "up" }, 1000);
			$('.topmenu2').css({'background-image':'url(/images/newimages/search_up.jpg)'  });
		}
	});
	
	$(".footer_content_inner2_2").click(function(event){
		if(!$('#newsletter').is(':visible')){
			$('#newsletter').fadeIn("slow");
			$('#newsletter').css({backgroundPosition: '0 45'});
			newsletter_up = 1;
		}
		else{
			$('#newsletter').fadeOut("slow");
			$('#newsletter').css({backgroundPosition: '0 35'});
			newsletter_up = 0;
		}
	});
});


 function SignupNewsletter(){
				
		lemail = $('#newsletter1').val();
		frm = $('#frmSignup')
		
		if(_CF_checkfrmSignup(frm[0]))
		{

	 	
	 	$.ajax(
		 {
			 type: "get",
			 url: "/c4admin/cfc/signup_newsletter.cfc",
			 data: {
			 method: "fncProcessNewsletter",returnFormat: 'json',email:lemail
			 
		 },
					
		 dataType: "json",
			success: function( r ){ 		
				alert('Thank you we have received your request for a newsletter');
				$('#newsletter1').val('Newsletter sign-up...');		
		 },
		 
		 error: function( r, strError ){
		 	//alert(strError)
		 }
				 
		});
	
		}
		else{
			alert('Please provide a valid email address');
			$('#newsletter1').val('Newsletter sign-up...');
		}
}






function dropclick(str){
	
	if(dropcount == 1){
				
		window.location="/index.cfm?seourl="+str;	
		dropcount = 2			
	}
	

	else if(dropcount == 2){
		dropcount = 1;
	}

}




