/* +----------------------------------------------------------+
   |  
   |Modifications:
   |	16-April-2010: By Surya                               |
   |         modified the function to display HTML help files |
   |    28-May-2010: By Richa Bhadola			      |
   |         PTK:Moved function getReleaseNotes()from login.php to functions.js|
   |														  |
   |	© Copyright 2008 Thomson Reuters Inc                  |
   |   Modification not permitted without written permission  |
   |   from Thomson Reuters Inc.							  |
   +----------------------------------------------------------+ */

var lastMouseX;
var lastMouseY;
var curPopupWindow = null;
var helpWindow = null;

var ACCOUNT_ID = 0;
var ACCOUNT_NAME = 1;

curDate = new Date();
in12Years = new Date(curDate.getFullYear() + 15, 1, 1);

window.onresize = function()
{
	if(document.all['tools'])
	{
		document.all['tools'].style.visibility = 'hidden';
	}
}

function HowManyDecimals(fValue){
	if(parseFloat(fValue)==0){
		return 0;
	}
	
	if(parseFloat(fValue)<1){
		if(parseFloat(fValue)<0.1){
			return 3;
		} else {
			return 2;
		}
	} else {
		if(parseFloat(fValue)>20){
			return 0;
		} else {
			return 1;
		}
	}
}


function HowManyDecimalsContiuousIV(fValue){
	if(parseFloat(fValue)==0){
		return 0;
	}
	
	if(parseFloat(fValue)<5){
		if(parseFloat(fValue)<0.1){
			return 3;
		} else {
			return 2;
		}
	} else {
		if(parseFloat(fValue)>20){
			return 0;
		} else {
			return 1;
		}
	}
}


function selectAccount(fieldName)
{
	var newAccount = showModalDialog(
		"includes/select_acct.php",
        "",
        "font-family:arial; font-size:12; dialogWidth:30em; dialogHeight:30em; padding:10px; help:no; status:no;" );
	
	if(newAccount != null)
	{
		field = document.all[fieldName];
		selOption = findOption(field, newAccount[ACCOUNT_ID]);
		if(selOption != -1)
		{
			field.selectedIndex = selOption;
		}
		else
		{
			var newOption = document.createElement("OPTION");
			field.options.add(newOption);
			newOption.innerText = newAccount[ACCOUNT_NAME];
			newOption.value = newAccount[ACCOUNT_ID];
			field.selectedIndex = findOption(field, newAccount[ACCOUNT_ID]);
		}
	}
}

function parseQueryToArray(queryString) {
	var results = new Array();
	if (queryString != '') 
	{
		var srchArray = queryString.split("&");
		var tempArray = new Array();
		for (i = 0; i < srchArray.length; i++) 
		{
			tempArray = srchArray[i].split("=");
			results[unescape(tempArray[0])] = unescape(tempArray[1]);
		}
	} 
	return results;
}

function findOption(field, value)
{
	for(i = 0; i < field.options.length; i++)
	{
		if(field.options[i].value == value)
		{ 
			return i;
		}
	}
	return -1;
}
 
function showToolsMenu(toolsLink)
{
	hideAllMenus();
	posX = event.x-event.offsetX;
	posY = (event.y-event.offsetY)+document.body.scrollTop;
	//posX = toolsLink.parentElement.parentElement.parentElement.parentElement.parentElement.offsetLeft;
	//xPos = document.all['bread'].style.pixelLeft + aLink.offsetLeft;
	toolMenu = document.all['tools'];
	selects = document.getElementsByTagName('select');
	showPositionedMenu('tools', posX-100, posY+16);
	for(i = selects.length; --i >= 0;)
	{
		selectOffsetLeft = selects[i].offsetLeft+selects[i].offsetWidth;
		selectOffsetTop = selects[i].offsetTop;
		prt = selects[i].offsetParent;
		while(prt && prt.tagName != 'BODY')
		{
			selectOffsetLeft += prt.offsetLeft;
			selectOffsetTop += prt.offsetTop;
			prt = prt.offsetParent;
		}
		if(selectOffsetLeft >= toolMenu.offsetLeft && selectOffsetTop <= toolMenu.offsetTop + toolMenu.offsetHeight)
		{
			selects[i].style.visibility = 'hidden';
		}
	}
}

