var setTimerIDx;
function Trim(nStr)
{
	return nStr.replace(/(^\s*)|(\s*$)/g, "");
}

function isItEmpty( obj, msg )
{
	if ( typeof( obj ) != "object" )
	{
		obj = document.getElementById( obj );
	}

	if( Trim(obj.value) == "" || parseInt(obj.value) < 0 )
	{
		if( msg != null )
			alert( "Please enter valid " + msg );
		obj.focus();
		return true;
	}
	else
	{
		return false;
	}
}

function isItAlphaNumericSpace( obj, msg , pattern)
{
	if ( typeof( obj ) != "object" )
	{
		obj = document.getElementById( obj );
	}

    if( pattern == null )
    	patt = /^[A-z][A-z\d\s]+$/;
    else
        patt = pattern;
		
	if( patt.test( obj.value) )
	{
		return true;
	}
	else
	{
	    if( msg == null )
    		alert("Please enter Alphanumeric only");
        else
            alert("Please enter Alphanumeric only in " + msg);
		obj.focus();
		return false;
	}
}

function isItEmail(obj,msg)
{
	if ( typeof( obj ) != "object" )
	{
		obj = document.getElementById( obj );
	}

	patt = /^([A-z\d_]+\.)?([A-z\d_]+)@([A-z\d_]+)\.([A-z\d_]{2,3})(\.+[A-z\d_]{2})?$/;
	if( patt.test( obj.value ) )
	{
		return true;
	}
	else
	{
	    if( msg == null )
    		alert("Please enter valid Email");
        else
            alert("Please enter valid " + msg);
		obj.focus();
		return false;
	}
}

function isValueMatch(value, msg)
{
	if( !value.match(/^[\dA-z\s\-]+$/) )
	{
		msg = (msg == null ?"":msg);
		
		alert("Please enter valid alphanumeric only " + 
			( msg == "" ?"":" in "+msg ));
		return false;
	}
	else
	{
		return true;
	}
}

function IsItUserName(obj,msg)
{
	var patt = /^[A-z][A-z\d]*$/;

	if (!patt.test(obj.value))
	{
		alert("Please enter valid values in " + msg);
		obj.focus();
		return false;
	}
	else
		return true;
}

function isItNumeric(obj,msg, pattern)
{
    return IsItNumeric(obj,msg, pattern)
}
function IsItNumeric(obj,msg, pattern)
{
	if ( typeof( obj ) != "object" )
	{
		obj = document.getElementById( obj );
	}
	
	if( pattern == null )
	    patt = /^[\d]*\.?[\d]+?$/;
    else
        patt = pattern;

	if( patt.test( obj.value ) )
	{
		return true;
	}
	else
	{
		alert( "Please enter only  numeric values in " + msg);
		obj.focus();
		return false;
	}
}

function Convert2Numeric(objectThis)
{
	v = parseFloat("0" + objectThis.value);
	objectThis.value=v;
}

function passwordlength(obj)
{
	if ( obj.value.length < 5 )
	{
		alert( 'Password should have atleast 5 characters' );
		obj.focus();
		return false;
	}
	return true;
}


function IsItPhone(obj,msg,pattern)
{
	if ( typeof( obj ) != "object" )
	{
		obj = document.getElementById( obj );
	}
	
	if( pattern == null )
    	patt = /^[\d]+$/;
    else
        patt = pattern;

	if( patt.test( obj.value ) )
	{
		return true;
	}
	else
	{
		alert( "Please enter valid " + msg);
		obj.focus();
		return false;
	}
}



function isItAlphabeticOnly(obj,msg,pattern)
{
	if ( typeof( obj ) != "object" )
	{
		obj = document.getElementById( obj );
	}
	
	if( pattern == null )
    	patt = /^[A-z]+$/;
    else
        patt = pattern;

	if( patt.test( obj.value ) )
	{
		return true;
	}
	else
	{
		alert( "Please enter only  Alphabetic and Numeric values in " + msg);
		obj.focus();
		return false;
	}
}


