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_showHide(){
  var i,p,v,obj,args=MM_showHide.arguments;
  for (i=0; i<(args.length-1); i+=2) {
		if ((obj=MM_findObj(args[i]))!=null) {
			v=args[i+1];
			if (obj.style) {
				obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; 
			}
			obj.visibility=v; 
		}
	}
}
function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj("s"+args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

// locate objects
function findPosX(obj) {
    var curleft = 0;
    if (obj.offsetParent) {
        while (1) {
            curleft+=obj.offsetLeft;
            if (!obj.offsetParent) {
                break;
            }
            obj=obj.offsetParent;
        }
    } else if (obj.x) {
        curleft+=obj.x;
    }
    return curleft;
}
function findPosY(obj) {
    var curtop = 0;
    if (obj.offsetParent) {
        while (1) {
            curtop+=obj.offsetTop;
            if (!obj.offsetParent) {
                break;
            }
            obj=obj.offsetParent;
        }
    } else if (obj.y) {
        curtop+=obj.y;
    }
    return curtop;
}

function xWidth(e,w){
	if(!(e=xGetElementById(e)))
		return 0;
	if (xNum(w)) {
		if (w<0)
			w = 0;
		else
			w=Math.round(w);
	} else 
		w=-1;
		var css=xDef(e.style);
	
	if (e == document || e.tagName.toLowerCase() == 'html' || e.tagName.toLowerCase() == 'body') {
		w = xClientWidth();
	}else if(css && xDef(e.offsetWidth) && xStr(e.style.width)) {
		if(w>=0) {
			var pl=0,pr=0,bl=0,br=0;
			if (document.compatMode=='CSS1Compat') {
				var gcs = xGetComputedStyle;pl=gcs(e,'padding-left',1);
				if (pl !== null) {
					pr=gcs(e,'padding-right',1);
					bl=gcs(e,'border-left-width',1);
					br=gcs(e,'border-right-width',1);
				}else if(xDef(e.offsetWidth,e.style.width)){
					e.style.width=w+'px';pl=e.offsetWidth-w;
				}
			}
			w-=(pl+pr+bl+br);
			if(isNaN(w)||w<0) 
				return;
			else 
				e.style.width=w+'px';
		}
		w=e.offsetWidth;
	}
	else if(css && xDef(e.style.pixelWidth)) {
		if(w>=0) 
			e.style.pixelWidth=w;w=e.style.pixelWidth;
	}
	return w;
}

/* X Library, Copyright 2001-2005 Michael Foster (Cross-Browser.com). Distributed under the terms of the GNU LGPL */
/* floater_xlib.js compiled with XC v0.22b, see floater_xlib.txt for contributor copyrights, license info and documentation */
var xVersion='4.0',xOp7Up,xOp6Dn,xIE4Up,xIE4,xIE5,xNN4,xUA=navigator.userAgent.toLowerCase();if(window.opera){var i=xUA.indexOf('opera');if(i!=-1){var v=parseInt(xUA.charAt(i+6));xOp7Up=v>=7;xOp6Dn=v<7;}}else if(navigator.vendor!='KDE' && document.all && xUA.indexOf('msie')!=-1){xIE4Up=parseFloat(navigator.appVersion)>=4;xIE4=xUA.indexOf('msie 4')!=-1;xIE5=xUA.indexOf('msie 5')!=-1;}else if(document.layers){xNN4=true;}xMac=xUA.indexOf('mac')!=-1;
function xDef(){for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])=='undefined') return false;}return true;}
function xGetComputedStyle(oEle, sProp, bInt){var s, p = 'undefined';var dv = document.defaultView;if(dv && dv.getComputedStyle){s = dv.getComputedStyle(oEle,'');if (s) p = s.getPropertyValue(sProp);}else if(oEle.currentStyle) {var a = sProp.split('-');sProp = a[0];for (var i=1; i<a.length; ++i) {c = a[i].charAt(0);sProp += a[i].replace(c, c.toUpperCase());}   p = oEle.currentStyle[sProp];}else return null;return bInt ? (parseInt(p) || 0) : p;}
function xGetElementById(e){if(typeof(e)!='string') return e;if(document.getElementById) e=document.getElementById(e);else if(document.all) e=document.all[e];else e=null;return e;}
function xNum(){for(var i=0; i<arguments.length; ++i){if(isNaN(arguments[i]) || typeof(arguments[i])!='number') return false;}return true;}
function _xSlideTo(e){if (!(e=xGetElementById(e))) return;var now, s, t, newY, newX;now = new Date();t = now.getTime() - e.C;if (e.stop) { e.moving = false; }else if (t < e.slideTime) {setTimeout("_xSlideTo('"+e.id+"')", e.timeout);if (e.slideLinear) s = e.B * t;else s = Math.sin(e.B * t);newX = Math.round(e.xA * s + e.xD);newY = Math.round(e.yA * s + e.yD);xMoveTo(e, newX, newY);e.moving = true;}  else {xMoveTo(e, e.xTarget, e.yTarget);e.moving = false;}  }
function xStr(s){for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])!='string') return false;}return true;}
function xTop(e,iY){if(!(e=xGetElementById(e)))return 0;var css=xDef(e.style);if(css&&xStr(e.style.top)){if(xNum(iY))e.style.top=iY+'px';else{iY=parseInt(e.style.top);if(isNaN(iY))iY=xGetComputedStyle(e,'top',1);if(isNaN(iY))iY=0;}}else if(css&&xDef(e.style.pixelTop)){if(xNum(iY))e.style.pixelTop=iY;else iY=e.style.pixelTop;}return iY;}
function xLeft(e,iX){if(!(e=xGetElementById(e)))return 0;var css=xDef(e.style);if(css&&xStr(e.style.left)){if(xNum(iX))e.style.left=iX+'px';else{iX=parseInt(e.style.left);if(isNaN(iX))iX=xGetComputedStyle(e,'left',1);if(isNaN(iX))iX=0;}}else if(css&&xDef(e.style.pixelLeft)){if(xNum(iX))e.style.pixelLeft=iX;else iX=e.style.pixelLeft;}return iX;}
function xHeight(e,h){if(!(e=xGetElementById(e)))return 0;if(xNum(h)){if(h<0)h=0;else h=Math.round(h);}else h=-1;var css=xDef(e.style);if(e==document||e.tagName.toLowerCase()=='html'||e.tagName.toLowerCase()=='body'){h=xClientHeight();}else if(css&&xDef(e.offsetHeight)&&xStr(e.style.height)){if(h>=0){var pt=0,pb=0,bt=0,bb=0;if(document.compatMode=='CSS1Compat'){var gcs=xGetComputedStyle;pt=gcs(e,'padding-top',1);if(pt!==null){pb=gcs(e,'padding-bottom',1);bt=gcs(e,'border-top-width',1);bb=gcs(e,'border-bottom-width',1);}else if(xDef(e.offsetHeight,e.style.height)){e.style.height=h+'px';pt=e.offsetHeight-h;}}h-=(pt+pb+bt+bb);if(isNaN(h)||h<0)return;else e.style.height=h+'px';}h=e.offsetHeight;}else if(css&&xDef(e.style.pixelHeight)){if(h>=0)e.style.pixelHeight=h;h=e.style.pixelHeight;}return h;}

