	/**********************************************************************
	 BEGIN MODAL DIALOG CODE
	***********************************************************************/


	
	// Global for browser version branching.
	//var IsNav = ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >= 4));
	var dialogWin = new Object();

	// Generate a modal dialog.
	function openDialog(winName, url, width, height, retFunctionName, mousePosition, args) {
	   	if (!dialogWin.win || (dialogWin.win && dialogWin.win.closed)) {
	    	
	    	// Initialize properties of the modal dialog object.
	      	dialogWin.name = winName;
	      	dialogWin.returnFunction =  isFunction(retFunctionName) ?  retFunctionName  : function(){ return true; } ;
	      	dialogWin.returnedValue = "";
	      	dialogWin.args = (args) ? args + "," : "";
	      	dialogWin.url = url;
	      	dialogWin.width = width;
	      	dialogWin.height = height;

			// Window positioning
			if(mousePosition)
			{
				dialogWin.left = xMousePos;
				dialogWin.top = yMousePos;
				var attr = dialogWin.args + "Left=" + dialogWin.left + ",Top=" + dialogWin.top + ", width=" + dialogWin.width + ",height=" + dialogWin.height;
			}
			else
			{
				if((args.indexOf("left")>0)||(args.indexOf("top")>0))
				{
					var attr = dialogWin.args + "width=" + dialogWin.width + ",height=" + dialogWin.height;	
				}
				else
				{
					if(IsNav)
					{
						// 1/3rd of the main window.
						dialogWin.left = (window.screenX + ((window.outerWidth - dialogWin.width) / 2) > 0) ? (window.screenX + ((window.outerWidth - dialogWin.width) / 2)) : 0;
						//dialogWin.top = window.screenY + ((window.outerHeight - dialogWin.height) / 2);
						dialogWin.top = (window.screenY + ((window.outerHeight/3) - (dialogWin.height/3)) > 0) ? (window.screenY + ((window.outerHeight/3) - (dialogWin.height/3))) : 0;
						var attr = dialogWin.args + "screenX=" + dialogWin.left + ",screenY=" + dialogWin.top + ", width=" + dialogWin.width + ",height=" + dialogWin.height;
					}
					else
					{
						// 1/3rd of the screen.
						if(width == pdmScreenSize.Width && height == pdmScreenSize.Height)
						{
							dialogWin.left = 0;
							dialogWin.top = 0;						
						}
						else
						{
							dialogWin.left = (((screen.width - dialogWin.width) / 2) > 0) ? ((screen.width - dialogWin.width) / 2) : 0;
							dialogWin.top = (((screen.height/3) - (dialogWin.height/3)) > 0) ? ((screen.height/3) - (dialogWin.height/3)) : 0;
						}
							
						var attr = dialogWin.args + "left=" + dialogWin.left + ",top=" + dialogWin.top + ", width=" + dialogWin.width + ",height=" + dialogWin.height;
					}
				}
			}

			//blockEvents();
			DisableCurrentForm();
	      	dialogWin.win=window.open(dialogWin.url, dialogWin.name, attr);
	      	dialogWin.win.focus();
	      	
	      //	dialogWin.win.onUnload = unblockEvents;
	       dialogWin.win.onUnload = ReleaseBlockEvents;
	    }
	    else  // aleady open 
	    {
			dialogWin.win.focus();
		}
	}


	function openUrl(winName, url, args) 
	{
	   	if (!dialogWin.win || (dialogWin.win && dialogWin.win.closed)) 
	   	{		  
	   	    dialogWin.name = winName;
	        dialogWin.url = url; 	
	      	dialogWin.win=window.open(dialogWin.url, dialogWin.name, args);
	      	dialogWin.win.focus(); 
	      	
	    }
	    else
	    {
			dialogWin.win.focus();
			
		}
	}


	// Since links in Internet Explorer 4 can't be disabled, preserve IE link onclick
	// event handlers while they're "disabled." Restore when reenabling the main window.
	var IELinkClicks;
	// Disable form elements and links in all frames for IE.
	function disableFormsOld() {
	   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;
	      }
	   }
	}


	function disableForms() {
		IELinkClicks = new Array();

		if(frames.length > 0){
			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;
				}
			}
		}

		for (var i = 0; i < document.forms.length; i++) {
			for (var j = 0; j < document.forms[i].elements.length; j++) {
				document.forms[i].elements[j].disabled = true;
			}
			IELinkClicks[i] = new Array();
			for (k = 0; k < document.links.length; k++) {
				IELinkClicks[i][k] = document.links[k].onclick;
				document.links[k].onclick = deadend;
			}
		}

		var divs = document.getElementsByTagName('div');
		for(i=0; i<divs.length; i++){
			divs[i].disabled = true;
		}
	}

	// Restore IE form elements and links to normal behavior.
	function enableForms() {
		if(frames.length > 0){
			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++) {
					try{
						frames[h].document.links[i].onclick = IELinkClicks[h][i];
					}catch(ex){}
				}
			}
		}
		for (var i = 0; i < document.forms.length; i++) {
			for (var j = 0; j < document.forms[i].elements.length; j++) {
				document.forms[i].elements[j].disabled = false;
			}
			for (k = 0; k < document.links.length; k++) {
				try{
					document.links[k].onclick = IELinkClicks[i][k];
				}catch(ex){}
			}
		}

		var divs = document.getElementsByTagName('div');
		for(i=0; i<divs.length; i++){
			divs[i].disabled = false;
		}
	}


    function DisableCurrentForm()
     {
	   if (IsNav)
	   {
	      window.captureEvents(Event.CLICK | Event.MOUSEDOWN | Event.MOUSEUP | Event.FOCUS);
	      window.onclick = deadend;
	   }
	   else
	   {
	      disableForms();
	   }
	 
	  window.onfocus = CheckCurrentMode;
	}
	
	
	function deadend() {
	   if (dialogWin.win && !dialogWin.win.closed) {
	      dialogWin.win.focus();
	      return false;
	   }
	}
	
	
