// ***********************************************************************************************************************
// JavaScript website common functions  
// Macromedia function collection  
// ***********************************************************************************************************************

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// ***********************************************************************************************************************
// JavaScript website common functions  
// by striker - email: striker@auskalo.com
// ***********************************************************************************************************************

function centeredWindow(url,name,ancho,alto){
	xpos = ((screen.width)/2)-(ancho/2);
	ypos = ((screen.height)/2)-(alto/2);
	features = 'width='+ancho+',height='+alto+',left='+xpos+',top='+ypos+'directories=0,resizable=0,location=0,status=0,scrollbars=1,toolbar=0,menubar=0,titlebar=0';
	newCenteredWindow = window.open(url,name,features);
}

function mouseOver(src,color) {
 		src.style.cursor = 'hand';
 		src.bgColor = color;
}
	
function mouseOut(src,color) {
		src.style.cursor = 'default';
 		src.bgColor = color;
}

// ***********************************************************************************************************************
// Scroller fuctions
// ***********************************************************************************************************************
function flvS3(v1){//v1.0
var v2=MM_findObj(v1),v3=0,v4=0,v5=0,v6=0;if (!v2){this.x=this.y=this.h=this.w=0;return;}var v7=(document.layers)?v2:v2.style;v3=v7.left;v4=v7.top;if ((v3==""||v4=="")&&document.all&&!window.opera){if (v3==""){v3=v2.offsetLeft;}if (v4==""){v4=v2.offsetTop;}}if (v2.offsetHeight){v5=v2.offsetHeight;v6=v2.offsetWidth;}else if (document.layers){v5=v7.clip.height;v6=v7.clip.width;}this.x=parseInt(v3);this.y=parseInt(v4);this.h=parseInt(v5);this.w=parseInt(v6);}

function flvS8(v1,v2,v3){//v1.0
var v4=(document.layers)?v1:v1.style;var v5=flvS5();eval("v4.left='"+v2+v5+"'");eval("v4.top='"+v3+v5+"'");}
	
function flvS5(){//v1.0
var v1=((parseInt(navigator.appVersion)>4||navigator.userAgent.indexOf("MSIE")>-1)&&(!window.opera))?"px":"";return v1;}
				
function flvXAS1(){
var v1=arguments,v2=v1.length,v3='AutoScrollContainer',v4='AutoScrollContent';var v5=MM_findObj(v3),v6=MM_findObj(v4);if (!v5){return;}if (v5.XAS1!=null){clearTimeout(v5.XAS1);}var v7=(v2>0)?parseInt(v1[0]):1;if (v7){var v8=(v2>1)?parseInt(v1[1]):1,v9=(v2>2)?parseInt(v1[2]):50,v10=(v2>3)?parseInt(v1[3]):1;var v11=new flvS3(v3),v12=new flvS3(v4);var v13=v12.x,v14=v12.y,v15=0,v16=0;if (v10==1){var v17=-1*v12.h;v15=v12.x;if (v14>=v17){v16=v12.y-v8;}else {v16=v11.h;}}else {var v18=-1*v12.w;v16=v12.y;if (v13>=v18){v15=v12.x-v8;}else {v15=v11.w;}}flvS8(v6,v15,v16);v5.XAS1=setTimeout("flvXAS1("+v7+","+v8+","+v9+","+v10+")",v9);}}

// ***********************************************************************************************************************
// General JavaScript customization
// ***********************************************************************************************************************

var colorOver = '#30303F';
var colorOut = '#F7F7F7';

// ***********************************************************************************************************************
// Form check functions
// ***********************************************************************************************************************

/* msg array declaration */
msg = new Array('es','en');
msg['es'] = new Array();
msg['en'] = new Array();

/* array values */
msg['es'][0] = 'Por favor, introduzca un criterio de búsqueda';
msg['en'][0] = 'Please, enter a word or phrase to perform the search';

msg['es'][1] = 'Por favor, escriba su nombre';
msg['en'][1] = 'Please, write your name';

msg['es'][2] = 'Por favor, escriba el nombre del destinatario';
msg['en'][2] = 'Please, write the name of the addressee';

msg['es'][3] = 'Por favor, introduzca una dirección de email válida';
msg['en'][3] = 'Please, enter a valid email address';

msg['es'][4] = 'Por favor, introduzca su identificador de cliente';
msg['en'][4] = 'Please, enter your client id';

msg['es'][5] = 'Por favor, introduzca una descripción breve de sus necesidades';
msg['en'][5] = 'Please, enter a short description of your needs';

msg['es'][6] = 'Por favor, introduzca sus apellidos';
msg['en'][6] = 'Please, enter your secondname';

msg['es'][7] = 'Por favor, introduzca un telefono de contacto';
msg['en'][7] = 'Please, enter contact phone number';

msg['es'][8] = 'Por favor, introduzca en nombre de su ciudad';
msg['en'][8] = 'Please, enter your city name';

msg['es'][9] = 'Por favor, introduzca su código postal';
msg['en'][9] = 'Please, enter your zip code';