function showmenu(id) {
	_submenu = document.getElementById("submenu_" + id);
	if (_submenu) {
		_menu = document.getElementById("menu_" + id);
		
		_x = findPosX(_menu);
		_y = findPosY(_menu) - 5;
		
		_width = xWidth('menu_' + id);
		
		xLeft('submenu_' + id, _x + _width);
		xTop('submenu_' + id, _y);
		MM_showHide('submenu_' + id, 'show');
	}
}

function hidemenu(id) {
	if (document.getElementById("submenu_" + id)) {
		//document.getElementById("submenu_" + id).style.visibility = 'hidden';
	}
}

function showsubmenu (arr_str) {
	id_array = arr_str.split(',');
	document.getElementById("submenu_" + id_array[0]).style.visivility = 'visible';
	
	for (i=1;i<id_array.length;i++) {
		_submenu = document.getElementById("submenu_" + id_array[i]);
		if (_submenu) {
			_menu = document.getElementById("menu_" + id_array[i]);
			
			_x = findPosX(_menu);
			_y = findPosY(_menu) - 5;
			
			//_width = xWidth(_menu);
			_width = xWidth("menu_" + id_array[i]);
			
			xLeft('submenu_' + id_array[i], _x + _width);
			xTop('submenu_' + id_array[i], _y);
			MM_showHide('submenu_' + id_array[i], 'show');
			/*
			_submenu.style.left = _x + _width + 'px';
			_submenu.style.top = _y + 'px';
			_submenu.style.visibility = 'visible';
			*/
		}
	}
}

function hidesubmenu (arr_str) {
	id_array = arr_str.split(',');
	for (i=0;i<id_array.length;i++) {
		_submenu = document.getElementById("submenu_" + id_array[i]);
		if (_submenu) {
			_submenu.style.visibility = 'hidden';
		}
	}
}





