function getHTTPObject()
{
     var xmlhttp;

    /*@cc_on
    @if (@_jscript_version >= 5)
    try{
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e){
    try{
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch (e){
    xmlhttp = false;
    }
    }
    @else
    xmlhttp = false;
    @end @*/

    if (!xmlhttp && typeof XMLHttpRequest != 'undefined'){
        try{
            xmlhttp = new XMLHttpRequest();
        }
        catch (e){
            xmlhttp = false;
        }
    }
    return xmlhttp; 
}


function hHttpUser(){	
	if (http.readyState == 4) {
		if (http.status == 200) {			  	  
			results = http.responseText;//.split(",");				 
			enProceso = false;			
			if (results == "EXISTS")
			{
				alert("Ya existe otro usuario con ese "+caracteristica);				
				control.focus();
			}	
		}		
	}			
}


function redundance(afield, value, oldValue, action){
	if (!enProceso && http) {					
		if (afield=="id_legal"){caracteristica="documento"; control=document.forms[0].txtLegal;}
		if (afield=="email"){caracteristica="correo electrónico"; control=document.forms[0].txtEmail;}
		var url = "../proveedor/redundancia.php?campo="+afield+"&viejo="+oldValue+"&valor="+value+"&accion="+action;  		
		//alert(url);
		http.open("GET", url, true);		   
		http.onreadystatechange = hHttpUser;		  		
		enProceso = true;
		http.send(null);				
	}		
}


function highLightS(_sl, _element){
	for (h=0; h<_sl.options.length; h++)
	{
		if (_sl.options[h].value == _element)
		{
			_sl.options.selectedIndex = h;
			break;
		}
	}
}

function highLightM(_sl, _arrSel){
	var csm = 0;
	for (i=0; i<_sl.options.length; i++)	
	{
		for (j=0; j<_arrSel.length; j++)
		{
			if (_sl.options[i].value == _arrSel[j])
			{
				_sl.options[i].selected = true;
				csm++;
				break;
			}
		}
	}
	if (csm==0)
	{
		_sl.options[0].selected = true;
	}
}

function check(_chk,_form){
	for (i=1; i<_form.elements.length; i++)
	{
		_form.elements[i].checked = _chk.checked;
	}
}

function allways_lose_focus(_alt){
	_alt.focus();	
}

function beforeSub(_form){
	var ec = false;
	for (i=1; i<_form.elements.length; i++)
	{
		if(_form.elements[i].checked)
		{
			ec = true;
		}
	}
	if (ec){
		_form.submit();
	}
	else
	{
		alert("No table selected");
	}
}

function indexO(table, element){
	for (i=0; i<table.length; i++)
	{
		if(table[i] == element)
		{
			return i;
		}
	}
	return -1;
}

function indexDO(table, element){
	for (i=0; i<table.length; i++)
	{
		if(element.indexOf(table[i]) != -1)
		{
			return i;
		}
	}
	return -1;
}

function clearOperator(sl){
	var i = sl.options.length-1;
	while (i>=0)
	{			
		sl.options[i] = null;
		i = sl.options.length-1;			
	}
}	

function selectList(sl, slalt){
	slalt.disabled = !(sl.options[sl.selectedIndex].value == "L");
	modMade = true;
}


function newcheck(_chk,_name,_form){
	for (i=1; i<_form.elements.length; i++)
	{
		if (_form.elements[i].id == _name)
		{
			_form.elements[i].checked = _chk.checked;
		}
	}
}

function checkBeforeSubmit(_action, _form, _id, _msg){
	var selMade = false;
	var i = 0;
	var frm = eval(_form);
	frm.action = _action;
	while ((!selMade) && (i<frm.elements.length))
	{
		selMade = ((frm.elements[i].id == _id) && (frm.elements[i].checked));
		i++;
	}
	if (selMade)
	{
		if (_msg != "")
		{
			if (confirm(_msg))
			{
				frm.submit();
			}
		}
		else
		{
			frm.submit();	
		}
	}
	else
	{
		alert("Seleccione un elemento");
	}
}

	
function delOptions(_sl)
{
	var i = _sl.options.length-1;
	while (i>=0)
	{			
		if (_sl.options[i].selected)
		{
			_sl.options[i] = null;
			i = _sl.options.length-1;			
		}
		else
		{
			i--;
		}			
	}
}	
	
function clearSelect(_sl){
	var j = _sl.options.length-1;
	while (j>=0)
	{			
		_sl.options[j] = null;
		j = _sl.options.length-1;			
	}
}	

function passOptions(_source, _target){
	for (k=0; k<_source.options.length; k++)
	{
		if (_source.options[k].selected)
		{
			_target.options[_target.options.length] = new Option(_source.options[k].text, _source.options[k].value);
		}
	}
	delOptions(_source);
	modMade = true;
}
	
function passAllOptions(_source, _target){
	for (k=0; k<_source.options.length; k++)
	{
		_target.options[_target.options.length] = new Option(_source.options[k].text, _source.options[k].value);			
	}
	clearSelect(_source);
	modMade = true;
}	
	
	
function xpand(_form, _suf){
	panel = eval("document.getElementById('pn"+_suf+"')");
	imag = eval("document.getElementById('img"+_suf+"')");
	if (panel.style.display == "none")
	{
		panel.style.display = "inline";
		imag.src = "../images/minus.gif";
	}
	else
	{
		panel.style.display = "none";
		imag.src = "../images/plus.gif";
	}
}
	
function goto(url){
	window.location = url;
}
	
