	function openWindow (filename) {
			var ww = window.open(filename, 'popup1', 'height=600, width=700, top=10, left=10, scrollbars=1, resizable=1');
			ww.focus();
	}
	
	function openPDFWindow (filename) {
			var ww = window.open(filename, 'popup1', 'height=650, width=900, top=10, left=10, scrollbars=1, resizable=1');
			ww.focus();
	}
	
	function openNotesWindow (filename) {
			var ww = window.open(filename, 'popup1', 'height=600, width=700, top=10, left=10, scrollbars=1, resizable=1');
			ww.focus();
	}
	
	function openComplianceWindow (filename) {
			var ww = window.open(filename, 'popup1', 'height=650, width=850, top=10, left=10, scrollbars=1, resizable=1');
			ww.focus();
	}
	
	function openConversionRateWindow (filename) {
			var ww = window.open(filename, 'popup1', 'height=400, width=500, top=10, left=10, scrollbars=0, resizable=0');
			ww.focus();
	}
	
	
	function round2decimals(obj) {
		if( trim(obj.value) != "" ) {
			obj.value = formatCurrencyForDecimals(trim(obj.value), 2);
		}
	}
	
	function round4decimals(obj) {
		if( trim(obj.value) != "" ) {
			obj.value = formatCurrencyForDecimals(trim(obj.value), 4);
		}
	}

	function formatCurrencyForDecimals(original_number, decimals) {
		var result1 = original_number * Math.pow(10, decimals);
		var result2 = Math.round(result1);
		var result3 = result2 / Math.pow(10, decimals);
		return pad_with_zeros(result3, decimals);
	}
	
	function formatCurrency(original_number) {
		var decimals = 2;
		var result1 = original_number * Math.pow(10, decimals);
		var result2 = Math.round(result1);
		var result3 = result2 / Math.pow(10, decimals);
		return pad_with_zeros(result3, decimals);
	}
	
	function pad_with_zeros(rounded_value, decimal_places) {
		var value_string = rounded_value.toString();
		var decimal_location = value_string.indexOf(".");
		if (decimal_location == -1) {
			decimal_part_length = 0;
			value_string += decimal_places > 0 ? "." : "";
		}
		else {
			decimal_part_length = value_string.length - decimal_location - 1;
		}
		
		var pad_total = decimal_places - decimal_part_length;
		if (pad_total > 0) {
			for (var counter = 1; counter <= pad_total; counter++) 
				value_string += "0";
		}
		return value_string;
	}
	
	function IEKeyCap() {
		//alert(window.event.keyCode + " -- IEKeyCap");
		if ((window.event.keyCode < 46) || (window.event.keyCode > 57) || (window.event.keyCode == 47) ) {
			window.event.keyCode = 0;
		}
	}
	
	function NoDotIEKeyCap() {
		//alert(window.event.keyCode + " -- IEKeyCap");
		if ((window.event.keyCode <= 46) || (window.event.keyCode > 57) || (window.event.keyCode == 47) ) {
			window.event.keyCode = 0;
		}
	}
	
	function IntIEKeyCap() {
		//alert(window.event.keyCode + " -- IEKeyCap");
		if ((window.event.keyCode < 46) || (window.event.keyCode > 57) || (window.event.keyCode == 47)) {
			window.event.keyCode = 0
		}
	}
		
	function NegtIEKeyCap() {	// function also allows negative sign. 
		if ((window.event.keyCode < 45) || (window.event.keyCode > 57) || (window.event.keyCode == 47)) {
			window.event.keyCode = 0
		}
	}
	
	function trim(str) {
		//alert(str + " === trim");
		for( lspace=0 ; lspace<str.length ; lspace++ )
			if( str.charAt(lspace)!=' ' )
				break;
		str = str.substring( lspace );
		for( rspace=str.length-1 ; rspace>=0 ; rspace-- )
			if( str.charAt(rspace)!=' ' )
				break;
		str = str.substring( 0, rspace+1 );
		return str;
	}

	function float(t1)	{
		var a,i,s
		var count=0
		var r=""
		var chk=0
		a=t1.value.length
		for(i=0;i<a;i++) {	
			s=t1.value.substring(i,i+1)
			if(s>="0" && s<="9" || s=="." || s=="-" && count<1) {}
			else {
				chk=1
				alert("Please enter float/real values only.");
				t1.focus();
				break;
			}
			if(s==".") {
				count=count+1
			}
		}
	}
	
	function Text_Counter(field, maxlimit) {	
		if (field.value.length > maxlimit)
			field.value = field.value.substring(0, maxlimit);		
	}
	
	function Edit_Check(arg,index){
		//alert(arg);
		//alert(index);
		if(index != -1  )
			alert("Your changes have not been saved yet. \n\nPlease press update to save your changes or cancel to discard your changes, \nbefore taking a new Action");
		else{
			window.location.href = arg;
		}
	}
	
	function clickButton(e, buttonid){ 	
	var bt = document.getElementById(buttonid); 
	if (typeof bt == 'object'){ 
		if (event.keyCode == 13){ 		
			bt.click(); 
			return false; 
		} 
	} 
} 

// Used for telephone no / Fax : format 999-999-9999
 function autofill(str_objID)
	{
		if (eval(document.getElementById(str_objID).value.length)==3 || eval(document.getElementById(str_objID).value.length)==7)
		{
			document.getElementById(str_objID).value = document.getElementById(str_objID).value +'-';
		}
	}//function autofill(str_objID)
	
