

function getWindowHeight() {
	var windowHeight=0;
	if (typeof(window.innerHeight)=='number') {
		windowHeight=window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight=document.documentElement.clientHeight;
		}
		else {
			if (document.body&&document.body.clientHeight) {
				windowHeight=document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}
function ShowTopics(URL)
		{			
			var billingRef=document.forms[0].txtBillingRef.value;
			window.location.href=URL + "&txtBillingRef=" + encodeURIComponent(billingRef);
		}
function setFooterPos(){
}

function setFooterPos1(){
	if(document.getElementById){
		var windowHeight=getWindowHeight();
		if (windowHeight>0){
			var contentHeight=document.getElementById('bodyContent').offsetHeight;
			var headerHeight=document.getElementById('header').offsetHeight;
			var footerElement = document.getElementById('footerDiv');
			var footerHeight = footerElement.offsetHeight;
			if ((windowHeight-(headerHeight + contentHeight + footerHeight)) >=0){
				footerElement.style.position='relative';
				footerElement.style.top = ((windowHeight-25)-(headerHeight + contentHeight + footerHeight)) + 'px';
			}else{
				footerElement.style.position='static';
			}
		}
	}
}

//window.onload=function(){
//	setFooterPos1()
//}

//window.onresize=function(){
//	setFooterPos1()
//}


function heightmaker(formName) {
	var d = document;
	//var y = -172;
	var y = 0;
	if (self.innerHeight) {
		y += self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		y += document.documentElement.clientHeight;
	} else if (document.body) {
		y += document.body.clientHeight;
	} 

	x=document.getElementById('footer').clientHeight;
	var logo=0;
	logo +=document.getElementById('logo').clientHeight;

	var primnav;

	primnav=document.getElementById('primnav').clientHeight;

	var secnav=0;
	if (document.getElementById('secnav'))
		secnav=document.getElementById('secnav').clientHeight;
	d.getElementById(formName).style.height = (y-x-primnav-secnav) +'px';
	document.getElementById('footer').style.top=(y-x-primnav-secnav) +'px';
}

function compareDate(sDate,eDate)
{
		
		var startdate = new Date(sDate);
		var enddate = new Date(eDate);
		var msPerDay = 24 * 60 * 60 * 1000; 
		var daysLeft = (enddate.getTime() - startdate.getTime()) / msPerDay;
		if (daysLeft <0) 
        {
         return false;
        }
        else
        {
       	return true;
       	}
}

function openPopUp(QueryString,Path)
{
	var URL;
	var returnValue;
	
	URL = Path + "/com/requestHandler/hrefHandler.aspx?Action=" + QueryString;
	returnValue=window.showModalDialog(URL, 'myBilling', 'width=250,height=150,resizable=no,scrollbars=no,border=thin,status=no;');
	
	if (returnValue == "No")
	{	
		return false;
	}
	if (returnValue == "Yes")
	{
		//window.parent.submit();
		return true;
	}
	return false;		
	 

}

function GetClickValue(Value)
{
	
	document.forms[0].lblButtonhid.value = Value;
	
}
//-----------To Check atleast one check box selected in grid--------------


function SelectedCheckBox()
{
	
			var selectFlag=0;
			var checkBoxExistFlag=0;
			var ml = document.forms[0];
			var len = ml.elements.length;
			
			for (var i = 0; i < len; i++) 
			{
				var e = ml.elements[i];
				if (e.name.indexOf("ChkRowSelect")>=0) 
				{
					
					checkBoxExistFlag=1;
					if(e.checked)
						{selectFlag=1;break;}
				}
			}
			if(checkBoxExistFlag==1 && selectFlag==0)
			{
				
				alert("Please select at least one document.");	return false;
			}
			else if(checkBoxExistFlag==0)
			{return true;}
			else if(selectFlag==1)
			{return true;}
		
}
function SelectedCheckBox(lMessageType)
{
			
			var selectFlag=0;
			var checkBoxExistFlag=0;
			var ml = document.forms[0];
			var len = ml.elements.length;
			
			for (var i = 0; i < len; i++) 
			{
				var e = ml.elements[i];
				if (e.name.indexOf("ChkRowSelect")>=0) 
				{
					
					checkBoxExistFlag=1;
					if(e.checked)
						{selectFlag=1;break;}
				}
			}
			if(checkBoxExistFlag==1 && selectFlag==0)
			{
				if(lMessageType=='Email')
				alert("Please select at least one e-mail address.");	
				else if(lMessageType=='CompanyWatch')
				alert("Please select at least one company name.");	
				else if(lMessageType=='FilingPartyWatch')
				alert("Please select at least one filing party name.");	
				else if(lMessageType=='KeepList')
				alert("Please select at least one document.");	
				else 
				alert("Please select at least one document.");	
				return false;
			}
			else if(checkBoxExistFlag==0)
			{return true;}
			else if(selectFlag==1)
			{return true;}
		
}
//to check radi button selected
function SelectedRadioButton()
{
	
			var selectFlag=0;
			var radioButtonExistFlag=0;
			var ml = document.forms[0];
			var len = ml.elements.length;
			
			for (var i = 0; i < len; i++) 
			{
				var e = ml.elements[i];
				if (e.name.indexOf("rbRowSelect")>=0) 
				{
					
					radioButtonExistFlag=1;
					if(e.checked)
						{selectFlag=1;break;}
				}
			}
			if(radioButtonExistFlag==1 && selectFlag==0)
			{
				
				alert("Please select at least one file number.");	return false;
			}
			else if(radioButtonExistFlag==0)
			{return true;}
			else if(selectFlag==1)
			{return true;}
		
}
		function validateEmail(lemail) {
			if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(lemail)){
			return true;
			}
			return false;
			}
//----------- Email Validation--------------
	function ValidEmail(lsEmailID)
		{
		
			if (lsEmailID.length >0)
			{
				lsEmailIDList = lsEmailID.split(';');
				var liCounter;
				var lsCurEmailID;
				for (liCounter=0;liCounter < lsEmailIDList.length;liCounter++){
					lsCurEmailID = lsEmailIDList[liCounter];
					if(validateEmail(lsCurEmailID)==true)
					{return true;}
					else
					{alert("The address you entered  '" +
							 lsCurEmailID + "'  contains some invalid characters.");
					return false;
					}
				}
			}
			return true;
	   }
	
//----------- Email Validation commaseparated--------------
	function ValidEmailComma(lsEmailID)
		{
			
			lsEmailID=trim(lsEmailID);
			if (lsEmailID.length >0)
			{
				if(lsEmailID.charAt(0)==",")
				{
					
					alert('Please remove extra comma (,) from the entered address(es).');
					return false;
				
				}				
				if(lsEmailID.charAt(lsEmailID.length-1)==",")
				{
					
					alert('Please remove extra comma (,) from the entered address(es).');
					return false;
				}
				
				lsEmailIDList = lsEmailID.split(',');
			
				var liCounter;
				var lsCurEmailID;
				var loCounterSec;
				for (liCounter=0;liCounter < lsEmailIDList.length;liCounter++)
				{
					lsCurEmailID = trim(lsEmailIDList[liCounter]);
					//check tha validity of the email
					if(validateEmail(lsCurEmailID)==false)
					{
						alert("The address you entered  '" +lsCurEmailID + "'  contains some invalid characters.");
						return false;
					}
					else
					//check for duplicate
					{
						if(lsEmailIDList.length>1)
						{
							for (loCounterSec=0;loCounterSec < lsEmailIDList.length;loCounterSec++)
							{
								if(loCounterSec!=liCounter && trim(lsEmailIDList[loCounterSec])==lsCurEmailID)
								{
									alert("Please remove duplicate entry for address '" +lsCurEmailID + "'.");
									return false;
								}	
							}
						}
					}
				}
			}
			return true;
	   }
	   
//----------- Email Validation commaseparated then space--------------
	function ValidEmailCommaSpace(lsEmailID)
	{
		if (trim(lsEmailID).length >0)
			{
				if(lsEmailID.charAt(lsEmailID.length-1)==",")
				{
					lsEmailID=lsEmailID.substring(0,lsEmailID.length-1);
				}
				//alert(lsEmailID);
				lsEmailIDList = lsEmailID.split(',');
				//alert("CommaSepared : "+lsEmailIDList.length);
				if(lsEmailIDList.length==1)
				{
					//alert("No CommaSeparated.So check for space.");
					
					//check for space
					lsEmailIdListSpace=lsEmailID.split(' ');
					//alert("SpaceSepared : "+lsEmailIdListSpace.length);
					if(lsEmailIdListSpace.length==1)
					{
						//alert("No SpaceSeparated.So check for email.");
						if(validateEmail(lsEmailID)==false)
						{
							alert("The address you entered  '" +lsEmailID + "' contains some invalid characters.");
							return false;
						}	
					}
					else
					{
						//alert("space separated.So check.");
						var liCounter;
						var lsCurEmailID;
						for (liCounter=0;liCounter < lsEmailIdListSpace.length;liCounter++){
							lsCurEmailID = trim(lsEmailIdListSpace[liCounter]);
							if(validateEmail(lsCurEmailID)==false)
							{alert("The address you entered  '" + lsCurEmailID + "'  contains some invalid characters.");
							return false;
							}
						}
						
					}
				
				}
				else
				{
					//alert("comma separated.So check.");
					var liCounter;
					var lsCurEmailID;
					for (liCounter=0;liCounter < lsEmailIDList.length;liCounter++){
						lsCurEmailID = trim(lsEmailIDList[liCounter]);
						if(validateEmail(lsCurEmailID)==false)
						{alert("The address you entered  '" +lsCurEmailID + "'  contains some invalid characters.");
						return false;
						}
					}
				}
				
			}
			return true;


	}
function returnString(lsString)
{

							var newStr;
							  for (i = 0; i < lsString.length; i++){   
								 var c = lsString.charAt(i);
								 if (c != " ")
								 {
								 newStr=lsString.substring(i,lsString.length-i+1);
								 break;
								 }
							 }	
							
							if(newStr=='undefined')
							{return " ";}
							else
							{return newStr;}
}   
//-----------Check Box Click functions start-----------------------

//<!--////////////////////////////////////////////////////////////
//		<!-- This script automatically creates the alternating table row colors -->
//		<!-- Change the "#results tbody tr.even td" CSS style to change the row color.  -->
		//onload = function() {heightmaker(document.forms[0].name); stripe ('results') };
		function stripe(id) {
			var table = document.getElementById(id);
			if (! table) { return; }
		    
			var trs = table.getElementsByTagName("tr");

			for (var i = 1; i < trs.length; i += 2) {
			trs[i].className += " even";
			}
			HighlightBack();
		}
		
		function HighlightBack()
		{
	
			var ml = document.forms[0];
			var len = ml.elements.length;
			for (var i = 0; i < len; i++) 
			{
				var e = ml.elements[i];
				if (e.name.indexOf("ChkRowSelect")>=0) 
				{
			
					if (e.checked == true)
					{
						Highlight(e);
					}
				}
			}
		}

		<!--////////////////////////////////////////////////////////////
		<!-- This script changes the table row colors when checkbox is selected-->
		function Toggle(e)
			{
			if (e.checked) {
				Highlight(e);	
				if (document.forms[0].toggleAll) document.forms[0].toggleAll.checked = AllChecked();
			}
			else {
				Unhighlight(e);
				if (document.forms[0].toggleAll) document.forms[0].toggleAll.checked = false;
				
			}
			}

			function ToggleAll(e)
			{

			if (e.checked) {
				CheckAll();
			}
			else {
				ClearAll();
			}
			}

			function Check(e)
			{
			e.checked = true;
			Highlight(e);
			}

			function Clear(e)
			{
			e.checked = false;
			Unhighlight(e);
			}

			function CheckAll()
			{
			
			var ml = document.forms[0];
			var len = ml.elements.length;
			for (var i = 0; i < len; i++) {
				var e = ml.elements[i];
				
				if (e.name.indexOf("ChkRowSelect")>=0) {
				Check(e);
				}
			}
			//ml.toggleAll.checked = true;
			}

			function ClearAll()
			{
			var ml = document.forms[0];
			var len = ml.elements.length;
			for (var i = 0; i < len; i++) {
				var e = ml.elements[i];
				if (e.name.indexOf("ChkRowSelect")>=0) {
				Clear(e);
				}
			}
			//ml.toggleAll.checked = false;
			}

			function Highlight(e)
			{
			var r = null;
			if (e.parentNode && e.parentNode.parentNode) {
				r = e.parentNode.parentNode;
			}
			else if (e.parentElement && e.parentElement.parentElement) {
				r = e.parentElement.parentElement;
			}
			if (r) {
				
				if (r.className == "msgnew") {
				r.className = "msgnews";
				}
				else if (r.className == "msgnew even") {
				r.className = "msgnewseven";
				}
				else if (r.className == "msgold") {
				r.className = "msgolds";
				}
				else if (r.className == "msgold even") {
				r.className = "msgoldseven";
				}
			}
			}


			function Unhighlight(e)
			{
			var r = null;
			if (e.parentNode && e.parentNode.parentNode) {
				r = e.parentNode.parentNode;
			}
			else if (e.parentElement && e.parentElement.parentElement) {
				r = e.parentElement.parentElement;
			}
			if (r) {
				if (r.className == "msgnews") {
				r.className = "msgnew";
				}
				else if (r.className == "msgnewseven") {
				r.className = "msgnew even";
				}
				else if (r.className == "msgoldseven") {
				r.className = "msgold even";
				}
				else if (r.className == "msgolds") {
				r.className = "msgold";
				}
			}
			}

			function AllChecked()
			{
			ml = document.forms[0];
			len = ml.elements.length;
			for(var i = 0 ; i < len ; i++) {
				if (ml.elements[i].name.indexOf("ChkRowSelect") >=0 && !ml.elements[i].checked) {
				return false;
				}
			}
			return true;
			}
			
//-----------Check Box Click functions end-----------------------
//To close a page

function closeme()		{
		window.close();
		window.returnValue="Close";
		}
//Javascript for SIC Code,Auditors etc pages



//Function to show the popup in center
function viewsearchwindow(path)
 {
	if (document.all)
		var xMax = screen.width, yMax = screen.height;
	else
	if (document.layers)
		var xMax = window.outerWidth, yMax = window.outerHeight;
	else
	var xMax = 640, yMax=480;	
    var xOffset = (xMax - 320)/2, yOffset = (yMax - 200)/2;
	window.open(path,'SaveSearch','width=320,height=200,screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+'');
}	

//Javascript for Save Search 
function ShowSaveScreen(Path)
{
	var objForm=document.forms[0];
	var searchFor,searchComp,source,SText;
	//read searchParams and PText,SText values
	var searchParams;
	if(objForm.hdnSearchParams)
		searchParams=objForm.hdnSearchParams.value;
	//if (searchParams.indexOf("#")>0)
	//	searchParams=searchParams.replace("#","@");	
	if (searchParams.indexOf("#")>0)
		searchParams=replaceOccurrence(searchParams);
		
		
	if (objForm.hdnSearchField)
		searchFor=objForm.hdnSearchField.value;
	if (objForm.hdnSearchComp)
		searchComp=objForm.hdnSearchComp.value;
	if (objForm.hdnSearchFor)
		searchFor=objForm.hdnSearchFor.value;
	
		
	var PText=objForm.ucHeader_hdnPText.value;
	
	if (objForm.hdnSource)
		source=objForm.hdnSource.value;
	if(source=="FParty")
		SText="Filing Party";
	else
		SText=objForm.ucHeader_hdnSText.value;
	
	var returnVal;
	var url;
	//TCS Fix: While building the querystring, append "PText" and "SText" before "searchParams" so that they
	//don't get truncated if the length of querystring is greater than 2053.
	if (PText!="Registrations")
		url=Path + "&PText=" + PText + "&SText=" + SText + "&searchComp='" + searchComp + "'" + "&searchFor='" + searchFor + "'" + "&searchParams='" + searchParams + "'";
	else
		url=Path + "&PText=" + PText + "&SText=" + SText + "&searchComp='" + searchComp + "'" + "&searchFor='" + searchFor + "'" ;

	if (document.forms[0].ucSearch_hdnSaveQString)
	{
		
		document.forms[0].ucSearch_hdnSaveQString.value=searchParams;
	}
	
	viewsearchwindow(url);
	
}

//----------------------------------------
//------------------Date Validation function--------------------

// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var dtCh2="-";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function isNotBlank(s){
	var i;
	var v;
	v=trim(s);	
    for (i = 0; i < v.value.length; i++){   
        // Check that current character is any character.
        var c = v.value.charAt(i);
        if ((c != "")) return true;
    }
    // Blank Field.
    alert("Please do not leave blank");
    s.focus();
    return false;
}



function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31;
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30;}
		if (i==2) {this[i] = 29;}
   } 
   return this;
}

