﻿//NO MODIFICAR EN LA VISTA DE DISEO<SCRIPT LANGUAGE="JavaScript">

/* CHANGE HISTORY
**************
DATE               Marker                 CR#                      Description
****               ******                 ***                      ***********
04/04/07           [001]                 150794                 Browser Compatibility
30/05/07	   [002] 	         KP defect#970		Browser Compatibility  
07/06/07           [003]                 KP Defect#949          Browser Compatibility change for text area max length
21/06/2007	   [004] 	         KP Defect#948          Browser Compatability
10/07/2007	   [005]		 KP Defect#1177		Browser Compatibility
19/07/2007	   [006]		 OCMS Defect#183216	Browser Compatibility(innerHTML)
9/10/2007	   [007]		 176544							Function to alert message on getting double quotes characters.
20/02/2008	   [008]		 190171			Code Merge
**************
*/


//BGF
//false=user can't use mouse right click
//true=the other case
var bUseRightClick = false;
var oTempObj;   //Kp Defect 1008
//BGF
//true=show advisory alert 
//false=don't show advisory alert 
var bShowAlertObjectDoesntExist = false;
var blnTemp;   //Kp Defect 1008
blnTemp=false;  //Kp Defect 1008

//-----------------------------------------------------------------------------
// Browser
//-----------------------------------------------------------------------------
// It creates and object to know which browser and version we use.
//-----------------------------------------------------------------------------
function Browser() {
	var agent =  navigator.userAgent.toLowerCase();

	this.ns = (navigator.appName.toLowerCase() == 'netscape');//Es Netscape
	this.ie = (agent.indexOf("msie") != -1);//Es Explorer

	if (this.ie) {
		this.major = agent.split('msie ')[1];
		this.major = this.major.split(';')[0];
		this.minor = this.major.split('.')[1];
		this.major = parseInt(this.major);
	} else {
		this.major = parseInt(navigator.appVersion);
	}

	this.ns3 = (this.ns && (this.major == 3));
	this.ns4 = (this.ns && (this.major == 4));
	this.ns6 = (this.ns && (this.major >= 5));

	this.ie3 = (this.ie && (this.major == 3));
	this.ie4 = (this.ie && (this.major == 4));
	this.ie5 = (this.ie && (this.major == 5));
	this.ie6 = (this.ie && (this.major > 5) || (this.mayor==5 && this.minor == 5));
}// Browser

// creamos el objeto browser que utilizamos en todas
// las funciones para saber que navegador es el utilizado.


var oBrowser = new Browser();

//-----------------------------------------------------------------------------
// getObject
//-----------------------------------------------------------------------------
//	It converts an object name string to the reference of this one.
//	RPS 15/03/2002
//	intFrameNumber, optional if it <> null then this frame is to manage it
//	In order to allow an only include of this page.
//-----------------------------------------------------------------------------
function getObject(obj,intFrameNumber,bObjFrame) {

	var theObj;

	if (typeof obj == "string") {
		if (oBrowser.ns6 || oBrowser.ie5 || oBrowser.ie6) {//si es Netscape6 o Explorer 5 o Explorer 6
		

			if  (bObjFrame != null){

					theObj = bObjFrame.document.getElementById(obj);
			}else{
	
				if  (intFrameNumber != null){

					theObj = frames[intFrameNumber].document.getElementById(obj);
				}else{

					theObj = document.getElementById(obj);
				}
			}
			
		} else {

			if (oBrowser.ie4) {//si es Explorer 4
				if  (bObjFrame != null){
						theObj = bObjFrame.document.all[obj];
				}else{
					if  (intFrameNumber != null){
						theObj = frames[intFrameNumber].document.all[obj];
					}else{
						theObj = document.all[obj];
					}
				}
			
			} else{
				// Default (Opera)
				theObj = document.getElementById(obj);
			}
		}
	} else {
		theObj = obj;
	}
	return theObj;
}// getObject