function MM_showHideLayers_test(id_page,valor2,opcion) { //v6.0
	//MM_showHideLayers('".$option1['id_page']."','','hide')
	//var i,p,v,obj,args=MM_showHideLayers.arguments;
	//alert("HOLA");
//	setTimeout("afterFiveSeconds('" + id_page + "')",80);
 document.getElementById("s"+id_page).style.visibility='hidden';
}

  function afterFiveSeconds(id_page){
//	alert("HOLitas");
// document.getElementById("s"+id_page).style.visibility='hidden';
}
function locateSubmenu(submenu) {
	if(document.getElementById("o"+submenu) && document.getElementById("s"+submenu)) {
		//alert( document.getElementById("td"+submenu).width);
		document.getElementById("s"+submenu).style.left = (findPosX(document.getElementById("o"+submenu))) + 'px';
		document.getElementById("s"+submenu).style.top = (findPosY(document.getElementById("o"+submenu))+33) + 'px';
	}
//	document.getElementById("img" + submenu).src = imageOver;
}
function locateSubmenu_p(submenu) {
	if(document.getElementById("o"+submenu) && document.getElementById("s"+submenu)) {
		//alert( document.getElementById("td"+submenu).width);
		document.getElementById("s"+submenu).style.left = (findPosX(document.getElementById("o"+submenu))+185) + 'px';
		document.getElementById("s"+submenu).style.top = findPosY(document.getElementById("o"+submenu)) + 'px';
	}
//	document.getElementById("img" + submenu).src = imageOver;
}

function changeMenu(state, tr) {
	if(state == 0) {
		MM_showHideLayers('2','','hide');
		MM_showHideLayers('4','','hide');
		document.getElementById("o2").style.top = 27 + 'px';
		document.getElementById("o4").style.top = 27 + 'px';
		if(document.getElementById("ttop")) {
			document.getElementById("ttop").style.height = 65 + 'px';
			document.getElementById("tbottom").style.height = 65 + 'px';
		}
		document.getElementById("t2").style.height = 27 + 'px';
		document.getElementById("t4").style.height = 27 + 'px';
		if(document.getElementById("tr"+tr)) {
			document.getElementById("tr"+tr).style.color = '#FFFFFF';
		}
	} else {
		document.getElementById("o2").style.top = 75 + 'px';
		document.getElementById("o4").style.top = 123 + 'px';
		if(document.getElementById("ttop")) {
			document.getElementById("ttop").style.height = 0 + 'px';
			document.getElementById("tbottom").style.height = 0 + 'px';
		}
		document.getElementById("t2").style.height = 75 + 'px';
		document.getElementById("t4").style.height = 123 + 'px';
		if(document.getElementById("tr"+tr)) { document.getElementById("tr"+tr).style.background = '#F47C32'; }
		MM_showHideLayers('2','','show');
		MM_showHideLayers('4','','show');
		locateSubmenu(2);
		locateSubmenu(4);
	}
}


function validarEmail(str_email) {
	var s = str_email;
	//var filter=/^[A-Za-z]([A-Za-z_])*(\.([A-Za-z0-9_])+)*@([A-Za-z0-9])+(\.([A-Za-z0-9_])+)+([A-Za-z])$/;
	var filter=/^[A-Za-z0-9_-]([A-Za-z0-9_-])*(\.([A-Za-z0-9_-])+)*@([A-Za-z0-9_-])+(-([A-Za-z0-9_-])+)?(\.([A-Za-z0-9_-])+)+([A-Za-z])$/;
	if (s.length == 0 ) return false;
	if (filter.test(s)) {
		return (true);
	} else {
		return (false);
	}
}

function update_shadow() {
	content_table = document.getElementById('content_bg');
	div_s = document.getElementById('div_shadow');
	img_s = document.getElementById('shadow_rep');
	
	left = findPosX(content_table) - 19;
	height = xHeight('content_bg') - 294 - 29;
	
	xLeft('div_shadow', left);
	xHeight('shadow_rep', height);
	MM_showHide('div_shadow','','show');
	MM_showHide('div_meses','show');
	try {
		update_table_meses();
	} catch(e){
		
	}
}

function ajaxObject() {
	var ajaxObject=false;
	try {
		/* DIFERENT BROWSERS */
		ajaxObject = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			/* IE */
			ajaxObject = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (E) {
			ajaxObject = false;
		}
	}
	
	if (!ajaxObject && typeof XMLHttpRequest!='undefined') {
		ajaxObject = new XMLHttpRequest();
	}
	return ajaxObject;
}
//addToCart(this.form, 'display_loading_add_to_cart');