// Used for EIN	
function autofillEIN(str_objID)
	{
		if (eval(document.getElementById(str_objID).value.length)==2)
		{
			document.getElementById(str_objID).value = document.getElementById(str_objID).value +'-';
		}		
	}//function autofillEIN(str_objID)


function checkMailId(mailids,comment)
	{
		var arr = new Array('.com','.net','.org','.biz','.coop','.info','.museum','.name','.pro'
							,'.edu','.gov','.int','.mil','.ac','.ad','.ae','.af','.ag','.ai','.al',
							'.am','.an','.ao','.aq','.ar','.as','.at','.au','.aw','.az','.ba','.bb',
							'.bd','.be','.bf','.bg','.bh','.bi','.bj','.bm','.bn','.bo','.br','.bs',
							'.bt','.bv','.bw','.by','.bz','.ca','.cc','.cd','.cf','.cg','.ch','.ci',
							'.ck','.cl','.cm','.cn','.co','.cr','.cu','.cv','.cx','.cy','.cz','.de',
							'.dj','.dk','.dm','.do','.dz','.ec','.ee','.eg','.eh','.er','.es','.et',
							'.fi','.fj','.fk','.fm','.fo','.fr','.ga','.gd','.ge','.gf','.gg','.gh',
							'.gi','.gl','.gm','.gn','.gp','.gq','.gr','.gs','.gt','.gu','.gv','.gy',
							'.hk','.hm','.hn','.hr','.ht','.hu','.id','.ie','.il','.im','.in','.io',
							'.iq','.ir','.is','.it','.je','.jm','.jo','.jp','.ke','.kg','.kh','.ki',
							'.km','.kn','.kp','.kr','.kw','.ky','.kz','.la','.lb','.lc','.li','.lk',
							'.lr','.ls','.lt','.lu','.lv','.ly','.ma','.mc','.md','.mg','.mh','.mk',
							'.ml','.mm','.mn','.mo','.mp','.mq','.mr','.ms','.mt','.mu','.mv','.mw',
							'.mx','.my','.mz','.na','.nc','.ne','.nf','.ng','.ni','.nl','.no','.np',
							'.nr','.nu','.nz','.om','.pa','.pe','.pf','.pg','.ph','.pk','.pl','.pm',
							'.pn','.pr','.ps','.pt','.pw','.py','.qa','.re','.ro','.rw','.ru','.sa',
							'.sb','.sc','.sd','.se','.sg','.sh','.si','.sj','.sk','.sl','.sm','.sn',
							'.so','.sr','.st','.sv','.sy','.sz','.tc','.td','.tf','.tg','.th','.tj',
							'.tk','.tm','.tn','.to','.tp','.tr','.tt','.tv','.tw','.tz','.ua','.ug',
							'.uk','.um','.us','.uy','.uz','.va','.vc','.ve','.vg','.vi','.vn','.vu',
							'.ws','.wf','.ye','.yt','.yu','.za','.zm','.zw'); 
		var mai = mailids;
		var val = true;
		
		var dot = mai.lastIndexOf(".");
		var ext = mai.substring(dot,mai.length);
		var at = mai.indexOf("@");
		var dom = dot - at;
		var sp = mai.indexOf(	" ");
		
		if(dom >= 4 && at >1 && sp == -1)
		{
			for(var i=0; i<arr.length; i++)
			{
				if(ext == arr[i])
				{
					val = true;
					break;
				} 
				else
				{
					val = false;
				}
			}
			if(val == false)
			{
				alert("Your Mail ID [ "+mai+" ] is not correct.\n[Field : " + comment + "]\n\nCause : \n1. Any space exists in your mail id.\n    [At : Start, Middle or End]\n2. Id length is less then 2.\n3. Domain name length is less then 3.\n4. Extension does not exists.");
				return false;
			}
		}
		else
		{
			alert("Your Mail ID [ "+mai+" ] is not correct.\n[Field : " + comment + "]\n\nCause : \n1. Any space exists in your mail id.\n    [At : Start, Middle or End]\n2. Id length is less then 2.\n3. Domain name length is less then 3.\n4. Extension does not exists.");
			return false;
		}
		
		return true;
	}
	
function RoundOffValue(objTextBox)
	{
	if(objTextBox.value != '' && objTextBox.value != '.')
		objTextBox.value = (eval(objTextBox.value)).toFixed(2);
	else
		objTextBox.value = '0.00';
	}
	
function IEKeyCapCheck(evt,ctltxtBox)
    {
        var k
		var k = evt.keyCode? evt.keyCode : evt.charCode
	    
	    if((k == 46) && (ctltxtBox.value.indexOf('.') > 0))
	    {
	        return false;
	    }
	    else
	    {
	        if ((k <= 46) || (k > 57) || (k == 47))
		    {
			    if((k == 39) || (k == 9) || (k == 8) || (k == 46)) //(k == 37) ||
				    return true;
			    else
				    return false;
		    }
	    }
    }
    
function SelectAllCheckbox(pCheckBox)
    {
        for(j = 0; j < document.forms[0].elements.length - 1; j++)
		{
		    if(document.forms[0].elements[j].type == "checkbox" && document.forms[0].elements[j].value != 'All')
			{
				if(pCheckBox.checked)
				{
				    document.forms[0].elements[j].checked = true;
				}
				else
				{
				    document.forms[0].elements[j].checked = false;
				}
				
				EnableDisable(document.forms[0].elements[j].id);
			}
		}
	}