function isDate(dateField){

if (dateField.value.length==0){
		return true;
	}
	var dtStr=dateField.value;
	var daysInMonth = DaysArray(12);
	var pos1;
	var pos2;
	var bflag1=false;
	var bflag2=false;
	var usedChar;
	pos1=dtStr.indexOf(dtCh);
	
	if (pos1==-1)
	{
		pos1=dtStr.indexOf(dtCh2);
		usedChar='-';
	}
	else
		usedChar='/';
	pos2=dtStr.indexOf(dtCh,pos1+1);
	if(pos2<1)
		pos2=dtStr.indexOf(dtCh2,pos1+1);
	var strMonth=dtStr.substring(0,pos1);
	var strDay=dtStr.substring(pos1+1,pos2);
	var strYear=dtStr.substring(pos2+1);
	strYr=strYear;
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1);
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1);
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1);
	}
	month=parseInt(strMonth);
	day=parseInt(strDay);
	year=parseInt(strYr);
	if (pos1==-1 || pos2==-1){
		alert("The date format should be: mm/dd/yyyy or mm-dd-yyyy");
		//dateField.focus();
		return false;
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month");
		//dateField.focus();
		return false;
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day");
		//dateField.focus();
		return false;
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear);
		//dateField.focus();
		return false;
	}
	
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false)
		bflag1= true;
	else
		bflag1=false;
	if (dtStr.indexOf(dtCh2,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh2))==false)
		bflag2= true;
	else
		bflag2=false;
	if ((usedChar=="/") && (bflag1))
	{
		
		alert("Please enter a valid date");
		//dateField.focus();
		return false;
	}
	if ((usedChar=="-") && (bflag2))
	{
		alert("Please enter a valid date");
		//dateField.focus();
		return false;
	}

