var Pop;
function nada(){return false;}
function openEditObj(aPath,aParams,options){
	var width,height;
	if (document.all){
		width=screen.availWidth;
		height=screen.availHeight;}
	else if (document.layers||document.getElementById){
		if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth){
			height = screen.availHeight;				
			width = screen.availWidth;}}
	if (options=='' || options==undefined) 
		options='width=' + width + ',height=' + height + ',top=' + GetY(height) + ',left=' + GetX(width) + ',resizable=1,scrollbars=1,status=1';				
	return windowOpen(aPath, aParams,options);}
function WindowPrint(aPath, aParams){
	if (aPath)	{
		var options='width=400,height =300,top=' + GetY(300) + ',left=' + GetX(400) + ',resizable=1,scrollbars=1,status=1,menubar=1';
		windowOpen(aPath, aParams,options);}
	 else
		window.print();		
	 return false;}
function Imprimir(){		
	window.print();
	return false;}
function solVisita(aPath,aParams,options){	
	if (options=='')
		options='width=800,height =300,top=' + GetY(300) + ',left=' + GetX(800) + ',scrollbars=auto';
	return windowOpen(aPath, aParams,options);}
function windowOpenModal(aPath, aParams, aObj, options){
    if (options=='')
		//options='dialogWidth:800;dialogHeight:600;dialogTop:' + GetY(600) + ';dialogLeft:' + GetX(800) + ';scroll:auto;status:0;centrer:1';
		options='dialogWidth:800px;dialogHeight:600px;scroll:0;status:0;centrer:1;resizable:1;';
	aPath=GetPath(aPath);	
	if (aParams.indexOf('?')<0)
	    aParams='?' + aParams;
	var Args = new Array(window,aObj);  
  	window.showModalDialog(aPath + aParams + "&noframe=True",Args,options);	
	return false;}
function windowOpenX(aPath, aParams){
	aPath=GetPath(aPath);	
	if (aParams.indexOf('?')<0)
	    aParams='?' + aParams;				  
  	Pop=window.open(aPath + aParams + "&noframe=True",'_blank','');	
	Pop.status='Window';
	Pop.focus();
	return false;}
function windowOpenXMLDEF(aPath, aParams){
	return windowOpenX(aPath, aParams,'');}
function windowOpen(aPath, aParams,options){
    if (options=='')
		options='width=800,height =600,top=' + GetY(600) + ',left=' + GetX(800) + ',scrollbars=auto';
	if (aPath.substr(0,7)!="http://")
		aPath=GetPath(aPath);	
	if (aParams.indexOf('?')<0)
	    aParams='?' + aParams;				  
  	Pop=window.open(aPath + aParams + "&noframe=True",'_blank',options);	
	Pop.status='Window';
	Pop.focus();
	return false;}
function GeofactoryOpen(aPath, aParams,options){
    if (options=='')
		options='width=600,height =500,top=' + GetY(500) + ',left=' + GetX(600) + ',scrollbars=auto';
	if (aParams.indexOf('?')<0)
	    aParams='?' + aParams;				  
  	Pop=window.open(aPath + aParams + "&noframe=True",'_blank',options);	
	Pop.status='Window';
	Pop.focus();
	return false;}
function LoadFavorito(aLocation,aLocationProp, aPath, aControl){
	Obj=eval(aLocation);
	Obj.setAttribute(aLocationProp,GetPath(aPath));
	return false;}
function LoadFavIni(aLocation,aLocationProp, aPath, aControl){
	Obj=eval(aLocation);
	Obj.location.href=GetPath(aPath);
	return false;}
function editClose(){
	if (window.opener.document.location.href.indexOf('edit.aspx')==-1)
		window.opener.document.location.href=window.opener.document.location.href;		
	window.close();}
function editCloseModal(aText,aValue){
	if (window.parent)
		if (window.parent.document.location.href.indexOf('newobj.aspx')!=-1){
			window.parent.dialogArguments[0].ReloadComboBox(window.parent.dialogArguments[1],"<option value ='" + aValue + "'>" +  aText +  "</option>");
			window.parent.dialogArguments[0].cbBlur(window.parent.dialogArguments[1]);}
	window.close();}
function editCloseModalNoModal(aText,aValue,aControl){
	if (window.parent){
			
			window.parent.opener.ReloadComboBox(window.parent.opener.document.getElementById(aControl),"<option value ='" + aValue + "'>" +  aText +  "</option>");
			window.parent.opener.cbBlur(window.parent.opener.document.getElementById(aControl));}
	window.close();}
function OpenPrintWindow(aPath, aParams){
 	options='width=300,height =300,top=' + GetY(300) + ',left=' + GetX(300) + ',resizable=yes';
	return windowOpen(aPath, aParams,options);}
function OpenXSLPrintWindow(aPath, aParams){
 	options='width=0,height=0,top=-1000,left=-1000';
	return windowOpen(aPath, aParams,options);}