function hideToolsMenu()
{
	toolMenu = document.all['tools'];
	if(toolMenu)
	{ 
		if((!event.toElement) || (event.toElement != toolMenu && !toolMenu.contains(event.toElement)))
		{ 
			hideAllMenus();
			selects = document.getElementsByTagName('select');
			for(i = selects.length; --i >= 0;)
			{
				selects[i].style.visibility = 'visible';
			}
		}
	}
	
}

function setLastMousePosition(e) {
	if (navigator.appName.indexOf("Microsoft") != -1) e = window.event;
	lastMouseX = e.screenX;
	lastMouseY = e.screenY;
}

function openClickout(url) {
		// Taken out due to inconsistent escape results between java and javascript
        //window.open('/sales/linkout.jsp?url='+escape(url), "_blank", 'width=640,height=480,dependent=no,resizable=yes,toolbar=yes,status=yes,directories=yes,menubar=yes,scrollbars=1', false);
	window.open(url, "_blank", 'width=640,height=480,dependent=no,resizable=yes,toolbar=yes,status=yes,directories=yes,menubar=yes,scrollbars=1', false);
}

function openPopup(url, name, pWidth, pHeight, features, snapToLastMousePosition) {
   closePopup();
	if (snapToLastMousePosition) {
		if (lastMouseX - pWidth < 0) {
			lastMouseX = pWidth;
		}
		if (lastMouseY + pHeight > screen.height) {
			lastMouseY -= (lastMouseY + pHeight + 50) - screen.height;
		}
                lastMouseX -= pWidth;
                lastMouseY += 10;
		features +=	",screenX=" + lastMouseX + ",left=" + lastMouseX + "screenY=" + lastMouseY + ",top=" + lastMouseY;
	}
	else
	{
		//added by sriv 11/24/2003
		var winl = (screen.width-pWidth)/2;
  		var wint = (screen.height-pHeight)/2;
		features += ",top="+wint+",left="+winl;
	}
	curPopupWindow = window.open(url, name, features, false);

}
//PTK: modified the function to display HTML help files (By Surya)
function showNeofaxHelp(intTopicIndex,strDoc){
		var strURL = "help_pop_frameset.php?TopicIndex=" + intTopicIndex+"&strDoc="+strDoc;
					//strURL += "&strDoc=" + strDoc;
	openPopup(strURL,'Help', 700,400, 'width=700,height=400,toolbar=no,status=no,directories=no,menubar=no,resizable=yes,scrollable=yes,scrollbars=yes', false);
}

function closePopup() {
	if (curPopupWindow != null) {
	   
		if (!curPopupWindow.closed) {
			curPopupWindow.close();
		}
		curPopupWindow = null;
	}
}

function openLookup(baseURL,modified,searchParam) {
	if (modified == '1') baseURL = baseURL + searchParam;
	openPopup(baseURL, "lookup", 350, 300, "width=350,height=300,toolbar=no,status=no,directories=no,menubar=no,resizable=yes,scrollable=no", true);
}

function pick(form,field,val) {
	eval("document."+form+"[\""+field+"\"].value=" + "\""+val+"\"");
	eval("document."+form+"[\""+field+"\"].focus();");
	eval("document."+form+"[\""+field+"\"].select();");
   closePopup();
	return false;
}

function showCalendar(url) {
	openPopup(url, "Calendar", 200, 150, "width=200,height=150,dependent=yes,resizable=yes,toolbar=no,status=no,directories=no,menubar=no", true);
}

function showNDCCodes(url) {
	openPopup(url, "NDC", 300, 400, "width=300,height=400,dependent=yes,resizable=yes,toolbar=no,status=no,directories=no,menubar=no", true);
}