//-----------------------------------------------------------------------------
// isUndefined
//-----------------------------------------------------------------------------
//	It returns true if the property passed as parameter is undefined
//	RPS 03/07/2002
//-----------------------------------------------------------------------------
function isUndefined(obj){

	var bResult;

	if (oBrowser.ns6 || oBrowser.ie6) {//If Netscape6 or Explorer 5.5 or Explorer 6
		bResult = obj == undefined;
			
	} else {
		if (oBrowser.ie4 || oBrowser.ie5) {//If Explorer 4 or Explorer 5.0
			bResult = typeof(obj) == 'undefined';
		}
	}

	return bResult;
}

//-----------------------------------------------------------------------------
// ElementWrite  NOT NEEDED BECAUSE INNERHTML RUNS UNDER NS6 AND EXPLORER 4,5 & 6
//-----------------------------------------------------------------------------
// It writtes in the object passed as param, e. a DIV
//-----------------------------------------------------------------------------
function ElementWrite(obj,text) {
	var theObj = getObject(obj);
	//[006] Starts
	if (oBrowser.ie4 || oBrowser.ie5 || oBrowser.ie6) {//si es Explorer 4 o Explorer 5 o Explorer 6		
		theObj.innerText = text;
		//theObj.childNodes[0].nodeValue = text;
	}
	if (oBrowser.ns6) {//si es Netscape6				
		theObj.innerHTML = text;
	}
	//[006] Ends
}// ElementWrite

//-----------------------------------------------------------------------------
// ElementGet
//-----------------------------------------------------------------------------
// It get in the object passed as param, e. a DIV
//-----------------------------------------------------------------------------
function ElementGet(obj) {
	var theObj = getObject(obj);
	//[006] Starts
	if (oBrowser.ie4 || oBrowser.ie5 || oBrowser.ie6) {//si es Explorer 4 o Explorer 5 o Explorer 6
		return theObj.innerText;
	}
	if (oBrowser.ns6) {//si es Netscape6
		return theObj.innerHTML;
	}
	//[006] Ends
}// ElementGet

function alerta(str){
	if (bShowAlertObjectDoesntExist)
		alert(str);
}

//-----------------------------------------------------------------------------
// putValue
//-----------------------------------------------------------------------------
// Bruno Gonzalez 29/03/2001	
//
//	Put the value to the object called 'obj'.The programmer doesn't have
//	to know where the object is, only the name of the object and the value.
//-----------------------------------------------------------------------------
function putValue(obj,value) {
	var theObj = getObject(obj);
	
	if (theObj==null) //If the object name is wrong or doesn't exist
		alerta('The ' + obj + ' object doesn\'t exist');
	else  //everything is ok
		theObj.value=unescape(value);
	
}// putValue


//-----------------------------------------------------------------------------
// getValue
//-----------------------------------------------------------------------------
// Bruno Gonzalez 29/03/2001	
//
//	get the value from the object called 'obj'.The programmer doesn't have
//	to know where the object is, only the name of the object.
//-----------------------------------------------------------------------------
function getValue(obj) {
	var theObj = getObject(obj);
	
	if (theObj==null) //If the object name is wrong or doesn't exist
		alerta('The ' + obj + ' object doesn\'t exist');
	else  //everything is ok
		return theObj.value;
	
}// getValue

//-----------------------------------------------------------------------------
// getParent
//-----------------------------------------------------------------------------
//Gonzalo Mazarrasa 19/4/2001
// get the parent of a Object
//-----------------------------------------------------------------------------
function getParent(obj){
	
	var temp=getObject(obj);

	if (oBrowser.ns6){
		return temp.parentNode;
	} else {
		return temp.parentElement;
	}
	
}//getParent

//-----------------------------------------------------------------------------
// getEventTarget
//-----------------------------------------------------------------------------
//Gonzalo Mazarrasa 1/6/2001
//Oscar Olivares (Review) 3/10/2005
// get the event target
//-----------------------------------------------------------------------------
function getEventTarget(e){
		//[005] Starts		
 		if(!e){
  			if((window)&&(window.event)){
   				e=window.event;
	  		}else{
   				return false;
  		      }
 		}
 		if(e.target){return e.target}
 		if(e.srcElement){return e.srcElement}
		return false;
		//[005] Ends
}//getEventTarget