function validateNum (num) {
	quant = parseInt(num);
	var filter = /^([0-9])*$/;
	if (isNaN(quant) || num == '' || !filter.test(num)) {
		return(false);
	} else {
		return(true);
	}
}

function addToCart(id_skin, input_obj, display_loading) {
	if (!validateNum(input_obj.value)) {
		alert(unescape("Por favor ingrese un n%FAmero entero v%E1lido."));
		input_obj.focus();
		return(false);
	}
	
	document.getElementById(display_loading).innerHTML = '<img src="imagenes/loading.gif" width="16" height="16" alt="" />';
	
	ao = ajaxObject();
	
	_values_send="id_product=" + id_skin + "&quantity=" + quant;
	_URL_="addtocart.php?";
	
	ao.open("GET",_URL_+_values_send,true);
	ao.onreadystatechange = function() {
		if (ao.readyState == 4) {
			if(ao.status == 200) {
				document.getElementById(display_loading).innerHTML = ao.responseText;
			}
		}
	}
	ao.send(null);
	return(false);
}

function removeFromCart (id_skin) {
	if (!window.confirm(unescape("%BFConfirma que desea eliminar el %EDtem seleccionado?"))) {
		return(false);
	}
	h = xHeight('td_carrito');
	document.getElementById('td_carrito').innerHTML = '<div align="center" style="height:' + h + 'px">Removiendo...</div>';
	ao = ajaxObject();
	
	_values_send="id_product=" + id_skin;
	_URL_="removefromcart.php?";
	
	ao.open("GET",_URL_+_values_send,true);
	ao.onreadystatechange = function() {
		if (ao.readyState == 4) {
			if(ao.status == 200) {
				document.getElementById('td_carrito').innerHTML = ao.responseText;
			}
		}
	}
	ao.send(null);
	return(false);
}

function cambiarI (Idimg,imgx) {
    document.images[Idimg].src = imgx;
}


/*This is the code for the calendar/*/

var oldLink = null;
// code to change the active stylesheet
function setActiveStyleSheet(link, title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
  if (oldLink) oldLink.style.fontWeight = 'normal';
  oldLink = link;
  link.style.fontWeight = 'bold';
  return false;
}

// This function gets called when the end-user clicks on some date.
function selected(cal, date) {
  cal.sel.value = date; // just update the date in the input field.
  if (cal.dateClicked )
    // if we add this call we close the calendar on single-click.
    // just to exemplify both cases, we are using this only for the 1st
    // and the 3rd field, while 2nd and 4th will still require double-click.
    cal.callCloseHandler();
}

// And this gets called when the end-user clicks on the _selected_ date,
// or clicks on the "Close" button.  It just hides the calendar without
// destroying it.
function closeHandler(cal) {
  cal.hide();                        // hide the calendar
//  cal.destroy();
  _dynarch_popupCalendar = null;
}

// This function shows the calendar under the element having the given id.
// It takes care of catching "mousedown" signals on document and hiding the
// calendar if the click was outside.
function showCalendar(id, format, showsTime, showsOtherMonths) {
	if(id=='sel3')
	{
		if(document.getElementById("WhichCalendar"))
		document.getElementById("WhichCalendar").value=1;
	}else if(id=='rel3')
	{
		if(document.getElementById("WhichCalendar"))
		document.getElementById("WhichCalendar").value=2;
	}
  var el = document.getElementById(id);
  if (_dynarch_popupCalendar != null) {
    // we already have some calendar created
    _dynarch_popupCalendar.hide();                 // so we hide it first.
  } else {
    // first-time call, create the calendar.
    var cal = new Calendar(1, null, selected, closeHandler);
    // uncomment the following line to hide the week numbers
    // cal.weekNumbers = false;
	 var todayx = new Date();

	if(showsTime=="res")
		limite="1900";
	else
		limite=todayx.getFullYear()
		showsTime=null;
    if (typeof showsTime == "string") {
      cal.showsTime = true;
      cal.time24 = (showsTime == "24");
    }
    if (showsOtherMonths) {
      cal.showsOtherMonths = true;
    }
	
    _dynarch_popupCalendar = cal;     // remember it in the global var

    cal.setRange(limite, 2070);        // min/max year allowed.
	cal.setDisabledHandler(isDisabled);
    cal.create();
	
  }
  _dynarch_popupCalendar.setDateFormat(format);    // set the specified date format
  _dynarch_popupCalendar.parseDate(el.value);      // try to parse the text in field
  _dynarch_popupCalendar.sel = el;                 // inform it what input field we use
  _dynarch_popupCalendar.idx=id;
  // the reference element that we pass to showAtElement is the button that
  // triggers the calendar.  In this example we align the calendar bottom-right
  // to the button.
  _dynarch_popupCalendar.showAtElement(el.nextSibling, "Br");        // show the calendar

  return false;

  
}