// window.onfocus = CheckCurrentMode;
	function CheckCurrentMode()
	 {
	   try
	   {
	 
			if(dialogWin.win && !dialogWin.win.closed)
			{
				dialogWin.win.focus();
				
			}
		    
		else // Dialog win does't exist !
		{
				ReleaseBlockEvents() ;
		}
		}catch(err){ ReleaseBlockEvents() ;}
	}


	
	
    // 	dialogWin.win=window.open(dialogWin.url, dialogWin.name, attr);
	// dialogWin.win.onUnload = ReleaseBlockEvents;
	
	function ReleaseBlockEvents() 
	{
	   if (IsNav) 
	   {
			window.releaseEvents(Event.CLICK | Event.MOUSEDOWN | Event.MOUSEUP | Event.FOCUS);
			window.onclick = null;
	   }
	    else
	    {
		 enableForms();
	    }
	    window.focus();
	    window.onfocus = null;
	  
	}
	
	// Called by POPup Page Submit Btton (onclick =) need to post pack
	
	function HandleSubmit(retVal) 
	{
		if (self && !self.closed)
		{
			dialogWin.returnedValue = retVal;
			if(document.getElementById("__POPUPPOSTBACK_PARAMETERS")!= null)
			{
				document.getElementById("__POPUPPOSTBACK_PARAMETERS").value = retVal;
			};
			
			
			ReleaseBlockEvents();
			
		}
		dialogWin.returnFunction();
		dialogWin.win.close();
		
		//return false;
	}
	
	
	// use OpenWindow class to create  popup page , 
	function ClientPageHandleSubmit(retVal) 
	{
	
	    HandleSubmit(retVal) ;
	    __doPostBack('','');	
		//return false;
	}
	
	
	
	
	
	
	// use OpenDialog to create popup page  Called by POPup Page cancell Btn ( not do post back )
	function HandleCancel() 
	{
	   // self-- dialogWin.win
		if (self && !self.closed)
		{
			ReleaseBlockEvents();
			
		}
		
		dialogWin.win.close();
		
		//return false;
	}
	
	
	
	/**************************
	  will dorp folowing method  END MODAL DIALOG CODE
	**************************/

	/* Ok Cancel Button handle function
	**********************************/
	function handleBtnClick(retVal) {
		if (self && !self.closed) {
			dialogWin.returnedValue = retVal;
			unblockEvents();
		}
		dialogWin.win.close();
		return false;
	}
	
	
	
	// Grab all Navigator events that might get through to form elements while
	// dialog is open. For Internet Explorer, disable form elements.
	function blockEvents() {
	   if (IsNav) {
	      window.captureEvents(Event.CLICK | Event.MOUSEDOWN | Event.MOUSEUP | Event.FOCUS);
	      window.onclick = deadend;
	   } else {
	      disableForms();
	   }
	   window.onfocus = checkModal;
	  
	}

	// As dialog closes, restore the main window's original event mechanisms.
	function unblockEvents() {
	   if (IsNav) {
			window.releaseEvents(Event.CLICK | Event.MOUSEDOWN | Event.MOUSEUP | Event.FOCUS);
			window.onclick = null;
	   } else {
			enableForms();
	   }
	   window.onfocus = null;
	  dialogWin.returnFunction();
	}

	function checkModal() {
		if(dialogWin.win && !dialogWin.win.closed){
			dialogWin.win.focus();
			if(!isUndefined(dialogWin.win.dialogWin)){
				if(dialogWin.win.dialogWin.win){
					dialogWin.win.checkModal();
				}
			}
      		return false;
	   }else{
			unblockEvents();
	   }
	}
	
// add by sean 2007

function UltraWebGrid1_EditKeyDownHandler(gridName, cellId, key){
    
    //Get the cell being edited    
    var cell = igtbl_getCellById(cellId);
    
    //Get the row of the cell being edited
    var row = cell.getRow();

    //Key Codes Down = 40, Up = 38, Right = 39, Left = 37
    
    switch(key)
    {
        //If Down Key
        case 40:
            
            //Check to see if there is a next row
            var nextRow = row.getNextRow();
            if(nextRow != null)
            {
                //End editing of the current cell
                cell.endEdit(true); 
                
                //Active and begin edit on the cell below it
                nextRow.getCell(cell.Index).activate();
                nextRow.getCell(cell.Index).beginEdit();
            }
            break;
        //If up key
        case 38:
            //Check to see if there is a previous row
            var prevRow = row.getPrevRow();
            if(prevRow != null)
            {
                //End editing of the current cell
                cell.endEdit(true);
                
                //Active and begin edit on the cell above it
                prevRow.getCell(cell.Index).activate();
                prevRow.getCell(cell.Index).beginEdit();
            }
            break;
        //If right key
        case 39:
            //Check to see if there is a next cell in the row
            var nextCell = cell.getNextCell();
            if(nextCell != null)
            {
                //End editing of the current cell
                cell.endEdit(true);
                
                //Active and begin edit on the cell to the right
                nextCell.activate();
                nextCell.beginEdit();
            }
            break;
        //If left key
        case 37:
            //Check to see if there is a previous cell in the row
            var prevCell = cell.getPrevCell();
            if(prevCell != null)
            {
                //End editing of the current cell
                cell.endEdit(true);
                
                //Active and begin edit on the cell to the left
                prevCell.activate();
                prevCell.beginEdit();
            }
            break;
    }
}


