var pp;
function windowOpen(ps_Path, ps_Params,ps_Options){
    if (ps_Options=='')
		ps_Options='width=700,height =500,top=' + getY(500)+ ',left=' + getX(700)+ ',scrollbars=auto';
	ps_Path=resolveUrl(ps_Path);
	if (ps_Params=="")
	    ps_Params='?' + "newWindow=False";
	else
	    ps_Params='?' + ps_Params + "&newWindow=False";		  
  	pp=window.open(ps_Path + ps_Params,'_blank',ps_Options);	
	pp.status='Window';
	pp.focus();
	return false;}
function windowOpenEx(ps_Path, ps_Params,ps_Options,ps_Key,pb_RS){
    if (ps_Options=='') ps_Options='width=700,height =500,top=' + getY(500)+ ',left=' + getX(700)+ ',scrollbars=auto';
	ps_Path=resolveUrl(ps_Path);
	if (ps_Params=="") ps_Params='?' + "newWindow=False";
	else ps_Params='?' + ps_Params + "&newWindow=False";   	
	if (ps_Key!=undefined) ps_Params= ps_Params + '&PageKey=' + ps_Key;
	else ps_Params= ps_Params + '&PageKey=' + Object("pageKey").value;	
	if (pb_RS!=undefined) ps_Params= ps_Params + '&ReleaseSession=' + pb_RS;
	else ps_Params= ps_Params + '&ReleaseSession=false';	
  	pp=window.open(ps_Path + ps_Params ,'_blank',ps_Options);	
	pp.status='Window';
	pp.focus();
	return false;}
function windowShowModalDialog(ps_Path, ps_Params,ps_Options){
    if (ps_Options=='') ps_Options='dialogWidth:700px;dialogHeight:500px;dialogTop:' + getY(500)+ ';dialogLeft:' + getX(700)+ ';scroll:auto';
	ps_Path=resolveUrl(ps_Path);
	if (ps_Params=="") ps_Params='?' + "newWindow=False";
	else ps_Params='?' + ps_Params + "&newWindow=False";		  
  	if(isIE()) window.showModalDialog(ps_Path + ps_Params ,window ,ps_Options);	
  	else window.open(ps_Path,'','modal=yes,dialog=yes');
	return false;}
function windowShowModalDialogEx(ps_Path, ps_Params,ps_Options, ps_Key, pb_RS){
    if (ps_Options=='') ps_Options='dialogWidth:700px;dialogHeight:500px;dialogTop:' + getY(500)+ ';dialogLeft:' + getX(700)+ ';scroll:auto';
	ps_Path=resolveUrl(ps_Path);
	if (ps_Params=="") ps_Params='?' + "newWindow=False";
	else ps_Params='?' + ps_Params + "&newWindow=False";
	if (ps_Key!=undefined) ps_Params= ps_Params + '&PageKey=' + ps_Key;
	else ps_Params= ps_Params + '&PageKey=' + Object("pageKey").value;
	if (pb_RS!=undefined) ps_Params= ps_Params + '&ReleaseSession=' + pb_RS;
	else ps_Params= ps_Params + '&ReleaseSession=false';	  
  	if(isIE()) window.showModalDialog(ps_Path + ps_Params ,window ,ps_Options);	
  	else window.open(ps_Path,'','modal=yes,dialog=yes');
	return false;}
function redirect(ps_Path, ps_Params){
	ps_Path=resolveUrl(ps_Path);
	if (ps_Params=="")
	    ps_Params='?' + "newWindow=True";
	else
	    ps_Params='?' + ps_Params + "&newWindow=True";		  
  	window.location.href=ps_Path + unescape(ps_Params);
	return false;}
function redirectEx(ps_Path, ps_Params, ps_Key, pb_RS){
	ps_Path=resolveUrl(ps_Path);
	if (ps_Params=="")
	    ps_Params='?' + "newWindow=False";
	else
	    ps_Params='?' + ps_Params + "&newWindow=False";
	if (ps_Key!=undefined)
	     ps_Params= ps_Params + '&PageKey=' + ps_Key;
	else
	     ps_Params= ps_Params + '&PageKey=' + Object("pageKey").value;
	if (pb_RS!=undefined)
	     ps_Params= ps_Params + '&ReleaseSession=' + pb_RS;
	else
	     ps_Params= ps_Params + '&ReleaseSession=false';
  	window.location.href=ps_Path + ps_Params;	
	return false;}