function openComboBox(url) {
	openPopup(replaceChar(url, ' ', '%'), "Select", 220, 270, "width=270,height=200,dependent=yes,resizable=yes,toolbar=no,status=no,directories=no,menubar=no,scrollbars=1", true);
}

function replaceChar(s, oldchar, newchar) {
	var retval = '';
	for (i = 0; i < s.length; i++) {
		if (s.charAt(i) == ' ') {
			retval = retval + '%';
		} else {
			retval = retval + s.charAt(i);
		}
	}	
	return retval;
}

function openHelp(url) {
	url = url.replace("#", "%23");
	var browserName = navigator.appName;
	if (helpWindow != null && browserName != "Netscape") { helpWindow.close(); }
	var w = window.open(url, "Help", "width=500,height=400,toolbar=no,status=no,directories=no,menubar=no,resizable=yes,screenX=" + window.screenX + ",left=" + window.screenX + "screenY=" + window.screenY + ",top=" + window.screenY, true);
    	w.focus();
	helpWindow = w;
}

function doPrint() {
	alert("This dialog will be replaced by a new browser window containing a printable version" +
		  " of the current page. The user can then select print from the browsers file menu to"+
		  " print the page. Alternatively, this could be an automatically generated Acrobat file.");
}

function doExport() {
	alert("This dialog will be replaced by a File-Save As dialog. Clicking on save in this dialog will save the contents of the current page to a file (in .csv format).");
}

function listProperties(obj) {
	var names = "";
	for (var i in obj) names += i + ", ";
	alert(names);
}

function lookupPick(formName, parentIdElementName, parentEditElementName, id, display) {
    
	var parentIdElement = "document." + formName + "[\"" + parentIdElementName + "\"]";
	var parentEditElement = "document." + formName + "[\"" + parentEditElementName + "\"]";
	var parentEditOldValueElement = "document." + formName + "[\"" + parentEditElementName + "_lkold" + "\"]";
	if (eval(parentIdElement + ".type") == "select-one") {
		var found = false;
		for (i = 0; i < eval(parentIdElement + ".options.length"); i++) {
			if (eval(parentIdElement + ".options[" + i + "].value") == id ) {
				eval(parentIdElement + ".selectedIndex=" + i);
				found = true;
				break;
			}
		}
		if (!found) {
			eval(parentIdElement + ".options[" + parentIdElement + ".options.length] = new Option('" + display + "','" + id + "')");
			eval(parentIdElement + ".selectedIndex=" + parentIdElement + ".options.length - 1");
		}
		eval(parentEditElement + ".value = " + "\"" + display +"\"");    
		eval(parentEditOldValueElement + ".value = " + "\"" + display +"\"");
	} else {
		eval(parentIdElement + ".value = " + "\"" + id +"\"");    
		eval(parentEditElement + ".value = " + "\"" + display +"\"");
		eval(parentEditOldValueElement + ".value = " + "\"" + display +"\"");
	}
	 	
		var parentSubmitParam = parentEditElementName+"_lspf";		
	    var doPost = eval("document."+formName+"[\""+ parentSubmitParam + "\"].value");
	   	if (doPost == '1') {
	   		eval("document."+formName+".submit()");	   
		}
		closePopup();
  
		return false;
}

function insertTS(field,datetime,alias) {
	field.value = "---------------------------------\n"+ alias + " " +datetime + "\n\n\n" + field.value;
}