//*******************************************************************************
// --------------------------------Dinamic Tables-------------------------------
//*******************************************************************************
function putCell(obj){
//GMI 25/4/2001
//Insert a cell 
var temp=getObject(obj);

	if (oBrowser.ns6)
		return temp.insertCell(temp.cells.length+1);
	else
		return temp.insertCell();
}

function putRow(obj){
//GMI 25/4/2001
//Insert a Row
var temp=getObject(obj);

	if (oBrowser.ns6)
		return temp.insertRow(temp.rows.length+1);
	else
		return temp.insertRow();
}

//*******************************************************************************
//-------------------------------------------------------------------------------
//*******************************************************************************


//-------------------------------------------------------------------------------
// Enable
//-------------------------------------------------------------------------------
// Bruno Gonzalez 29/03/2001	
//	Enables an object
//-----------------------------------------------------------------------------
function Enable(obj) {
	var theObj = getObject(obj);
	
	if (theObj==null){ //If the object name is wrong or doesn't exist
		alerta('The ' + obj + ' object doesn\'t exist');
	}else  //everything is ok
	
	theObj.disabled = false;
	
}// Enable

//-----------------------------------------------------------------------------
// Disable
//-----------------------------------------------------------------------------
// Bruno Gonzalez 29/03/2001	
//
//	Disables an object
//-----------------------------------------------------------------------------
function Disable(obj) {
	var theObj = getObject(obj);
	
	if (theObj==null) //If the object name is wrong or doesn't exist
		alerta('The ' + obj + ' object doesn\'t exist');
	else               //everything is ok
	
	theObj.disabled = true;
	
}// Disable

//-----------------------------------------------------------------------------
// hide   NO HACE FALTA PQ STYLE-DISPLAY FUNCIONA EN NS6 Y EXPLORER 4,5 Y 6
//-----------------------------------------------------------------------------
// Oculta el objeto especificado sin reservar el espacio
// Si el objeto es un div y antes de este no hay un <BR>
// se 'come' un retorno de carro
//-----------------------------------------------------------------------------
function hide(obj) {
	var theObj = getObject(obj);
	if (oBrowser.ns6) {//si es Netscape6
		theObj.style.display = 'none';
		//theObj.style.visibility = 'hidden';
		//theObj.style.height = '0px';
	}
	if (oBrowser.ie4 || oBrowser.ie5 || oBrowser.ie6) {//si es Explorer 4 o Explorer 5
		theObj.style.display = 'none';
	}
}

//-----------------------------------------------------------------------------
// show   NO HACE FALTA PQ STYLE-DISPLAY FUNCIONA EN NS6 Y EXPLORER 4,5 Y 6
//-----------------------------------------------------------------------------
// Muestra el objeto especificado
// Si el objeto es un div y antes de este no hay un <BR>
// se 'come' un retorno de carro
//-----------------------------------------------------------------------------
function show(obj) {
	var theObj = getObject(obj);
	if (oBrowser.ns6) {//si es Netscape6
		theObj.style.display = '';
		//theObj.style.visibility = 'visible';
		//theObj.style.height = '';
	}
	if (oBrowser.ie4 || oBrowser.ie5 || oBrowser.ie6) {//si es Explorer 4 o Explorer 5
		if (theObj != null) {
			theObj.style.display = '';
		}
	}
}


//[008] Starts, functions replaced

//*******************************************************************************
// ------ BEGIN MODAL DIALOG CODE (can also be loaded as external .js file)-----
//*******************************************************************************

// One object tracks the current modal dialog opened from this window.
var dialogWin = new Object()