function GetPath(aPath){	
	var DirS =new Array('/Bot/','/Controls/','/Docs/','/Forms/','/Images/','/JavasCript/','/Modulos/','/ModulosMobiles/','/Reports/','/Styles/','/Uploads/','/Xml/','/Xsl/');	
	var AP=new String(location.href);
	var PTO=new String(aPath);	
	var RPP;
	var PrP;
	var Parameters =new String('');	
	PrP=aPath.lastIndexOf('?');
	if (PrP !=-1){
	   PTO=aPath.slice(0,PrP);
	   Parameters=aPath.slice(PrP);}
	AP=AP.toLowerCase();	
	PTO=PTO.toLowerCase();		
	PTO=PTO.slice(1,PTO.length);			
	for (counter=0;counter<DirS.length;counter++){		
		var Directory=new String(DirS[counter]);		
		Directory=Directory.toLowerCase();			
		RPP=AP.lastIndexOf(Directory);		
		if (RPP > -1){ 
			AP=AP.slice(0,RPP);							
			return AP + PTO + Parameters;}}	
	if (RPP=-1)
		return AP}
function ConfirmAction(aText){		
	if(confirm(aText))
		return true;
	else
		return false;}
function GetTxtId(aAbI){
	var BtI=new String(aAbI);
	var McI;
	var McTxI;
	var RPP;	
	RPP=BtI.lastIndexOf('_');
	BtI=BtI.slice(RPP+4,BtI.length);	
	McI=new String(aAbI);
	RPP=McI.lastIndexOf('_');	
	McI=McI.slice(0,RPP);	
	McTxI= McI +'_txt'+  BtI;
	return McTxI;}
function PostBackParent(aTarget,aArgument){
	 var  form = opener.document.forms[0];
	 form.__EVENTTARGET.value =aTarget;
	 form.__EVENTARGUMENT.value =aArgument;
	 form.submit();
	 window.close();}
function PostBack(aTarget,aArgument){
	var  form = opener.document.forms[0];
	 form.__EVENTTARGET.value =aTarget;
	 form.__EVENTARGUMENT.value =aArgument;
	 form.submit();}
function GoBack(){
	history.back();	
	return false;}
function GoForWard(){
	history.forward();	
	return false;}
function GetX(aWidth){	
    var xMax = screen.width;    	
    return  (xMax/2)-(aWidth/2);}
function GetY(aHeight){	
    var  yMax = screen.height;
    return  (yMax/2)-(aHeight/2);}
function Open(aPath){		
	aPath=GetPath(aPath);	
	Pop=window.open(aPath,'Window','width=' + (screen.width -10)+ ',height =' + (screen.height -30) +',top=0,left=0,resizable=yes');	
	Pop.opener.close();
	Pop.status='Window';
	Pop.focus();
	return false;}
function OpenCalendar(aObjectId, postBack, aPath, aControlType){		
	var txtName;
	var txtValue;		
	if (aControlType == 1){txtId=GetTxtId(aObjectId);	}
	else{txtId=aObjectId;}	
	txtValue=Object(txtId).value	
	aPath=GetPath(aPath);	
	Pop=window.open(aPath+"?id="+ txtId + "&selected="+txtValue+"&postBack="+postBack
	,'Calendar'	
	,'dependent=1,width=170,height=225,top=' + GetY(225) + ',left=' + GetX(170));			
	Pop.focus();	
	return false;}
function OpenCalendarModal(aObjectId, postBack, aPath, aControlType){		
	var txtName,txtValue;
	if (aControlType == 1){txtId=GetTxtId(aObjectId);}
	else{txtId=aObjectId;}	
	txtValue=Object(txtId).value	
	options='dialogWidth:190px;dialogHeight:280px;scroll:0;status:0;centrer:1;resizable:1;';	
  	window.showModalDialog(GetPath('~/Forms/Modals/ModalCalendar.aspx') + '?Url='+ aPath + "&noframe=True" + "&id=" + txtId + "&selected=" + txtValue + "&postBack=" + postBack ,window ,options);
	return false;}
function SetDate(newDate,IdControl,postBack){	
	eval("opener.document.forms[0].elements['"+ IdControl + "'].value ='" + newDate + "';");		
	window.close();	
	if (postBack)
		__doPostBack('IdControl','');		
	return false;}
function SetDateModal(newDate,IdControl,postBack){	
	parent.dialogArguments.document.forms[0].elements[IdControl].value = newDate;
	parent.close();		
	if (postBack)
		__doPostBack('IdControl','');		
	return false;}
function OpenUpload(aObjectId, postBack, aPath, aControlType, aTypeUpload, aUploadPath){
	var txtName;
	var txtValue;	
	if (aControlType == 1){txtId=GetTxtId(aObjectId);}
	else{	txtId=aObjectId;}			
	txtValue=eval("document.forms[0]."+txtId+".value;");	
	aPath=GetPath(aPath);
	Pop=window.open(aPath + "?Id=" + txtId + "&Selected=" + aUploadPath + "&postBack=" + postBack +"&TypeUpload="+aTypeUpload
	,'Upload','dependent=1,width=0,height=0,top=10000,left=10000');
	Pop.status='Upload'
	Pop.focus();	
	return false;}
