function confirmLink(theLink, theText){
    if (theText == '' || typeof(window.opera) != 'undefined') {
        return true;
    }
    var is_confirmed = confirm(theText);
    if (is_confirmed) {
        theLink.href += '&confirmado=1';
    }
    return is_confirmed;
}
//------------------------------------------------------------------------
function openW(mypage,myname,w,h,features){
	if(screen.width){
		var winl = (screen.width-w)/2;
		var wint = (screen.height-h)/2;
	} else {
		winl = 0;wint =0;
	}
	if (winl < 0) winl = 0;
	if (wint < 0) wint = 0;

	var settings = 'height=' + h + ',';
	settings += 'width=' + w + ',';
	settings += 'top=' + wint + ',';
	settings += 'left=' + winl + ',';
	settings += features;

	win = window.open(mypage,myname,settings);
	win.window.focus();
}
//------------------------------------------------------------------------
function doPreview(wich, where){
	var objFile = document.getElementById(wich); //imagen
	var objImg = document.getElementById(where); //preview
	objImg.src = objFile.value;
}
//------------------------------------------------------------------------
function spanish(){
	document.getElementById('english').style.display = "none";
	document.getElementById('spanish').style.display = "";
	
	document.forms[0]['nombre1'].focus();
}

function english(){
	document.getElementById('english').style.display = "";
	document.getElementById('spanish').style.display = "none";

	document.forms[0]['nombre2'].focus();
}

function change(cual) {
	if (cual == 1){
		td1 = document.getElementById('tdspanish');
		ln1 = document.getElementById('link1');
		td1.className = 'bordetab';
		ln1.className = 'tmDataLink1';
		
		td2 = document.getElementById('tdenglish');
		ln2 = document.getElementById('link2');
		td2.className = 'bordetab1';
		ln2.className = 'tmDataLink';
	} else {
		td1 = document.getElementById('tdenglish');
		ln1 = document.getElementById('link2');
		td1.className = 'bordetab';
		ln1.className = 'tmDataLink1';
		
		td2 = document.getElementById('tdspanish');
		ln2 = document.getElementById('link1');
		td2.className = 'bordetab1';
		ln2.className = 'tmDataLink';
	}
}
//------------------------------------------------------------------------
var idControlEdicion;
function EditarContenido(idControl){
	idControlEdicion = idControl;
	var newWindow = window.open('../../cOmmOns/html_editor/editor_html.php', 'HTMLEditor', 'width=570,height=360');
	newWindow.focus();
}

function RecuperarContenido(){
	return document.getElementById(idControlEdicion).value;	
}

function CallbackEditarContenido(value){
	document.getElementById(idControlEdicion).value = value;
}
//------------------------------------------------------------------------
function openMapa(ventana){
	var w = 0, h = 0; popW = 725; popH = 540;

   	w = window.innerWidth;
   	h = window.innerHeight;

	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	
    popupWindow=open(''+ventana+'','Window','resizable=no,scrollbars=no,width='+popW+',height='+popH+',top='+topPos+',left='+leftPos);
    if (popupWindow.opener == null)
		popupWindow.opener = self;
}
//------------------------------------------------------------------------
function openWin(ventana,popW,popH){
	var w = 0, h = 0;
	
   	w = window.innerWidth;
   	h = window.innerHeight;
   	
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	
    popupWindow=open(''+ventana+'','Window','resizable=no,scrollbars=yes,width='+popW+',height='+popH+',top='+topPos+',left='+leftPos);
    if (popupWindow.opener == null)
		popupWindow.opener = self;
}
//------------------------------------------------------------------------
var win1Open = null
var win2Open = null

function openPopUp(windowURL, windowName, windowWidth, windowHeight){
	var winHandle = window.open(windowURL,windowName,"toolbar=no,scrollbars=yes,resizable=no,width=" + windowWidth + ",height=" + windowHeight)
	return winHandle
}
function winClose(){
	if(win1Open != null) win1Open.close()
	if(win2Open != null) win2Open.close()
}
function openPopUpWindow(){}
//------------------------------------------------------------------------
function getOptions(padre,otra_ruta){
	if (otra_ruta){
		window.frames['iframeOculto'].location = 'cOmmOns/carga_dinamica.php?padre='+padre;
	} else {
		window.frames['iframeOculto'].location = '../../cOmmOns/carga_dinamica.php?padre='+padre;
	}
}

function fillSelect(arrOptions){
	var cantidad = arrOptions.length;
	var mi_objeto = document.frmOrigen.hijo;

	mi_objeto.options.length = 0;
	
	for (i = 0; i < cantidad; i++){
		mi_objeto.options[i] = new Option(arrOptions[i].nombre);
		mi_objeto.options[i].value = arrOptions[i].id;
	}
	mi_objeto.options[0].selected = true;
}
//------------------------------------------------------------------------
function highlight_div(checkbox_node){
    label_node = checkbox_node.parentNode;

    if (checkbox_node.checked){
		label_node.style.backgroundColor='#04337C';
		label_node.style.color='#ffffff';
	} else {
		label_node.style.backgroundColor='#ffffff';
		label_node.style.color='#000000';
	}
}
//------------------------------------------------------------------------
function mostrarDivOrden(){
	if (document.getElementById('orden_portada').style.display == 'none'){
		document.getElementById('orden_portada').style.display = '';
	} else {
		document.getElementById('orden_portada').style.display = 'none';
	}
}

