var bafheight="";
var cereerheight="";

$(document).ready(function(){
						   
	//MASKER
	
	$(window).bind("resize",function()
	{
		$('.pgecontainer').pgeConCen();					   
	});
	
	$(window).bind("load",function(){
		$('#promotion').PgeMask(function(){
			$('.pgecontainer img').click(function(){
				$(this).PgeUnloadmask();					
			});								 
		});							   
	});
	
	
	//---/
    
	//Top Header Show/Hide function
	maxHeight = 60;
    minHeight = 0;
	minWidth= 0;
	maxWidth =563;
	
	
	
	
	bafheight=$('#friend').height();
	cereerheight=$('#career').height();
	
	$('#career').height(22);
	$('#friend').height(22);
	
	$('#baf_toggle').click(function(){
		if($('#friend').height()==22)
		{
			$('#friend').animate({
				height: bafheight			
			});
		}
		else
		{
			$('#friend').animate({
				height: 22				
			});	
		}
	});
	
	$('#cereers_toggle').click(function(){
		if($('#career').height()==22)
		{
			$('#career').animate({
				height: cereerheight			
			});
		}
		else
		{
			$('#career').animate({
				height: 22				
			});	
		}
	});
	
	
	$('#baf_form').submit(function(){
		$('#baf_result').text("Processing...");
		if(CheckEmail($('#baf_email').val()))
		{
			Femail=$('#baf_email').val();
			$.post("layout/scripts/sndmail.php",{process: "baf", emailaddr: Femail},function(data){
				$('#baf_result').text(data);				  
			});
		}
		else
		{
			$('#baf_result').text("Please enter a valid email address");	
		}
		return false;
	});
	
	$('#career_form').submit(function(){
		if(CheckInps()==4)
		{
			if(CheckEmail($('.tb_format').eq(3).val()))
			{
				i1=$('.tb_format').eq(0).val();
				i2=$('.tb_format').eq(1).val();
				i3=$('.tb_format').eq(2).val();
				i4=$('.tb_format').eq(3).val();
				
				$.post("layout/scripts/sndmail.php",{process: "career", f1: i1, f2: i2, f3: i3, f4: i4},function(data){
					$('#baf_career').text(data);				  
				});
			}
			else
			{
				$('#baf_career').text("Please enter a valid email address");
			}
		}
		else
		{
			$('#baf_career').text("Please fill in all fields");		
		}
		return false;
	});
	
	
	
	
		
		
	
    $("#toggle").click(
      function(){
	  	curHeight = $("#no1").height();
	  	if(curHeight==60)
		{
			$("#no1").animate({height: minHeight+"px"}, { queue:false, duration:400 });
		}
		else
		{
			$("#no1").animate({height: maxHeight+"px"}, { queue:false, duration:400 });
		}
      });
	
    $("#toggle2").click(function () {
      $("#info_hide").slideToggle("slow");
    });
	

	//Cycle plugin
	$('#dispimagebox') .cycle({  
		fx:     'scrollLeft',
		easing: 'easeInOut',
		speed: 1500,
		delay:  -5000,
		timeout:  7000
	});
	
	//Cycle Thumb function
	$('#goto1').click(function() { 
		$('#dispimagebox').cycle(0); 
		return false; 
	}); 
	 
	$('#goto2').click(function() {  
		$('#dispimagebox').cycle(1);  
		return false;  
	}); 
	$('#goto3').click(function() { 
		$('#dispimagebox').cycle(2); 
		return false; 
	}); 
	 
	$('#goto4').click(function() {  
		$('#dispimagebox').cycle(3);  
		return false;  
	});

});

	function addBookmark()
	{
		
		var title="Malcolm John | Le Vacherin";
		var url="http://www.all-sorted.co.uk/malcolmjohn/lavacherin/";
		
		if(window.sidebar)
		{ 
			window.sidebar.addPanel(title, url,""); 
		}
		else if( document.all )
		{
			window.external.AddFavorite( url, title);
		}
		else if( window.opera && window.print )
		{
			return true;
		}
	}




function CheckEmail(inputemail) {
AtPos = inputemail.indexOf("@");
StopPos = inputemail.lastIndexOf(".");

	if (AtPos == -1 || StopPos == -1)
	{
		return false;
	}
	else
	{
		return true;	
	}

}

function CheckInps()
{
	i=0;
	$('.tb_format').each(function(){
		if($(this).val()!="")
		{
			i++;
		}
	});
	return i;
}