
//alert('lee');

function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

 $(document).ready(function(){
 
 
  var latestpanelpos=0;
  var searchpos = false;
  var latestpos = false;
  var loginstate = false;
 
 function loginshow(){
 
 loginstate = true;
 	
 $('#login_account').animate({
 height: "310", 
 width: "250"
 
  }, 500);
 
 }
 
  function loginhide(){
  
  loginstate = false;
  $('#login_account').animate({
  height: "32", 
  width: "142"       }, 500);
  
  }
  
 
  $("#login_account").click(function(event){
    event.stopPropagation();
   });
   
 
 $("#account_login").click(function(event){
    event.stopPropagation();
   if(loginstate){
  		 loginhide();
   } else {
      loginshow();
   }
 });
 
 
$("body").click
(
  function(e)
  {
    if(e.target.id !== "#login_account")
    {
      loginhide();
    }
  }
);
	 
		//$("#latest_jobs_wrapper").css('top', '-192px');

		 
	
	  
	  $("#latest_arrow_down").click(function(e){
	  e.preventDefault();
	  if(latestpanelpos==-1824){}else{
	  latestpanelpos=latestpanelpos-912;
	  	  
	  $('#latest_frame').animate({
	      top: '-=200px'
	    }, 1000, function() {
	      // Animation complete.
	    });
	  }
	  });
	  
	  $("#latest_arrow_up").click(function(e){
	   e.preventDefault();
	  if(latestpanelpos==0){}else{
	      latestpanelpos=latestpanelpos+912;
	      
	 
	      
	  $('#latest_frame').animate({
	      top: '+=200px'
	    }, 1000, function() {
	      // Animation complete.
	    });
	    }
	  });
	  
	  
	  
	   $("#search_tab").click(function(){
	   		
	   		if (searchpos == false){
	   		searchpos = true;
	   		 loginhide();
	   	   $("#search_tab").css('background', 'url("/images/search-jobs-close.png")');
	   	   		
	   	   		$('#search_banner_wrapper').animate({
	   	   		     marginTop: '0px'
	   	   		  }, 1000, function() {
	   	   		    // Animation complete.
	   	   		  });   		  
	   		  }
	   		  
	   		  else{
	   		  searchpos = false;
	   		 loginhide();
	   		 $("#search_tab").css('background', 'url("/images/search-jobs-tab.png")');
 	
	   		  $('#search_banner_wrapper').animate({
	   		       marginTop: '-70px'
	   		    }, 1000, function() {
	   		      // Animation complete.
	   		    });   
	   		  	
	   		  }
	   					
	       });
	       
	       
	       $("#latest_tab").click(function(){
	       	   

	       		if (latestpos == false){
	       		latestpos = true;
	       	    $("#latest_tab").css('background', 'url("/images/latest-jobs-close.png")');
	
	       	   		$('#latest_banner_wrapper').animate({
	       	   		     marginTop: '0px'
	       	   		  }, 1000, function() {
	       	   		    // Animation complete.
	       	   		  });   		  
	       		  }
	       		  
	       		  else{
	       		  latestpos = false;
				  $("#latest_tab").css('background', 'url("/images/latest-jobs.png")');
	
	       		  $('#latest_banner_wrapper').animate({
	       		       marginTop: '-200px'
	       		    }, 1000, function() {
	       		      // Animation complete.
	       		    });   
	       		  	
	       		  }
	       					
	           });
  
 });
 
function submitQuickLogin() {
	if (document.getElementById('login_email').value == '') {
		alert('Please enter your email address.'); 
		return false;
	}
	if (document.getElementById('login_password').value == '') {
		alert('Please enter your password.'); 
		return false;
	}
}

function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");
  if (x==c_name)
    {
    return unescape(y);
    }
  }
}

function restrictChars(objInput, objMessage, maxLength){
	
	if (objInput.value.length > maxLength) {
		objInput.value = objInput.value.substring(0, maxLength); 
	} 
	
	objMessage.value = maxLength - objInput.value.length
}
 
 

