//
var currWin = null;
function OpenEditWindow(URL)
{
	currWin = window.open(URL);
}

// detectPopupBlocker.js 
function detectPopupBlocker() {
  var myTest = window.open("about:blank","","directories=no,height=100,width=100,menubar=no,resizable=no,scrollbars=no,status=no,titlebar=no,top=0,location=no");
  if (!myTest) {
    alert("Popup Blocker\r\n\r\nOpening of this site was prevented by a popup blocker.\r\n" +
          "Please add this site to your non-blocked sites by:\r\n\r\n"+
          "1. clicking on the yellow information bar above,\r\n" +
          "2. selecting 'Always allow pop-ups from this site...',\r\n"+
          "3. and confirming the dialog with 'yes'.");
    self.close();
  } else {
    myTest.close();
    //alert("No popup blocker was detected.");
  }
  
}
//window.onload = detectPopupBlocker;

//////////////////////////////////////DialogWindow////////////////////////////	
		
function checkModal() {
	try{
	setTimeout("finishChecking()", 50)
	return true
	}catch(e){}
}

function finishChecking()
{
	try{
	if (dialogWin.win && !dialogWin.win.closed) {
		dialogWin.win.focus() 
    	}
	}catch(e){}
}

	// One object tracks the current modal dialog opened from this window.
//var dialogWin = new Object()
var dialogWin;
var Nav4 = ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) == 4))
// 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 openDGDialog(url, width, height, res)
 { 
    
   dialogWin = new Object();
   try{
	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
		// 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 (Nav4) {
			// Center on the main window.
			dialogWin.left = window.screenX + 
			   ((window.outerWidth - dialogWin.width) / 2)
			dialogWin.top = window.screenY + 
			   ((window.outerHeight - dialogWin.height) / 2)
			
		} 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=" + (window.screen.availWidth/2-width/2) + ",top=" + 
			  ((res==0)?(window.screen.availHeight/2-height/2):0) +
			  ",resizable="+((res==0)?0:1)+",location=0,toolbar=0,directories=0,status=0,menubar=0,width=" + dialogWin.width + 
			   ",height=" + dialogWin.height
		
		
		// Generate the dialog and make sure it has focus.
		dialogWin.win=window.open(dialogWin.url, dialogWin.name, attr)
		dialogWin.win.focus()
	} else {
		dialogWin.win.focus()
	}
	}catch(e) {
	    //detectPopupBlocker();
	}
}

//return empty string if there is no this cookie
function getCookieValue(cookieName)
{
    var splitChar = ";";//default
    var str1, str2, arr1, arr2, retValue = "";
    str1 = new String(document.cookie);
    arr1 = str1.split(splitChar);
    for(i = 0; i<= arr1.length-1; i++)
    {
        str2 = new String(arr1[i]);
        if(str2.indexOf(cookieName) != -1)
        {
            arr2 = str2.split("=");
            if(arr2.length == 2) retValue = arr2[1];
            break;
        }	        
    }
    return retValue;
}

//set value to cookie
function setCookieValue(cookieName, newValue)
{
    var splitChar = ";";//default
    var cookString = new String(document.cookie);
    var oldValue = getCookieValue(cookieName, splitChar);
    if(oldValue != "")
    {
        var findString = cookieName + "=" + oldValue;
        cookString = cookString.replace(findString, (cookieName + "=" + newValue));
        document.cookie = cookString;
    }
    else
    {
        document.cookie = cookieName + "=" + newValue;
    }
}