var MINUTE = 60 * 1000;
var HOUR = 60 * MINUTE;
var DAY = 24 * HOUR;
var WEEK = 7 * DAY;

// If this handler returns true then the "date" given as
// parameter will be disabled.  In this example we enable
// only days within a range of 10 days from the current
// date.
// You can use the functions date.getFullYear() -- returns the year
// as 4 digit number, date.getMonth() -- returns the month as 0..11,
// and date.getDate() -- returns the date of the month as 1..31, to
// make heavy calculations here.  However, beware that this function
// should be very fast, as it is called for each day in a month when
// the calendar is (re)constructed.
function isDisabled(date) {
  var today = new Date();
//  document.getElementById("Rmonth")
//  maniana=new Date(today.getFullYear(),today.getMonth(),(today.getDate()+90)); 
  maniana=new Date(document.getElementById("Syear")+"/"+document.getElementById("Smonth")+"/"+document.getElementById("S")); 
//  alert(maniana);
  return (Math.abs(date.getTime() - maniana.getTime() ) / DAY) > 90;
}

function flatSelected(cal, date) {
  var el = document.getElementById("preview");
  el.innerHTML = date;
}


function changeDate(id1, id2,idobj,idyear) {	
		var mesr=document.getElementById("Rmonth").value;		
		mesr=parseInt(mesr);		
		var anor=document.getElementById("Ryear").value;		
		if(anor[0]=="0")
		{
			anor=parseInt(anor[1]);
		}
		else
			anor=parseInt(anor);
	
		mess=document.getElementById("Smonth").value;
		mess=parseInt(mess);
		anos=document.getElementById("Syear").value;
		
		if(anos[0]=="0")
		{
			anos=parseInt(anos[1]);
		}else
			anos=parseInt(anos);
	
		/*alert("El ao de salida:"+parseInt(anos));
		alert("El mes de salida:"+parseInt(mess));
		alert("El ao de regreso:"+parseInt(anor));	
		alert("El mes de regreso:"+parseInt(mesr));*/
		aux=0;
		while((parseInt(mesr) < parseInt(mess) && parseInt(anor) <= parseInt(anos)) || (parseInt(anor) < parseInt(anos)) )
		{
			//alert("Toy adentro");
			aux=1;
			anor=parseInt(anos)+1;			
		}
		document.getElementById("Ryear").value=anor;
//		alert("El ao Fin es:"+anor);		
	  var valx = document.getElementById(id1).value +" "+ document.getElementById(id2).value + " " + document.getElementById(idyear).value;
	  document.getElementById(idobj).value=valx;
  	if(aux==1)
	{
	  valx = document.getElementById("Rmonth").value +" "+ document.getElementById("Rday").value + " " + document.getElementById('Ryear').value;
	  document.getElementById("rel3").value=valx;
	}

}
function locateSubmenu2(submenu) {
//		alert("todo");


	if(document.getElementById("o"+submenu)) {
		w = xWidth("td"+submenu);
		//document.getElementById("s"+submenu).style.left = findPosX(document.getElementById("o"+submenu)) + w - 13 + 6 + 'px';
		//172-13+6
/*		document.getElementById("s"+submenu).style.left = findPosX(document.getElementById("o"+submenu)) + (w+2) + 'px';
		document.getElementById("s"+submenu).style.top = findPosY(document.getElementById("o"+submenu)) - 5 + 'px';*/
		document.getElementById("s"+submenu).style.left = findPosX(document.getElementById("o"+submenu)) + (w+8) + 'px';
		document.getElementById("s"+submenu).style.top = (findPosY(document.getElementById("o"+submenu))-13) + 'px';
	}
}
function changeDateback(idorigen, idmes,idia,idyear) {	
	var cadenaOrigen= document.getElementById(idorigen).value;
	cadenaOrigen=cadenaOrigen.split(" ");
	if	(cadenaOrigen.length >=2)
	{
			document.getElementById(idmes).selectedIndex= cadenaOrigen[0]-1;
			document.getElementById(idia).value=cadenaOrigen[1];
			document.getElementById(idyear).value=cadenaOrigen[2];
				var mesr=document.getElementById("Rmonth").value;		
				mesr=parseInt(mesr);		
				var anor=document.getElementById("Ryear").value;
				
				if(anor[0]=="0")
				{
					anor=parseInt(anor[1]);
				}
				else{
					anor=parseInt(anor);
				}
			
				mess=document.getElementById("Smonth").value;
				mess=parseInt(mess);
				anos=document.getElementById("Syear").value;
				
				if(anos[0]=="0")
				{
					anos=parseInt(anos[1]);
				}else{
					anos=parseInt(anos);
				}
			
				/*alert("El ao de salida:"+parseInt(anos));
				alert("El mes de salida:"+parseInt(mess));
				alert("El ao de regreso:"+parseInt(anor));	
				alert("El mes de regreso:"+parseInt(mesr));*/
				aux=0;
				while((parseInt(mesr) < parseInt(mess) && parseInt(anor) <= parseInt(anos)) || (parseInt(anor) < parseInt(anos)) )
				{
//					alert("Toy adentro");
					aux=1;
					anor=parseInt(anos)+1;					
				}

				document.getElementById("Ryear").value=anor;
//				alert("El ao Fin es:"+anor);		
				if(aux==1)
				{
				  valx = document.getElementById("Rmonth").value +" "+ document.getElementById("Rday").value + " " + document.getElementById('Ryear').value;
				  document.getElementById("rel3").value=valx;
				}
			
			
	}
	
//	var valx = cadenaOrigen +" "+ document.getElementById(idorigen).value;
	//document.getElementById(idobj).value=valx;
}