var ctrlPressed = false;

function UltraWebGrid1_KeyDownHandler(gridName, cellId, key)
{
    if (key == 17)
        ctrlPressed = true;
    else if (ctrlPressed && key == 67)
    {
        var rowString = "";
        var isFirstRow = true;
        var grid = igtbl_getGridById(gridName);
        
        for (var rowId in grid.SelectedRows)
        {
            var row = igtbl_getRowById(rowId);

            if (!isFirstRow)
                rowString += '\n';

            for (var i=0; i < row.cells.length; i++)
            {
                if (i != 0)
                    rowString += '\t';

                var cell = row.getCell(i);
                rowString += cell.getValue();
            }

            if (isFirstRow)
                isFirstRow = false;
        }

        window.clipboardData.setData('Text',rowString);
    }
}

function UltraWebGrid1_KeyUpHandler(gridName, cellId, key)
{
    if (key == 17)
        ctrlPressed = false;
}



/* Utilities.js *************************************************************************** 
Description: PDM Common Utility Scripts
******************************************************************************************/
    
    function pdm_Browser()
	{     
			this.AgentName			=navigator.userAgent.toLowerCase();
			this.MajorVersionNumber =parseInt(navigator.appVersion);
			this.IsDom				=(document.getElementById)?true:false;
			this.IsNetscape			=(document.layers?true:false);
			this.IsNetscape4Plus	=(this.IsNetscape && this.MajorVersionNumber >=4)?true:false;
			this.IsNetscape6		=(this.IsDom&&navigator.appName=="Netscape");
			this.IsOpera			=this.AgentName.indexOf('opera')!=-1;
			this.IsMac				=(this.AgentName.indexOf("mac")!=-1);
			this.IsIE				=(document.all?true:false);
			this.IsIE4				=(document.all&&!this.IsDom)?true:false;
			this.IsIE4Plus			=(this.IsIE && this.MajorVersionNumber >= 4)?true:false;
			this.IsIE5				=(document.all&&this.IsDom)?true:false;
			this.IsWin				=((this.AgentName.indexOf("win")!=-1) || (this.AgentName.indexOf("16bit")!=-1));

	}
	

	// ****************** //
	// User Identification
	// ****************** //

  
    // page security global var
     //var IsV2KSA = null;
    // var IsInSysAdminDomain = null;
	//var IsDataChanged = null;

	// *************************************** //
	// Define Scopes for Template Tab and Block
	// *************************************** //
	
	var pdmBrowser = new pdm_Browser();
    var EnablePageCloseConfirm = true;
      
	var ControlDefineScope = new Object();
		ControlDefineScope.SDF = 1;
		ControlDefineScope.UDF = 2;

   
 
   
   	//****************************** BEGIN MOUSE POSITION TRACKING *****************
	
	//var IsNav4 = document.layers;
	var xMousePos = 0;
	var yMousePos = 0;
	
	document.onkeypress = CheckCarriage;
	document.onmousemove = captureMousePosition;
	
	document.onunload = releaseMouse;

	function captureMousePosition(e)
	{
	    xMousePos = (document.all) ? event.clientX+document.documentElement.scrollLeft : e.pageX;
	    yMousePos = (document.all) ? event.clientY+document.documentElement.scrollTop : e.pageY;
	
	
	    //xMousePos = (document.all) ? window.event.x + document.body.scrollLeft : e.pageX;
	    //yMousePos = (document.all) ? window.event.y + document.body.scrollTop : e.pageY;
	}
	

	if(pdm_Browser.IsNetscape)
	{
		document.captureEvents(Event.MOUSEMOVE);
	}
	
	

	function releaseMouse()
	{
		if(pdm_Browser.IsNetscape)
		{
			document.releaseEvents(Event.MOUSEMOVE);
		}
		document.onmousemove = null;
	}
	
	//********************** END MOUSE POSITION TRACKING *************
	
   
   
   
      
      
     //************************* for the page zoom and print...........
     
 
	
	 var PrintLayoutWidth = new Object();
		PrintLayoutWidth.Portrait = 750;
		PrintLayoutWidth.Landscape = 1000;
		
	var PrintLayoutHeight = new Object();
		PrintLayoutHeight.Portrait = 1000;
		PrintLayoutHeight.Landscape = 750;
	
	
	function ZoomToPortraitPrint(controlID,aControl)
	{		
		var controlWidth = document.getElementById(controlID).offsetWidth;
		var controlHeight = document.getElementById(controlID).offsetHeight;
			
		var allMargin = parseFloat(document.body.rightMargin) + parseFloat(document.body.leftMargin);	
												
		// Check the higher difference between width and height
		var widthDiff = 0;	var heightDiff = 0;
						
		widthDiff = controlWidth - PrintLayoutWidth.Portrait;			
		
		heightDiff = controlHeight - PrintLayoutHeight.Portrait;			
		
		if(widthDiff > heightDiff)
		{		
			if((controlWidth + allMargin * 1.5) != 0 )
				document.getElementById(controlID).style.zoom =  PrintLayoutWidth.Portrait/(controlWidth + allMargin * 1.5); 
		}
		else
		{
			if((controlHeight + allMargin * 1.5) != 0)
				document.getElementById(controlID).style.zoom =  PrintLayoutHeight.Portrait/(controlHeight + allMargin * 1.5); 
		}		
	}	
	
		
	function ZoomToLandscapePrint(controlID,aControl)
	{
		var controlWidth = document.getElementById(controlID).offsetWidth;
		var controlHeight = document.getElementById(controlID).offsetHeight;
			
		var allMargin = parseFloat(document.body.rightMargin) + parseFloat(document.body.leftMargin);	
				
		// Check the higher difference between width and height
		var widthDiff = 0;	var heightDiff = 0;
					
		widthDiff = controlWidth - PrintLayoutWidth.Landscape;			
		
		heightDiff = controlHeight - PrintLayoutHeight.Landscape;			
		
		if(widthDiff > heightDiff)
		{		
			if((controlWidth + allMargin * 1.5) != 0)
				document.getElementById(controlID).style.zoom =  PrintLayoutWidth.Landscape/(controlWidth + allMargin * 1.5); 
		}
		else
		{
			if((controlHeight + allMargin * 1.5) != 0)
				document.getElementById(controlID).style.zoom =  PrintLayoutHeight.Landscape/(controlHeight + allMargin * 1.5); 
		}	 		
	}	

		
	if( pdmBrowser.IsIE )
	{		
		document.onkeydown = zoomthisPage;
	} 
	
	var ZoomFactorForTab = 0;
	function zoomthisPage( )
	{
//		var keyCode = event.keyCode;
//		 
//		 
//		
//		if( keyCode == 17)
//			pdmkeyCtrlPressed=true;
//			
//	    if( (keyCode == 107 || keyCode == 187) && pdmkeyCtrlPressed )
//	    {
//			ZoomFactorForTab +=5;
//			document.body.style.zoom = document.body.style.zoom = 1+ ZoomFactorForTab/100 ;
//		}
//			
//			
//		if( ( keyCode == 109 || keyCode == 189 ) && pdmkeyCtrlPressed )
//		{
//			ZoomFactorForTab -=5;
//			document.body.style.zoom = document.body.style.zoom = 1+ ZoomFactorForTab/100 ;
//		}
//			 	
	
				
	    			
	         		
		
	}


     
     
	//*****************  this part is disable Mouse Right Button click ******************
 
	function clickNS(e)
	{
		if (e.which==2 || e.which==3) 
		{
			return false;
		}
	}	
	if (! pdmBrowser.IsIE4Plus)
	{
		document.captureEvents(Event.MOUSEDOWN || Event.MOUSEUP);
		document.onmousedown=clickNS;
		document.onmouseup= clickNS;
		document.oncontextmenu= new Function("return false"); 
	}else
	{
	
		document.onmouseup= new Function("return false");
		document.oncontextmenu= new Function("return false");

	}
	//********************** End ******************************************************
	
	
	
   
 