function IsCorrectMaxLen(obj,len,objname)
{
  if(Trim(obj.value).length>len)
  {
	alert("Please enter less than " + len + " letters in " + objname);
	obj.focus();
	
	return true;
  }
  else
  {
	return false;
  }
}

function notPrice(obj,msg)
{
	exp = /^[\d]*[\.]{0,1}[\d]{1,8}$/;
	if (!exp.test(obj.value))
	{
		alert("Please enter valid values in " + msg);
		obj.focus();
		//obj.value="";
		return true;
	}
	else
		return false;
}




function notSelected(obj,msg)
{

	if (obj.options[obj.selectedIndex].value == "" || obj.options[obj.selectedIndex].value  == "-1" )
	{
		alert("Please select the "+ msg);
		obj.focus();
		return true;
	}else
		return false;
}
function isnotspecial(obj,msg)
{ 
	
	exp=/[^a-zA-Z0-9]/;
	 	if(exp.test(obj.value))
		{
		alert("Please enter valid "+ msg);
		//alert("Please enter valid");
		obj.focus();
		return true;
		}
 	else
		return false;
}

/*
function fnChkDecimal(obj,msg)
{
	//exp = /^[\d]/;
	exp = /^[\d]*[\.]{0,1}[\d]{1,2}$/;
	if (!exp.test(obj.value))
	{
		alert("Please enter the values in less than the two decimal point" + msg);
		//obj.value="";
		obj.focus();
		return true;
	}
	else
		return false;
}
*/


function notImageFile(obj,msg)
{
	//var exp = /^.+\.(jpg|gif|jpeg|png|JPG|JPEG|GIF|PNG)$/;
	var exp = /^.+\.(jpg|gif|jpeg|JPG|JPEG|GIF)$/;
	//var exp = /^.+\.(gif|GIF)$/;
	if (!exp.test((obj.value).toLowerCase()))
	{
		alert("Please choose JPG or GIF file for "+msg);
		obj.focus();
		return true;
	}
	else
		return false;
}

function focus2control(objId)
{
	setTimerIDx = window.setInterval( "go2focus('" + objId + "')",100);

}

function go2focus( objID )
{
	document.getElementById(objID).focus();
	window.clearInterval(setTimerIDx);
}

function ToolTips2DgPage( dgID, CollectOfValues )
{
	if ( document.getElementById(dgID) )
	{
		var obj = document.getElementById(dgID);
		//var msg4tooltips = document.getElementById(hiddenControlID).value;
		var msg4tooltips = CollectOfValues;

		msg4toolstrs = msg4tooltips.split(",");
		var pgno = 0;

		for( var r=0; r<msg4toolstrs.length; r++)
		{
			if ( msg4toolstrs[r] != "" )
			{
				if ( obj.childNodes[0].childNodes[ obj.childNodes[0].childNodes.length -1 ].childNodes[0].childNodes[pgno] )
				{
					idx = parseFloat( "0" + obj.childNodes[0].childNodes[ obj.childNodes[0].childNodes.length -1 ].childNodes[0].childNodes[pgno].innerText );
					if ( idx > 0 )
					{
						obj.childNodes[0].childNodes[ obj.childNodes[0].childNodes.length -1 ].childNodes[0].childNodes[pgno].title = 
								msg4toolstrs[ idx-1 ];
					}
				}
				pgno+=2;
			}
		}
	}
}


