/*
*Libreria de JavaScript.
*/
/***************************************************************
 * Function by create Object XMLHttpRequest for send data Ajax *
 ************************************************************ */
function objAjax(){
	var xmlHttp = false;
		try{
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(E){
				xmlHttp = false;
			}
		}
		if(!xmlHttp && typeof XMLHttpRequest != 'undefined'){
			xmlHttp = new XMLHttpRequest();
		}
		return xmlHttp;
}
/*********************************
 *Function by Check and UnCheck 
 *@example:
 * 	<input type="checkbox" name="SLT_ALL" value="CheckORUnCheckAll" onClick="this.value=check(this.form.nameCheck)">
 *********************************/
function Check4UnCheck(field){
	var checkFlag = "false";
	if(checkFlag == "false"){
		for(i=0;i < field.length; i++){
			field[i].checked = true;
		}
		checkFlag == "true";
		return "UnCheck All";
	}else{
		for(i=0;i < field.length; i++){
			field[i].checked = false;
		}
		checkFlag == "true";
		return "Check All";
	}
}
/*
*@Method: showPopWin for creating modal windows
*@acces: public
*@var: url,title,width,height,returnFunc
*@example :
*	showPopWin(url,title, width, height, returnFunc)
*/

var ventanaPopup = null;
function showPopWin(url,title, width, height){
	 var left   = (screen.width  - width)/2;
	 var top    = (screen.height - height)/2;
	 var args = "width=" + width + ",height=" + height;
 		args += ",center=yes";
 		args += ",minimize=no";
		args += ",menubar=no";
		args += ",resizable=no";
		args += ",scrollbars=no";
		args += ",status=no";
		args += ",toolbar=no";
		args += ",top="+top;
		args += ",left="+left;
		args += ",modal=true";
		args += ",directories=no";
 ventanaPopup = window.open(url,"_blank",args);
}
/*
*@Method: controlPopup to give control to windows
*@acces: public
*@var: none
*@example :
*	controlPopup()
*/
function controlPopup() {
    if (ventanaPopup == null) {
        return;
    } else if (!ventanaPopup.closed) {
        ventanaPopup.focus();
    }
}
/*
*@Method: window.onfocus to give focus to windows
*@acces: public
*@var: none
*@example :
*	window.onfocus = functionName
*/
window.onfocus = controlPopup;
/*
*@Method: Mak4Rand close the windows
*@acces: public
*@var: none
*@example :
*	onClick='WinClose()'
*/
function WinClose(){
	if(confirm('Desea cerrar la venta?')){
		window.close()
	}
}
/*
*@Method: Mak4Rand change the letters to uppercase
*@acces: public
*@var: val
*@example :
*	onChange="Mak4UpperCase(this)"
*/
function Mak4UpperCase(val){
	val.value = val.value.toUpperCase()
}
/*
*@Method: Mak4Rand to change the color to the rows
*@acces: public
*@var: fila,obj
*@example :
*	rowColor(this)
*/
var row = null;
function rowColor(obj) {
	if (row == null){
		row = obj;
	}
	var x = obj.style.backgroundColor;
	row.style.backgroundColor = x;
	obj.style.backgroundColor = '#9bc6dc';
	row = obj;
}
/*
*@Method: Mak4Rand for creating a random number
*@acces: public
*@var: aleat
*@example :
*	Mak4Rand()
*/
function Mak4Rand(){
	aleat = Math.random()*5000;
	aleat = Math.round(aleat);
	return aleat;
}

function Loading(xTop,xLeft){
		return '<table style="text-align:center;top:'+xTop+'px; left:'+xLeft+'px;width:100%;height:100%;"><tr><td ><img src="resource/pleasewait.gif" top="+xTop+"px; left="+xLeft+"px; height="16" border="0"><br>Please wait Loading...</td></tr></table>'
}
function rTrim(sStr){
	while(sStr.charAt(0) == " "){
		sStr = sStr.substr(1, sStr.length -1);
	}
	return sStr;
}
function lTrim(sStr){
	while(sStr.charAt(sStr.length -1) == " "){
		sStr = sStr.substr(0,sStr,length - 1)
	}
	return sStr;
}
function allTrim(sStr){
	return rTrim(lTrim(sStr));
}