return true;
}

function CheckDate(Field)
{
	
	var dt=Field;
	bValid=true;
	
	if (dt.value.length==0){
		return true;
	}
	if (isDate(dt)==false)
	{
		dt.focus();		
		return false;
	}
    return true;
 }
//---------------Price Pop up-------------------------------------
function ShowPricePopUp(Message)
{
 //TCS Fix: Do not displpay price pop-up if charge is 0
 if (Message.indexOf("$0")<0)
 {
	if (confirm(Message))
			return true;
 }
				
	return false;
}

//------------------------------------------------------------------
//-----------------varifySpecialChar-----------------------------
function verifySpecialChar(lsInput)
{
		
		
		 var bflag=true;

		 if (lsInput.length >0)
          {
			var lsSplChars = "^';:~";
			for (var i = 0; i < lsInput.length; i++) 
			{
			  if (lsSplChars.indexOf(lsInput.charAt(i)) != -1) 
		       {
	            
				bflag=false;
	           }   
	     	}	
          }
        
        if (bflag==true)
			 return true;
		else
			alert ("The input string has special characters." + "\nFollowing "+lsSplChars+" characters  are not allowed.\n");
			return false;	 
		}
//------------------varifySpecialChar end-----------------------------


//-----------------verifyPhoneFaxZipNumber-----------------------------
function verifyPhoneFaxZipNumber(lsInput,lsType)
{
		
		
		 var bflag=true;
		if(lsInput.charAt(i)=='-')
		{
			bflag=false;
		}
		 if (lsInput.length >0 && bflag ==true )
          {
			var lsSplChars = "-0123456789";
			for (var i = 0; i < lsInput.length; i++) 
			{
			  if (lsSplChars.indexOf(lsInput.charAt(i)) == -1) 
		       {
	            
				bflag=false;
	           }   
	     	}	
          }
        
        if (bflag==true)
			 return true;
		else
			alert ("Enter currect "+lsType);
			return false;	 
		}