function setFocus() {
    var sidebarSearch;
	// search for a tabIndexed field to focus on
    for(var firstIndex=1; firstIndex < 5; firstIndex ++ ){
	    var nextIndex = firstIndex;
        for (var frm = 0; frm < document.forms.length; frm++) {
            for (var fld = 0; fld < document.forms[frm].elements.length; fld++) {
                var elt = document.forms[frm].elements[fld];
			    if ( elt.tabIndex != nextIndex ) continue;
                if ((elt.type == "text" || elt.type == "textarea" || elt.type == "password")
                   && elt.name != "sbstr" &&  elt.name.indexOf("owner") != 0) {
				    elt.focus();
	                if (elt.type == "text") {
	                    elt.select();
	                }
	                return true;
			    } else {
				    nextIndex++;
				    fld = 0;
			    }
		    }
	    }
    }

	// failed to find a tabIndexed field, try to find the field based on it's natural position.
    for (var frm = 0; frm < document.forms.length; frm++) {
        for (var fld = 0; fld < document.forms[frm].elements.length; fld++) {
            var elt = document.forms[frm].elements[fld];
            // skip buttons, radio, or check-boxes
            // to skip "select" types, remove from if statement
            if (elt.type == "text" || elt.type == "textarea" || elt.type == "password") {
                if (elt.name == "sbstr" && document.forms[frm].name == "sbsearch") { 
                    sidebarSearch = elt; 
                } else if (elt.name.indexOf("owner") != 0) {
                    
					// if a field is hidden it cannot receive the focus and this will throw 
					// an error, lets catch that error and discard it
					try
					{
						elt.focus(); 
						// select text in text field or textarea
		                if (elt.type == "text") {
		                    elt.select();
		                }
					}
					catch(e) {}
                    return true;
                }
            }
        }
    }

    if (sidebarSearch != null) {
       sidebarSearch.focus();
    }
    return true;
}

function setNamedFocus(element_name) {
    for (var frm = 0; frm < document.forms.length; frm++) {
        for (var fld = 0; fld < document.forms[frm].elements.length; fld++) {
            var elt = document.forms[frm].elements[fld];
            if (elt.name == element_name) {
                elt.focus();
                if (elt.type == "text") {
                    elt.select();
                }
                return true;
            }
        }
    }
    return true;
}

// removes the leading and trailing spaces from a string, 
// similar to the java.lang.String.trim() function
// added by lturetsky, taken from http://www.voy.com/1888/58.html
function trim(st) {
	var len = st.length
	var begin = 0, end = len - 1;
	while (st.charAt(begin) == " " && begin < len) {
		begin++;
	}
	while (st.charAt(end) == " " && begin < end) {
		end--;
	}
	return st.substring(begin, end+1);
}

// removes the leading and trailing characters from a string, 
//added by sriv 11/19/2003
function trim(st, ch) {
	var len = st.length
	var begin = 0, end = len - 1;
	while (st.charAt(begin) == ch && begin < len) {
		begin++;
	}
	while (st.charAt(end) == ch && begin < end) {
		end--;
	}
	return st.substring(begin, end+1);
}

// removes the leading characters from a string, 
//added by sriv 08/25/2004
function ltrim(st, ch) {
	var len = st.length
	var begin = 0, end = len - 1;
	while (st.charAt(begin) == ch && begin < len) {
		begin++;
	}
	return st.substring(begin, end+1);
}

// removes the trailing characters from a string, 
//added by sriv 08/25/2004
function rtrim(st, ch) {
	var len = st.length
	var begin = 0, end = len - 1;
	while (st.charAt(end) == ch && begin < end) {
		end--;
	}
	return st.substring(begin, end+1);
}

function formatPhone (field) {
	field.value = trim(field.value);

    var ov = field.value;
    var v = "";
    var x = -1;

	// is this phone number 'escaped' by a leading plus?
	if (0 < ov.length && '+' != ov.charAt(0)) {	// format it
	    // count number of digits
	    var n = 0;
		if ('1' == ov.charAt(0)) {	// skip it
			ov = ov.substring(1, ov.length);
		}

	    for (i = 0; i < ov.length; i++) {
	        var ch = ov.charAt(i);

	        // build up formatted number
	        if (ch >= '0' && ch <= '9') {
	            if (n == 0) v += "(";
	            else if (n == 3) v += ") ";
	            else if (n == 6) v += "-";
	            v += ch;
	            n++;
	        }
	        // check for extension type section; 
	        // are spaces, dots, dashes and parentheses the only valid non-digits in a phone number?
	        if (! (ch >= '0' && ch <= '9') && ch != ' ' && ch != '-' && ch != '.' && ch != '(' && ch != ')') {
	            x = i;
	            break;
	        }
	    }
	    // add the extension
	    if (x >= 0) v += " " + ov.substring(x, ov.length);

	    // if we recognize the number, then format it
	    if (n == 10 && v.length <= 40) field.value = v;
	}
    return true;
}