//******************** this part for close window confirmpage *****************
				 
		function ConfirmExit( ) 
		{ 
		   if(EnablePageCloseConfirm)
			{
			  var cy = event.clientY; 
				if (  cy <= 0  ) 
				{  			  
					event.returnValue =  'If you have made any changes to the fields without clicking the Save button, \nyour changes will be lost.  Are you sure you want to exit this page?'; 
				}
			}			
		} 

//**************************************** end ************************






	var IsNav = ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >= 4));

	function hideIGMenuItems(menuID, action){
		if(arguments.length <= 2)
			return true;
		for(i=2; i<arguments.length; i++)
		{
		   try
		   {
			
			 document.getElementById( menuID  + '_' + arguments[i]).disabled = action;
			 igmenu_getItemById( menuID + '_' + arguments[i]).setEnabled(!action);
		    }catch (er){}
		   // 
		     
			
		}
	}

// ************************** Disable Return key 


 function CheckCarriage(evt)
   {

    var evt  = (evt) ? evt : ((event) ? event : null);

    var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);

    if ((evt.keyCode == 13) && (node.type=="text")) {return false;}

  }



	
	
	// String Manipulation Functions
	// *****************************

	function strRemove(strText, toRemove) 
	{
		/*
		**  Remove all occurrences of a token in a string
		**    text  string to be processed
		**    toRemove  token to be removed
		**  returns new string
		*/
		
		i = strText.indexOf(toRemove);
		r = "";
		
		if (i == -1) 
			return strText;
			
		r += strText.substring(0,i) + strRemove(strText.substring(i + toRemove.length), toRemove);
		
		return r;
	}
  
    function strLtrim() {
        return this.replace(/^\s+/,'');
    }

    function strRtrim() {
        return this.replace(/\s+$/,'');
    }	

	function strTrim(){
        return this.replace(/^\s+/,'').replace(/\s+$/,'');
    }

	String.prototype.ltrim = strLtrim;
	String.prototype.rtrim = strRtrim;
    String.prototype.trim = strTrim;
	// END


	// Data/Object Validation Functions
	//*********************************

	function isUndefined(obj){
		return (typeof(obj)=='undefined');
	}

	function isNull(obj){
		return ((typeof(obj)=='object')&&(!obj));
	}	

	function isBoolean(obj){
		return (typeof(obj)=='boolean');
	}	
	
	function isString(obj){
		return (typeof(obj)=='string');
	}
	
	function isNumber(obj){
		return ((typeof(obj)=='number')&&(isFinite(obj)));
	}
	
	function isFunction(obj){
		return (typeof(obj)=='function');
	}
	
	function isObject(obj){
		return ((obj && typeof(obj)=='object')||isFunction(obj));
	}
	
	function isArray(obj){
		return ((isObject(obj)) && (obj.constructor==Array));
	}
	
	function isEmpty(obj){
		var iCnt, val;
		if(isObject(obj)){
			for(iCnt in obj){
				val = obj[iCnt];
				if((isUndefined(val))&&(isFunction(val))){
					return false;
				}
			}
		}
		return true;
	}
	// END
	

	// User Input Validation Functions
	//*******************************
	
	// Date Validation Functions
	//**************************
	
	
	
	
	
	
	
	
	
	
	
	//**************** get screen max  width  & height************				
	function pdm_ScreenSize()
	{
		var xMax;
		var yMax;
		if (pdmBrowser.IsIE)
		{
			xMax = screen.width - 10  ;
			yMax = screen.height - 55 ;			
		}
		else //if (ig.IsNetscape)
		{
			xMax = window.outerWidth ;
			yMax = window.outerHeight ;
		}
		
		this.Width = xMax;
		this.Height = yMax;						
	}
	var pdmScreenSize = new pdm_ScreenSize();	
	//************************** End ********************************
	