//------------------verifyPhoneFaxZipNumber end-----------------------------
//-----------------varifySpecialChar-----------------------------
function verifySpecialCharInString(lsInput,lsType)
{
		
		
		 var bflag=true;

		 if (lsInput.length >0)
          {
			var lsSplChars = "@$%^*?<>";
			for (var i = 0; i < lsInput.length; i++) 
			{
			  if (lsSplChars.indexOf(lsInput.charAt(i)) != -1) 
		       {
	            
				bflag=false;
	           }   
	     	}	
          }
        
        if (bflag==true)
			 return true;
		else
			alert ("Special characters ( " + lsSplChars+" ) are not allowed in "+lsType+" .");
			return false;	 
		}
//------------------varifySpecialChar end-----------------------------
//------------------Date Validation function End----------------
//------------------Function for document Function View,Save,Print link
function ShowPopUpView(urlPath)
{

	
	var selectFlag=0;
	var ml = document.forms[0];
	var len = ml.elements.length;
	var Params;
	for (var i = 0; i < len; i++) 
	{
		var e = ml.elements[i];
	
		if (e.name.indexOf("ChkRowSelect")>=0) 
		{
			if(e.checked)
			{
				var myLength = e.name.length-1;
				var index=e.name.substring(myLength,myLength + 1);
				
				var s="lblHidKeyValue" + index;
				
				
				
				
			}
							
		}
	}
	var returnVal;
	returnVal=window.showModalDialog(urlPath);
	if (returnVal != "Close")
	{	
		if (returnVal=="1")
		{
			document.forms[0].txtFormatOption.value="HTML";
		}
		if (returnVal=="2")
		{
			document.forms[0].txtFormatOption.value="DOC";
		}
		if (returnVal=="3")
		{
			document.forms[0].txtFormatOption.value="PDF";
		}
		document.forms[0].submit();
		
	}

			

}