// Generate a modal dialog.
// Parameters:
//    url -- URL of the page/frameset to be loaded into dialog
//    width -- pixel width of the dialog window
//    height -- pixel height of the dialog window
//    returnFunc -- reference to the function (on this page)
//                  that is to act on the data returned from the dialog
//    args -- [optional] any data you need to pass to the dialog
function openDialog(url, width, height, returnFunc, args) {
	if (!dialogWin.win || (dialogWin.win && dialogWin.win.closed)) {

			// Initialize properties of the modal dialog object.
		dialogWin.returnFunc = returnFunc
		dialogWin.returnedValue = ""
		dialogWin.args = args
		dialogWin.url = url
		dialogWin.width = width
		dialogWin.height = height
		dialogWin.scrollbars=true;
		// Keep name unique so Navigator doesn't overwrite an existing dialog.
		dialogWin.name = (new Date()).getSeconds().toString()
		// Assemble window attributes and try to center the dialog.
		if (oBrowser.ns6) {
			// Center on the main window.
			dialogWin.left = window.screenX + 
			   ((window.outerWidth - dialogWin.width) / 2)
			dialogWin.top = window.screenY + 
			   ((window.outerHeight - dialogWin.height) / 2)
			var attr = "screenX=" + dialogWin.left + 
			   ",screenY= " + dialogWin.top +",resizable=no,width=" + 
			   dialogWin.width + ",height=" + dialogWin.height + ",scrollbars=yes" 
		} else {
			// The best we can do is center in screen.
			dialogWin.left = (screen.width - dialogWin.width) / 2
			dialogWin.top = (screen.height - dialogWin.height) / 2
			var attr = "left=" + dialogWin.left + ",top= " 
			   + dialogWin.top +",resizable=no,width=" + dialogWin.width + 
			   ",height=" + dialogWin.height+ ",scrollbars=yes"  
		}
		
		// Generate the dialog and make sure it has focus.
		if (oBrowser.ie) {
			dialogWin.win=window.open(dialogWin.url, dialogWin.name, attr + ",modal=1");
		} else {
			
			if (dialogWin.url.indexOf(location.host) > 0) {
				dialogWin.win=window.open(dialogWin.url, dialogWin.name, attr + ",modal=1");
			} else {
				//-----------------------------------------------
				// Mozilla cannot open a relative url
				// This functionallity tries to open desired page
				//
				// Author: OOM 21/11/2003
				//
				
				var oUrl = dialogWin.url.split("/");
				var sFirstFolder;
				var i=0;
				var bContinue=true;
				var sNewUrl = "";
				var bHTTPS = false;
				var sUrl = location.href.replace("http://", "").split(".asp")[0];
				
				if (sUrl.indexOf("https://",0)>=0){
					sUrl = sUrl.replace("https:", "");
					bHTTPS=true;
				}

				var oData = sUrl.split("/");
			
				if (oUrl.length > 1) {
					sFirstFolder = oUrl[0];
					//i < oData.length -1 to avoid asp page name
					while ((i < oData.length -1) && (bContinue)) {
						bContinue= (oData[i] != sFirstFolder);
						if (bContinue) sNewUrl = sNewUrl + oData[i] + "/";
						i++;
					}
				sNewUrl = sNewUrl + dialogWin.url
			
				} else {
					sNewUrl = sUrl.substring(0, sUrl.lastIndexOf("/")) + "/" + dialogWin.url;
				}
				if (bHTTPS){
					dialogWin.win=window.open("https://" + sNewUrl, dialogWin.name, attr + ",modal=1");
				}else{
					dialogWin.win=window.open("http://" + sNewUrl, dialogWin.name, attr + ",modal=1");
				}
				//-----------------------------------------------
			}
		}

		//dialogWin.win.focus()
	} else {
		//dialogWin.win.focus()
	}
}//openDialog


