// JScript File

String.prototype.replaceAll=function(s1, s2) {return this.split(s1).join(s2)}

function findObjWithClientId(Id)
{
    var ctrls = document.all;
    for(var count = 0; count < ctrls.length ; count ++)
    {
        var index = ctrls[count].id.indexOf(Id);
        if(index != -1)
        {
            if((ctrls[count].id.length - index) == Id.length)
            {
                return ctrls[count];
            }
        }
    }
    return null;
}

 function GetRadWindow()
	{
		var oWindow = null;
		if (window.radWindow) oWindow = window.radWindow;
		else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
		return oWindow;
	}

    function CloseRadWindow()
    {
        var currentWindow = GetRadWindow();
        currentWindow.argument = getParam("returnParam").replaceAll("%24","$");
        //alert(currentWindow.argument);
        currentWindow.Close();
        return false;
    }
    
    function getParam( name )
    {  
        name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  
        var regexS = "[\\?&]"+name+"=([^&#]*)";  
        var regex = new RegExp( regexS );  
        var results = regex.exec( window.location.href );  
        if( results == null )    
         return "";  
        else    
            return results[1];
    }
    
 
     function ShowRadWindow(id, url, width, height)
    {
         var oWnd = $find(id);
        oWnd.setSize(width, height);
        oWnd.setUrl(url);
        oWnd.show();
        return false;
    }
    
   function openWindow(url,width,height,name){
	var left = (screen.width/2) - width/2;
	var top = (screen.height/2) - height/2;
	var styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top;
	name = "_blank";
	var oWnd = window.open(url,name, styleStr);

    }
    
  
    function popUpWindow()
{
	var args=popUpWindow.arguments
	if (args.length < 3){
		alert('Minimum parameters required are Url,width,height');
		return
	} 
	var URLStr=args[0];
	var width=args[1];
	var height=args[2];
	var modalwindow='';
	var obj;
	if (args.length >= 4)
	{	
		modalwindow=args[3];
		if (args.length=5){
		obj=args[4];}
	}
	
	var left = (screen.width/2) - width/2;
	var top = (screen.height/2) - height/2;
	var style ='dialogHeight:'+ height +'px;';
		style +=' dialogWidth:' + width + 'px;';
		style +=' dialogTop:' + top + 'px;';
		style +=' dialogLeft:' + left + 'px;';
		style +=' edge:Raised;Center: Yes; help: no; resizable:no;scroll:no;status:no';
	var retVal;
	if(modalwindow = 'true'){
		retVal=window.showModalDialog(URLStr,obj,style);		
		return(retVal);
	}
	else{
		 retVal=window.showModalessDialog(URLStr, 'oWnd',style );
		return(retVal);}
}