//*************** this part is aoturesize imagepopup page ****************************


function showImageAutoSizePopup( img, imgCaption  ) 
 {	 
 
 
	
	
	
 
 
	w = window.open('','SkechPreviewPage','top='+pdmScreenSize.Height+',left='+pdmScreenSize.Width+',toolbar=no,menubar=yes,location=no,directories=yes,status=no,scrollbars=yes,resizable=yes,copyhistory=no,width=10,height=10');
	w.document.write( "<html><head><title>"+imgCaption+"</title>" );	
	w.document.write( "<STYLE TYPE='text/css'>" );
	w.document.write( "TD {font-family: verdana; font-size: 10px;FONT-WEIGHT: bold; color: Blue; text-decoration : none; cursor:hand;}");	
	w.document.write( "IMG {border-color : gray; cursor: url('../../Common/Images/MAGNIFY.CUR'); }" );	
	w.document.write( "</STYLE>" );
	w.document.write( "<style media=print> .clsNoPrint { DISPLAY: none; } 	</style>" );
	
	w.document.write( "<script language='JavaScript' src='../../Common/Scripts/newUtilities.js'></script>" );
	
	w.document.write( "<script language='JavaScript'>\n");
	w.document.write( "IE5=NN4=NN6=false\n");
	w.document.write( "if(document.all)IE5=true;\n");
	w.document.write( "else if(document.getElementById)NN6=true\n");
	w.document.write( "else if(document.layers)NN4=true\n");
	
	w.document.write( "function autoSize() {\n");
	w.document.write( "	self.moveTo(((("+pdmScreenSize.Width+" - document.images[0].width+30 ) > 0 ) ? (( "+pdmScreenSize.Width+" -document.images[0].width+30 )/2) : 0 ),((("+pdmScreenSize.Height+" - document.images[0].height+31+50) > 0 ) ? (( "+pdmScreenSize.Height+" -document.images[0].height+31+50)/3): 0 ))\n");
	w.document.write( "	if(IE5) self.resizeTo( (((document.images[0].width+30)>"+pdmScreenSize.Width+") ? ("+pdmScreenSize.Width+") : (document.images[0].width+30)),(((document.images[0].height+81)> "+pdmScreenSize.Height+") ? ("+pdmScreenSize.Height+"):(document.images[0].height+81)) )\n");
	w.document.write( "	else if(NN6) self.sizeToContent()\n");
	w.document.write( "	else top.window.resizeTo(((document.images[0].width+20) > "+pdmScreenSize.Width+"  ? "+pdmScreenSize.Width+" : (document.images[0].width+20)) ,((document.images[0].height+50) > "+pdmScreenSize.Height+" ? "+pdmScreenSize.Height+" :(document.images[0].height+50)) )\n");
	w.document.write( "	self.focus()\n");
	w.document.write( "}\n");
	
	w.document.write( "function ZoomImage(scope) {\n");
	w.document.write( "var aImage = document.images['SketchImage']\n");
	w.document.write( "var imgRatio = (aImage.width / aImage.height)\n");
	w.document.write( "aImage.style.width = ((aImage.width + scope) < 100 )? 100 : (aImage.width + scope)  \n");
	w.document.write( "aImage.style.height = (aImage.width * (1/imgRatio)) \n");
	w.document.write( "autoSize();");
	w.document.write( "}\n");	
		 
	w.document.write( "</script>\n");
	
	w.document.write( "</head><body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0 onLoad='javascript:autoSize();'>");
		
	w.document.write("	<table class='clsNoPrint' cellpadding='0' cellspacing='0' border='0'>");
	w.document.write("		<tr>");
	w.document.write("			<td colspan='7' height='5'></td>");	
	w.document.write("		</tr>");	
	w.document.write("		<tr>");
	w.document.write("			<td nowrap width='5'></td>");
	w.document.write("			<td nowrap><font onclick=\"ZoomToPortraitPrint('MainTable',this)\">Fit To Portrait</font></td>");
	w.document.write("			<td nowrap><font onclick=\"ZoomToLandscapePrint('MainTable',this)\">&nbsp;|&nbsp;Fit To Landscape</font></td>");
	w.document.write("			<td nowrap><font onclick='ZoomImage(100);'>&nbsp;|&nbsp;Zoom In</font></td>");
	w.document.write("			<td nowrap><font onclick='ZoomImage(-100);'>&nbsp;|&nbsp;Zoom Out</font></td>");
	w.document.write("			<td nowrap><font onclick='javascript:top.window.close();'>&nbsp;|&nbsp;Close</font></td>");
	w.document.write("			<td width='100%'></td>");
	w.document.write("		</tr>");	
	w.document.write("		<tr>");
	w.document.write("			<td colspan='7'><hr></td>");	
	w.document.write("		</tr>");
	w.document.write("	</table>");	
	
	w.document.write("	<table id='MainTable' cellpadding='0' cellspacing='0' border='0'>");
	w.document.write("		<tr>");	
	w.document.write("			<td>");
	w.document.write("				<img id='SketchImage' src='"+img.src+"' border=0 alt='"+imgCaption+". Click to Zoom in Image' onclick= ZoomImage(100); >");
	w.document.write("			</td>");
	w.document.write("		</tr>");	
	w.document.write("	</table>");
	
			
			
			
	//w.document.write( "<table cellpadding=0 cellspacing=0 border=0><tr><td align='left'><font onclick=ZoomImage(100);>(ZoomIn)&nbsp;&nbsp;</font><font onclick=ZoomImage(-100);>(ZoomOut)</font></td></tr><tr><td height=10></td></tr><tr><td colspan=1></td></tr>" );
	//w.document.write( "<tr><td align='center' colspan=1><a href='javascript:top.window.close();'>close</a>&nbsp;&nbsp;</td></tr>" );
	w.document.write( "</body></html>" );
	w.document.close();
}