function openDialogWithoutScrolls(url, width, height, returnFunc, args) {
	if (!dialogWin.win || (dialogWin.win && dialogWin.win.closed)) {

			// Initialize properties of the modal dialog object.
		dialogWin.returnFunc = returnFunc
		dialogWin.returnedValue = ""
		dialogWin.args = args
		dialogWin.url = url
		dialogWin.width = width
		dialogWin.height = height
		dialogWin.scrollbars=false;

		// Keep name unique so Navigator doesn't overwrite an existing dialog.
		dialogWin.name = (new Date()).getSeconds().toString()
		// Assemble window attributes and try to center the dialog.
		if (oBrowser.ns6) {
			// Center on the main window.
			dialogWin.left = window.screenX + 
			   ((window.outerWidth - dialogWin.width) / 2)
			dialogWin.top = window.screenY + 
			   ((window.outerHeight - dialogWin.height) / 2)
			var attr = "screenX=" + dialogWin.left + 
			   ",screenY= " + dialogWin.top +",resizable=no,width=" + 
			   dialogWin.width + ",height=" + dialogWin.height + ",scrollbars=no" 
				} else {
			// The best we can do is center in screen.
			dialogWin.left = (screen.width - dialogWin.width) / 2
			dialogWin.top = (screen.height - dialogWin.height) / 2
			var attr = "left=" + dialogWin.left + ",top= " 
			   + dialogWin.top +",resizable=no,width=" + dialogWin.width + 
			   ",height=" + dialogWin.height+ ",scrollbars=no"  
		}
		
		// Generate the dialog and make sure it has focus.
		if (oBrowser.ie) {
			dialogWin.win=window.open(dialogWin.url, dialogWin.name, attr + ",modal=1");
		} else {
			
			if (dialogWin.url.indexOf(location.host) > 0) {
				dialogWin.win=window.open(dialogWin.url, dialogWin.name, attr + ",modal=1");
			} else {
				//-----------------------------------------------
				// Mozilla cannot open a relative url
				// This functionallity tries to open desired page
				//
				// Author: OOM 21/11/2003
				//
				
				var oUrl = dialogWin.url.split("/");
				var sFirstFolder;
				var i=0;
				var bContinue=true;
				var sNewUrl = "";
				var bHTTPS = false;
				var sUrl = location.href.replace("http://", "").split(".asp")[0];
				
				if (sUrl.indexOf("https://",0)>=0){
					sUrl = sUrl.replace("https:", "");
					bHTTPS=true;
				}

				var oData = sUrl.split("/");
				
				if (oUrl.length > 1) {
					sFirstFolder = oUrl[0];
					//i < oData.length -1 to avoid asp page name
					while ((i < oData.length -1) && (bContinue)) {
						bContinue= (oData[i] != sFirstFolder);
						if (bContinue) sNewUrl = sNewUrl + oData[i] + "/";
						i++;
					}
					sNewUrl = sNewUrl + dialogWin.url
			
				} else {
					sNewUrl = sUrl.substring(0, sUrl.lastIndexOf("/")) + "/" + dialogWin.url;
				}
			
				//window.open("http://" + sNewUrl, dialogWin.name, attr + ",modal=1");
				
				if (bHTTPS){
					dialogWin.win=window.open("https://" + sNewUrl, dialogWin.name, attr + ",modal=1");
				}else{
					dialogWin.win=window.open("http://" + sNewUrl, dialogWin.name, attr + ",modal=1"); //[002]
				}
				
				
				//-----------------------------------------------
			}
		}

		//dialogWin.win.focus()
	} else {
		//dialogWin.win.focus()
	}
}//openDialogWithoutScrolls


//[008] Ends

// Event handler to inhibit Navigator form element 
// and IE link activity when dialog window is active.
function deadend() {
	if (dialogWin.win && !dialogWin.win.closed) {
		dialogWin.win.focus()
		return false
	}
}

// Since links in IE4 cannot be disabled, preserve 
// IE link onclick event handlers while they're "disabled."
// Restore when re-enabling the main window.
var IELinkClicks

// Disable form elements and links in all frames for IE.
function disableForms() {
	IELinkClicks = new Array()
	for (var h = 0; h < frames.length; h++) {
		for (var i = 0; i < frames[h].document.forms.length; i++) {
			for (var j = 0; j < frames[h].document.forms[i].elements.length; j++) {
				frames[h].document.forms[i].elements[j].disabled = true
			}
		}
		IELinkClicks[h] = new Array()
		for (i = 0; i < frames[h].document.links.length; i++) {
			IELinkClicks[h][i] = frames[h].document.links[i].onclick
			frames[h].document.links[i].onclick = deadend
		}
	}
}

