// JS Compilation Effects

// Form fields validation
function showContent(){
	$('.loading').hide();	
	$('.content').show().css('visibility','visible');
} 

function ValidateQuickInquiry(){
	
	var emailFilter=/^.+@.+\..{2,3}$/;
	$(".validationresponse:visible").hide();

	var fullname = $('#txtFullname').val();
	if (fullname==''){
		addResponse("txtFullname",'Your full name is required');
		return false;
	}
	var txtEmail = $('#txtEmail').val();
	if (txtEmail==''){
		addResponse("txtEmail",'Email address is required');
		return false;
	}
	
	if (!(emailFilter.test(txtEmail))) {
		addResponse("txtEmail",'Please enter a valid email address');
		return false;
	}
	
	var txtBusinessTel = $('#txtBusinessTel').val();
	if (txtBusinessTel==''){
		addResponse("txtBusinessTel",'Your Business Telephone requiredd');
		return false;
	}
	
	var code = $('code').val();
	var c0de = $('code').val();
	

	if (code!=c0de){
		addResponse("code",'Incorrect Code');
		return false;
	}
	
	
	return true;;
}
function validateOnSubmit() {

	var emailFilter=/^.+@.+\..{2,3}$/;
	$(".validationresponse:visible").hide();

	if (jQuery.trim(document.formdata.txtFullname.value) == "") {
		document.formdata.txtFullname.value="";
		document.formdata.txtFullname.focus();
		addResponse("txtFullname",'Your full name is required');
		return false;
	}
	if (jQuery.trim(document.formdata.txtEmail.value) == "") {
		document.formdata.txtEmail.value="";
		document.formdata.txtEmail.focus();
		addResponse("txtEmail",'Email address is required');
		return false;
	}
	if (!(emailFilter.test(document.formdata.txtEmail.value))) {
		document.formdata.txtEmail.focus();
		addResponse("txtEmail",'Please enter a valid email address');
		return false;
	}
	if (jQuery.trim(document.formdata.txtBusinessTel.value) == "") {
		document.formdata.txtBusinessTel.value="";
		document.formdata.txtBusinessTel.focus();
		addResponse("txtBusinessTel",'Your Business Telephone required');
		return false;
	}
	if (jQuery.trim(document.formdata.txtMobile.value) == "") {
		document.formdata.txtMobile.value="";
		document.formdata.txtMobile.focus();
		addResponse("txtMobile",'Your mobile required');
		return false;
	}
	if (jQuery.trim(document.formdata.txtSubject.value) == "") {
		document.formdata.txtSubject.value="";
		document.formdata.txtSubject.focus();
		addResponse("txtSubject",'Subject is required');
		return false;
	}

	if (jQuery.trim(document.formdata.txtMessage.value) == "") {
		document.formdata.txtMessage.value="";
		document.formdata.txtMessage.focus();
		addResponse("txtMessage",'Your message required','textarea');
		return false;
	}



	if(jQuery.trim(document.formdata.code.value) == '') {
			document.formdata.code.value="";
			document.formdata.code.focus();
			addResponsenew("code",'Please enter the captcha code');
			return false;
	}
//	var capt = document.formdata.getElementById('code');


	return true;
}

function isAlphaNumeric(e){
	var unicode=e.charCode? e.charCode : e.keyCode
	if (unicode!=8 && unicode!=13 && unicode!=9){
		str=String.fromCharCode(unicode);
		var re = /^[a-z A-Z]+$/;
		 // validation fails if the input doesn't match the regular expression
		if(!re.test(str)){
			return false;
		}
	}
	return true;
}

function addResponse(name,msg,type) {
	if(type==null) { type="input" }
	$(type+"[name="+name+"]").next(".validationresponse").html(msg);
	$(type+"[name="+name+"]").next(".validationresponse").show('slow');
	return false;
}

function addResponsenew(name,msg){
	$("[name="+name+"]").parent().children(".validationresponse").html(msg);
	$("[name="+name+"]").parent().children(".validationresponse").show('slow');
	return false;
}

function addResponseCustom(id,msg) {
	$("#"+id).html(msg);
	$("#"+id).show('slow');
	return false;
}