//************************************* End  ***********************************************************



	
	//****************** this part for __CLIENTPAGE_PARAMETERS objects **********
	
	
	
	function  AddNewKey ( pdmKeyValueObj )
	{
		var clientPageHiddenObj = document.getElementById( "__CLIENTPAGE_PARAMETERS" );
		var parameters = clientPageHiddenObj.value;
				
		parameters = AddToken( parameters ) + pdmKeyValueObj.key + "=" + pdmKeyValueObj.value ; 
		
		clientPageHiddenObj.value = parameters ;
	
	}
	
	function  UpdateKey ( pdmKeyValueObj)
	{
		var clientPageHiddenObj = document.getElementById( "__CLIENTPAGE_PARAMETERS" );
		var parameters = clientPageHiddenObj.value;
				
		
	
	}
	
	
	
	function  validate ( pdmKeyValueObj)
	{
		var clientPageHiddenObj = document.getElementById( "__CLIENTPAGE_PARAMETERS" );
		var parameters = clientPageHiddenObj.value;
		
		if( parameters.indexOf( pdmKeyValueObj.key )> -1 )
		{
		
		  return true;
		}
			
		else 
		{
		    return false;	
		
		}
			
	
	}
	
	function AddToken( parameters )
	{
		if( parameters )
			return  parameters + "|" ;
		else
			return "";

	}
	
	function pdmKeyValueObject( aKey, aValue )
	{
		this.key = aKey;
		this.value = aValue;
	}
	 
	
	//******************end ****************
	
	
	
	
	//*********** keyboard keycode38 ~ 40 to controal grid the active cells *********
	var pdmkeyCtrlPressed;
	function pdmKey38_40DownPressedForIgGrid(gridID, cellID, keyCode)
	{
	 
		if( keyCode == 17)
		{
			pdmkeyCtrlPressed=true;
			return ;
		}
			
		var cell = igtbl_getCellById(cellID);
		var row = igtbl_getRowById(cellID);
		var column = igtbl_getColumnById(cellID);
		if( pdmkeyCtrlPressed )
		{			 	
			switch( keyCode )
			{		
				
				
				 // key left		
				case 37:					 			 						
					var prevCell = cell.getPrevCell();
					if( prevCell != null )
					{
						cell.endEdit();		
						prevCell.activate();
						pdmkeyCtrlPressed = false;
					}
					break;
				//key up		
				case 38: 				 
					var prevRow = row.getPrevRow();
					if( prevRow != null )
					{
						cell.endEdit();		
						var cellup = prevRow.getCellByColumn(column);
						prevRow.activate();						 
						cellup.activate();
						pdmkeyCtrlPressed = false;
					}					
					break;
				// key right		
				case 39: 				 
						var nextCell = cell.getNextCell();
						if( nextCell != null )
						{ 
							cell.endEdit();		
							nextCell.activate();
							pdmkeyCtrlPressed = false;								
						}
					break;
				case 40: //key down					
					var nextRow = row.getNextRow(); 
					if( nextRow != null )
					{
						cell.endEdit();		
						var cellDown = nextRow.getCellByColumn(column);
						nextRow.activate();					
						cellDown.activate();
						pdmkeyCtrlPressed = false;
					}
					
					break;
				case 85: //undo deleteRows
					pdmUndoKeyDownHandler(gridID, cellID, keyCode);
					break;
					
//				default:
//				    pdmkeyCtrlPressed = false;
//				    break;
				 
			}
		}
	}
	//******************************* end *********************************************
	
	//*************************** this part for undo delete row on client side  by press key Ctrl(17) + U(85) **********
	 
	function pdmUndoKeyDownHandler(gn, cellID, keyCode)
	{
		if( keyCode == 17)
		{
			pdmkeyCtrlPressed=true;
			retrun;
		}
					
		//Ctrl(17) + U(85)			
		if( pdmkeyCtrlPressed && keyCode == 85 )
		{
			var aGrid = igtbl_getGridById(gn);	
			var rows = aGrid.Rows;	
		    var delRows = rows.deletedRows;	
			var length = delRows.length ;

			var insertIndex = 0 ;	
			var count =0;				 
			for( var rowId in aGrid.DeletedRows )
			{
				var strRId = rowId.split('_')				
				if( count == 0 )
					insertIndex = strRId[1];
				if( eval(strRId[1]) <= eval(insertIndex) )
					insertIndex  = strRId[1];
				
				count++;						
			}

			var delId = gn + "r_"+ insertIndex;
			var delRow = getDelRow( delId, delRows );
			if( delRow != null && rows.getRowById( delId ) == null)
			{
				aGrid.suspendUpdates(true);
				delRow.setSelected(false);			 
				rows.insert( delRow,  insertIndex  );
				aGrid.suspendUpdates(false);
				//pdmkeyCtrlPressed = false;
				return;	
			}
		} 	
	}
	
	function getDelRow(  delRowId, delRows )
	{
		for( var i = delRows.length-1; i>=0; i-- )
		{
			var delRow = delRows[i];
			if( delRowId == delRow.Id )
				return delRow;				
		}
		return null;
	}
	//*************************** end **************************
	
	//This function is for empty a control value
	function resetControls( controlID )
	{
		var controlType = document.getElementById( controlID ).type;
		
		if(controlType == "text")
			document.getElementById( controlID ).value = "";		
		else if(controlType == "select-one")
			document.getElementById( controlID ).selectedIndex = 0 ;	
	}
	
	
	
	
	//*************************** wraping ddl, textBox change confirm script *************
	
	function  pdmControlAlertMode()
	{
		 this.NoPostBackNoValueChange = 1 ;
		 this.NoPostBackConfirm = 2 ;
		 this.PostBackConfirm = 3 ;
	}	 
	
	
	
	function pdmControlDataChangeConfirm( aControl, action, msg  )
	{
		 var ControlAlertMode = new pdmControlAlertMode();
		 
		 if( action == ControlAlertMode.NoPostBackNoValueChange )
		 {			
			alert( msg );				
			
		 }
		 else if( action == ControlAlertMode.NoPostBackConfirm )
		 {
			var controlType = null ;
			try{ controlType = aControl.attributes['ControlType'];}catch(ex){}
			if(  !confirm(msg)  )
			{
				
				if( controlType != null && controlType.value == 'CheckBoxList' )
				{
					//aControl.selectedIndex = aControl.attributes['ControlOldValue' ].value;
					 
				}
				else if( aControl.type == "text" )
				{
					aControl.value = aControl.defaultValue ;
				}
				else if( aControl.type == "select-one" )
				{
					aControl.selectedIndex = aControl.attributes['ControlOldValue' ].value;
				}
				 				
			}
			else
			{
				if( controlType != null && controlType.value == 'CheckBoxList' )
				{
					//aControl.attributes['ControlOldValue' ].value = aControl.selectedIndex ;
				}
				if( aControl.type == "text" )
				{
					aControl.value = aControl.value ;
					aControl.defaultValue = aControl.value ;
				}
				else if( aControl.type == "select-one" )
				{
					aControl.attributes['ControlOldValue' ].value = aControl.selectedIndex ;
				}
			}
		 
			
		 }
		 else if( action == ControlAlertMode.PostBackConfirm )
		 {
			var controlType = null ;
			try{ controlType = aControl.attributes['ControlType'];}catch(ex){}
			
			if(  !confirm(msg)  )
			{
				if( controlType != null && controlType.value == 'CheckBoxList' )
				{
					//aControl.selectedIndex = aControl.attributes['ControlOldValue' ].value;
				}
				if( aControl.type == "text" )
				{
					aControl.value = aControl.defaultValue ;
				}
				else if( aControl.type == "select-one" )
				{
					aControl.selectedIndex = aControl.attributes['ControlOldValue' ].value;
				}
				 				
			}
			else
			{
				if( controlType != null && controlType.value == 'CheckBoxList' )
				{
					//aControl.attributes['ControlOldValue' ].value = aControl.selectedIndex ;
				}
				if( aControl.type == "text" )
				{
					aControl.value = aControl.value ;
					aControl.defaultValue = aControl.value ;
				}
				else if( aControl.type == "select-one" )
				{
					aControl.attributes['ControlOldValue' ].value = aControl.selectedIndex ;
				}
				
				__doPostBack( aControl.name, '' );
				
				//__doPostBack( aControl.id, '' );
				//aButton.Attributes.Add( "onClick"," pdmControlDataChangeConfirm( this, '"+aControlAlertMode.GetHashCode()+"','"+ msg +"'  ) ; return false;" );
				// "__doPostBack('"+ aControl.UniqueID.Replace(':','$') +"'  " + @" , 
			}
			
		 }
	}
	
	

					
                    
				
	
