function cambiafondo(src,color) 
{
 src.bgColor=color;
 }

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_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_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];}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);


function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v;return obj; }
}

function check_advanced_search(form)
{
	if( !(form['use_hotel[value]'].checked || form['use_resort[value]'].checked || form['use_rentacar[value]'].checked || form['use_availability[value]'].checked ) ){
		alert('At least one of hotel,resorts... types should be checked.');
		return false;
	}
	return true;
}


function is_explorer(){

  var explorador="";
  var cadena_explorer="Microsoft Internet Explorer";
	    
  explorador=navigator.appName;
  if (explorador.search(cadena_explorer)!=-1){
     return true;
  }else{
     return false;
  }
							 
}

function changeLayer(showLayer,hideLayer)
{
	MM_showHideLayers(showLayer,'','show');
	MM_showHideLayers(hideLayer,'','hide');
}

var Timers=new Array();

function changeLayerFade(showLayer,hideLayer)
{
	if( ! is_explorer() ){
		changeLayer(showLayer,hideLayer);
	}else{
		Timers[1] = setInterval("doFadeIn('"+showLayer+"')", 50);
		Timers[2] = setInterval("doFadeOut('"+hideLayer+"')", 50);
	}
}

function fadeLayer(layer,tipo)
{
	if( is_explorer() ){
		if(tipo == 'show'){
			Timers[1] = setInterval("doFadeIn('"+layer+"')", 50);
		}else{
			Timers[2] = setInterval("doFadeOut('"+layer+"')", 50);
		}
	}else{
		MM_showHideLayers(layer,'',tipo);
	}
}

function showLogin()
{
	MM_showHideLayers('mascota','','show');
}

function hideLogin()
{
	MM_showHideLayers('mascota','','hide');
}

function doFadeIn(_v) 
{
	MM_showHideLayers(_v,'','show');
	if ( eval(_v+".filters.alpha.opacity") < 100)
		eval( _v + ".filters.alpha.opacity="+ _v+".filters.alpha.opacity+20");
	else{
		clearInterval(Timers[1]);
		MM_showHideLayers(_v,'','show');
		eval( _v + ".filters.alpha.opacity=100");
	}
		
}

function doFadeOut(_v) 
{
	if ( eval(_v+".filters.alpha.opacity") > 0)
		eval( _v + ".filters.alpha.opacity="+ _v+".filters.alpha.opacity-20");
	else{
		clearInterval(Timers[2]);
		eval( _v + ".filters.alpha.opacity=0");
		MM_showHideLayers(_v,'','hide');
	}
}


function quitaPx(value)
{
	rgx = /(\d+)(p.)?/
	var pos=rgx.exec(value);
	return pos[1];
}

function moveDiv(id,x,y)
{
	obj=document.getElementById(id);
	obj.style.left = x+ parseInt(quitaPx(obj.style.left));
	//obj.style.top = y+ parseInt(quitaPx(obj.style.top));
	//return new Array(parseInt(obj.style.left),parseInt(obj.style.top))
}

function MoveClipDiv(id,x,y)
{
	obj=document.getElementById(id);
	rgx = /rect\((\d+)p. (\d+)p. (\d+)p. (\d+)p.\)/
	var pos=rgx.exec(obj.style.clip);
	c1=obj.style.clip;
	pos[1]=parseInt(pos[1])+y;
	pos[2]=parseInt(pos[2])+x;
	pos[3]=parseInt(pos[3])+y;
	pos[4]=parseInt(pos[4])+x;
	obj.style.clip='rect('+ pos[1] +'px '+pos[2]+'px '+pos[3]+'px '+pos[4]+'px)';
}

function change_clipping(id,x1,y1,x2,y2)
{
	obj=document.getElementById(id);
	obj.style.clip='rect('+ x1 +'px '+y1+'px '+x2+'px '+y2+'px)';
}

function change_size(id,x,y)
{
	obj=document.getElementById(id);
	alert(obj.style.height);
	obj.style.height=y+"px";
	obj.style.visibility='visible';
	change_clipping(id,0,0,x,y);
	alert(obj.style.height);
/*	obj.style.right=x;
	obj.style.botton=y; */
}


function init_desplazable(capa,paso_tiempo,num_pasos,width)
{
	Timers[3] = setInterval("mover_desplazable('"+capa+"',"+num_pasos+","+width+")", paso_tiempo);
	obj=document.getElementById(capa);
}

var posidx=1;
var sentido=1;

function mover_desplazable(capa,max,width)
{

	altov=5
	anchov=5

	delta=sentido*width
	moveDiv(capa,-delta,0);

//	MoveClipDiv(capa,delta,0)

	posidx=posidx+sentido;
	if( sentido>0 && posidx >= max ){
		moveDiv(capa,max*width,0);	
		posidx=1;
	}

}

function mover_desplazable(capa,max,width)
{

	altov=5
	anchov=5

	delta=sentido*width
	moveDiv(capa,-delta);

	MoveClipDiv(capa,delta,0)

	posidx=posidx+sentido;
	if( sentido>0 && posidx >= max ){
		sentido=-sentido;
	}else if( sentido<0 && posidx<=1){
		posidx=1;
		sentido=-sentido;
	}
}
function resize_full_article(ancho){
        var altura_ventana=document.altura.height+50;
        var max_altura=600;
		
	center_window(window,ancho,10);
	if (altura_ventana<=max_altura){
		window.resizeTo(ancho,altura_ventana);
		center_window(window,ancho,altura_ventana);
	}else{
		window.resizeTo(ancho,max_altura);
		center_window(window,ancho,max_altura);
	}
	
}
var showing_login=1;

function flash_logged()
{
	cookie= cookie_get('AUTH');
	if( cookie==null || cookie == ''){
		login_msg()
	}else{
		openBrowser('http://www.cvctraveller.com','tully',1024,768)
	}

}


function center_layer(layer,width_,height_)
{
	if (self.pageYOffset)
	{
		layer.style.top=(((window.pageYOffset+(self.screen.height/2)))-height_);
	}else{
		if (document.documentElement && document.documentElement.scrollTop){
			layer.style.top=(((document.documentElement.scrollTop+(self.screen.height/2)))-height_);
		}else{
			if (document.body){
				layer.style.top=(((document.body.scrollTop+(self.screen.height/2)))-height_);
			}
		}
	}

	layer.style.left=0; //(self.screen.width-width_)/2;


}

function login_msg()
{
	layer = document.getElementById('loginlayer');
	layer.style.visibility='visible';
	document.forms[0].user.focus();
	center_layer(layer,400,200);
}
function close_login()
{
	layer = document.getElementById('loginlayer');
	layer.style.visibility='hidden';
}
function login_failed_msg()
{
	alert("Log-in failed,please check the password");
	login_msg();
}

function show_wait()
{
	if (!showing_login)
	{
		layer = document.getElementById('searchmsg');
		center_layer(layer,230,230);
		layer.style.visibility='visible';
		window.status='Searching...';
		return true;
	}
}

function set_cursor(name)
{
	document.body.style.cursor=name;
}

function set_hand_cursor()
{
	set_cursor('hand');
	set_cursor('pointer');
}

function clear_cursor()
{
	set_cursor('default');
}
