//javascript sheet



emai = /^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i
								function ValidationCheck() {
									
										
										
										
									if (document.send_ebook.f_name.value=="" || document.send_ebook.f_name.value=="First name..."){
												alert("Please enter your first name");
												return false;
										}
										
										if (document.send_ebook.l_name.value=="" || document.send_ebook.l_name.value=="Last name..."){
												alert("Please enter your last name");
												return false;
										}
										
										
									
									if (!emai.test(document.send_ebook.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;
										}
										
										
										
								return true;
								}
				   

				   
		
				   
				   

			

/* DROPDOWN FOR IE6 */
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);







/*************************  HIGHLIGHTING CURRENT PAGE  **************************/
$(document).ready(function() {
	
	var theFields  = '#f_name,#l_name,#email,#tel';//list the fields to use
		
		  			
			//store the original values
			var fields = theFields.split(',');
						//loop to get the values
					for (i=0;i<fields.length;i++)
					{
					
								fields[i] = new Array(fields[i],$(fields[i]).val())
					
					}



  //clear the original value on focus
		  //$(theFields).one("focus", function() {
		 
		  $(theFields).focus(function() {
  			$(this).val("");
			});	
			



				//now restore the original value if necessary
				$(theFields).blur(function () { 
					 
					 //get the original value
					 		for (i=0;i<fields.length;i++)
							{
							
									if (fields[i][0] == '#'+$(this).attr('id'))
									{
									
											if ($(this).val() =='')
											{
												$(fields[i][0]).val(fields[i][1])
											}
									}
							
							}
					 
					 
				 });
	
	/*
			var theFields  = '#f_name,#l_name,#email';//list the fields to use
		
		  //clear the original value on focus
		  $(theFields).focus(function() {
  			$(this).val("");
			});	
			
			//store the original values
			var fields = theFields.split(',');
						//loop to get the values
					for (i=0;i<fields.length;i++)
					{
					
								fields[i] = new Array(fields[i],$(fields[i]).val())
					
					}


				//now restore the original value if necessary
				$(theFields).blur(function () { 
					 
					 
					 //if the field the user is leaving is left blank
					 if ($(this).val() == '')
					 {
					 //get the original value
					 		for (i=0;i<fields.length;i++)
							{
							
									if (fields[i][0] == '#'+$(this).attr('id'))
									{
									
											$(fields[i][0]).val(fields[i][1])
									
									}
							
							}
					 
					 }//end of field blank
				 });

						   
*/

	$("#nav li ul").hover(
  function () {
	  $(this).prev().addClass('nav_on');
	 
	  }, 
  function () {
	 	$(this).prev().removeClass('nav_on');
	
	  }
	);
					   
						   
						   
						   
						   

//$('.more_link').hide();

			/**********************************************************************************************/
			
			/*   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
		$('#nav li a').each(function(index) {
   				
						if ($(this).attr('href')== href)
						{
									
									$(this).addClass('nav_on');
									$(this).parent().addClass('nav_li_on');
						}//end if
							
	  			});//end loop
		
		




		
					
});









// DROPDOWN
/*
$(document).ready(function() {
	

	function megaHoverOver(){
		$(this).find(".sub").stop().fadeTo('fast', 1).show();
			
		//Calculate width of all ul's
		(function($) { 
			jQuery.fn.calcSubWidth = function() {
				rowWidth = 0;
				//Calculate row
				$(this).find("ul").each(function() {					
					rowWidth += $(this).width(); 
				});	
			};
		})(jQuery); 
		
		if ( $(this).find(".row").length > 0 ) { //If row exists...
			var biggestRow = 0;	
			//Calculate each row
			$(this).find(".row").each(function() {							   
				$(this).calcSubWidth();
				//Find biggest row
				if(rowWidth > biggestRow) {
					biggestRow = rowWidth;
				}
			});
			//Set width
			$(this).find(".sub").css({'width' :biggestRow});
			$(this).find(".row:last").css({'margin':'0'});
			
		} else { //If row does not exist...
			
			$(this).calcSubWidth();
			//Set Width
			$(this).find(".sub").css({'width' : rowWidth});
			
		}
	}
	
	function megaHoverOut(){ 
	  $(this).find(".sub").stop().fadeTo('fast', 0, function() {
		  $(this).hide(); 
	  });
	}


	var config = {    
		 sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)    
		 interval: 70, // number = milliseconds for onMouseOver polling interval    
		 over: megaHoverOver, // function = onMouseOver callback (REQUIRED)    
		 timeout: 250, // number = milliseconds delay before onMouseOut    
		 out: megaHoverOut // function = onMouseOut callback (REQUIRED)    
	};

	$("ul#nav li .sub").css({'opacity':'0'});
	$("ul#nav li").hoverIntent(config);

});

*/


		function closeConf()
		{
			
			
													
													$('#application_confirm').fadeOut('slow');
			
			
			
		}





	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.strCAPTCHA.value==""){
                alert("Please enter a security code");
                return false;
        }
	
		
		
return true;
}