function Table2DropDown( TableObj , ColumnNames, DropDownObject , SelectedValue, Select1stText , IsAddAll , GroupBy)
{	
	if ( TableObj == null )
		return;

	var totrows = TableObj.Rows.length;

	var ColumnsSplit = ColumnNames.split(',');
	var ddlObj = document.getElementById( DropDownObject );
	
	/*
	
	var optgroupscount = ddlObj.getElementsByTagName("optgroup");
	//alert( optgroupscount.itemcross + "\n" + optgroupscount
	for( var r=optgroupscount.length -1; r>=0 ;r--)
	{
		if ( window.navigator.appName == "Microsoft Internet Explorer")
		{
			ddlObj.remove(0);
			//optgroupscount.options.remove( r );
		}
		else
		if ( window.navigator.appName == "Netscape" || window.navigator.appName == "Opera")
		{
			ddlObj.remove(optgroupscount);
			//optgroupscount.optgroup[ r ] = null ;
		}
	}

	var optionsCount = ddlObj.options.length;
	for( var r=optionsCount -1; r>=0 ;r--)
	{
		if ( window.navigator.appName == "Microsoft Internet Explorer")
			ddlObj.options.remove( r );
		else
		if ( window.navigator.appName == "Netscape" || window.navigator.appName == "Opera")
			ddlObj.options[ r ] = null ;
	}
	*/
	
	ddlObj.innerHTML = "";

	if ( Select1stText != null )
	{
		if ( window.navigator.appName == "Microsoft Internet Explorer")
		{
			cr = document.createElement('option');
			cr.value = -1;
			if ( Select1stText != null )
				cr.innerText = "-- Select " + Select1stText + " --";
			else
				cr.innerText = "-- Select --";
			ddlObj.options.appendChild( cr );
		}
		else
		if ( window.navigator.appName == "Netscape" || window.navigator.appName == "Opera")
		{
			if ( Select1stText != null )
				myOption = new Option("-- Select " + Select1stText + " --","-1");
			else
				myOption = new Option("-- Select --","-1");
			ddlObj.options[ddlObj.options.length] = myOption;
		}
	}
	
	if ( IsAddAll )
	{
		if ( window.navigator.appName == "Microsoft Internet Explorer")
		{
			cr = document.createElement('option');
			cr.value = -2;
			cr.innerText = "-- Select All --";
			ddlObj.options.appendChild( cr );
		}
		else
		if ( window.navigator.appName == "Netscape" || window.navigator.appName == "Opera")
		{
			myOption = new Option("-- Select All --","-2");
			ddlObj.options[ddlObj.options.length] = myOption;
		}
	}	

	if ( SelectedValue == null ) SelectedValue="-1";
	
	previousGroup = "";
	indentSpace= "";

	for(var r=0; r < totrows; r++)
	{
		row = TableObj.Rows[r];
		
		//
		// Insert OptGroup into dropdown
		//
		if( GroupBy != null )
		{
			if( previousGroup != row[GroupBy] )
			{
				previousGroup = row[GroupBy];

				if ( window.navigator.appName == "Microsoft Internet Explorer")
				{
					cr = document.createElement('optgroup');
					cr.value = previousGroup;
					cr.label = previousGroup ;
					ddlObj.options.appendChild( cr );
				}
				else
				if ( window.navigator.appName == "Netscape" || window.navigator.appName == "Opera")
				{
					cr = document.createElement('optgroup');
					cr.value = previousGroup;
					cr.label = previousGroup ;
					ddlObj.appendChild( cr ) ;

					/*
					cr = document.createElement('<optgroup value="' +  previousGroup +  ' " >');
					cr.innerText = previousGroup ;
					ddlObj.options.add( cr );
					*/
				}
				indentSpace="    ";
			}
		}
		
		if ( row[ ColumnsSplit[0] ] != "" && row[ ColumnsSplit[1] ] != "" )
		{
			if ( window.navigator.appName == "Microsoft Internet Explorer")
			{
				cr = document.createElement('option');
				cr.value = row[ ColumnsSplit[0] ] ;
				cr.innerText = indentSpace + row[ ColumnsSplit[1] ] ;
				if ( SelectedValue == row[ ColumnsSplit[0] ] )
					cr.selected = true;
					
				ddlObj.options.appendChild( cr );
			}
			else
			if ( window.navigator.appName == "Netscape" || window.navigator.appName == "Opera")
			{
			
				myOption = new Option(indentSpace + row[ ColumnsSplit[1] ], row[ ColumnsSplit[0] ]);
				if ( SelectedValue == row[ ColumnsSplit[0] ] )
					myOption.selected = true;
				ddlObj.options[ddlObj.options.length] = myOption;
				/*
				cr = document.createElement('<option value="' +  row[ ColumnsSplit[0] ] +  ' " >');
				cr.innerText = row[ ColumnsSplit[1] ] ;
				if ( SelectedValue == row[ ColumnsSplit[0] ] )
					cr.selected = true;
				ddlObj.options.add( cr );
				*/
			}
		}
	}
	
	if ( SelectedValue == "-1" )
	{
		ddlObj.options.selectedIndex=0;
	}

}