function oneway(valor) { 
//	alert(valor);
	if(valor=="OneWay")
	{
		document.getElementById('sel3').value="";
		document.getElementById('sel3').disabled=true;
		document.getElementById('lfechar').disabled=true;
	}
	else if(valor=="RoundTrip")
	{
		
		document.getElementById('sel3').disabled=false;
		document.getElementById('lfechar').disabled=false;
		
	}
}
function showp(valor) { 
	i=0;
	for(i=1;i<(9);i++) {
		if(i<=valor)
		{
			if (document.getElementById('div_p'+i))
			{
				document.getElementById('div_p'+i).style.display ="";
			}
		}
		else
		{
			if (document.getElementById('div_p'+i))
			{
				document.getElementById('div_p'+i).style.display ="none";
			}
		}
	}
}

function showcity(valor) { 
	if(valor=="si")
	{
		if (document.getElementById('ciudad'))
		{
			document.getElementById('ciudad').value="";
			document.getElementById('ciudad').disabled=false;
		}		
	}
	if(valor=="no")
	{
		if (document.getElementById('ciudad'))
		{
			document.getElementById('ciudad').value="";
			document.getElementById('ciudad').disabled=true;		
		}		
	}	
}
function cambiar_clase(Idimg,estilo) {	
	document.getElementById(Idimg).className=estilo;
}
function Unselect_btn(id_btn){
	id_seleccionado=document.getElementById("btn_selected").value;
//	alert (id_seleccionado);
	//	alert (id_btn);
	if(id_seleccionado!=id_btn)
	{
		cambiar_clase(id_seleccionado,"number_porta");
	}
	document.getElementById("btn_selected").value=id_btn;	
}
function aleatorio(inferior,superior){
	numPosibilidades = superior - inferior
	aleat = Math.random() * numPosibilidades
	aleat = Math.round(aleat)
	return parseInt(inferior) + aleat
} 
function get_direccion(id_page){
	s_value="1";
	height = xHeight(document.getElementById("contendor_imagenes"));
	document.getElementById("contendor_imagenes").innerHTML = '<table width="100px;" style="height:' + height + 'px;" ><tr><td valign="middle" style="height:' + height + 'px; text-align:center"><center><img src="images/loading.gif" width="16" height="16" alt="Cargando" /> Cargando...</center></td></tr></table>';	
	ao = ajaxObject();
	_URL_=base_url+"ajax_pages/pagina_selec.php?id_page=" + id_page;	
	ao.open("GET",_URL_,true);
	ao.onreadystatechange = function() {
		if (ao.readyState == 4) {
			if(ao.status == 200) {
				document.getElementById("contendor_imagenes").innerHTML = ao.responseText;
			}
		}
	}
	ao.send(null);	
	llamar_img('0',id_page);	
}
function llamar_img(numero_img,id_page){
//	alert("hola"+numero_img);
	height_1 = xHeight(document.getElementById("content_images"));
	document.getElementById("content_images").innerHTML = '<table width="650" style="height:' + height_1 + '"  ><tr><td valign="middle" style="height:' + height_1 + 'px; text-align:center"><center><img src="images/loading.gif" width="16" height="16" alt="Cargando" style="padding-left:90px;"/> Cargando...</center></td></tr></table>';	

	ao_1= ajaxObject();
	_URL_=base_url+"ajax_pages/image_selec.php?id_page=" + id_page +"&number_img=" + numero_img ;	
	ao_1.open("GET",_URL_,true);
	ao_1.onreadystatechange = function() {
		if (ao_1.readyState == 4) {
			if(ao_1.status == 200) {
				document.getElementById("content_images").innerHTML = ao_1.responseText;
			}
		}
	}
	ao_1.send(null);
}
function cambiar_titulo(numero_img,id_page){
	height_1 = xHeight(document.getElementById("title_image_selected"));
	document.getElementById("title_image_selected").innerHTML = '<table width="650" style="height:' + height_1 + '"  ><tr><td valign="middle" style="height:' + height_1 + 'px; text-align:center"><center><img src="images/loading.gif" width="16" height="16" alt="Cargando" style="padding-left:90px;"/> Cargando...</center></td></tr></table>';	

	ao_2= ajaxObject();
	_URL_=base_url+"ajax_pages/title_image_selec.php?id_page=" + id_page +"&number_img=" + numero_img ;	
	ao_2.open("GET",_URL_,true);
	ao_2.onreadystatechange = function() {
		if (ao_2.readyState == 4) {
			if(ao_2.status == 200) {
				document.getElementById("title_image_selected").innerHTML = ao_2.responseText;
			}
		}
	}
	ao_2.send(null);
}
function sendReqinfo(){
		frm = document.getElementById("reqinfo");
		if (!validateReqinfoForm()) {
			//frm.submit();
			return(false);
		}
	}