//=========================== this part for sort grid by enter num ========= 

	function pdmIgGridAfterSortCellUpdate( gn, cellId )
	{
		var aGrid = igtbl_getGridById(gn);
		aGrid.clearSelectionAll();
		var rows = aGrid.Rows;	
		var aRow = igtbl_getRowById( cellId );	
		aRow.setSelected(true);						
		var cell = igtbl_getCellById(cellId); 
		var index = rows.indexOf(aRow);
		
		if( cell == aRow.getCellFromKey("Sort")  )		
		{
			var newIndex = cell.getValue();
			if( newIndex <= rows.length && newIndex > 0 )
			{
				try
				{
					aGrid.suspendUpdates(true);
					var upRow = rows.remove(index, false );	
					rows.insert( aRow,newIndex-1  );					
					aGrid.suspendUpdates(false);
					
					return true;	
					
				}catch(ex){return true;}
			}
			else
			{
				alert('The sort number is out of rows');
				return true;
			}
			
		}	
		else
		{
			try{
				pdmIgGridAfterCellUpdateHandler( aGrid, aRow, cell );
				return true;
			}catch(ex){return true;}
		}
		
		
		
	
	}

//==========================  end ==========================================
	
	
//=========================  this part for sort grid , move row up or down =========================	
	function pdmGridRowSortMoveUpOrDown( gn, cellId )
	{
		var aGrid = igtbl_getGridById(gn);
		aGrid.clearSelectionAll();
		var rows = aGrid.Rows;		
		var aRow = igtbl_getRowById( cellId );	
		aRow.setSelected(true);	
		var index = rows.indexOf(aRow);
		var cell = igtbl_getCellById(cellId); 
		var cellKey = cell.Column.Key;
			
		if( cell == aRow.getCellFromKey("MoveUp")  )
		{
			if( index != -1 && aRow.getPrevRow() != null )
			{	  
				try
				{
				    cell.setValue('i');
					aGrid.suspendUpdates(true);

					var upRow = rows.remove(index-1, false );											
					rows.insert( upRow,index  );	
					 
					aGrid.suspendUpdates(false);
				
					
					return true;	
				}catch(ex){return true;}
			}	
			else
				return true;	 
		}	  
 		else if( cell == aRow.getCellFromKey("MoveDown") )
		{
			if( index != -1 && aRow.getNextRow() != null )
			{
				try
				{	
				    	 cell.setValue('i');
					aGrid.suspendUpdates(true);		
										    
					var downRow = rows.remove(index+1, false );										 									  	 
					rows.insert( downRow,index );	
					
					aGrid.suspendUpdates(false);
					
					return true;
				}catch(ex){return true;}	
			}
			else
				return true;		 
		}
		else if( cell == aRow.getCellFromKey("Link") )
		{
			try
			{
				pdmPopupLinkHandler(gn, cellId);
				return true;
			}catch(ex){ return true; }
		}
		// Added by David for confirmation of delete row at client side
		else if( cell == aRow.getCellFromKey("DeleteIcon") )
		{
			try
			{
				return DeleteConfirm(gn, cellId);
			}catch(ex){ return true; }
		}
		// End added by David
		else if( cellKey.indexOf("PDMImageSketchBtn") == 0 )
		{
			try
			{				
				pdmOpenSketchMgtWithSketchId(gn, cellId);
				return true;
			}
			catch(ex)
			{ 
				return true; 
			}			
		}
		else if( cellKey.indexOf("PDMImageDeleteBtn") == 0 )
		{
			try
			{
				pdmValidateBeforeDeleteRow(gn, cellId);
				return true;
			}
			catch(ex)
			{ 
				return true; 
			}			
		}
	}	
	
	