function redirectIFrame(ps_IDIFrame, ps_Path, ps_Params){
	ps_Path=resolveUrl(ps_Path);
	if (ps_Params=="") ps_Params='?' + "newWindow=True";
	else ps_Params='?' + ps_Params + "&newWindow=True";
    var oIFrame = Object(ps_IDIFrame);
    if(oIFrame)oIFrame.src=ps_Path + unescape(ps_Params);
    return false;}
function resolveUrl(ps_Path){
	var o_Dir =new Array('/Controls/','/Forms/','/Images/','/JavaScript/','/Xml/');
	var s_App=new String(location.href),s_Pto=new String(ps_Path),i_Rpos,i_Ppos,s_Par =new String(''),x;
	i_Ppos=ps_Path.lastIndexOf('?');
	if (i_Ppos !=-1){
	   s_Pto=ps_Path.slice(0,i_Ppos);
	   s_Par=ps_Path.slice(i_Ppos);}
	s_App=s_App.toLowerCase();	
	s_Pto=s_Pto.toLowerCase();		
	s_Pto=s_Pto.slice(1,s_Pto.length);
	for(x=0;x<o_Dir.length;x++){		
		var s_Dir=new String(o_Dir[x]);	
		s_Dir=s_Dir.toLowerCase();		
		i_Rpos=s_App.lastIndexOf(s_Dir);		
		if (i_Rpos > -1){ 		
			s_App=s_App.slice(0,i_Rpos);			
			return s_App + s_Pto + s_Par;}}
	if (i_Rpos=-1){ 		
		i_Rpos=s_App.lastIndexOf("/");			
		s_App=s_App.slice(0,i_Rpos);							
		return s_App +  s_Pto + s_Par;}}
function getX(aWidth){	
    var xMax = screen.width;    	
    return  (xMax-parseInt(aWidth))/2;}
function getY(aHeight){	
    var  yMax = screen.height;
    return  (yMax-parseInt(aHeight))/2;}
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 Centrar(IDObjeto){
    var Obj=Object(IDObjeto);
    Obj.style.top=getX(Obj.style.width);
    Obj.style.left=getY(Obj.style.height);}
function isIE(){return (navigator.appName=='Microsoft Internet Explorer');}
function isNS(){return (navigator.appName=='Netscape');}
function move(ControlID, Direction){
    var oCtrl=document.getElementById(ControlID);
    var iOffset=5;    
    switch(Direction){
        case 'up': oCtrl.style.top=(parseInt(oCtrl.style.top)+iOffset)+'px';break;
        case 'down': oCtrl.style.top=(parseInt(oCtrl.style.top)-iOffset)+'px';break;
        case 'left': oCtrl.style.left=(parseInt(oCtrl.style.left)-iOffset)+'px';break;
        case 'right': oCtrl.style.left=(parseInt(oCtrl.style.left)+iOffset)+'px';break;}}
function getCurrentProperty(ControlID, PropertyName){
    var oCtrl=Object(ControlID);
    if(document.defaultView) return document.defaultView.getComputedStyle(oCtrl,'').getPropertyValue(PropertyName);
    return oCtrl.currentStyle.getAttribute(PropertyName);}        
function scroll(Direction, Limit){
    var oDivMovil = Object('divMovil');
    var oDivFijo = Object('divFijo');
    var fijoWidth = oDivFijo.scrollWidth;
    var movilWidth = oDivMovil.scrollWidth;
    var movilLeft = parseInt(getCurrentProperty(oDivMovil.id, "left"));    
    if(isIE()){
        switch(Direction){
            case "left":if(Math.abs(movilLeft)<(movilWidth-Limit)) move(oDivMovil.id, Direction);break;                                                        
            case "right":if(movilLeft<0) move(oDivMovil.id, Direction);break;}}
    else{
        switch(Direction){
            case "left":if(Math.abs(movilLeft)<Math.abs(movilWidth-fijoWidth+movilLeft)) move(oDivMovil.id, Direction);break;                                                        
            case "right":if(movilLeft<0) move(oDivMovil.id, Direction);break;}}}
function changePlace(ControlID, DestinationID){
    var oDest = Object(DestinationID);
    var oCtrl = Object(ControlID);
    oDest.appendChild(oCtrl);
    return false;}           
function randomLogo(cellID, className, maxItems){
    var num = Math.round(Math.random() * (maxItems-1)) + 1;
    var obj = Object(cellID);
    if(obj) obj.className = className + num;}
function isNumber(keyCode){
    var retValue=false;
    switch(keyCode){    
        case 13: //enter
        case 0:case 8: //delete
        case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57: //numbers
            retValue=true;}
    return retValue;}
function veranuncio(url){window.open(url,'anuncio','width=340, height=320');}