function validateReqinfoForm() {
		frm = document.getElementById('reqinfo');
		msg = document.getElementById('Mensaje');
		
		if (frm.elements['Nombre'].value == "")
		 {
			alert("Por favor ingrese su Nombre");				
			frm.elements['Nombre'].focus();				
			return(false);
		}
		
		if (frm.elements['Apellidos'].value == "") {				
			alert("Por favor ingrese sus Apellidos");
			frm.elements['Apellidos'].focus();
			return(false);
		}
		
		if (frm.elements['EMail'].value == "") {
			alert("Por favor ingrese su Correo Electrónico");
			frm.elements['EMail'].focus();
			return(false);
		}
		
		if (frm.elements['Pais'].value == "") {
			alert("Por favor ingrese su País");
			frm.elements['EMail'].focus();
			return(false);
		}
		
		if(!validarEmail(frm.elements['EMail'].value)) {
			alert(unescape("Por favor ingrese un Correo Electrónico valido"));
			frm.elements['EMail'].focus();
			return(false);
		}
		
		if (frm.elements['Ciudad'].value == "") {
			alert("Por favor ingrese una Ciudad");
			frm.elements['Ciudad'].focus();
			return(false);
		}
		
		if (msg.value == "") {
			alert("Por favor llene sus Preguntas / Comentarios");
			msg.focus();
			return(false);
		}		
		return(true);
}
function cambiarI(Idimg,imgx) {
    document.images[Idimg].src = imgx;
}
function pulsar(id_page) {	
	p.run(); 
	get_direccion(id_page);
} 
function close_fomr(){
	p.clearit();
}
function change_font(id_div,color_){

	document.getElementById((id_div)).style.color=color_;	
}
function change_style_btn(id_div,prendido){
	if(document.getElementById(id_div))
	if(prendido==1){
		if(document.getElementById("segundo_level_activado").value!=id_div)
		{
		cambiar_clase(id_div,"button_menu2_sel");//cmbia la clase principal
		cambiarI ((id_div+"img_t"),"images/btn_menu2sel_h.gif");//cambia el la imagen de arriba
		cambiar_clase((id_div+"cnt"),"button_menu2_sel_content");//cambia el contenido del 
		cambiarI((id_div+"img_bt"),"images/btn_menu2sel_b.gif");//cambia el la imagen de arriba	
	    cambiarI ((id_div+"fle"),"images/bullet_menu_sel.gif");//cambia la flechita		
		}
	}else{
		if(document.getElementById("segundo_level_activado").value!=id_div)
		{
			cambiar_clase(id_div,"button_menu2");//cmbia la clase principal
			cambiarI ((id_div+"img_t"),"images/btn_menu2_h.gif");//cambia el la imagen de arriba
			cambiar_clase((id_div+"cnt"),"button_menu2_content");//cambia el contenido del 
			cambiarI ((id_div+"img_bt"),"images/btn_menu2_b.gif");//cambia el la imagen de arriba
		    cambiarI ((id_div+"fle"),"images/bullet_menu_sel.gif");//cambia la flechita
		    cambiarI ((id_div+"fle"),"images/bullet_menu_white.gif");//cambia la flechita
		/*	if(sin_hijos==1)
			cambiarI ((id_div+"fle"),"images/btn_menu2sel_b.gif");//cambia la flechita*/
		}
	}
//	document.getElementById(id_div).style.color=color_;	
}






