

/*************************  HIGHLIGHTING CURRENT PAGE  **************************/
$(document).ready(function() {


			/**********************************************************************************************/
			
			/*   ATTENTION, FOR THIS SCRIPT TO WORK YOU MUST SET THE HREF WITHIN THE LINK TO A FULL URL    */
			/*   FOR INSTANCE http://mydomain.com/page1.html AS OPPOSED TO  page1.html                     */
		//set the ID of the menu
			
				//current location
			var href = jQuery(location).attr('href');
		
		//REPEAT THE SCRIPT BELOW IF YOU WANT THIS TO WORK ON SEVERAL MENUS
		$('#top_nav li a').each(function(index) {
   				
						if ($(this).attr('href')== href)
						{
									$(this).addClass('top_nav_on');
									$(this).parent().addClass('top_nav_li_on');
						}//end if
							
	  			});//end loop
		
		
$('.more_link').hide();
		
					
});


/******* CUFON ***********/
Cufon.replace('h1');
Cufon.replace('h2');
Cufon.replace('h3');
Cufon.replace('h4');
Cufon.replace('h5');
Cufon.replace('#tagline', { fontFamily: 'Gotham Narrow Book' });
Cufon.replace('#tagline strong', { fontFamily: 'Gotham Narrow Bold' });
Cufon.replace('.opps_header');
Cufon.replace('.opps_in');
Cufon.replace('#opps_top_header');
Cufon.replace('#opps_top_header_inside');


var greyOpen = 0;
function greyPage()
		{
			
			if (greyOpen==0)
			{
				
				//create the layer and show it
					$("#grey_layer").animate({
						opacity: 0.6,
						width: '100%',
						height: $(document).height()   
					 });
				
				greyOpen = 1;
			}
			else
			{
						$("#grey_layer").animate({
						opacity: 0,
						width: '0px',
						height: '0px'   
					 });
				
				greyOpen = 0;
			}
			
		}//end function	



function hideJobs()
{
	
	$('#full_detail').slideUp('fast');
	
	$('#full_detail_content').html('')
	greyPage();
}



//show the job detail


	
	
	
function showDetail(jobId,action)
{
	
	$('#jobId').val(jobId);
	
	greyPage();
		
		$('#full_detail_content').html('Loading content')
		
		if ($('#attach').val() =='')
		{
			$('#prev_docs').hide();
		}
		
		//now we get the detail
		
	
				$.ajax({
						
								type: "GET",
								url: "ajax/job_detail.asp",
								data: {jobId: jobId},
								success: function(dataBack){
														
														//place the layer
														
														
														var layerH = 700;
														var topM = 150;//top margin
														if ($(window).height()<900)
														{
															
															topM = 50;
														}
														
																if ((layerH + topM + 80) >$(window).height())
																{
																	
																	layerH =$(window).height() - (topM + 80); 
																	
																	
																}
														
														//resize the height if needs be
														
														
														//alert('window height: '+$(window).height() + 'topM: ' + topM + 'layerH: ' + layerH)
														$('#full_detail').css('height',layerH+'px');
														$('#full_detail_content').css('height',(layerH-70)+'px');
														$('#job_apply').css('height',(layerH-70)+'px');
														$('#full_detail').css('top',($(window).scrollTop()+topM)+'px');
														
														//show job name
														$('#job_detail_title').html($('#job_link_'+jobId).html());
														
														
														
														$('#full_detail_content').html(dataBack)
													
												
													$('#full_detail').slideDown(600);
													
													if (action==1)
													{
													
														$('#full_detail_content').hide();
														$('#job_apply').show();
														$('.apply_job_button').html('View job detail');
														$('#button2').show();
														applyOp = 1;
													}
													
													
														
													},
													error: function(x,e){
																		if(x.status==0){
																		alert('You are offline!!\n Please Check Your Network.');
																		}else if(x.status==404){
																		alert('Requested URL not found.');
																		}else if(x.status==500){
																		alert('Internel Server Error.');
																		}else if(e=='parsererror'){
																		alert('Error.\nParsing JSON Request failed.');
																		}else if(e=='timeout'){
																		alert('Request Time out.');
																		}else {
																		alert('Unknow Error.\n'+x.responseText);
																		}
																	}
																			
						
						
						
						});

		//end of Ajax
			

}//end function