function selectOrden(indice){
	var posicion = document.getElementById('orden');
	posicion.options[indice-1].selected = true;
}
//------------------------------------------------------------------------
function valSelectAlojamientos(){
	var optProvincia = document.getElementById('provincia');
	var valProvincia = optProvincia.options[optProvincia.selectedIndex].value;
	
	var optCiudad = document.getElementById('ciudad');
	var valCiudad = optCiudad.options[optCiudad.selectedIndex].value;
	
	var optTipo = document.getElementById('tipo');
	var valTipo = optTipo.options[optTipo.selectedIndex].value;
	
	document.location = 'alojamientos.php?provincia='+valProvincia+'&ciudad='+valCiudad+'&tipo='+valTipo;
}
//------------------------------------------------------------------------
function agregarIncluye(theTable,estado,numero){
	theRow = theTable.insertRow(theTable.rows.length);
	theCell= theRow.insertCell(0);
	theCell.innerHTML = '<input class="tmInput" name="'+estado+'incluye'+numero+'[]" size="85">';
	theCell = theRow.insertCell(1);
	theCell.innerHTML ='&nbsp;<img id="delRow" onClick="borrarFila(this)" src="../../cOmmOns/images/borrar.gif" title="Borrar">';
}

function agregarFecha(theTable){
	theRow = theTable.insertRow(theTable.rows.length);
	theCell= theRow.insertCell(0);
	theCell.innerHTML = '<input class="tmInput" name="fecha[]" size="15">&nbsp;&nbsp;[dd/mm/yyyy]&nbsp;&nbsp;';
	theCell = theRow.insertCell(1);
	theCell.innerHTML ='&nbsp;<img id="delRow" onClick="borrarFila(this)" src="../../cOmmOns/images/borrar.gif" title="Borrar">';
}

function borrarFila(theRow){
	theRow.parentNode.parentNode.parentNode.deleteRow(theRow.parentNode.parentNode.rowIndex);
}
//------------------------------------------------------------------------
var contItinerario = 0;
function agregarItinerario(theTable,numero){
	contItinerario++;
	
	var dia = 'D�a';
	var cnt = 'Contenido';
	var del = 'Borrar';

	if (numero == 2){
		dia = 'Day';
		cnt = 'Content';
		del = 'Delete';
	}
	theRow  = theTable.insertRow(theTable.rows.length);
	theCell = theRow.insertCell(0);
	theCell.innerHTML = dia+'&nbsp;<input class="tmInput" name="itinerario'+numero+'['+contItinerario+'][indice]" size="8">';
	theCell = theRow.insertCell(1);
	theCell.innerHTML ='&nbsp;&nbsp;&nbsp;';
	theCell = theRow.insertCell(2);
	theCell.innerHTML = cnt+'&nbsp;';
	theCell = theRow.insertCell(3);
	theCell.innerHTML ='<textarea name="itinerario'+numero+'['+contItinerario+'][valor]" rows="2" cols="53" class="tmTextarea"></textarea>';
	theCell = theRow.insertCell(4);
	theCell.innerHTML ='&nbsp;&nbsp;';
	theCell = theRow.insertCell(5);
	theCell.innerHTML ='<img onClick="delItinerario(this)" src="../../cOmmOns/images/borrar.gif" title="'+del+'">';
}

function delItinerario(theRow){
	if (contItinerario > 0){contItinerario--;}
	theRow.parentNode.parentNode.parentNode.deleteRow(theRow.parentNode.parentNode.rowIndex);
}
//------------------------------------------------------------------------
function mostrarDivComo(cual){
	if (cual == 1){
		document.getElementById('como').style.display = 'none';
		document.getElementById('valorRegistrarcomo').value = 'Particular';
	} else {
		document.getElementById('como').style.display = '';
		document.getElementById('valorRegistrarcomo').value = 'Prospecto';
	}
}
//------------------------------------------------------------------------
function cambiarEstadoInput(){
	var miInput = document.getElementById('porcentaje');
	miInput.readOnly = !miInput.readOnly;
}
//------------------------------------------------------------------------
function destino(id1) {
	document.location.href = "destinos_detalle.php?Id="+id1;
}
//------------------------------------------------------------------------
function mostrarDivCombinacion(){
	if (document.getElementById('div_combinacion').style.display == 'none'){
		document.getElementById('div_combinacion').style.display = '';
	} else {
		document.getElementById('div_combinacion').style.display = 'none';
	}
}
function abrir(miurl){
    openWin(miurl,'1000','1000')
    }       