
// Returns the entire query string passed to the current page.
function getQueryString(){ 
        zquery = parent.location.search; 
        zquery = zquery.substring(1,zquery.length); 
        return (zquery); 
} 

// Parses a query string 'queryString' for the variable 'queryName'
// and returns the value associated with that name.
function parseQuery (queryString, queryName) {
	startIndex = queryString.indexOf(queryName);
	if (startIndex == -1) {
		return "";
	}
	
	startIndex = queryString.indexOf("=", startIndex) + 1;
	endIndex = queryString.indexOf("&", startIndex);
	if (endIndex == -1) {
		endIndex = queryString.length;
	}
	return queryString.substring(startIndex, endIndex);
}

function setCookie(name, value) { // use: setCookie("name", value);
    if (value != null && value != "")
      document.cookie=name + "=" + escape(value);
//    bikky= document.cookie; // update bikky
  }
  
//==================================================================================================
// Function:   NewPopupWindow() 
// Arguments:  url, window name, width, height, center window, window features
// Purpose:    This function will create a new window and set the appropiate parameters
// Notes:      * Window Name is used to set the target window.  Use this parameter to create seperate windows and to re-use existing windows.
//             * w & h accepts both length and percentages for both width and height. Example: '550','260' or '75%','45.68%'
//             * centered argument is a yes|no flag whether to center the new window or not.
//             * winFeatures argument is used to pass any extra window parameters. Example: 'menubar,toolbar,location,scrollbars,status,resizable'
//             * To fix the location of the new window don't center the window and add the 'top=' and 'left=' values to the winFeatures parameter.
//             * To use the default window width and height then pass blank or no value for w & h. Example: '',''
//             * To dynamically control the new window after it is created use the oPopupWindow object reference.  FYI: Declare oPopupWindow variable outside the function so it is in global scope.
//==================================================================================================

var oPopupWindow;

function NewPopupWindow(url, winName, w, h, centered, winFeatures) {
    
    var sWinL,sWinT
    var sWidth,sHeight
    var sWinProps

    sWinL = "",sWinT = "",sWidth = "",sHeight = "";
    
    // Determine width
    if (w.search("%") >= 0) {
        sWidth = w.substring(0,w.search("%"));
        sWidth = parseFloat(sWidth);
        sWidth = sWidth / 100;
        sWidth = screen.width * sWidth;
        sWidth = Math.round(sWidth);
        w = sWidth;
        sWidth = "width=" + sWidth;
    } else if (w != "") {
        sWidth = "width=" + w;
    }
    
    // Determine height
    if (h.search("%") >= 0) {
        sHeight = h.substring(0,h.search("%"));
        sHeight = parseFloat(sHeight);
        sHeight = sHeight / 100;
        sHeight = screen.height * sHeight;
        sHeight = Math.round(sHeight);
        h = sHeight;
        sHeight = ",height=" + sHeight;
    } else if (h != "") {
        sHeight = ",height=" + h;
    }

    // Center new window
    if (centered.toLowerCase() == "yes") {
        sWinL = (screen.width - w) / 2;
        sWinL = ",left=" + sWinL;
        sWinT = (screen.height - h) / 2;
        sWinT = ",top=" + sWinT;
    }
    
    sWinProps = sWidth + sHeight + sWinL + sWinT;
    
    if (winFeatures != "") {
        sWinProps = sWinProps + "," + winFeatures;
    }

    oPopupWindow = window.open(url, winName, sWinProps)

    if (parseInt(navigator.appVersion) >= 4) { oPopupWindow.focus() }

}
