// Validation Scripts

function Trim(nStr){return nStr.replace(/(^\s*)|(\s*$)/g,"");}
//To check main Delete Button 

function fnDelete(){
     if(selectedcount>0)
        {
          if(confirm("Are you sure, you want to delete"))
            return true
          else return false
        }
      else{
       alert("please select atleast one record to delete")
       return false;
       }
 }
 
 //To change the User status to Gsa User
 function addGsaUser(){
    if(selectedcount>0){
     if(confirm("Are you sure, you want to AddGSAUSER"))
            return true
          else return false
    
    }
    else{
       alert("Please select atleast one user to change GSA Status")
       return false;
       }
 }
 
 // Not to allow KeyPressEvent
 
 function fnNoChar(e)
{
   
    var ObjBrowser = navigator.appName; 
    if (ObjBrowser == "Microsoft Internet Explorer")
    {
       var keyno = window.event.keyCode;
    }
    else
    {
       var keyno = e.which || e.keyCode;
    }   
 	if (keyno) 
 	{
		alert("Select the date by click on the calendar");
		if (e.preventDefault)
    		e.preventDefault();
		e.returnValue = false;
		return false;
	}
	else
	{
	  return true;
	}
}
 
 //To change User as Non-Gsa User
 //------------------------------
 function delGsaUser(){
 if(selectedcount>0)
 {
    if(confirm("Are you sure, Do you want to change user status to Non-GSA user"))
          return true
          else return false
        }
      else{
          alert("Please select atleast one user to change GSA Status")
          return false;
       }
 }
 //To change  Finance User status
 function fn_Status_Active(){
 if(selectedcount>0)
 {
    if(confirm("Are you sure, Do you want to change user status to Active"))
          return true
          else return false
        }
      else{
          alert("Please select atleast one user to change the Status")
          return false;
       }
 }
 //To Change Finance User DeActive
 
 
  function fn_Status_DeActive(){
 if(selectedcount>0)
 {
    if(confirm("Are you sure, Do you want to change user status to DeActive"))
          return true
          else return false
        }
      else{
          alert("Please select atleast one user to change the Status")
          return false;
       }
 }
 
  //To change  Approved
  function fn_Status_Approve()
  {
    if(confirm("Are you sure, Do you want to change user status to Approve"))
    {
   
         return true;
     }
          else
                   { 
                   
          return false;
          }
     }
      

 
 // To Change UnApproved
 
 //To change  Approved
  function fn_Status_UnApproved()
  { 
 
    if(confirm("Are you sure, Do you want to change user status to Rejected"))
          return true
       else return false
        }

 
 
 
 
 //To Select All Check Boxes
 function fnSelectAll(obj){      
 
 
                  for(i=0;i<=document.getElementById('ctl00_cnt_Main_dg_City').rows.length;i++){
                        if(i==1)i='01';if(i==2)i='02';if(i==3){i='03'};if(i==4)i='04';if(i==5)i='05';if(i==6)i='06';if(i==7)i='07';if(i==8)i='08';if(i==9)i='09'
                               if(document.getElementById('ctl00_cnt_Main_dg_City_ctl'+i+'_chk_Delete')){
                               if(obj.checked){
                                 selectedcount++;
                                    document.getElementById('ctl00_cnt_Main_dg_City_ctl'+i+'_chk_Delete').checked=true
                                }else{
                                selectedcount--;
                                 document.getElementById('ctl00_cnt_Main_dg_City_ctl'+i+'_chk_Delete').checked=false
                                }
                        }
                  }
              }
              
 //To check whether the Individual Check Boxes are checked
 
  var selectedcount=0
 function fnDeleteCheck(obj){
    if(obj.checked)
    selectedcount++
    else selectedcount--
}
// Function for onkey validate

    function fnkeyvalidate(){
     if(window.event.keyCode==13){
        return fnValidate();
    }   
}
 
 //To check whether the object value is null or not
 
function isNull(obj,msg){
	if (Trim(obj.value)==""){
		alert("Please enter the " +msg);
		obj.focus();
		return true;
	}
	else
	{
		return false;
	}
}  

// to check the given address is valied email address
function isEmail(obj,msg)
{
//	var exp=/\w+([-+.$]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
	var exp=/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
	if (!exp.test(obj.value))
	{		
		alert("Please enter valid "+msg);
		obj.focus();
		return true;
	}
	else
	{
		return false;
		}
}