msg['es'][10] = 'Por favor, introduzca su país';
msg['en'][10] = 'Please, enter your country';

msg['es'][11] = 'Por favor, introduzca un breve comentario';
msg['en'][11] = 'Please, enter a short comment';

msg['es'][12] = 'Por favor, introduzca su país de origen';
msg['en'][12] = 'Please, enter your country';

// form functions
function checkEmail(str) { 
	var at="@";
	var dot="."; 
	var lat=str.indexOf(at); 
	var lstr=str.length;
	var ldot=str.indexOf(dot);	
	if (str.indexOf(at)==-1){ return(false) }
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){ return(false) }
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){ return(false) } 
	if (str.indexOf(at,(lat+1))!=-1){ return(false) }
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){ return(false) }
	if (str.indexOf(dot,(lat+2))==-1){ return(false) }
	if (str.indexOf(" ")!=-1){ return false }
	return true 
}


function checkTopSearchForm($form, $lang){	
	if ($form.search.value == null || $form.search.value == ""){
		alert(msg[$lang][0]);
		return(false);
	}
	return(true);
}

function checkAccommodationCheckboxes($num, $all){
	$form = document.form;
	if ($all == true){
		for ($i=1; $i<=$num; $i++){
			$checkbox = eval('$form.accommodation' + $i);
			$checkbox.checked = false;
		} 
	} else {
		$form.accommodation0.checked = false; 
	}	
	return(false);
}

function checkActivitiesCheckboxes($num, $all){
	$form = document.form;
	if ($all == true){
		for ($i=1; $i<$num; $i++){
			$checkbox = eval('$form.activity' + $i);
			$checkbox.checked = false;
		} 
	} else {
		$form.activity0.checked = false; 
	}	
	return(false);
}

function checkRecommend($form, $lang){
	if ($form.senderName.value == "" || $form.senderName.value == null){
		alert(msg[$lang][1]);
		return(false);
	}
	if ($form.name.value == "" || $form.name.value == null){
		alert(msg[$lang][2]);
		return(false);
	}
	if (checkEmail($form.email.value) == false){
		alert(msg[$lang][3]);
		return(false);		
	}
	return(true);
}

function checkTourForm($form, $lang){
	if ($form.name.value == "" || $form.name.value == null){
		alert(msg[$lang][1]);
		return(false);
	}
	if ($form.id.value == "" || $form.id.value == null){
		alert(msg[$lang][4]);
		return(false);
	}
	if (checkEmail($form.email.value) == false){
		alert(msg[$lang][3]);
		return(false);		
	}
	if ($form.comment.value == "" || $form.comment.value == null){
		alert(msg[$lang][5]);
		return(false);
	}
	alert("Formulario correcto");
	return(false);
}

function checkReservationForm($form, $lang){
	if ($form.name.value == "" || $form.name.value == null){
		alert(msg[$lang][1]);
		return(false);
	}
	if ($form.secondname.value == "" || $form.secondname.value == null){
		alert(msg[$lang][6]);
		return(false);		
	}
	if ($form.phone.value == "" || $form.phone.value == null){
		alert(msg[$lang][7]);
		return(false);		
	}
	if ($form.city.value == "" || $form.city.value == null){
		alert(msg[$lang][8]);
		return(false);		
	}	
	if ($form.country.value == "" || $form.country.value == null){
		alert(msg[$lang][12]);
		return(false);		
	}	
	if ($form.zip.value == "" || $form.zip.value == null){
		alert(msg[$lang][9]);
		return(false);		
	}	
	if (checkEmail($form.email.value) == false){
		alert(msg[$lang][3]);
		return(false);		
	}
	if ($form.comment.value == "" || $form.comment.value == null){
		alert(msg[$lang][5]);
		return(false);
	}
	return(true);
}

function checkFormSurvey($form, $lang){
	// alert("Formulario correcto");
	return(true);
}

function checkTipAFriend($form, $lang){
	if ($form.senderName.value == "" || $form.senderName.value == null){
		alert(msg[$lang][1]);
		return(false);
	}
	if ($form.name.value == "" || $form.name.value == null){
		alert(msg[$lang][2]);
		return(false);
	}
	if (checkEmail($form.email.value) == false){
		alert(msg[$lang][3]);
		return(false);		
	}
	return(true);
}

function checkCommentForm($form, $lang){
	if ($form.name.value == "" || $form.name.value == null){
		alert(msg[$lang][1]);
		return(false);
	}
	if ($form.city.value == "" || $form.city.value == null){
		alert(msg[$lang][8]);
		return(false);
	}
	if ($form.country.value == "" || $form.country.value == null){
		alert(msg[$lang][10]);
		return(false);
	}
	if (checkEmail($form.email.value) == false){
		alert(msg[$lang][3]);
		return(false);		
	}
	if ($form.comment.value == "" || $form.comment.value == null){
		alert(msg[$lang][11]);
		return(false);
	}
	return(true);
}

function checkAdvancedSearch($form, $lang){
	if ($form.search.value == null || $form.search.value == ""){
		alert(msg[$lang][0]);
		return(false);
	}
	return(true);
}