function goSearch(op){	
	if (frmToolBar.txtCriteria.value == "")
	{
		alert("Enter a search criteria");	
		frmToolBar.txtCriteria.focus();		
		if (op==0){	return false;}
	}
	else
	{		
		frmToolBar.hValue.value = "'"+frmToolBar.txtCriteria.value.toUpperCase()+"'";				
		frmToolBar.hOperator.value = frmToolBar.slOperator.options[frmToolBar.slOperator.selectedIndex].value;
		frmToolBar.hPage.value = "";
		frmToolBar.action = "locatecid.asp";
		frmToolBar.submit();
		return true;
	}
}
	
function vcs(cid){
	window.open("callsummary.asp?cid="+cid, "_blank", 'menubar,width=790,height=590');
}
	
function indexOfSL(_sl, text){
	for (x=0; x<_sl.options.length; x++)
	{
		if (_sl.options[x].value == text)
		{
			return x;
		}
	}
	return 0;
}
	
function RTrim(VALUE){
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	if(v_length < 0){
		return"";
	}
	var iTemp = v_length -1;

	while(iTemp > -1){
		if(VALUE.charAt(iTemp) == w_space){
		}
		else{
			strTemp = VALUE.substring(0,iTemp +1);
			break;
		}
		iTemp = iTemp-1;
	} //End While
	return strTemp;
} //End Function

function LTrim(VALUE){
	var w_space = String.fromCharCode(32);
	if(v_length < 1){
		return"";
	}
	var v_length = VALUE.length;
	var strTemp = "";

	var iTemp = 0;

	while(iTemp < v_length){
		if(VALUE.charAt(iTemp) == w_space){
		}
		else{
			strTemp = VALUE.substring(iTemp,v_length);
			break;
		}
		iTemp = iTemp + 1;
	} //End While
	return strTemp;
} //End Function


function Trim(TRIM_VALUE){
	if(TRIM_VALUE.length < 1){
		return"";
	}
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	if(TRIM_VALUE==""){
		return "";
	}
	else
	{
		return TRIM_VALUE;
	}
} //End Function

function before_Submit_Prov(_action){
		
}

function adjuster(table){
	var res = screen.width;
	if (res<1000) {
		res = 760;	
	}
	else
	{
		res = 960;	
	}
	table.width = res;
}

function o_w(afile, w, h){
	url = "../../common/doc.php?file=" + afile;
	var opciones="toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width="+w+", height="+h+", top=0, left=0";
	window.open(url,"",opciones);		
}

function o_wg(afile, w, h){
	var opciones="toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, width="+w+", height="+h+", top=0, left=0";
	window.open(afile,"",opciones);		
}

function o_wgc(){
	o_wg('http://www.galeriamuseoaguilar.com/esp/home/camaras.html', 570, 490);	
}

function o_wgce(){
	o_wg('http://www.galeriamuseoaguilar.com/eng/home/camaras.html', 570, 490);	
}



function playVideo(title, path, prev, next){
	var opciones="toolbar=no, location=no, directories=no, status=yes, scrollbars=yes, width="+screen.width+", height="+screen.height;
	var url = "../../common/play.php?titulo="+title+"&path="+path+"&prev="+prev+"&next="+next;
	window.open(url,"",opciones);			
}

function playit(emisionId){
	var opciones="toolbar=no, location=no, directories=no, status=yes, scrollbars=yes, width="+screen.width+", height="+screen.height;
	var url = "../../common/playit.php?eid="+emisionId;
	window.open(url,"",opciones);			
}

function playGVideo(title, path, prev, next){
	var opciones="toolbar=no, location=no, directories=no, status=yes, scrollbars=yes, width="+screen.width+", height="+screen.height;
	var url = "../../common/playGoogle.php?titulo="+title+"&path="+path+"&prev="+prev+"&next="+next;
	window.open(url,"",opciones);			
}


function ep(file, autor, titulo, linea_base){
	var opciones="toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=yes, resizable=no, width="+screen.width+", height="+screen.height+", top=0, left=0";
	var url = "../../common/zoom.php?file="+file+"&autor="+autor+"&titulo="+titulo+"&linea_base="+linea_base;
	window.open(url,"",opciones);			
}


function ep1(file, titulo){
	var opciones="toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=yes, resizable=no, width="+screen.width+", height="+screen.height+", top=0, left=0";
	var url = "../common/zoom.php?file="+file+"&titulo="+titulo;
	window.open(url,"",opciones);			
}

function sp(){		
   var _href = location.href;
   var _hostname = location.hostname;
   var _pathname = location.pathname;
   var _port = location.port;
   var _protocol = location.protocol;
   
   _pos = _pathname.indexOf('/eng/');
   if (_pos!=-1)
   {
    	_pathname = _pathname.substring(0,_pos+1) + "esp" + _pathname.substring(_pos+4);   
   }
   else
   {
		if (_pathname == "/index-en.html"){
			_pathname = "/";	
		}   
   }
   
   window.location = _protocol + "//" + _hostname + _port + _pathname;
   //alert(_protocol + "//" + _hostname + _port + _pathname);
}

function en(){		
   var _href = location.href;
   var _hostname = location.hostname;
   var _pathname = location.pathname;
   var _port = location.port;
   var _protocol = location.protocol;
   
   _pos = _pathname.indexOf('/esp/');
   if (_pos!=-1)
   {
    	_pathname = _pathname.substring(0,_pos+1) + "eng" + _pathname.substring(_pos+4);   
   }
   else
   {
		if ((_pathname == "/index.html") || (_pathname == "/")){
			_pathname = "/index-en.html";	
		}   
   }
   
   window.location = _protocol + "//" + _hostname + _port + _pathname;
   //alert(_protocol + "//" + _hostname + _port + _pathname);
}
 
  
  function customPrint(){
	 document.getElementById('fotos').style.display = "none";
	 window.print();
	 document.getElementById('fotos').style.display = "inline";
  }