// To check the Combo is empty or not
function chkCombo(obj,msg){
	if (obj.options[obj.selectedIndex].value == "" || obj.options[obj.selectedIndex].value  == "-1" ||obj.options[obj.selectedIndex].value=="-2"){
		alert("Please Choose the "+ msg);
		obj.focus();
		return false;
	}else
		return true;
}

function fnChkNum(obj,msg)
{
	//exp = /^[\d]*[-|\s]*[\d]*[-|\s]*[\d]*[-|\s]*[\d]*[-|\s]*[\d]*[-|\s]*[\d]*[-|\s]*[\d]*$/;

	exp = /^[\d]/;
	exp = /^[\d]*[\s]*[\d]*$/;

	if (!exp.test(obj.value))
	{
		alert("Please enter only numeric values in "+msg);
		obj.focus();
		return true;
	}
	else
		return false;
}

        
//**************************End of Function Related to Anna University ****************************

function fnSingleQuoteReplace(str){
	return str.replace(/'/g,"\#")
}	


function fnChkAlphaPhone(obj)
     {
	exp = (/(^([a-z]|[A-Z]|[0-9]|[ ]|[-]|[","]|[.]|[";"]|["("]|[")"])*$)/);
	if (!exp.test(obj.value) || obj.value.indexOf('"') >= 0 )
	{
		alert("Special characters are not accepted");
		obj.focus();
		return false;
	}
	else
   	   return true;
}



     
    
        
        
        
        
var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December');


function fnPaste()
	{	
	event.returnValue=false;
	}



// to check the given year format is correct or not

function chkYear(obj,msg){
	dt=new Date()
	if(Trim(obj.value)>dt.getFullYear()){
		alert("Invalid "+msg)
		obj.focus();
		return false;
	}
	else 
		return true;
}
function setFCKEditorValue( instanceName , text )

{	
	var oEditor = FCKeditorAPI.GetInstance( instanceName );
	oEditor.SetHTML( text );
		
}
//To strip the editor values
function stripEditorNull(obj)
{
	strTmp = obj.value;
	strTmp = strTmp.replace('<HTML>',"");
	strTmp = strTmp.replace('<HEAD>',"");
	strTmp = strTmp.replace('<META content="MSHTML 6.00.2800.1106" name=GENERATOR>',"");
	strTmp = strTmp.replace('<LINK href="webadmi/" type=text/css rel=stylesheet>',"");
	strTmp = strTmp.replace('</HEAD>',"");
	strTmp = strTmp.replace('<BODY>',"");
	strTmp = strTmp.replace('<P>',"");
	strTmp = strTmp.replace('</P>',"");
	strTmp = strTmp.replace('<DIV>',"");
	strTmp = strTmp.replace('</DIV>',"");
	strTmp = strTmp.replace(/&nbsp;/g,"");
	strTmp = strTmp.replace("</BODY>","");
	strTmp = strTmp.replace("</HTML>","");	
	return strTmp;
}
// to find thelength of the given content
 
function isLen(obj,siz,msg)
{
	if(Trim(obj.value)!="")	
		{
		var strLen=obj.value;
		if(strLen.length < siz)
			{
			alert(msg+" should be atleast " + siz + " characters");
			obj.focus();
			return true;  
			} 
		else
			{
			return false;
			}	
		}	
}
// To find whether two objects are same
function isSame(obj1,obj2,msg1,msg2)
	{
	if((Trim(obj1.value))==(Trim(obj2.value)))
		{
		alert(msg1+" is matched with the "+msg2);
		obj2.focus();
		return false;
		}
	else
		{
		return true;
		}	
	}	
// to find whether two objects are not same
function isNotSame(obj1,obj2,msg1,msg2)
	{
	if((Trim(obj1.value))!=(Trim(obj2.value)))
		{
		alert(msg1+" is not same as  "+msg2);
		obj2.focus();
		return false;
		}
	else
		{
		return true;
		}	
	}	

// to compare the two object values
function isCorrect(obj1,obj2,msg1,msg2)
	{
	if((Trim(obj1.value)) > (Trim(obj2.value)))
		{
		alert(msg1+" should be less than "+msg2);
		obj2.focus();
		return false;
		}
	else
		{
		return true;
		}	
	}	
// to check the textarea
function isTxtareaNull(obj)
{
	if(Trim(obj.innerText) == "")
	{
		alert("Please enter the " + obj.tagName);
		obj.focus();
		return false;
	}
	else
		return true;
}

// to check is text area editor
 function isTxtareaEditor(obj,msg)
{
	if(Trim(obj.value) == "")
	{
		alert("Please enter " + msg);
	 	return true;
	}
	else
	{
		return false;
	}
}

// to check the given address is valied Web address
function isURL(obj,msg){
	var RegExp="^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$"
    var matchURL=(obj.value).match(RegExp);
    if(matchURL!=null){ 
        return false; 
    }else{ 
       	alert("Please enter valid "+msg);
		obj.focus();
		return true;
    } 
}




// To check the given zipcode format
function notZipcode(obj,msg)
{
	exp = /[a-zA-Z|\d]-{1}/;
	if (!exp.test(obj.value))
	{
		alert("Please enter valid "+msg);
		obj.focus();
		return false;
	}
	else
		return true;
}

// To check whether the object is checked or not

function notChecked(obj,msg)
{
	
	checked = false;
	if(obj.length)
		{
		for(i=0;i<obj.length;i++)
			{
			if(obj[i].checked)
			{checked = true;break;}
			}
		}
	else if(obj.checked)
		j=0;
		checked = true;

	if(!(checked))
	{
		alert("Please select the "+msg);
		if(obj.length)
			obj[0].focus();
		else
			obj.focus();
		return true;
	}
}

// To validate the given password 
 function fnChkAlphaForUserName(obj,msg)
{
	exp = (/(^([a-z]|[A-Z]|[0-9]|[_]|[-])*$)/);
		if (!exp.test(obj.value))
		{
			alert("Please enter valid "+msg);
			obj.focus();
			return false;
		}
		else
			return true;
}
function isPassword(obj)
{ 
	if ((obj.value.length)<5)
	{
		alert("Password should have atleast 5 characters");
		obj.focus();
		obj.value="";
		return false;
	}
	exp=/[^a-zA-Z0-9]/;
	 	if(exp.test(obj.value))
		{
		alert("Special characters not accepted");
		obj.focus();
		return false;
		}
 	else
		return true;
}
// To validate the image file formats

function notImageFile(obj,msg)
{
	var exp = /^.+\.(jpg|gif|jpeg|JPG|JPEG|GIF)$/;
	if (!exp.test((obj.value).toLowerCase()))
	{
		alert("Please choose jpg or gif file for "+msg);
		obj.focus();
		return true;
	}
	else
	{
		return false;
	}
}
// to validate the flash and image file formats
function notImageorFlashFile(obj,msg)
{
	//var exp = /^.+\.(jpg|gif|jpeg|png|JPG|JPEG|GIF|PNG)$/;
	var exp = /^.+\.(jpg|gif|jpeg|JPG|JPEG|GIF|swf|flv)$/;
	//var exp = /^.+\.(gif|GIF)$/;
	if (!exp.test((obj.value).toLowerCase()))
	{
		alert("Please choose JPG or GIF or SWF file for "+msg);
		obj.focus();
		return false;
	}
	else
		return true;
}

// to validate the image or video files
function notImageorVideoFile(obj,msg)
{
	//var exp = /^.+\.(jpg|gif|jpeg|png|JPG|JPEG|GIF|PNG)$/;
	var exp = /^.+\.(jpg|gif|jpeg|JPG|JPEG|GIF|wav|mpeg|avi)$/;
	//var exp = /^.+\.(gif|GIF)$/;
	if (!exp.test((obj.value).toLowerCase()))
	{
		alert("Please choose JPG or GIF or SWF file for "+msg);
		obj.focus();
		return false;
	}
	else
		return true;
}

// to validate the document file
function notDocFile(obj,msg)
{
	if(Trim(obj.value)!="")	
		{
		var exp = /^.+\.(DOC|doc|TXT|txt)$/;
		if (!exp.test((obj.value).toLowerCase()))
			{
			alert("Please choose doc or txt file for "+msg);
			obj.value="";
			obj.focus();
			return false;
			}
		else
			return true;	
		}
		else
		return false;
}
// To validate the pdf files

function notPdfFile(obj,msg)
{
	var exp = /^.+\.(pdf|PDF)$/;
	if (!exp.test((obj.value).toLowerCase()))
	{
		alert("Please upload a valid pdf file");
		obj.value="";
		obj.focus();
		return true;
	}
	else
	{
		return false;
	}
}
function notPdfDocFile(obj,msg)
{
	var exp = /^.+\.(pdf|doc|PDF|DOC|XLS|xls|txt|TXT)$/;
	if (!exp.test((obj.value).toLowerCase()))
	{
		alert("Please choose Pdf or Doc or Xls file for "+msg);
		obj.value="";
		obj.focus();
		return false;
	}
	else
		return true;
}

function notPdfDocFile1(obj,msg){
	var exp = /^.+\.(pdf|doc|PDF|DOC|xls|XLS)$/;
	if (!exp.test((obj.value).toLowerCase())){
		alert("Please choose pdf or doc or xls file for "+msg);
		obj.value="";
		obj.focus();
		return true;
	}else
		return false;
}
// To validate the file is excel file or not
function notXLSFile(obj,msg)
{
	var exp = /^.+\.(XLS|xls)$/;
	if (!exp.test((obj.value).toLowerCase()))
	{
		alert("Please upload xls file"+msg);
		obj.value="";
		obj.focus();
		return false;
	}
	else
		return true;
}
// To validate the price
function notPrice(obj,msg)
{
	exp = /^[\d]*[\.]{0,1}[\d]{1,2}$/;
	if (!exp.test(obj.value))
	{
		alert("Please enter valid "+msg);
		obj.focus();
		return false;
	}
	else
		return true;
}

// To validate the entered value is number or not
function fnChkNum(obj,msg)
{
	exp = /^[\d]/;
	if (!exp.test(obj.value))
	{
		alert("This field contains invalid characters");
		obj.focus();
		return false;
	}
	else
		return true;
}

function fnChkNumbers(obj,msg)
{
	exp = /^[\d]/;
	if (!exp.test(obj.value))
	{
		alert("Please enter valid value in "+msg);
		obj.focus();
		return true;
	}
	else
		return false;
}

// To validate the alphapets and numbers
function fnChkAlpha(obj,msg)
{
	exp = (/(^([a-z]|[A-Z]|["."]|[\s])*$)/);
	if (!exp.test(obj.value))
	{
		alert("Please enter only alphabets in "+msg);
		obj.focus();
		return false;
	}
	else
		return true;
}
function fnChkAlphaAdmin(obj,msg){
exp = (/(^([a-z]|[A-Z]|[_]|[-]|[.]|[","]|[ ]|["'"])*$)/);
		if (!exp.test(obj.value))
		{
			alert("Please enter only alphabets in "+msg);
			obj.focus();
			return false;
		}
		else
			return true;
}	
function fn4UName(obj,msg){
exp=(/(^[a-z]|[A-Z]|[_]$)/)
	if(!exp.test(obj.value)){
		alert("Please Enter only Alphabets in"+msg)
		obj.focus();
		return false;
	}
		else return true;
}
function fn4All(obj,msg){
	exp=(/(^[a-z]|[A-Z]|[0-9]|[_]|[-]|[']|["]|[.]*$)/);
	if(!exp.test(obj.value)){
		alert("Please Enter only Alphabets in"+msg)
		obj.focus();
		return false;
	}
	else return true;
}
// To validate the number,char and some special characters
function fnChkAlphaNum(obj)
     {
	exp = (/(^([a-z]|[A-Z]|[0-9]|[_]|[-]|[']|["]|[.]|[ ])*$)/);
	if (!exp.test(obj.value))
	{
		alert("Special characters are not accepted");
		obj.focus();
		return false;
	}
	else
   	   return true;
}

function fnChkAlphaNumerics(obj,msg)
     {
	exp = (/(^([a-z]|[A-Z]|[0-9]|[_]|[-]|[']|["]|[.]|[ ])*$)/);
	if (!exp.test(obj.value))
	{
		alert("Special characters are not accepted in "+msg);
		obj.focus();
		return false;
	}
	else
   	   return true;
}

// To vlaidate the folder name
function fnChkFolderName()
{
	if (((window.event.keyCode < 48) || (window.event.keyCode > 57)) && ((window.event.keyCode < 65) || (window.event.keyCode > 90)) && ((window.event.keyCode < 97) || (window.event.keyCode > 122)) && (window.event.keyCode != 95))
	{
		alert("Only Alphabets(A-Z, a-z), Numbers(0-9) and Underscore(_) are allowed");
		window.event.keyCode = 0;
	}

}
// To get the country details
function GetCountry(defaultValue,isNotWithSelect)
{
	var sCountry="Afghanistan,Albania,Algeria,American Samoa,Andorra,Angola,Anguilla,Antarctica,Antigua and Barbuda,Argentina,Armenia,Aruba,Australia,Austria,Azerbaidjan,Bahamas,Bahrain,Bangladesh,Barbados,Belarus,Belgium,Belize,Benin,Bermuda,Bolivia,Bosnia-Herzegovina,Botswana,Bouvet Island,Brazil,British Indian O. Terr.,Brunei Darussalam,Bulgaria,Burkina Faso,Burundi,Buthan,Cambodia,Cameroon,Canada,Cape Verde,Cayman Islands,Central African Rep.,Chad,Chile,China,Christmas Island,Cocos (Keeling) Isl.,Colombia,Comoros,Congo,Cook Islands,Costa Rica,Croatia,Cuba,Cyprus,Czech Republic,Czechoslovakia,Denmark,Djibouti,Dominica,Dominican Republic,East Timor,Ecuador,Egypt,El Salvador,Equatorial Guinea,Estonia,Ethiopia,Falkland Isl.(Malvinas),Faroe Islands,Fiji,Finland,France,France (European Ter.),French Southern Terr.,Gabon,Gambia,Georgia,Germany,Ghana,Gibraltar,Great Britain (UK),Greece,Greenland,Grenada,Guadeloupe (Fr.),Guam (US),Guatemala,Guinea,Guinea Bissau,Guyana,Guyana (Fr.),Haiti,Heard & McDonald Isl.,Honduras,Hong Kong,Hungary,Iceland,India,Indonesia,Iran,Iraq,Ireland,Israel,Italy,Ivory Coast,Jamaica,Japan,Jordan,Kazachstan,Kenya,Kirgistan,Kiribati,Korea (North),Korea (South),Kuwait,Laos,Latvia,Lebanon,Lesotho,Liberia,Libya,Liechtenstein,Lithuania,Luxembourg,Macau,Madagascar,Malawi,Malaysia,Maldives,Mali,Malta,Marshall Islands,Martinique (Fr.),Mauritania,Mauritius,Mexico,Micronesia,Moldavia,Monaco,Mongolia,Montserrat,Morocco,Mozambique,Myanmar,Namibia,Nauru,Nepal,Netherland Antilles,Netherlands,Neutral Zone,New Caledonia (Fr.),New Zealand,Nicaragua,Niger,Nigeria,Niue,Norfolk Island,Northern Mariana Isl.,Norway,Oman,Pakistan,Palau,Panama,Papua New,Paraguay,Peru,Philippines,Pitcairn,Poland,Polynesia (Fr.),Portugal,Puerto Rico (US),Qatar,Reunion (Fr.),Romania,Russian Federation,Rwanda,Saint Lucia,Samoa,San Marino,Saudi Arabia,Senegal,Seychelles,Sierra Leone,Singapore,Slovak Republic,Slovenia,Solomon Islands,Somalia,South Africa,Spain,Sri Lanka,St. Helena,St. Pierre & Miquelon,St. Tome and Principe,St.Kitts Nevis Anguilla,St.Vincent & Grenadines,Sudan,Suriname,Svalbard & Jan Mayen Is,Swaziland,Sweden,Switzerland,Syria,Tadjikistan,Taiwan,Tanzania,Thailand,Togo,Tokelau,Tonga,Trinidad & Tobago,Tunisia,Turkey,Turkmenistan,Turks & Caicos Islands,Tuvalu,Uganda,Ukraine,United Arab Emirates,United Kingdom,United States,Uruguay,US Minor outlying Isl.,Uzbekistan,Vanuatu,Vatican City State,Venezuela,Vietnam,Virgin Islands (British)";
	var xCountry=sCountry.split(",");
	var str="";
	if (!isNotWithSelect)str+="<option value='' selected>Select Country</option>\n";else str+="<option value='' selected>Doesn't Matter</option>\n";
	for(i=0;i<xCountry.length; i++)
	if(xCountry[i]==defaultValue)str+="<option value='"+xCountry[i]+"' selected>"+xCountry[i]+"</option>\n";else str+="<option value='"+xCountry[i]+"'>"+xCountry[i]+"</option>\n";
	document.write(str);
}
// To display the selected date
function fnShowDate(obj,msg) 
	{
 		var retdate=window.showModalDialog("includes/calender.htm","","dialogHeight: 219px; dialogWidth: 273px;  center: Yes; help: No; resizable: No; status: No;titlebar:No");
		obj.value=retdate;
 	}
// to validate the selected value in combo
function isNullCbo(obj,msg)
{
	if (Trim(obj.value)=="")
	{
		alert("Please select the " + msg);
		obj.focus();
		return true;
	}
	else
		return false;
		
}
// To validate the checkbox whether checked or not

function notChecked1(obj)
{
	checked = false;
	if(obj.length)
	{
		for(i=0;i<obj.length;i++)
		{
			if(obj[i].checked)
			{checked = true;break;}
		}
	}
	else if(obj.checked)
		checked = true;

	if(!(checked))
	{alert("Please select atleast one record(s)");return true;}
}

// To validate the selected checkbox

function notSelected(obj)
{
	if (obj.options[obj.selectedIndex].value == "")
	{
		alert("Please select the "+ obj.tagName);
		obj.focus();
		//obj.document.body.innerHTML.focus();
		return true;
	}
	else
		return false;
}




//table to drop down
function table2dropdown( TableObj , ColumnNames, DropDownObject , SelectedValue, Select1stText , IsAddAll )
{	

	if ( TableObj == null )
		return;

	var totrows = TableObj.Rows.length;

	var ColumnsSplit = ColumnNames.split(',');
	var ddlObj = document.getElementById( DropDownObject );


	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 ;
	}

	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";

	for(var r=0; r < totrows; r++)
	{
		row = TableObj.Rows[r];
		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 = fnFindQuotes(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(fnFindQuotes(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;
	}

}
//
// Author : A Shankar
// Date : 21st March 2007
// Remark : insertRow() - add new row to the Table Tag by various browser compatible.
//

function insertRow( tblObj )
{
	var insertRowObj;
	var tableObj;
	
	if ( typeof(tblObj) == "object" )
		tableObj = tblObj;
	else
		tableObj = document.getElementById(tblObj);
	
	if ( window.navigator.appName == "Microsoft Internet Explorer")
	{
		insertRowObj = tableObj.childNodes[0].insertRow();
	}
	else
	if ( window.navigator.appName == "Netscape" || window.navigator.appName == "Opera")
	{
		rowid =  tableObj.rows.length ; // <tr>
		insertRowObj = tableObj.insertRow( rowid  );
	}

	return insertRowObj; 
}

function insertCell( insertRowObj, ColumnIndex )
{
	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>
	}

	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 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 fnSelectAllCheckBok(objTable,tableRowsCount,chkValue){
	for( i=1; i<tableRowsCount-1; i++)
	{
		if ( window.navigator.appName == "Microsoft Internet Explorer")
		{
			chkObj = document.getElementById(objTable).childNodes[0].childNodes[i].childNodes[1].childNodes[0];
		}
		else
		if ( window.navigator.appName == "Netscape" || window.navigator.appName == "Opera")
		{
			chkObj = document.getElementById(objTable).rows[i].childNodes[1].childNodes[0];
		}
		chkObj.checked = chkValue;
	}	
}

function fnSelectChkBox(objTable,i){
	if ( window.navigator.appName == "Microsoft Internet Explorer")
	{
		chkObj = document.getElementById(objTable).childNodes[0].childNodes[i].childNodes[1].childNodes[0];
	}
	else
	if ( window.navigator.appName == "Netscape" || window.navigator.appName == "Opera")
	{
		chkObj = document.getElementById(objTable).rows[i].childNodes[1].childNodes[0];
	}
	return chkObj;

}

function fnSelectChargeBox(objTable,i){
	if ( window.navigator.appName == "Microsoft Internet Explorer")
	{
		chkObj = document.getElementById(objTable).childNodes[0].childNodes[i].childNodes[2].childNodes[0];
	}
	else
	if ( window.navigator.appName == "Netscape" || window.navigator.appName == "Opera")
	{
		chkObj = document.getElementById(objTable).rows[i].childNodes[2].childNodes[0];
	}
	return chkObj;

}


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" || 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 ;

}

//
// 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);
}

function disableEnterKey(e)
{
     var key;

     if(window.event)
          key = window.event.keyCode;     //IE
     else
          key = e.which;     //firefox

     if(key == 13)
          return false;
     else
          return true;
}
