j_sepval = String.fromCharCode(20)
function setformobject()
{
/*
//to enable the controls, sothat the values can be submitted along with the form controls

	for(var i=0;i<=(document.forms[0].elements.length -1); i++)
	{
	alert('all' + eval(document.forms[0].elements(i).type));
		if(eval(document.forms[0].elements(i).type) == 'Text')
			{
			alert('text' + eval(document.forms[0].elements(i).id));
			if(document.forms[0].elements(i).disabled == true) 
				document.forms[0].elements(i).disabled = false;
			}
	}
*/
	j_objform = document.forms[0];
}

function setgenvariable()
{
	setformobject();
	
	if(j_objform.g_hd_detailpage)
		j_detailpage = j_objform.g_hd_detailpage.value + ".aspx";
	
	if(j_objform.g_hd_pk)
		j_arrpk = j_objform.g_hd_pk.value.split(",");
	
	if(j_objform.g_hd_mode)
		{
		//alert('setgenvariable : before j_mode = ' + j_mode);
		j_mode = j_objform.g_hd_mode.value;
		
		}
	if(j_objform.g_hd_browsepage)
		j_browsepage = j_objform.g_hd_browsepage.value;
	
	if(j_objform.g_hd_pageno)
		j_pageno = parseInt(j_objform.g_hd_pageno.value);
	if(j_objform.g_hd_pagecount)
		j_pagecount = parseInt(j_objform.g_hd_pagecount.value);
	if(j_objform.g_hd_pagesize)
		j_pagesize = parseInt(j_objform.g_hd_pagesize.value);
}

function closewindow()
{
	window.close();
}//closewindow()

function browseclicked()
{
	setgenvariable();
	if(beforebrowse() == false)
		return;
		
	var url;
	url = j_browsepage + ".aspx";
	if(j_querystring.length > 0)
		url = url + j_querystring;
		
	window.location.href = url;
}


function beforebrowse()
{
	return true;
}

/*********************/
/*TO BE DELETED LATER*/
function NotImplemented()
{
	alert(msg_not_avail);	//Message text is read from the database, id = 'not_avail';
	return;
}
/*TO BE DELETED LATER*/
/*********************/

//This handles the special characters being passed as querystrings into urls.
function fn_parseurl(urlencstr)
{
	var temp 
	temp = urlencstr;
	if(temp.length > 0)
	{
		//reg=/%/g;
		//temp = temp.replace(reg,"%25");
		temp = temp.toString();
		reg=/&/g;
		temp = temp.replace(reg,"%26");
		reg=/#/g;
		temp = temp.replace(reg,"%23");
		reg=/'/g;
		temp = temp.replace(reg,"''");
	}
	return temp;
	
} // end fn_parseurl(urlencstr)


function openwindow(url, winname,winprop)
{
	objwin = window.open(url, winname, winprop);
	objwin.focus();
}

function exitclicked(url)
{
	window.location.href=url
}


// Fix the no. of 0's after decimal 
function FixDecimal(s,n)
{
	var sNew =s;
	if(IsReal(s))
	{
		 sNew = Math.round(s * Math.pow(10,n))/Math.pow(10,n);
		if (n==4)
			{	
				//cast to string
				sNew = sNew.toString();
				var posDec = sNew.indexOf('.');
				if (posDec == -1) 
					sNew = sNew + ".0000";
				else if(posDec > -1)
					{
					var lastStr = sNew.substring(posDec+1, (sNew.length))
					var lenStr = lastStr.length;
					if (lenStr == 1) sNew = sNew + "000";
					if (lenStr == 2) sNew = sNew + "00";
					if (lenStr == 3) sNew = sNew + "0";
					}
			}
			else
			if (n==2)
			{	
				//cast to string
				sNew = sNew.toString();
				var posDec = sNew.indexOf('.');
				if (posDec == -1) 
					sNew = sNew + ".00";
				else if(posDec > -1)
					{
					var lastStr = sNew.substring(posDec+1, (sNew.length))
					var lenStr = lastStr.length;
					if (lenStr == 1) sNew = sNew + "0";
					}
			}
		}
		else
			sNew =0;
	return sNew;
}


/*~check if the validity of real(num only no sign)~*/
function IsReal(theInput)
{
	inputValue =trim(theInput);
	if (inputValue != '') 
	{
		var theDecLoc = inputValue.lastIndexOf(".");
		if ((theDecLoc != -1) && (theDecLoc != 0))
		{
			var theDecLocNext = inputValue.lastIndexOf(".",theDecLoc - 1);
			if  (theDecLocNext != -1)
				return false; /*invalid if two dots*/
		}
		var theLength = inputValue.length;
		for (var i = 0; i <= (theLength-1); i++)
		{
			var theChar = inputValue.substring(i,i+1);
			if ((theChar == ".") && ((theLength == 1) || (i == theLength - 1)))
				return false; /*position of the dot*/
			if ((theChar < "0" || theChar > "9") && (theChar != "."))
				return false; /*other than 0-9 or .*/
		}
	}	
	return true;
}

//Used to refer web-services generically from the top-frame
var j_wintop;
/*if (window.opener)
	j_wintop = window.opener.j_wintop;
else if(window.parent)	
	if (window.parent.frames["banner"])
		j_wintop = window.parent.frames["banner"];
	else
		j_wintop = window.parent.j_wintop;
else if(window.parent.parent)	
	if (window.parent.parent.frames["banner"])
		j_wintop = window.parent.parent.frames["banner"];
	else
		j_wintop = window.parent.parent.j_wintop;
*/
if(window.parent.parent)	
		j_wintop = window.parent.parent;

function OpenBackPage(trasnid,rptname)
{
	var str_rpt;
	var url
	var rptname
	var noOfItems
	var SectHide
	var win
	SectHide=""
 	var attr = "left=50,top=50,resizable=no,width=" + parseInt(screen.Width-30) + 
		",height=" + parseInt(screen.Height-30)

    url="?rptname="+rptname+"&trasnid="+trasnid
    url="../Reports/GenerateReport.aspx" + url
    win=window.open(url, rptname, attr)
    //win.focus()
}