//To retrieve checked value(s) from grid

function GetHiddenValues(f) {
				// Get a handle to our form object.
				//f = document.forms[0] ;
				var flag = false;
				// Iterate through the elements on our form and validate them

				var  values= "";
				for(var i=0; i<=f.elements.length-1; i++) {
					// Get a handle to the current element.
					var e = f.elements[i] ;
					if( e.type == "checkbox" && (e.name.substring(0,e.name.length-1)== "ChkRowSelect" || e.name.substring(0,e.name.length-2)== "ChkRowSelect")){ 
						if(e.checked){
							flag = true;
						}
					}
					if(e.type == "hidden" && (e.name.substring(0,e.name.length-1)== "lblHidKeyValue" || e.name.substring(0,e.name.length-2)== "lblHidKeyValue") ) {
						if (flag==true){
							flag=false;
							if (values != ""){
							values = values + ":" + e.value;
							}
							else{
								values =  e.value;
							}	
						}
					}
				}
	return values;				
}

//------------- Validation for SEC File No ----------
function verifyValidData(Field)
{	
		 var bflag=true;
		 var lsInput = Field.value;
		if(lsInput.charAt(0)=='-')
		{
			bflag=false;
		}
		 if (lsInput.length >0 && bflag ==true )
          {
			var lsSplChars = "-0123456789";
			for (var i = 0; i < lsInput.length; i++) 
			{
			  if (lsSplChars.indexOf(lsInput.charAt(i)) == -1) 
		       {
					Field.focus();		       	         
					bflag=false;
	           }   
	     	}	
          }
        
        if (bflag==true)
			 return true;
		else
			alert ("Enter a valid File No !");
		return false;	 
	}