// Restore IE form elements and links to normal behavior.
function enableForms() {
	for (var h = 0; h < frames.length; h++) {
		for (var i = 0; i < frames[h].document.forms.length; i++) {
			for (var j = 0; j < frames[h].document.forms[i].elements.length; j++) {
				frames[h].document.forms[i].elements[j].disabled = false
			}
		}
		for (i = 0; i < frames[h].document.links.length; i++) {
			frames[h].document.links[i].onclick = IELinkClicks[h][i]
		}
	}
}

// Grab all Navigator events that might get through to form
// elements while dialog is open. For IE, disable form elements.
function blockEvents() {
	//if (oBrowser.ns6) {
	//	window.captureEvents(Event.FOCUS)
	//	window.onclick = deadend
	//} else {
		disableForms()
	//}
	if (!oBrowser.ns6) {
		window.onfocus = checkModal;}
}

// As dialog closes, restore the main window's original
// event mechanisms.
function unblockEvents() {
	//if (oBrowser.ns6) {
	//	window.releaseEvents(Event.FOCUS)
	//	window.onclick = null
	//	window.onfocus = null
	//} else {
		enableForms()
	//}
}

// Invoked by onFocus event handler of EVERY frame,
// return focus to dialog window if it's open.
function checkModal() {
	if ( !dialogWin.win.closed) {
		if ( !dialogWin.win.closed) {
			//dialogWin.win.focus()	
		}
	}
}

//*******************************************************************************
//-----------------------  END MODAL DIALOG CODE---------------------------------
//*******************************************************************************


//-----------------------------------------------------------------------------
// setBGColor
//-----------------------------------------------------------------------------
// Establece el color del objeto pasado como argumento
//-----------------------------------------------------------------------------
function setBGColor(obj, color) {
	var theObj = getObject(obj);
	if (parent.bIsNav) {
		theObj.bgColor = color
	} else {
		theObj.backgroundColor = color
	}
}
//-----------------------------------------------------------------------------
// setZIndez
//-----------------------------------------------------------------------------
// Establece el Z-Index del Objeto
//-----------------------------------------------------------------------------
function setZIndex(obj, zOrder) {
	var theObj = getObject(obj);
	theObj.zIndex = zOrder
}

//-----------------------------------------------------------------------------
// DisableRigthClick
//-----------------------------------------------------------------------------
// Disables the rigth click
// Bruno.Gonzalez
//-----------------------------------------------------------------------------
function DisableRigthClick(e){
	if (!oBrowser.ns6){
		if (event.button==2){
			//alert("Wellcome to AdeccoWeb");
			event.returnValue=false;
		}
	}else{
		//alert("Wellcome to AdeccoWeb");
		//return false;
	}
}

//-----------------------------------------------------------------------------
// NS_OnlyNumbers_OnKeyUp
//-----------------------------------------------------------------------------
// Only let to put numbers in object, called in the KeyUp event for the Netscape
// Bruno.Gonzalez
// 8/5/2001
//-----------------------------------------------------------------------------
function NS_OnlyNumbers_OnKeyUp(){
	if (isNaN(getValue(this))){
		var len = getValue(this).length;
		var str = getValue(this);
		putValue(this,str.substring(0,len-1));
	}
}

//-----------------------------------------------------------------------------
// OnlyNumbers_onKeypress
//-----------------------------------------------------------------------------
// Only let to put numbers in object
// Bruno.Gonzalez
// 8/5/2001
//-----------------------------------------------------------------------------
function OldOnlyNumbers_onKeypress(object){
	if (oBrowser.ns6){//NS6
		getObject(object).onkeyup = NS_OnlyNumbers_OnKeyUp;		
	}else{//Explorer
		if ((event.keyCode < 48) || (event.keyCode > 57))
			event.keyCode = 0 ;
	}
}
	 