function dc () {
    return window.confirm('Are you sure?');
}

function clearcols () {
    for (var frm = 0; frm < document.forms.length; frm++) {
        for (var fld = 0; fld < document.forms[frm].elements.length; fld++) {
            var elt = document.forms[frm].elements[fld];
            if (elt.name == "c" || elt.name.substring(0,2) == "c_") {
                elt.checked = false;
            }
        }
    }
}

function setcols () {
    for (var frm = 0; frm < document.forms.length; frm++) {
        for (var fld = 0; fld < document.forms[frm].elements.length; fld++) {
            var elt = document.forms[frm].elements[fld];
            if (elt.name == "c" || elt.name.substring(0,2) == "c_") {
                elt.checked = true;
            }
        }
    }
}

function setUsername(uname, fname, lname, suffix) {
	if (uname.value.length == 0) {
		uname.value = 
					fname.value.substring(0,1).toLowerCase() 
					+ lname.value.toLowerCase()
					+ "@"
					+ suffix.value;
	}
}
function setAlias(alias, fname, lname) {
	if (alias.value.length == 0) {
		alias.value = fname.value.substring(0,1).toLowerCase() +
					  lname.value.substring(0,4).toLowerCase();
	}
}

// POPUP WINDOW NUMBER 1 
function popWin(url) {
  	closePopup();
  	curPopupWindow = window.open(url,"win","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=550,height=300",false);
}
function popWin2(url) {
   win = window.open(url,"win","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=720,height=500",false);
   //self.name = "tutWindow";
}
function adminWin(url) {
   win = window.open(url,"win","toolbar=1,location=1,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=800,height=600",false);
}

// Changed name of window for printWin so that Printable views do not disappear
// Newname is popWin, Oldname(changed) was curPopupWindow
function printWin(url) {
  popWin = window.open(url,"win","dependent=no,toolbar=0,directories=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1,width=750,height=550",false);
  popWin.focus();
}

function moveSelectElement2(sourceSelect, targetSelect, sourceLabel, targetLabel) {
	moveSelectElement3(sourceSelect, targetSelect, sourceLabel, targetLabel, false);
}


function moveSelectElement3(sourceSelect, targetSelect, sourceLabel, targetLabel, keepTarget) {
	if (sourceSelect.selectedIndex > -1) {
		for (i=0; i < sourceSelect.length; ++i) {  
			var selectedOption = sourceSelect.options[i];
			if (selectedOption.selected) {
				if (selectedOption.text != sourceLabel) {
					var newOption = new Option(selectedOption.text, selectedOption.value);
					if (targetSelect.options.length > 0 && targetSelect.options[0].text == targetLabel) {
						targetSelect.options[0] = newOption;
					} else {
						targetSelect.options[targetSelect.options.length] = newOption;
					}
				} else {
					sourceSelect.selectedIndex = -1;
				}
			}
		}
		if(!keepTarget)
		{	removeSelectElement3(sourceSelect, sourceLabel);
		}
	}
}


function removeSelectElement3(sourceSelect, sourceLabel)
{	if (sourceSelect.selectedIndex > -1)
	{	for (i=sourceSelect.length-1; i > -1; i--) 
		{	if (sourceSelect.options[i].selected) sourceSelect.options[i] = null;
		}
		if (sourceSelect.length == 0) 
		{	var placeHolder = new Option(sourceLabel, sourceLabel);
			sourceSelect.options[0] = placeHolder;
		}
	}
}