var applyOp = 0;

	function applyJob()
	{
		
		if (applyOp==0)
		{
			$('#full_detail_content').slideUp(300);
			$('#job_apply').slideDown(300);
			$('.apply_job_button').html('View job detail');
			$('#button2').show();
			applyOp = 1;
			
			
			
		}
		else
		{
			
			var x = confirm("Are you sure you wish to go back to the job detail without sending your application?\nYou can send your application by scrolling down to the bottom of the contact form.");
					if (x)
					{
						
								$('#job_apply').slideUp(300);
								$('#full_detail_content').slideDown(300);
								$('.apply_job_button').html('Back to the application form');
								applyOp = 0;
									$('#button2').hide();		
					}
			

		}
		
		
	}//end function
	
	
	
	
	
	
	
	
		emai = /^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i
function ValidationCheck2() {
	
		
		
		
	if (document.form5.name.value==""){
                alert("Please enter your name.");
                return false;
        }
		
		if (document.form5.tel.value==""){
                alert("Please enter your phone number");
                return false;
        }
		
		
	
	if (!emai.test(document.form5.email.value)){
	alert("Please enter a valid email address (email addresses contain a '@', no spaces and end with a domain extension such as .ie, .com, .fr....");	
	return false;
        }
		
		if (document.form5.comment.value==""){
                alert("Please enter a comment");
                return false;
        }
		
		if (document.form5.ear_from.value==""){
                alert("Please let us know how you heared from us.");
                return false;
        }
		
		if (document.form5.ear_from.value=="Website" && document.form5.ear_other.value==""){
                alert("Please let us know which website you have seen us on.");
                return false;
        }


		
		if (document.form5.strCAPTCHA.value==""){
                alert("Please type in the verification code");
                return false;
        }
				
		
		
			
			
			
			
			
		
		
return true;
}



		function confirmApp(jobId,enId)
		{
			
			
			$('#confirm_app').css('margin-left','-1400px')
			$('#confirm_app').html('<h4>Confirmation</h4><p>Thank you, your application has been sent out.</p><p>for job ID '+ jobId + ' your application ID is ' + enId + '</p><br /><a href="javascript:closeConf();" id="close_conf_link">Close</a>')
			
			
			
					$('#confirm_app').animate({
					opacity: 1,
					marginLeft: '-150px'
				  }, 300, function() {
					
					
				  });
							
		
		
			
			
			
		}//end function 


	function closeConf()
	{
		
		/*
		$("#confirm_app").animate({
						opacity: 1,
						marginLeft: '800px'
						   
					 });
			*/
		
		$('#confirm_app').animate({
    opacity: 1,
	marginLeft: '800px'
  }, 300, function() {
    
	$('#confirm_app').hide();
  });
		
		
		
		
	}
	

		function sendJob()
		{
		
				if (applyOp ==1)
				{
					
							var x = confirm("Are you sure you wish to leave?\nIt seems to have started on a job application.\nYou can send your application by scrolling down to the bottom of the contact form.");
					if (x)
					{
						
									document.location = 'sendjob.asp?jobId='+$('#jobId').val();	
					}
	
					
					
				}
		
		
			
			
		}


	function submitJ()
	{
		if (ValidationCheck2())
		{
			document.form5.submit();
		}
		
	}//end function
	
	
	
	/******* DROPDOWN ********/
	
	 sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


	function logout()
	{
		
		var x = confirm("Are you sure you wish to logout?");
		
		if (x)
		{
		document.location = 'logout.asp';	
			
		}
		
		
	}