function getValue( ddlObject )
{
	var ddlObj = document.getElementById( ddlObject );
	return ddlObj.options [ ddlObj.options.selectedIndex ].value ;
}

/*
function IsNull( objValue, value )
{
	if ( objValue == null )
		return value;
	else
		return objValue;
}
*/

//
// Author : A Shankar
// Date : 21st March 2007
// Remark : Add the following methods for format the Date
//

function Dateformat(date,format) {
	return DateFormat(date,format) ;
}

//
// Author : Shankar
// Date : 23rd March 2007
//
//

var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var DAY_NAMES=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');

function LZ(x) 
{
	return(x<0||x>9?"":"0")+x
}

function DateFormat(date,format) {

format=format+"";
	var result="";
	var i_format=0;
	var c="";
	var token="";
	var y=date.getYear()+"";
	var M=date.getMonth()+1;
	var d=date.getDate();
	var E=date.getDay();
	var H=date.getHours();
	var m=date.getMinutes();
	var s=date.getSeconds();
	var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;
	// Convert real date parts into formatted versions
	var value=new Object();
	if (y.length < 4) {y=""+(y-0+1900);}
	value["y"]=""+y;
	value["yyyy"]=y;
	value["yy"]=y.substring(2,4);
	value["M"]=M;
	value["MM"]=LZ(M); // here 
	value["MMM"]=MONTH_NAMES[M-1];
	value["NNN"]=MONTH_NAMES[M+11];
	value["d"]=d;
	value["dd"]=LZ(d);
	value["E"]=DAY_NAMES[E+7];
	value["EE"]=DAY_NAMES[E];
	value["H"]=H;
	value["HH"]=LZ(H);
	if (H==0){value["h"]=12;}
	else if (H>12){value["h"]=H-12;}
	else {value["h"]=H;}
	value["hh"]=LZ(value["h"]);
	if (H>11){value["K"]=H-12;} else {value["K"]=H;}
	value["k"]=H+1;
	value["KK"]=LZ(value["K"]);
	value["kk"]=LZ(value["k"]);
	if (H > 11) { value["a"]="PM"; }
	else { value["a"]="AM"; }
	value["m"]=m;
	value["mm"]=LZ(m);
	value["s"]=s;
	value["ss"]=LZ(s);
	

	while (i_format < format.length) {
		c=format.charAt(i_format);
		token="";
		while ((format.charAt(i_format)==c) && (i_format < format.length)) {
			token += format.charAt(i_format++);
			}
		if (value[token] != null) { result=result + value[token]; }
		else { result=result + token; }
		}
	return result;
}


//
// Author : A Shankar
// Date : 21st March 2007
// Remark : insertRow() - add new row to the Table Tag by various browser compatible.
//

function insertRow( tblObj , rowIndex )
{
	var insertRowObj;
	var tableObj;
	
	if ( typeof(tblObj) == "object" )
		tableObj = tblObj;
	else
		tableObj = document.getElementById(tblObj);
	
	if ( window.navigator.appName == "Microsoft Internet Explorer")
	{
		if ( rowIndex == null )
			insertRowObj = tableObj.childNodes[0].insertRow();
		else
			insertRowObj = tableObj.childNodes[0].insertRow(rowIndex);
		
	}
	else
	if ( window.navigator.appName == "Netscape" || window.navigator.appName == "Opera")
	{
		if ( rowIndex == null )
			rowid =  tableObj.rows.length  ; // <tr>
		else
			rowid = rowIndex;
		insertRowObj = tableObj.insertRow( rowid  );
	}

	return insertRowObj; 
}