//----------------verifyValidData ends

//----------------- Validate Deal value Fields
function vaildateNumericData(Field)
{	
		 var bflag=true;
		 var lsInput = Field.value;
		if((lsInput.charAt(0)==',')  || (lsInput.charAt(0)=='.'))
		{
			bflag=false;
		}
		
		 if (lsInput.length >0 && bflag ==true )
          {
			var lsSplChars = ",0123456789.";
			for (var i = 0; i < lsInput.length; i++) 
			{
			  if (lsSplChars.indexOf(lsInput.charAt(i)) == -1) 
		       {
					Field.focus();            
					bflag=false;
	           }   
	     	}	
          }
        
        if (bflag==true)
			 return true;
		else
			alert ("Please enter a numeric value !");
		return false;	 
	}
//----------------vaildateNumericData ends


function trim(inputString) {
   // Removes leading and trailing spaces from the passed string. Also removes
   // consecutive spaces and replaces it with one space. If something besides
   // a string is passed in (null, custom object, etc.) then return the input.
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
   return retValue; // Return the trimmed string back to the user
} 

//------ To fetch film numbers from Watch filings
function GetHiddenValuesFromWatch(f) {
	
				// Get a handle to our form object.
				//f = document.forms[ ;
				var flag = false;
				// Iterate through the elements on our form and validate them

				var  values= "";
				for(var i=0; i<=f.elements.length-1; i++) {
					// Get a handle to the current element.
					var e = f.elements[i] ;
							
					if(e.name.indexOf("ChkRowSelect")>0)
					{
						if(e.checked){
							flag = true;
						}
					}
					if(e.type == "hidden" && (e.name.indexOf("hdnFilmNo")>0) ) {
						
						if (flag==true){
							flag=false;
							if (values != ""){
							values = values + ":" + e.value;
							}
							else{
								values =  e.value;
							}	
						}
					}
				}
	return values;				
}
//Function to show the popup in center
		function centerwindow(path)	
	     {
			if (document.all)
				var xMax = screen.width, yMax = screen.height;
			else
				if (document.layers)
					var xMax = window.outerWidth, yMax = window.outerHeight;
				else
					var xMax = 640, yMax=480;	
				var xOffset = (xMax - 400)/2, yOffset = (yMax - 300)/2;
  				window.open(path,'List','width=400,height=300,resizable=yes,scrollbars=yes,toolbar=no,menubar=no,screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+'');
		}	
//-----------To Check atleast one check box selected in grid--------------


function SelectedCheckBoxInOther(lMessage)
{
	
			var selectFlag=0;
			var checkBoxExistFlag=0;
			var ml = document.forms[0];
			var len = ml.elements.length;
			
			for (var i = 0; i < len; i++) 
			{
				var e = ml.elements[i];
				if (e.name.indexOf("ChkRowSelect")>=0) 
				{
					
					checkBoxExistFlag=1;
					if(e.checked)
						{selectFlag=1;break;}
				}
			}
			if(checkBoxExistFlag==1 && selectFlag==0)
			{
				
				alert("Please select at least one document.");	return false;
			}
			else if(checkBoxExistFlag==0)
			{
				if(lMessage=='KeepList')
					{alert("Paper document(s) can not be added to the Keep List.");}
				if(lMessage=='Save')
					{alert("Paper document(s) can not be saved.");}
				if(lMessage=='Email')
					{alert("Paper document(s) can not be E-mailed.");}
				if(lMessage=='ViewPrint')
					{alert("Paper document(s) can not be viewed and printed.");}
				if(lMessage=='ViewAbstract')
					{alert("No Abstracts were found for the WSB number or numbers that you specified.");}
				return false;}
			else if(selectFlag==1)
			{return true;}
		
}


function replaceOccurrence(inString)
{
	var len = inString.length;
	var i=0
	
	for(i=0;i<len;i++)
	{
		if(inString.charAt(i)=='#')
			inString=inString.replace("#","@");	
		if(inString.charAt(i)=='&')
			inString=inString.replace("&","}");	
	
	}
	return inString;
}

<!--

function TrapEnter(btn, event)
{
	if (document.all)
	{
		if (event.keyCode == 13)
		{
			event.returnValue=false;
			event.cancel = true;
			btn.click();
		}

	}
	else if (document.getElementById)
	{

		if (event.which == 13)
		{
			event.returnValue=false;
			event.cancel = true;
			btn.click();
		}
	}
	else if(document.layers)
	{
		if(event.which == 13)
		{
			event.returnValue=false;
			event.cancel = true;
			btn.click();
		}
		}
}
	//Function for Full-Text display in No-Action
	function OpenFullText(url,appRoot)
	{
		var liWSBIndex;
		var liCompanyIndex;
		var sWsbNo;
		var htmlIndex;
		var htmlValue;
		var newurlPath;
		
		
		liWSBIndex=url.indexOf("sWsbNo");
		liCompanyIndex=url.indexOf("&SubjectCompany");
		sWsbNo=url.substring(liWSBIndex+7,liCompanyIndex);
		
		htmlIndex=url.indexOf("html");
		htmlValue=url.substring(htmlIndex+5);
		if (htmlValue=="True")//html Available
		{
				
			newurlPath=appRoot + '/com/requestHandler/hrefHandler.aspx?Action=ShowFormatOptViewPage&formName=FormatOption';
			newurlPath = newurlPath + '&Count=0' + '&values=' + sWsbNo  + '&module=NA' ;
			
			window.open(newurlPath,"FormatOptionWin",'resizable=no,width=400,height=400');
		}
		else
		{			
			window.location.href=url;
		}
		
		
		return false;
	}
	//Functions for Usage Summary Download
	function OpenOption(callerValue)
	{
		var getpath="hrefHandler.aspx?Action=ShowFormatOptDownloadPage" + "&callerValue=" + callerValue;
		centerwindow(getpath);
		return false;
	}
			
			
		
		//Function to show the popup in center
function centerwindow(path)	
{
	if (document.all)
		var xMax = screen.width, yMax = screen.height;
	else
		if (document.layers)
			var xMax = window.outerWidth, yMax = window.outerHeight;
		else
			var xMax = 640, yMax=480;	
		var xOffset = (xMax - 400)/2, yOffset = (yMax - 300)/2;
  		window.open(path,'List','width=400,height=300,resizable=yes,scrollbars=yes,toolbar=no,menubar=no,screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+'');
}	
		
//Function for checking Adobe is installed or not
function CheckAdobe()
{
	var browser_type;
	var bAdobe=true;
	browser_type = navigator.appName;

	if (browser_type.search(/netscape/i) == 0)
	{
		var numPlugin=navigator.plugins.length;
		for(i=0;i<numPlugin;i++)
		{
			plug=navigator.plugins[i];

			if (plug.name=='Adobe Acrobat')
			{
				bAdobe=true;
				i=numPlugin;
			}
			else
			{
				bAdobe=false;
			}

		}
	}
	if (browser_type.search(/microsoft/i) == 0) 
	{ 
		useAcrobat=navigator.mimeTypes && navigator.mimeTypes["application/pdf"]; 
		var aVerNo;var bCheckAdobe=false; 
		for(aVerNo=10;aVerNo>0;aVerNo--) 
		{ 
			try 
			{       
				var Adobe=new ActiveXObject("PDF.PdfCtrl." + aVerNo); 
				bCheckAdobe=true; 
				return true; 
			} 
			catch(e){} 
		}
		if (bCheckAdobe==false) 
		{
			
			
			for(aVerNo=10;aVerNo>0;aVerNo--) 
			{ 
				try 
				{
					var Adobe = new ActiveXObject("acroPDF.PDF." + aVerNo); 
					bCheckAdobe=true; 
					return true; 
				} 
				catch(e){} 
			} 
		}
		if (bCheckAdobe==false) 
		return false; 
	} 
	return bAdobe;
}

//---Function for setting Date range combo depending on the textbox.

function resetDate( fName)
{
	var bFlag=true;
	
	if (document.forms[0].txtStartDate.value!='') 
	{
		if (CheckDate(document.forms[0].txtStartDate))
		{	
				fName.selectedIndex = 0;
		}
		else
		{
			document.forms[0].txtStartDate.value="";
			bFlag=false;
		}

	}	

	if (document.forms[0].txtEndDate.value!='') 
	{
		if (CheckDate(document.forms[0].txtEndDate))
		{
				fName.selectedIndex = 0;
								
		}
		else
		{
			document.forms[0].txtEndDate.value="";
			bFlag=false;
		}
	}	
	
	if (document.forms[0].txtStartDate.value != '' && document.forms[0].txtEndDate.value != '')
	{
		if(compareDate(document.forms[0].txtStartDate.value,document.forms[0].txtEndDate.value)==false)
		{
			alert("Start Date Must Be Less Than End Date.");
			document.forms[0].txtStartDate.value='';
			document.forms[0].txtStartDate.focus();
			bFlag=false;
		}
						
	}
	if (bFlag==true)
		return true;	
	else
		return false;	
	
}

//---Function for Resetting Date fields
function resetDateField()
{
	document.forms[0].txtStartDate.value=''; 
	document.forms[0].txtEndDate.value=''; 
	return true;
}