//send the job application
	function sendApp()
	{
		
		
		//validate first
		var errors = '';
		var emai = /^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i;
			if (document.form5.name.value==''){errors = errors + '-Please enter your name\n'}
			if (document.form5.tel.value==''){errors = errors + '-Please enter your phone number\n'}
				if (!emai.test(document.form5.email.value)){errors = errors + '-Please enter a valid email address\n'}
			
			if (document.form5.comment.value==''){errors = errors + '-Please enter a comment\n'}
			if (document.form5.strCAPTCHA.value==''){errors = errors + '-Please enter the security code'}
			
			
			
			if (errors!='')
			{
				alert("The following fields are required:\n\n" + errors)
			}
			else
			{
				
				
				
				//see which button is selected
					var method_contact = 3;
						for (i=0;i<document.form5.method_contact.length;i++)
						{
							
							if (document.form5.method_contact[i].checked){method_contact = document.form5.method_contact[i].value;}
							
							
						}//closes for loop
				
				//cookie
				var cookie = 0;
				if (document.form5.cookie.checked){cookie = 1;}
				
				var copy = 0;
				if (document.form5.copy.checked){copy = 1;}
				
				var removeAtt_2 = 0;
				if (document.form5.removeAtt_2.checked){removeAtt_2 = 1;};
				
				 $('#submit_button').fadeOut('fast');
								   $('#submit_timer').fadeIn('slow');
					//send the detail to be emailed
							$.ajax({
								   
								  
				
						type: "POST",
						url: "ajax/send_app.asp",
						data: {jobId: document.form5.jobId.value,name: document.form5.name.value,tel: document.form5.tel.value,mobile: document.form5.mobile.value,address: document.form5.address.value,email: document.form5.email.value,comment: document.form5.comment.value,method_contact: method_contact, time_contact: document.form5.time_contact.value,cv_upload: document.form5.cv_upload.value,strCAPTCHA: document.form5.strCAPTCHA.value,cookie:cookie,attach:document.form5.attach.value,removeAtt_2:removeAtt_2,copy:copy},
						success: function(dataBack){
												
												var result = parseInt(dataBack.substring(0,1));
												
												
												
												if (result ==0){alert("ERROR: The security code you have entered is incorrect, your application could not be sent\nPlease try again")}
												else if (result ==1){alert('An error occured while sending your application by email\nIf this problem persist please contact the site owner reporting a Jmail error')}
												else {//captcha ok
												
														//for future application pass previously uploaded 
														//$('#past_attach').html(dataBack.substring(1,dataBack.indexOf('*|*')));
														//document.form5.attach.value = dataBack.substring(1,dataBack.indexOf('*|*'));
														
														//clear the upload field
														document.form5.cv_upload.value = '';
														$('#docs_upload').html('');
														
														
														
														//slide down
														
														
														//output confirmation
													var comment = '<br /><p><strong>Confirmation</strong></p><br /><p><strong>Your application has been sent successfully.</strong></p><p><strong>Your application ID is '+dataBack.substring(dataBack.indexOf('*|*')+3,dataBack.length)+'</strong></p><br /><a href="javascript:closeConf()" >Close</a>';
													
																									
													var top = $(window).scrollTop() + 350;
						
				
														window.document.getElementById("application_confirm").style.top = top + 'px';//place the layer
													
													
													
													
													
													$('#application_confirm').html(comment)
													
													$('#application_confirm').fadeIn('slow');
													
													//$('#application_confirm').delay(1000).fadeOut('slow');
													
													applyJob();
														
														
												
												
												
												
												
												}//end of captcha ok
												
												
								   $('#submit_timer').fadeOut('fast');
												$('#submit_button').fadeIn('slow');
												
											},
											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 validation ok
		
		
		
	}







function hideJobs()
{
	
	$('.jobdetail').slideUp('slow');
	
}



//show the job detail

var jobs_open = '';
	
function showDetail(jobId)
{
	
	
		//first hide all open jobs
		$('.jobdetail').slideUp('slow');
		
		//$('#jobdetail_'+jobId+'_row').slideDown('slow');
		
		
	
		if (jobs_open.indexOf('*'+jobId+'*')==-1){
				
			
			jobs_open = jobs_open + '*'+jobId+'*';
			
			

		//now we get the detail
		//alert('jobs');
	
		$.ajax({
				
						type: "GET",
						url: "ajax/job_detail.asp",
						data: {jobId: jobId},
						success: function(dataBack){
							
												//alert('ajax back:' + dataBack)
												$('#jobdetail_'+jobId+'').html(dataBack)
											$('#jobdetail_'+jobId+'').slideDown(700);
												
											},
											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 of if the call is new
		else
		{
			$('#jobdetail_'+jobId+'').slideDown(700);
			
		}

	//alert('we are currently working on the site, this should only take a minute or two, We appologize for the inconveniance'+ jobs_open)
}

var br_open = 0
function applyJob(jobId,job_detail)
{
	//alert('We are currently working on the site.\nThe job application is currently unavailable.\nPlease use the email address listed on all jobs to contact us.');
	
	if (br_open==0)
	{
		
		br_open = 1;
		
		//alert($(window).height())
		
		var h = 750;
		if ($(window).height() < h){h = $(window).height() -50}
		
		$("#applyjob_layer").css('height',h + 'px');
		
		$("#applyjob_layer").slideDown("slow");
		
		if (document.form5.attach.value!='' && document.form5.attach.value!='None')
														{
															
															$('#removeAtt').show();
														}
														else
														{$('#removeAtt').hide();document.form5.removeAtt_2.checked = false;}
		
		//get the detail of the job and display
		//$('#apply_jobdetail').html('<p>You have selected to apply to the position: '+job_detail+', job ID '+jobId+'</p><p>Person to contact: '+document.getElementById('name_contact').innerHTML+'</p>')
		
		
		
		
		
		document.form5.jobId.value = jobId
		
		
		
		
		
		
		
		
		
		
	}
	else
	{
		$("#applyjob_layer").slideUp("slow");
		br_open = 0;
	}
	
		
}//end of function



function removeDocs()
{
	
		if (document.form5.removeAtt_2.checked){alert('The previously uploaded documents will not be shown when submiting your application and will be removed for future applications')}	
	
}


function submitF()
{
	document.job_search.submit();
	
}