function moveUp(sourceSelect)
{	var sel_id;
	sel_id = sourceSelect.selectedIndex;
	if (sourceSelect.length > 1 && sel_id > 0) //got to have at least 2 items and not the first one is selected
	{	var prevOption = sourceSelect.options[sel_id-1];
		var newOption = new Option(prevOption.text, prevOption.value);
		var selectedOption = sourceSelect.options[sel_id];
		sourceSelect.options[sel_id-1] = new Option(selectedOption.text, selectedOption.value);
		sourceSelect.options[sel_id] = newOption;
		sourceSelect.focus();
		sourceSelect.selectedIndex = sel_id -1;
	}
}


function moveDown(sourceSelect)
{	var sel_id;
	sel_id = sourceSelect.selectedIndex;
	if (sourceSelect.length > 1 && sel_id < sourceSelect.length -1) //got to have at least 2 items and not the last one is selected
	{	var nextOption = sourceSelect.options[sel_id+1];
		var newOption = new Option(nextOption.text, nextOption.value);
		var selectedOption = sourceSelect.options[sel_id];
		sourceSelect.options[sel_id+1] = new Option(selectedOption.text, selectedOption.value);
		sourceSelect.options[sel_id] = newOption;
		sourceSelect.focus();
		sourceSelect.selectedIndex = sel_id + 1;
	}
}

function saveSelected(fromSelObj, toHidObj, delim, empty_label) {
    var i;
	toHidObj.value = '';
    for (i=0; i<fromSelObj.length; i++) {
        if (i > 0) {
            toHidObj.value += delim;
        }
        if (!(fromSelObj.length == 1 && fromSelObj.options[0].value == empty_label)) {
            toHidObj.value += fromSelObj.options[i].value;
        }
    } 
}