function insertCell( insertRowObj, ColumnIndex , innerHtml , Alignment)
{

	var insertCellObj;
	var rowObj ;
	
	if( typeof( insertRowObj ) == "object" )
		rowObj = insertRowObj;
	else
		rowObj = document.getElementById( insertRowObj );
	
	if ( window.navigator.appName == "Microsoft Internet Explorer")
	{
		insertCellObj = rowObj.insertCell(); // <td>
	}
	else
	if ( window.navigator.appName == "Netscape" || window.navigator.appName == "Opera")
	{
		insertCellObj = rowObj.insertCell(ColumnIndex); // <td>
	}
	
	if ( innerHtml != null )
		insertCellObj.innerHTML = innerHtml;
	
	if ( Alignment != null )
		insertCellObj.align = Alignment;

	return insertCellObj; 
}


function deleteRow( tableObj, RowIndex )
{
	var tblObj ;
	if ( typeof( tableObj ) == "object" )
		tblObj = tableObj ;
	else
		tblObj = document.getElementById(tableObj) ;

	if ( window.navigator.appName == "Microsoft Internet Explorer" || 
		window.navigator.appName == "Netscape" || window.navigator.appName == "Opera"
		)
	{
		tblObj.deleteRow(RowIndex);
	}
	
}

function dllOptionsClear( ddlObj )
{
	if ( typeof( ddlObj ) == "object" )
		ddlObj = ddlObj ;
	else
		ddlObj = document.getElementById(ddlObj) ;
		
	if ( window.navigator.appName == "Microsoft Internet Explorer")
	{
		ddlObj.options.length = 0;
	}
	else
	if ( window.navigator.appName == "Netscape" || window.navigator.appName == "Opera")
	{
		ddlObj.options.length = 0;
	}
	
}


function ddlOptionRemove( ddlObj, rowIndex )
{
	var ddlObj ;
	if ( typeof( ddlObj ) == "object" )
		ddlObj = ddlObj ;
	else
		ddlObj = document.getElementById(ddlObj) ;

	if ( window.navigator.appName == "Microsoft Internet Explorer")
	{
		ddlObj.options.remove( rowIndex );
	}
	else
	if ( window.navigator.appName == "Netscape" || window.navigator.appName == "Opera")
	{
		ddlObj.options[ rowIndex ] = null ;
	}
}


function ddlOptionAdd( ddlObj , optionObj )
{
	var ddlObj ;
	if ( typeof( ddlObj ) == "object" )
		ddlObj = ddlObj ;
	else
		ddlObj = document.getElementById(ddlObj) ;

	if ( window.navigator.appName == "Microsoft Internet Explorer")
	{
		ddlObj.options.appendChild( optionObj );
	}
	else
	if ( window.navigator.appName == "Netscape" )
	{
		myOption = optionObj;
		ddlObj.options[ddlObj.options.length] = myOption;
	}
	else
	if ( window.navigator.appName == "Opera")
	{
		myOption = optionObj;
		ddlObj.options[ddlObj.options.length] = myOption;
	}

}

function TableRowsCount( tblObject )
{
	var tblObj;
	var returnTotalRows=0;
	if ( typeof( tblObject ) == "object" )
		tblObj = tblObject;
	else
		tblObj = document.getElementById(tblObject);
		
		
	
	if ( window.navigator.appName == "Microsoft Internet Explorer")
	{
		returnTotalRows = tblObj.childNodes[0].childNodes.length ;
	}
	else
	if ( window.navigator.appName == "Netscape" || window.navigator.appName == "Opera")
	{
		returnTotalRows = tblObj.rows.length ;
	}
	
	return returnTotalRows ;

}