//for the menu second level

function runAccordion(index, height)
{
	var nID = "accordion" + index;
 var height_x= xHeight(("oc_"+nID));
// document.getElementById(("oc_"+nID)).offsetHeight;
  
   var id_div;
//  alert(index);
//  alert (openAccordion) ;
	id_div=("div_level_1_"+ (index-1));
  if(openAccordion=="")  {
	/*  document.getElementById("segundo_level_activado").value=("div_level_1_"+ (index-1)); 
	  change_style_btn(("div_level_1_"+ (index-1)),"1");	
	cambiarI ((id_div+"fle"),"images/bullet_menu_down.gif");//cambia la flechita
	  document.getElementById((id_div+"fle")).style.left="-2px";*/
//  	alert("Abriendo");
	}
  else{
	 document.getElementById("segundo_level_activado").value="-1"; 
/*  	 document.getElementById("segundo_level_activado").value="-1"; 
	 change_style_btn(("div_level_1_"+ (index-1)),"0");
	 document.getElementById((id_div+"fle")).style.left="0px";
	 cambiarI ((id_div+"fle"),"images/bullet_menu_white.gif");//cambia la flechita*/	
//	alert("Cerrando");
	}
  
  if(openAccordion == nID)
    nID = '';
	
  setTimeout("animate(" + new Date().getTime() + "," + TimeToSlide + ",'" + openAccordion + "','" + nID + "', " + (height_x) + ")", 40);

  openAccordion = nID;
}
function str_replace(cadena, cambia_esto, por_esto) {
      return cadena.split(cambia_esto).join(por_esto);
}


function animate(lastTick, timeLeft, closingId, openingId, height)
{ 
//document.getElementById((openingId).style.height = "50" + 'px';
	//alert(height);
	
//alert(openingId);
//  height= document.getElementById(("oc_"+openingId)).offsetHeight; 
//  alert(height);
//  alert(height);
//alert(xHeight(document.getElementById("oc_"+closingId)));
/*
alert(xHeight(document.getElementById(openingId)));*/
  var curTick = new Date().getTime();
  var elapsedTicks = curTick - lastTick;
  /*
  if(closingId == openingId) {
	  closingId = "";
  }*/ 
  var opening = (openingId == '') ? null : document.getElementById(openingId);
  var closing = (closingId == '') ? null : document.getElementById(closingId);

  
  ContentHeight = height;
  
  if(timeLeft <= elapsedTicks)
  {
    if(opening != null)
      opening.style.height = ContentHeight + 'px';
   
    if(closing != null)
    {
      closing.style.display = 'none';
      closing.style.height = '0px';
    }
    return;
  }
 
  timeLeft -= elapsedTicks;
  var newClosedHeight = Math.round((timeLeft/TimeToSlide) * ContentHeight);
  var id_div;
//  alert(index);
//  alert (openAccordion) ;
	
  if(opening != null)
  {
	//alert(openingId);
	index_1=str_replace(openingId,'accordion','');
	id_div=("div_level_1_"+ (index_1-1));
//	alert(id_div);
	  document.getElementById("segundo_level_activado").value=("div_level_1_"+ (index_1-1)); 
	  change_style_btn(("div_level_1_"+ (index_1-1)),"1");	
	  cambiarI ((id_div+"fle"),"images/bullet_menu_down.gif");//cambia la flechita
	  document.getElementById((id_div+"fle")).style.left="-2px";
//  	alert("Abriendo");
	
	
    if(opening.style.display != 'block')
      opening.style.display = 'block';
    opening.style.height = (ContentHeight - newClosedHeight) + 'px';
  }
 
  if(closing != null){	
  
  index_1=str_replace(closingId,'accordion','');
	id_div=("div_level_1_"+ (index_1-1));
//  document.getElementById("segundo_level_activado").value="-1"; 
	 change_style_btn(("div_level_1_"+ (index_1-1)),"0");
	 document.getElementById((id_div+"fle")).style.left="0px";
	 cambiarI ((id_div+"fle"),"images/bullet_menu_white.gif");//cambia la flechita*/	 
//	alert("Cerrando");
  
//	alert(closingId);
    closing.style.height = newClosedHeight + 'px';	
	}
    
    //alert(closingId);

  setTimeout("animate(" + curTick + "," + timeLeft + ",'" + closingId + "','" + openingId + "', " + height + ")", 33);

}