function openwizard(url, name, resizable) {
  var win = window.open('', name, 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable='+resizable+',width=675,height=550',false)
  if ((win.document.URL == '') || (win.document.URL == 'about:blank')) win.location = url; 
  win.focus ();
}

function escapeUTF(src) {
	var ret = "";
	for (i = 0; i < src.length; i++) {
		var ch = src.charCodeAt(i);
		if (ch <= 0x7F) {
			ret += escape(src.charAt(i));
		} else if (ch <= 0x07FF) {
			ret += '%' + ((ch >> 6) | 0xC0).toString(16) + '%' + ((ch & 0x3F) | 0x80).toString(16);
		} else if (ch >= 0x0800) {
			ret += '%' + ((ch >> 12) | 0xE0).toString(16) +
				   '%' + (((ch >> 6) & 0x3F) | 0x80).toString(16) + '%' + ((ch & 0x3F) | 0x80).toString(16);
		}
	}
	return ret;
}

function openRefer(url) {
	window.open(url, 'referv2', 'resizable=no,toolbar=no,status=no,directories=no,scrollbars=yes,width=420,height=500', false); 
}

function ClearDCNumberFormat(objTemp,strProperty){
	switch(strProperty){
		case "innerHTML":
			objTemp.innerHTML = objTemp.innerHTML.replace(",","");
			break;
		default:
			objTemp.value = objTemp.value.replace(",","");
			break;
	}
}

function AddDCNumberFormat(objTemp,strProperty){
	switch(strProperty){
		case "innerHTML":
			if(objTemp.innerHTML!=""){
				objTemp.innerHTML = MaskNumber(objTemp.innerHTML);
			}
			break;
		default:
			if(objTemp.value!=""){
				objTemp.value = MaskNumber(objTemp.value);
			}
			break;
	}
}

function MaskNumber(sValue) 
{
    if (sValue.length == 0) return "";

    //  Parse the value into a float number
	var iValue = parseFloat(sValue);
	//iValue = (Math.round(iValue * 100)) / 100;
	
	//  If the value is not a number, return an error
	if (isNaN(iValue))
	{
	    ReturnError("Not a valid number");
	    return "";
    }
    
    //  Return the value to a string to apply formatting
    sValue = iValue.toString();
    
    var sLeft = sValue;
	var sRight = "";
    
    //  Add commas if necessary
    if (sValue.indexOf(".") >= 0){
		sLeft = sValue.substring(0,sValue.indexOf("."));
		sRight = sValue.substring(sValue.indexOf(".")+1,(sValue.length));
    }    
    
    if(sLeft.length>4){
		for(var i=(sLeft.length-3);i>0;i=i-3){
			sLeft = sLeft.substring(0,i) + "," + sLeft.substring(i,sLeft.length);
		}
    }
    
    if(sRight.length>0){
		sValue = sLeft + "." + sRight;
    } else {
		sValue = sLeft;
    }
	
	return sValue;
}


/*==============================================================================================
Function: conv_amdate_to_dbdate
Description: convert american date from m/d/Y format to Y-m-d format
in: american date 
out: db date
==============================================================================================*/
function conv_amdate_to_dbdate(am_date){
	newsplit = am_date.split('/'); 
	db_date = newsplit[2]+'-'+newsplit[0]+'-'+newsplit[1];
	return db_date;
}
/*==============================================================================================
Function: conv_dbdate_to_amdate
Description: convert db date from Y-m-d format to m/d/Y format
in:  db date
out: american date
==============================================================================================*/
function conv_dbdate_to_amdate(db_date){
 newsplit = db_date.split("-"); 
 am_date = newsplit[1]+'/'+newsplit[2]+'/'+newsplit[0];
 return am_date;
}

//===================================================================================
// COOKIE MANIPULATION FUNCTIONS
//===================================================================================
function setCookie (name, value) 
{
     var argv = setCookie.arguments;
     var argc = setCookie.arguments.length;
     var expires = (argc > 2) ? argv[2] : null;
     var path = (argc > 3) ? argv[3] : null;
     var domain = (argc > 4) ? argv[4] : null;
     var secure = (argc > 5) ? argv[5] : false;
     document.cookie = name + "=" + escape (value) +
       ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
       ((path == null) ? "" : ("; path=" + path)) +
       ((domain == null) ? "" : ("; domain=" + domain)) +
       ((secure == true) ? "; secure" : "");
}

function getCookieVal(offset)
{
   var endstr = document.cookie.indexOf( ";", offset );
   if( endstr == -1 )
       endstr = document.cookie.length;
   return unescape( document.cookie.substring(offset, endstr) );
}

function getCookie(name)
{
	var arg = name+"=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	var j = 0;
	while( i < clen )
	{
		j = i + alen;
		if (document.cookie.substring( i, j ) == arg)
			return getCookieVal( j );
		i = document.cookie.indexOf( " ", i ) + 1;
		if( i == 0 )
			break;
	} return null;
}

function PrintFriendly(strSubScreen){
	var strURL = "neofax_print.php?subscreen="+strSubScreen+"&dummy=1";
		strURL += "&strTitle=Print Friendly";
	openPopup(strURL,'Print', 790,450, 'width=790,height=450,toolbar=no,status=yes,directories=no,menubar=yes,resizable=yes,scrollable=yes,scrollbars=yes', false);
}


function OverrideThis(strMessage) {
  var arr = showModalDialog( "NeoFaxPopup.php?source=pn_pop_override.php&Message="+strMessage,
                             "",
                             "dialogWidth:20em; dialogHeight:15em" );

  if (arr != null) {
    return arr;
  } else {
  	return false;
  }
}

//Sriv - 06/15/2004
function ShowMessagePopup(strMessage)
{
  //Fix 113
  var result = showModalDialog( "NeoFaxPopup.php?source=pop_message.php&Message="+escape(strMessage),
                             "",
                             "dialogWidth:20em; dialogHeight:15em" );
}

// PTK: Added By Richa Bhadola: the function has been moved from login.php to commonfunction file so that it can be called from Top Link also
function getReleaseNotes()
{
	var testPopUpWindow = window.open('release_notes.php','Neofax','width=600,height=500,left=250,top=130, scrollbars=YES');
	return false;
}