function TableRowsClear(TableObj,start)
{
	if ( typeof( TableObj ) == "object" )
		tblObj = TableObj;
	else
		tblObj = document.getElementById(TableObj);

	tableRowlength = TableRowsCount( tblObj );
	
	if( start==null) start=0;
	for(r=tableRowlength-1; r>=0; r--)
	{
		if( r>=start )
			deleteRow( tblObj, r );
	}
}

function TableCell(TableObj, rowIndex, columnIndex)
{

	if ( typeof( TableObj ) == "object" )
		tblObj = TableObj;
	else
		tblObj = document.getElementById(TableObj);

	if ( window.navigator.appName == "Microsoft Internet Explorer")
	{
		returnTotalRows = tblObj.childNodes[0].childNodes[rowIndex].childNodes[columnIndex];
	}
	else
	if ( window.navigator.appName == "Netscape" )
	{
		returnTotalRows = tblObj.rows[rowIndex].childNodes[columnIndex];
	}
	if ( window.navigator.appName == "Opera" )
	{
		returnTotalRows = tblObj.rows[rowIndex].childNodes[columnIndex];
	}
	
	return returnTotalRows;
}

function TableRow(TableObj, rowIndex )
{
	if ( typeof( TableObj ) == "object" )
		tblObj = TableObj;
	else
		tblObj = document.getElementById(TableObj);

	if ( window.navigator.appName == "Microsoft Internet Explorer")
	{
		returnTotalRows = tblObj.childNodes[0].childNodes[rowIndex];
	}
	else
	if ( window.navigator.appName == "Netscape" || window.navigator.appName == "Opera")
	{
		returnTotalRows = tblObj.rows[rowIndex];
	}
	
	return returnTotalRows;
}

//
// Author : A shankar
// Date : 30th March 2007
//
//