function isAlphaNumeric(e){
	var unicode=e.charCode? e.charCode : e.keyCode
	if (unicode!=8 && unicode!=13 && unicode!=9){
		str=String.fromCharCode(unicode);
		var re = /^[a-z A-Z]+$/;
		 // validation fails if the input doesn't match the regular expression
		if(!re.test(str)){
			return false;
		}
	}
	return true;
}

function addResponse(name,msg,type) {
	if(type==null) { type="input" }
	$(type+"[name="+name+"]").next(".validationresponse").html(msg);
	$(type+"[name="+name+"]").next(".validationresponse").show('slow');
	return false;
}

function addResponsenew(name,msg){
	$("[name="+name+"]").parent().children(".validationresponse").html(msg);
	$("[name="+name+"]").parent().children(".validationresponse").show('slow');
	return false;
}

function addResponseCustom(id,msg) {
	$("#"+id).html(msg);
	$("#"+id).show('slow');
	return false;
}

// detect flash browser
function getFlashMovieObject(movieName) { 
	if (window.document[movieName]) { 
		return window.document[movieName]; 
	} 
	if (navigator.appName.indexOf("Microsoft Internet") == -1) { 
		if (document.embeds && document.embeds[movieName]) 
			return document.embeds[movieName]; 
	} 
	else // if (navigator.appName.indexOf("Microsoft Internet")!=-1) 
	{ 
		return document.getElementById(movieName); 
	} 
} 


$(function() {
	$(".prog-list a").each(function(){
		$(this).click(function(){
			id=this.id;
			arr=id.split("_");
			ident=arr[arr.length-1];
			//content=$('#about_content_'+ident).html();
			$('.prog-content').each(function(){
				$(this).show();
			});
			$('.prog-content').each(function(){
				if(this.id!='content_'+ident){
					$(this).hide();
				}else{
					$(this).hide().fadeIn();
				}
			});
		});
	});
});

function cuber_conf() {
  var vars = { xml_location : 'CU3ER-config.xml' };
  var params = { wmode: 'transparent' };
	//swfobject.embedSWF('swf/CU3ER.swf', "cu3er", 938, 287, "9.0.45", "swf/expressinstall.swf", vars, params );
	swfobject.embedSWF('swf/nurai-inside-bg-flash.swf', "bgFlashScr", 1010, 250, "9.0.45", "swf/expressinstall.swf", vars, params );
}


function cufon_conf() {
	Cufon.set('fontFamily', 'Franklin Gothic Medium Cond')
		 .replace
			('h1')('h2')
		 ;
	Cufon.replace('div.menu ul li a', {fontSize: '18px', hover: {textShadow: '0px 0px #a9c696', color: '-linear-gradient(#254025, #254025)'}});
	Cufon.replace('h2.tagline, h2.tagline2, h3', {fontSize: '20px'});
	Cufon.replace('h3', {fontSize: '24px'});
	Cufon.replace('div.about-hf-info h2, span.h2title, div.bmi-calc-form h2, div.boxcontent h2, div.subbody-main h2', {fontSize: '24px'});
	Cufon.replace('div.subbody-rightnav h2, div.prog-text-content h2', {fontSize: '20px'});

//Cufon.replace('ul.country_destination_list li a', {fontSize: '14px', hover: {textShadow: '0px 0px #b69015', color: '-linear-gradient(#ffffff, #e2cd88)'}});
}


// General
$(document).ready(function(){
						   
	var initValue;
	$(':text, :text.inp-text').each(function(){
		$(this).focus(function(){
			initValue = $(this).attr('value');
			$(this).val('');
		});
		$(this).blur(function(){
			if($(this).val() == ''){
				$(this).val(initValue);
			}
		});
	});

	$('select,input,textarea').each(function(){
		$(this).click(function(){
			$(this).addClass('selected');
		});
		$(this).blur(function(){
			$(this).removeClass('selected');
		});
	});


	// Main menu site navigation
	cufon_conf();



});	


window.onload = function(){
	//$('.submenu ul').show();
	showContent();
	//popup('popUpDiv');
}