//=============================== end part sort grid , move row up or down  =================================================================



//======================= this part for move rows between grids on client side only  ==================
function pdmMoveSelectedRowsBetweenGrid( srcGridID, desGridID )
  {
		var srcGrid = igtbl_getGridById(srcGridID);
		var desGrid = igtbl_getGridById(desGridID);
	    var srcRows = srcGrid.Rows.rows;	    
        desGrid.clearSelectionAll();
        var desColumnsNum = desGrid.Bands[0].Columns.length;
        var srcColumnsNum = srcGrid.Bands[0].Columns.length;
		var colNum = ( desColumnsNum <= srcColumnsNum ? desColumnsNum : srcColumnsNum );
		 
		for(var i in srcRows )
		{
			var srcRow = srcRows[i];
			 if( srcRow != null &&  ( srcRow.getSelected() || srcRow.isActive() ))
			 {
				var desRow =  igtbl_addNew( desGridID, 0 ); 				     						 
				for(var j=0; j< colNum; j++)
				{
					var cellVal = srcRow.getCell(j).getValue();
					desRow.getCell(j).setValue(cellVal,false );
				}
				desRow.setSelected(true);				 
			 }	    
		}
		igtbl_deleteSelRows(srcGridID);
  }
  //========================= end move rows between grids on client side only ================================
  
  
  //========================= this part for fouce edit on first cell after add new row at client side. ========
		function pdmFocusAddNewRow( gn, rowId, index )
		{
			var grid = igtbl_getGridById(gn);
			var row =  grid.Rows.getRowById(rowId); 
			var aCell = row.getCell(0);	
		
			row.activate();
			aCell.activate();	
			grid.beginEdit();
		}  
  //========================= end ==============================================================================
  
  
  //====================== pdmCheckOneColumnHandler ====================
  function pdmCheckOneColumnHandler(gid, cellId, newValue )
  {
		var cell = igtbl_getCellById(cellId); 
		var aRow = igtbl_getRowById( cellId );			
		if( cell == aRow.getCellFromKey('CheckOne'))
		{
			if( newValue == "false" )
				return;
			else
			{
				try{ pdmRemoveAllCheckedCells( igtbl_getRowById( gid+'r_0'));}catch(ex){return;}				
				cell.setValue( newValue, false );				
				var aGrid = igtbl_getGridById(gid);
				aGrid.clearSelectionAll();
				aGrid.deleteSelectedRows();	  
				aRow.setSelected(true);
			}					
		}			
		else 
			return ;
				
  }
  
  function pdmRemoveAllCheckedCells( firstRow )
  {
	  if( firstRow )
	  {		 
		 firstRow.getCellFromKey('CheckOne').setValue( "false", false );
		 
		 pdmRemoveAllCheckedCells( firstRow.getNextRow(true));
	  }
	  else
		  return;
  }
  
  //====================== end ==============
  
  
  
/**

<ClientSideEvents KeyDownHandler="UltraWebGrid1_KeyDownHandler" KeyUpHandler="UltraWebGrid1_KeyUpHandler"></ClientSideEvents>
				
**/