// [001] start
function OnlyNumbers_onKeypress(oEvent){
var ikey;

		if (window.event)
		  ikey = oEvent.keyCode;
	else 
		  ikey = oEvent.which;

		if ( ikey > 47 && ikey < 58 || ikey == 8 )
		  return; 
		else 
	{
			if (ikey != 0 && !((oEvent.ctrlKey && ikey == 120) || (oEvent.ctrlKey && ikey == 99) || (oEvent.ctrlKey && ikey == 118) || (oEvent.ctrlKey && ikey == 97))) //[004]
				{
					if (window.event)
					  oEvent.returnValue = null; 
		else
					  oEvent.preventDefault();
	}
}

}

// [001] End

//-----------------------------------------------------------------------------
// OnlyNumbers_onKeypress
//-----------------------------------------------------------------------------
// Only let to put numbers in object
// Bruno.Gonzalez
// 8/5/2001
//-----------------------------------------------------------------------------
function keyCodeToNumber(lKeyCode) {
	var lNumber;
	
	switch (lKeyCode){
					case 48:
						lNumber = 0;
						break;
						
					case 49:
						lNumber = 1;
						break;
						
					case 50:
						lNumber = 2;
						break;
						
					case 51:
						lNumber = 3;
						break;
						
					case 52:
						lNumber = 4;
						break;
						
					case 53:
						lNumber = 5;
						break;
						
					case 54:
						lNumber = 6;
						break;
						
					case 55:
						lNumber = 7;
						break;
						
					case 56:
						lNumber = 8;
						break;
						
					case 57:
						lNumber = 9;
						break;
						
					default:
						break
	}
	
	return lNumber;
}

//-----------------------------------------------------------------------------
// NS_OnlyChars_OnKeyUp
//-----------------------------------------------------------------------------
// Only let to put numbers in object, called in the KeyUp event for the Netscape
// GMI
// 8/5/2001
//-----------------------------------------------------------------------------
function NS_OnlyChars_OnKeyUp(){
	if (!isNaN(getValue(this))){
		var len = getValue(this).length;
		var str = getValue(this);
		putValue(this,str.substring(0,len-1));
	}
}

//-----------------------------------------------------------------------------
// OnlyChars_onKeypress
//-----------------------------------------------------------------------------
// Only let to put numbers in object
// Bruno.Gonzalez
// 8/5/2001
//-----------------------------------------------------------------------------
function OnlyChars_onKeypress(object){
	if (oBrowser.ns6)//NS6
		getObject(object).onkeyup = NS_OnlyChars_OnKeyUp;		
	else//Explorer
		if ((event.keyCode > 48) || (event.keyCode < 57))
			event.keyCode = 0 ;
}

//-----------------------------------------------------------------------------
// putHideValues
//-----------------------------------------------------------------------------
//GMI 19/4/2001
// Esta Funcion se utiliza para poder meter valores ocultos en algun objeto.
function putHideValues(objeto,valor){
var temp=getObject(objeto);

	if (oBrowser.ns6)
		temp.id=valor;
	else
		temp.iden=valor;
}

//-----------------------------------------------------------------------------
//  getHideValues
//-----------------------------------------------------------------------------
//GMI 19/4/2001
// Esta Funcion se usa para recuperar los valores ocultos de un determinado objeto.
function getHideValues(objeto){

	var temp=getObject(objeto);

	if (oBrowser.ns6)
		return temp.id;
	else
		return temp.iden;
}

//Sergio de la flor
function TextArea_Maxlength_Onblur (oTextArea,lMaxLength, sMessage){	
	var oControl;
	oControl=getObject(oTextArea);
	if (oControl.value.length > lMaxLength){
		blnTemp=true;   //Kp Defect 1008
		alert(sMessage);
		blnTemp=false;    //Kp Defect 1008
		if (oBrowser.ns6) {
		//Kp Defect 1008 Start
			//oControl.setFocus;
		//	oControl.focus();	//No funciona con NetScape 7.0  
			oTempObj = oControl;   
			setTimeout('oTempObj.focus();',1);   
		  //Kp Defect 1008 End	
		} 
		else {
		  	//oControl.setFocus;
			oControl.focus();
		}
	}	
}