function SetFile(NewFile,IdControl,postBack){	
	eval("opener.document.forms[0].elements['"+ IdControl + "'].value ='" + NewFile + "';");		
	window.close();	
	if (postBack)
		__doPostBack('IdControl','');}
function OpenFinder(aPath){			
	aPath=GetPath(aPath);	
	Pop=window.open(aPath,'Buscador','dependent=1,scrollbars=1,width=750,height=550,top=' + GetY(550) + ',left=' + GetX(750));			  	
	Pop.status='Finder'
	Pop.focus();
	return false;}
function OpenSelecWindow(idname, tipodb, sql, postBack, cadenaconn, ventana,objeto){
	var txtId;		
	txtId=GetTxtId(idname);		
	ventana=GetPath(ventana);		
	Pop=window.open(ventana+'?id=' + txtId + '&objeto=' + objeto + '&Conn=' + cadenaconn + '&tipodb=' + tipodb + '&sql=' + sql + '&postBack=' + postBack, 'Seleccione' ,'dependent=1,scrollbars=1,width=750,height=550,top=' + GetY(550) + ',left=' + GetX(750));			  				
	Pop.status='Select'
	Pop.focus();
	return false;}
function OpenSelecWindowModal(idname, tipodb, sql, postBack, cadenaconn, ventana,objeto){
	var txtId,options;		
	txtId=GetTxtId(idname);	
	options ='dialogWidth:800px;dialogHeight:600px;scroll:0;status:0;centrer:1;resizable:1;'
	window.showModalDialog(GetPath('~/Forms/Modals/ModalSeleccion.aspx') + '?Url='+ ventana +'&id=' + txtId + '&objeto=' + objeto + '&Conn=' + cadenaconn + '&tipodb=' + tipodb + '&sql=' + sql + '&postBack=' + postBack + '&noframe=true', window ,options);
	return false;}
function OpenNotas(idname, postBack, ventana){
	var txtId;	
	txtId=GetTxtId(idname);
	ventana=GetPath(ventana);	
    Pop=window.open(ventana+'?id=' + txtId + '&postBack=' + postBack, 'Seleccione' ,'dependent=1,width=380,height=400,top=' + GetY(400) + ',left=' + GetX(380));		    
    Pop.status=document.forms[0].elements[txtId].value;		   
    Pop.focus();    
	return false;}
function OpenNotasModal(idname, postBack, ventana){
	var txtId,options;	
	txtId=GetTxtId(idname);	
	options ='dialogWidth:380px;dialogHeight:450px;scroll:0;status:0;centrer:1;resizable:1;'
    window.showModalDialog(GetPath('~/Forms/Modals/ModalSelNotas.aspx') + '?Url='+ ventana +'&id=' + txtId + '&postBack=' + postBack + '&noframe=true', window, options);  
	return false;}
function RefreshTree(aPath, aParams){	
	if (parent.window.TreeFrame)
	{
		var i;
		var x;
		var y;
		x=0;
		y=0;
		for (i=0;i<parent.window.frames.length;i++)
		{
			if (parent.window.frames(i).document.title=='menu')
			{
				
				if(parent.window.frames(i).document.forms[0].X.value)
					x = parent.window.frames(i).document.forms[0].X.value;
			
				if(parent.window.frames(i).document.forms[0].Y.value)
					y = parent.window.frames(i).document.forms[0].Y.value;
			}
		}
		parent.window.TreeFrame.src=GetPath(aPath) + "?" + aParams + "&ConfId=" + parent.window.TreeFrame.ConfId + "&X=" + x + "&Y=" + y;
	}
	return false;}
function CheckFrames(){
	if (window.parent.frames.length>0)
		return true;
	else{
		window.close();
		return false;}}
function SetSelected(aCellClass, aSelectedCellClass, aObject){
		var Tree = document.getElementsByTagName('TD');	
		for (var i=0;i< Tree.length-1;i++)	{
			if (Tree[i].className)
				if (Tree[i].className == aSelectedCellClass )
					Tree[i].className = aCellClass ;}		
		aObject.parentElement.className = aSelectedCellClass;
		if (aObject.parentElement.parentElement.children(1))
			aObject.parentElement.parentElement.children(1).className = aSelectedCellClass ;
		return true;}
function GetObject(aName){			
	if (document.getElementById){
  		this.Properties = document.getElementById(aName);
		this.Style = document.getElementById(aName).style;	}
	else if (document.all){
		this.Properties = document.all[aName];
		this.Style = document.all[aName].style;}
	else if (document.layers){
   		this.Properties = document.layers[aName];
   		this.Style = document.layers[aName];}}
function Object(aName){			
	if (document.getElementById)
  		return  document.getElementById(aName);
	else if (document.all)
		return  document.all[aName];
	else if (document.layers)
   		return  document.layers[aName];}
function findPosX(obj){
	var curleft = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curleft += obj.offsetLeft;
			obj = obj.offsetParent;}	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;}
function findPosY(obj){
	var curtop = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curtop += obj.offsetTop;
			obj = obj.offsetParent;}	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;}
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;} 
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;} 
	return strTemp;} 
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;} 
	return strTemp;} 
