// JS Compilation Effects

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



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.captcha_code.value) == '') {
			document.formdata.captcha_code.value="";
			document.formdata.captcha_code.focus();
			addResponsenew("captcha_code",'Please enter the captcha code');
			return false;
	}
//	var capt =document.formdata.getElementById('captcha_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;
}

// 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() {
	$(".list-tab-links a").each(function(){
		$(this).click(function(){
			id=this.id;
			arr=id.split("_");
			ident=arr[arr.length-1];
			//content=$('#about_content_'+ident).html();
			$('.inner_content_tabpanel').each(function(){
				$(this).show();
			});
			$('.inner_content_tabpanel').each(function(){
				if(this.id!='content_'+ident){
					$(this).hide();
				}else{
					$(this).hide().fadeIn();
				}
			});
		});
	});
});

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

$(function() {
	$(".country_destination_list a").each(function(){
		$(this).click(function(){
			id=this.id;
			arr=id.split("_");
			ident=arr[arr.length-1];
			//content=$('#about_content_'+ident).html();
			$('.topdest_content_panel').each(function(){
				$(this).show();
			});
			$('.topdest_content_panel').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/menu.swf', "flashmenu", 938, 125, "9.0.45", "swf/expressinstall.swf", vars, params );
	swfobject.embedSWF('swf/cavalli-flash-slides.swf', "flashslides", 934, 317, "9.0.45", "swf/expressinstall.swf", vars, params );
}


function cufon_conf() {
	Cufon.set('fontFamily', 'Franklin Gothic Medium Cond')
		 .replace
			('h1')('h2')('div.services_teaser_panel h2')('div.nl-content h2')('div.nl-content p')('a.link3')
			('div.person-contact-details h2')('div.toprightinfo span')('div.foreword_panel h1')('div.foreword_panel p')
			('div.ac_content_panel h3')('div.quickcontactform-panel h2.txtL1')('div.quickcontactform-panel h2.txtL2')
			('div.ls_leftheader_panel h2')('div#lifestyleportfolio-slider h1')('div.ls_innercontent_panel h2')
			('div.fleet_panel ul li a')('div.world_destination_panel h2')('div.top_destination_panel h2')('div.topdest_content_panel h')
			('ul.country_destination_list li a')
			//('h1, h2, div.services_teaser_panel h2, div.nl-content h2, div.nl-content p, a.link3')
		 ;
	Cufon.replace('h1', {fontSize: '20px'});
	Cufon.replace('h2, div.world_destination_panel ul li p', {fontSize: '16px'});
	Cufon.replace('h4', {fontSize: '20px', color: '-linear-gradient(#ffffff, #e2cd88)'});
	Cufon.replace('ul.country_destination_list li a', {fontSize: '14px', hover: {textShadow: '0px 0px #b69015', color: '-linear-gradient(#ffffff, #e2cd88)'}});
	Cufon.replace('div.topdest_content_panel h3', {fontSize: '14px'});
	Cufon.replace('div.world_destination_panel h2, div.top_destination_panel h2', {fontSize: '22px'});
	Cufon.replace('div.fleet_panel ul.fleet-list li a', {fontSize: '16px', hover: {textShadow: '0px 0px #b69015', color: '-linear-gradient(#ffffff, #e2cd88)'}});
	Cufon.replace('div.ls_innercontent_panel h2', {fontSize: '20px'});
	Cufon.replace('div#lifestyleportfolio-slider h1', {fontSize: '24px'});
	Cufon.replace('div.ls_leftheader_panel h2', {fontSize: '22px'});
	Cufon.replace('div.ac_content_tabpanel ul li a', {fontSize: '16px', hover: {textShadow: '0px 0px #b69015', color: '-linear-gradient(#ffffff, #e2cd88)'}});
	Cufon.replace('div.ac_content_panel h3', {fontSize: '18px'});
	Cufon.replace('div.quickcontactform-panel h2.txtL1', {fontSize: '22px', textShadow: '0px 1px #372b05'});
	Cufon.replace('div.quickcontactform-panel h2.txtL2', {fontSize: '34px', textShadow: '0px 1px #372b05'});
	Cufon.replace('div.person-contact-details h2', {fontSize: '25px'});
	Cufon.replace('div.person-contact-details p', {fontSize: '16px'});
	Cufon.replace('div.toprightinfo span', {fontSize: '13px'});
	Cufon.replace('div.foreword_panel h1', {fontSize: '32px', textShadow: '0px 2px #a47c0f'});
	Cufon.replace('div.foreword_panel p', {fontSize: '16px', textShadow: '0px 2px #a47c0f'});
	Cufon.replace('div.services_teaser_panel h2', {fontSize: '20px'});
	Cufon.replace('div.nl-content h2', {fontSize: '22px', textShadow: '1px 1px #845d02'});
	Cufon.replace('div.nl-content p', {fontSize: '14px', textShadow: '1px 1px #845d02'});
	Cufon.replace('a.link3', {fontSize: '12px', hover: {textShadow: '0px 0px #b69015', color: '-linear-gradient(#ffffff, #e2cd88)'}});
	Cufon.replace('div.mainnavlink ul.menu li', {fontSize:'16px', fontFamily: 'Franklin Gothic Medium Cond', hover: {textShadow: '0px 0px #b69015', color: '-linear-gradient(#ffffff, #e2cd88)'}});
	Cufon.replace('.sub ul li p', {fontSize:'11px', fontFamily: 'Arial'});
}


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

	// Main menu site navigation
	cufon_conf();

	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: 0, // number = milliseconds for onMouseOver polling interval    
		 over: megaHoverOver, // function = onMouseOver callback (REQUIRED)    
		 timeout: 0, // number = milliseconds delay before onMouseOut    
		 out: megaHoverOut // function = onMouseOut callback (REQUIRED)    
	};

	$("ul.menu li .sub").css({'opacity':'0'});
	$("ul.menu li").hoverIntent(config);
	

});	


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