//Bruno.Gonzalez

// [003] Start
	
function TextArea_Maxlength (oEvent ,obj,Max)
{
 var iCode;
   if (oBrowser.ns6)
       {
            iCode=oEvent.which; 
       }
    else
      {
            iCode=oEvent.keyCode;
	}
		
  if (obj.value.length > Max-1)
  {
           if (oBrowser.ns6)
           {
                if (iCode != 0)
                 {
		
                     if ((oEvent.ctrlKey && oEvent.which == 97)||(oEvent.ctrlKey && oEvent.which == 120)||(oEvent.ctrlKey && oEvent.which == 118) || (oEvent.ctrlKey && oEvent.which == 99)||(oEvent.which==8)) 
                     {
                               //allow ctrl+(V,C,X,A)                           
                      }
                      else
                      {                                              
                        oEvent.preventDefault();
                      }
                  }
            }
			else
			{
			     	oEvent.keyCode = 0;
			}     
  }
}


// [003] End

//Jmaria.Pairet
// This function is to avoid "copy & paste" in TextAreas
function TextArea_Maxlength_onBlur(obj,Max){
	if (obj.value.length > Max-1){
		var sValue;
		sValue = obj.value;
		obj.value = sValue.substring(0,Max);
	}
}

//-----------------------------------------------------------------------------
//  getTextValueCombo
//-----------------------------------------------------------------------------
//GMI 30/5/2002
// This function is used to get the Text value of a combo
// the parameter is the id of the combo 
function getTextValueCombo (sComboName){
	var combo = getObject(sComboName);
	var iSelIdx = combo.selectedIndex;

	if (iSelIdx>='0'){
		return combo.options[iSelIdx].text;
	}
}

//-----------------------------------------------------------------------------
//  cancelEvent
//-----------------------------------------------------------------------------
//OO 24/7/2001
// For cancel a event
function cancelEvent(oEvent)
{
	if (oEvent != null) 
{
		// [001] Start
		if (oBrowser.ns6 && (navigator.userAgent.indexOf('Firefox')==-1)) 
		{ // [001] End
			window.releaseEvents(oEvent);
		} 
		else 
		{
			oEvent.returnValue = false;
		}
	}
}

// [001] Start

function getObjectByName(obj,intFrameNumber,bObjFrame) {
	var theObj;
	if (typeof obj == "string") {
		if (oBrowser.ns6 || oBrowser.ie5 || oBrowser.ie6) {//si es Netscape6 o Explorer 5 o Explorer 6
			if  (bObjFrame != null){
					theObj = bObjFrame.document.getElementsByName(obj);
			}else{
				if  (intFrameNumber != null){
					theObj = frames[intFrameNumber].document.getElementsByName(obj);
				}else{
					theObj = document.getElementsByName(obj);
				}
			}			
		} else {
			if (oBrowser.ie4) {//si es Explorer 4
				if  (bObjFrame != null){
						theObj = bObjFrame.document.all[obj];
				}else{
					if  (intFrameNumber != null){
						theObj = frames[intFrameNumber].document.all[obj];
					}else{
						theObj = document.all[obj];
					}
				}			
			}
		}
	} else {
		theObj = obj;
	}
	return theObj;
}

//[007] Starts
//-----------------------------------------------------------------------------
//  Text_RemoveDoubleQuote_Onblur
//-----------------------------------------------------------------------------
// Function to alert message on getting double quotes characters.
function Text_RemoveDoubleQuote_Onblur(oTextArea, sMessage){	
	var oControl;
	oControl=getObject(oTextArea);	
	var sValue = new String(oControl.value);
		
	if (sValue.search('"')>=0)
	{		   
		alert(sMessage);
		   
		if (oBrowser.ns6) {		
			oTempObj = oControl;   
			setTimeout('oTempObj.focus();',1);
		} 
		else {		  	
			oControl.focus();
		}
		return false;
	}	
	else
	{
		return true;
	}
}
// [007] End

//</SCRIPT>