function popWindow(url,width,height,name) {
  popupWin = window.open(url,name,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=' + width + ',height=' + height);
}

function openWindow(url, name) {
  popupWin = window.open(url,name,'width=430,height=400,scrollbars=yes')
}

function popWindowScroll(url,width,height,name) {
  popupWin = window.open(url,name,'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=' + width + ',height=' + height);
}

function popWindowLocation(url,width,height,name) {
  popupWin = window.open(url,name,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=' + width + ',height=' + height);
}

function popWindowNoResize(url,width,height,name) {
  popupWin = window.open(url,name,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=' + width + ',height=' + height);
}


//
// Author : Shankar
// Date : 4th April 2007
// Get / Set the value from/to the FCKEditor control
//
function getFCKEditorValue( instanceName )
{
	var oEditor = FCKeditorAPI.GetInstance( instanceName );
	return oEditor.GetXHTML( true );
}

function setFCKEditorValue( instanceName , text )
{
	var oEditor = FCKeditorAPI.GetInstance( instanceName );
	oEditor.SetHTML( text );
}

function Calendar2Control( TextBoxObj, ButtonObj, DateFrom, DateTo )
{
	if ( DateFrom )
	{
		Calendar.setup
		(
			{
				inputField  : TextBoxObj,         // ID of the input field
				button      : ButtonObj,      // ID of the button 
				dateRange	: [DateFrom,DateTo]
			}
		);
	}
	else
	{
		Calendar.setup
		(
			{
				inputField  : TextBoxObj,         // ID of the input field
				button      : ButtonObj      // ID of the button 
			}
		);
	}
}


function CheckValuesInTable( Datarow )
{
		msg = "";
		for( r=0; r< Datarow.Rows.length; r++)
		{
			for( c=0; c< Datarow.Columns.length; c++)
			{
				msg += Datarow.Columns[c].Name + "=" + Datarow.Rows[r][ Datarow.Columns[c].Name ] + "\n" ;
			}
			msg += "\n\n";
		}
		alert(msg);
}


function showmodalDialog( url, windowname, options )
{
	if ( window.navigator.appName == "Microsoft Internet Explorer")
	{
		window.showModalDialog( url, windowname, options ) ;
	}
	else
	if ( window.navigator.appName == "Netscape" || window.navigator.appName == "Opera")
	{
		while( options.indexOf(';') >= 0 )
			options = options.replace(';',',');

		while( options.indexOf(':') >= 0 )
			options = options.replace(':','=');

		options = options.replace('dialogHeight','height');
		options = options.replace('dialogWidth','width');

		window.open( url, windowname, options + ',dependent,modal=yes' ) ;
//		window.open('xpopupex.htm','name',
//			'height=255,width=250,toolbar=no,directories=no,status=no,continued from previous linemenubar=no,scrollbars=no,resizable=no ,modal=yes');

	}
}


function getRowIndex( objElement )
{
	if ( window.navigator.appName == "Microsoft Internet Explorer")
	{
		dumObj = objElement;
		while ( dumObj.tagName.toLowerCase() != "tr" )
		{
			dumObj = dumObj.parentElement;
		}
		return dumObj.rowIndex;

	}
	else
	if ( window.navigator.appName == "Netscape" || window.navigator.appName == "Opera") 
	{
		dumObj = objElement;

		while ( dumObj.nodeName.toLowerCase() != "tr" ) 
		{
			dumObj = dumObj.parentNode;
		}

		return dumObj.rowIndex; 
	}
}

function dtb()
{
	objs = document.getElementsByTagName("input");
	objsels = document.getElementsByTagName("select");
	objtas = document.getElementsByTagName("textarea");

	if( rd == sd )
	{	//objs.length
		for(r=0; r<objs.length; r++)
			objs[r].disabled=true;
		for(r=0; r<objsels.length; r++)
			objsels[r].disabled=true;
		for(r=0; r<objtas.length; r++)
			objtas[r].disabled=true;

	}
}

function ol()
{
    divobj = document.createElement("div");
    olobj = document.createElement("ol");
    olobj.className = "clearBoth";
    olobj.style.listStyleType= "none";
    divobj.appendChild( olobj );
    return divobj;
}

function li(olObj)
{
    str = "";
    for(olr=1; olr<arguments.length ; olr++)
    {
        str+= arguments[olr] + "\r\n";
    }
    mli = document.createElement("li");
    mli.innerHTML = str;
    mli.className="clearBoth";
    olObj.childNodes[0].appendChild( mli );
}

function getParentElement( objElement )
{
	if ( window.navigator.appName == "Microsoft Internet Explorer")
	{
		return objElement.parentElement;
	}
	else
	if ( window.navigator.appName == "Netscape" || window.navigator.appName == "Opera") 
	{
	    return objElement.parentNode;
	}
}

function loadThisForm()
{
    r = 0;
}


function alertmsg(evt)
{
    if( evt.shiftKey )
        alert("Here");
}

function ClipBoardClearData()
{
    // just try to change until got it 
    if( window.navigator.appName == "Microsoft Internet Explorer")
    {
    window.clipboardData.clearData(); // ie is working fine while ff is not working. 
    }
    else
    if (window.navigator.appName == "Netscape" || window.navigator.appName == "Opera") 
    {
        //clipboardData.setData('Text',null);
    }
    
    // so you can find out and fix this problem on fF 
}


function divHidden()
{
    for(r=0; r<arguments.length;r++)
    {
        //alert(arguments[r]);
        document.getElementById( arguments[r] ).style.display="none";
    }
}


function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}

function getWindowsSize()
{
  var sizeOfX = 0, sizeOfY = 0;
  if( typeof( window.innerHeight ) == 'number' ) 
  {
    //Netscape compliant
    //sizeOfY = window.innerHeight;
    //sizeOfX = window.innerWidth;
    sizeOfY = document.body.scrollHeight;
    sizeOfX = document.body.scrollWidth;
  } else 
  if( document.body && ( document.body.sizeollLeft || document.body.sizeollTop ) ) 
  {
    //DOM compliant
    sizeOfY = document.body.sizeollTop;
    sizeOfX = document.body.sizeollLeft;
  } else 
  if( document.body && ( document.body.clientHeight || document.body.clientWidth ) ) 
  {
    //IE6 standards compliant mode
    //sizeOfY = document.body.clientHeight;
    //sizeOfX = document.body.clientWidth;
    sizeOfY = document.body.scrollHeight;
    sizeOfX = document.body.scrollWidth;
  }
  return [ sizeOfX, sizeOfY ];
}


function getWinHeight(objThis)
{
	objThis.height = 0;
	if (window.innerHeight) objThis.height = window.innerHeight - 18;
	else if (document.documentElement && document.documentElement.clientHeight)
	objThis.height = document.documentElement.clientHeight;
	else if (document.body && document.body.clientHeight)
	objThis.height = document.body.clientHeight;
}

function getAbsolutePos(el) {
	var r = { x: el.offsetLeft, y: el.offsetTop };
	if (el.offsetParent) {
		var tmp = getAbsolutePos(el.offsetParent);
		r.x += tmp.x;
		r.y += tmp.y;
	}
	return r;
};

function getMousePosition(event) 
{
    var posX = 0;
    var posY = 0;

    //var position = new Array(2);
    //position[0] = posX;
    //position[1] = posY;
    var position  = { x: 0, y: 0};
    
    //e.pageX - document.getElementById("divImage").offsetLeft

    posX = event.offsetX; // event.clientX + document.body.scrollLeft;
    posY = event.offsetY; // event.clientY + document.body.scrollTop;
    position.x = posX;
    position.y = posY;

    return position;
}

function getObjectPosition(objThis)
{
	//mouseX = (ns5)? evt.pageX: window.event.clientX + standardbody.scrollLeft;
	//mouseY = (ns5)? evt.pageY: window.event.clientY + standardbody.scrollTop;

    var ns5 = (!document.all || window.opera) ? true: false;


	var r ;
	
	if( ns5 )
	    r = { x: objThis.pageX , y: objThis.pageY };
	else
	    r = { x: window.event.clientX + window.event.scrollLeft , y: window.event.clientY };

	if (objThis.offsetParent) 
	{
		var tmp = getAbsolutePos(objThis.offsetParent);
		r.x += tmp.x;
		r.y += tmp.y;
	}
	return r;
}

function innerText( obj )
{
    if( window.navigator.appName == "Microsoft Internet Explorer")
    {
        return obj.innerText;
    }
    else
    if (window.navigator.appName == "Netscape" || window.navigator.appName == "Opera") 
    {
        return obj.textContent;
    }
}

 function autoTab(input,len, e)
         {
         
        
         var isNN = (navigator.appName.indexOf("Netscape")!=-1);
          var keyCode = (isNN) ? e.which : e.keyCode; 
          var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
          if(input.value.length >= len && !containsElement(filter,keyCode))
           {
            input.value = input.value.slice(0, len);
            input.form[(getIndex(input)+1) % input.form.length].focus();
           }
         function containsElement(arr, ele) 
         {
            var found = false, index = 0;
            while(!found && index < arr.length)
            if(arr[index] == ele)
            found = true;
            else
            index++;
            return found;
        }

      function getIndex(input) 
      {
            var index = -1, i = 0, found = false;
            while (i < input.form.length && index == -1)
            if (input.form[i] == input)index = i;
            else i++;
            return index;
      }
     return true;
}

function onmouseoverheader(ev)
{
    if(ev.shiftKey || ev.altkey)
        document.getElementsByName('div4CompanyLogoInwucHeader1')[0].style.display="block";
}

function onmouseoverheaderhidden()
{
    if( document.getElementsByName('div4CompanyLogoInwucHeader1')[0] )
        document.getElementsByName('div4CompanyLogoInwucHeader1')[0].style.display="none";
}


function ExpandCollapse(objId)
{
    if( document.getElementById(objId).style.display == "" ||
        document.getElementById(objId).style.display == "block" )
    {
        document.getElementById(objId).style.display = "none";
    }
    else
    {
        document.getElementById(objId).style.display = "block";
    }
}