function validateInputField()
{
	var radiobtn = '';	
	for (var i=0; i <document.searchAcctForm.searchby.length; i++)
	{
		if (document.searchAcctForm.searchby[i].checked)
		{
			radiobtn=document.searchAcctForm.searchby[i].value;
			a=1;
			
		}
	}
	var ip="false";
	
	if(radiobtn == "byip")
	{
		ip = verifyIP(document.searchAcctForm.strSearchTerm.value);
	}
	ip ="" + ip;
	checkSearchTerm();
	checkRadioSearchTerm();
	var dr=checkDateRange();
	if(ip=="false" && dr!=false)
	{
		document.searchAcctForm.action="search?st=true";
		document.searchAcctForm.submit();
	}
	else
	{
		return false
	}

	/*if(radiobtn=="bydaterange")
	{
				var strMonth = document.searchAcctForm.startmth.value;
				var endMonth = document.searchAcctForm.endmth.value;
				var strMonthValue =1;
				var endMonthValue =0;
				var strYear = document.searchAcctForm.startyear.value;
				var endYear = document.searchAcctForm.endyear.value;

				if(endMonthValue<strMonthValue){
					//d=document.getElementById("greater-error");
					//d.style.display = "block";
					return false;
				}
	}*/

}

function validateInst()
  {
	document.searchForm.action="search?st=true";
	document.searchForm.submit();		
  }

function checkRadioSearchTerm() 
{	

	var radiobtn = '';
	var accttype = '';
	var a=0;
	for (var i=0; i <document.searchAcctForm.searchby.length; i++)
	{
		if (document.searchAcctForm.searchby[i].checked)
		{
			 
		      radiobtn=document.searchAcctForm.searchby[i].value;
		      a=1;
		}   
	}
	
	if(radiobtn!="byip")
	{
	  	d=document.getElementById("search-ip-error");
		d.style.display = "none";
		//WBDP-902document.searchAcctForm.unsubscribeaccount.disabled=false;
	}
	if(radiobtn!="byinst")
	{
		if(document.searchAcctForm.searchacct[1].checked)
		{
			
			document.searchAcctForm.searchacct[0].checked = true;
			document.searchAcctForm.searchacct[1].checked = false;
			//WBDP-902document.searchAcctForm.unsubscribeaccount.disabled=false;
			
		} 
		document.searchAcctForm.searchacct[1].disabled = true;   	
	}
	else
	{
	     document.searchAcctForm.searchacct[1].disabled=false;
		 
	}
	   
	if(radiobtn=="byip" && document.searchAcctForm.strSearchTerm.value!=" ")
	{
	       verifyIP(document.searchAcctForm.strSearchTerm.value);
		   //WBDP-902document.searchAcctForm.unsubscribeaccount.disabled=false;
	}
	/*WBDP-902 else
	{
		if(radiobtn=="byip")
		{
			document.searchAcctForm.unsubscribeaccount.disabled=false;
		}
	}*/
	for (var i=0; i <document.searchAcctForm.searchacct.length; i++)
	{
		if (document.searchAcctForm.searchacct[i].checked && document.searchAcctForm.searchacct[i].disabled == false)
		{
		      accttype=document.searchAcctForm.searchacct[i].value;
		}
	}
	//ENH-109 changes starts here--

	/*WBDP-902if(radiobtn=="byadminemail")
	{
			
		document.searchAcctForm.unsubscribeaccount.disabled=true;
	}

	if(radiobtn=="uname")
	{
			
		document.searchAcctForm.unsubscribeaccount.disabled=false;
	} */
	
	/* WBDP-257.Search by RefURL . Donot disable the Unsubscribed acct while searching by refURL */
	/*WBDP-902 if(radiobtn=="byrefurl")
	{
		document.searchAcctForm.unsubscribeaccount.disabled=false;
	} */

	

	//ENH-109 changes starts here--
	
	/*Changes for WBDP-601 to disable the unsubscribed check box*/
	/*Changed for WBDP-681 as now search type will contain values of various search types*/
	if(document.searchAcctForm.searchType2.value.indexOf("bydaterange")!=-1 ||
		document.searchAcctForm.searchType2.value.indexOf("byproduct")!=-1)
	
	//WBDP-902document.searchAcctForm.unsubscribeaccount.disabled=true;

	document.searchAcctForm.acctType.value = accttype;      
	document.searchAcctForm.searchType.value = radiobtn;
}


function checkRadioButton(btnVal) 
{	
	//WBDP-256. Search by Active Accounts
	
	if(btnVal=='active'){
		
		  document.searchAcctForm.subscribedaccount.checked=false;
		  //WBDP-902.document.searchAcctForm.unsubscribeaccount.checked=false;
		  document.searchAcctForm.allaccount.checked=false;
		  document.searchAcctForm.completeAcct.value = 1;
		  document.searchAcctForm.activeAcct.value = 0;
		  document.searchAcctForm.expiredAcct.value = 0;
		  document.searchAcctForm.trialAcct.value = 0;
		  document.searchAcctForm.unSubscribedAcct.value = 0;
		  document.searchAcctForm.allAcct.value = 0;
		
	}
	
	if(btnVal=='subscribed'){
		
		  //WBDP-902.document.searchAcctForm.unsubscribeaccount.checked=false;
		  document.searchAcctForm.allaccount.checked=false;
		  //document.searchAcctForm.activeaccount.checked=false;
		  document.searchAcctForm.activeAcct.value = 1;
		  document.searchAcctForm.expiredAcct.value = 1;
		  document.searchAcctForm.trialAcct.value = 0;
		  document.searchAcctForm.unSubscribedAcct.value = 0;
		  document.searchAcctForm.allAcct.value = 0;
		  //Added for WBDP-256.search by Active Accounts
		  document.searchAcctForm.completeAcct.value = 0;
		  document.getElementById('actvaccount').checked=false;
		  
	}
	
	if(btnVal=='unsubs'){
		
		  //document.searchAcctForm.expiredaccount.checked=false;
		  document.searchAcctForm.allaccount.checked=false;
		  document.searchAcctForm.subscribedaccount.checked=false;
		  document.searchAcctForm.activeAcct.value = 0;
		  document.searchAcctForm.expiredAcct.value = 0;
	      document.searchAcctForm.trialAcct.value = 0;
		  document.searchAcctForm.unSubscribedAcct.value = 1;
		  document.searchAcctForm.allAcct.value = 0;
		  //Added for WBDP-256.search by Active Accounts
		  document.searchAcctForm.completeAcct.value = 0;
		  document.getElementById('actvaccount').checked=false;
		  
		
	}
	
	if(btnVal=='allaccounts'){
		  //document.searchAcctForm.expiredaccount.checked=false;
		  //WBDP-902.document.searchAcctForm.unsubscribeaccount.checked=false;
		  document.searchAcctForm.subscribedaccount.checked=false;
		  document.searchAcctForm.allAcct.value = 1;
		  document.searchAcctForm.unSubscribedAcct.value =1;
		  
		  document.searchAcctForm.activeaccount.checked=false;
		  
		  //Added for WBDP-256.search by Active Accounts
		  document.searchAcctForm.completeAcct.value = 0;
		  document.getElementById('actvaccount').checked=false;
		  
		  //WBDP-902 .Select Subscribed account as default
		  document.getElementById('subscribedaccount').checked=false;
		  
		
	}
	
	/*WBDP-256.Have changed the searchby[] value by 1 since searchby refURL was added*/
	
	/*WBDP-601 changes to declare a second search term begins here*/
	/*WBDP-681 changed to form the search type by cap separating
	the different search types*/
	if(btnVal=='country'){
		btn='bycountry';
		val=document.searchAcctForm.strAcctCntry.value;
		assignValues(btn,val);
		//WBDP-902document.searchAcctForm.unsubscribeaccount.disabled=false;
		
		
	}
	
	if(btnVal=='state'){
		btn='bystate';
		val=document.searchAcctForm.strAcctState.value;
		assignValues(btn,val);
		  //WBDP-902document.searchAcctForm.unsubscribeaccount.disabled=false;
		
	}
	if(btnVal=='salesrep'){
		//WBDP-902document.searchAcctForm.unsubscribeaccount.disabled=false;
		btn='bysalesrep';
		val=document.searchAcctForm.strSalesRep.value;
		assignValues(btn,val);
		
	}

    if(btnVal=='product'){
		//WBDP-902document.searchAcctForm.unsubscribeaccount.disabled=true;
		btn='byproduct';
		val=document.searchAcctForm.strAcctProduct.value;
		assignValues(btn,val);
	}

	if(btnVal=='descriptor'){
		//WBDP-902document.searchAcctForm.unsubscribeaccount.disabled=false;
		btn='bydesctype';
		val=document.searchAcctForm.strAcctDesc.value;
		assignValues(btn,val);
	}
	
	if(btnVal=='daterange'){
		var endMonth="30";
		
		if(document.searchAcctForm.endmth.value=="FEB")
		endMonth="28";
		var daterange = "01-"+document.searchAcctForm.startmth.value+"-"+document.searchAcctForm.startyear.value+" To "+endMonth+"-"
		+document.searchAcctForm.endmth.value+"-"+document.searchAcctForm.endyear.value;
		//WBDP-902document.searchAcctForm.unsubscribeaccount.disabled=true
		btn='bydaterange';
		val=daterange;
		if(document.searchAcctForm.startmth.value=="" && document.searchAcctForm.startyear.value=="" && document.searchAcctForm.endmth.value=="" && document.searchAcctForm.endyear.value=="")
		val="";
		assignValues(btn,val);
		
	}
		/*WBDP-601 changes to declare a second search term begins here*/
	//ENH-109 changes ends here

	checkRadioSearchTerm();
}
/*WBDP-681 New Function written to form the Cap separated string of
	search types of the drop-downs*/
function assignValues(btn,val)
{
	if(document.searchAcctForm.searchType2.value=='')
	{
		if(val!='')
		{
			document.searchAcctForm.searchType2.value=btn;
			document.searchAcctForm.strSearchTerm2.value=val;
		}
	}
	else
	{
		if(document.searchAcctForm.searchType2.value.indexOf(btn)==-1)
		{
			if(val!='')
			{
				document.searchAcctForm.searchType2.value=document.searchAcctForm.searchType2.value+'^'+btn;
				document.searchAcctForm.strSearchTerm2.value=document.searchAcctForm.strSearchTerm2.value+'^'+val;
			}
		}
		else
		{
			temp1=document.searchAcctForm.searchType2.value;
			temp2=document.searchAcctForm.strSearchTerm2.value;
			document.searchAcctForm.searchType2.value='';
			document.searchAcctForm.strSearchTerm2.value='';
			while(temp1!='' && temp2!='')
			{
				if(temp1.indexOf('^')!=-1)
				{
					temp3=temp1.substring(0,temp1.indexOf('^'));
					temp4=temp2.substring(0,temp2.indexOf('^'));
				}
				else
				{
					temp3=temp1;
					temp4=temp2;
				}
				if(btn==temp3)
				{
					if(val!='')
					{
						if(document.searchAcctForm.searchType2.value!='')
					{
						document.searchAcctForm.searchType2.value=document.searchAcctForm.searchType2.value+'^'+temp3;
						document.searchAcctForm.strSearchTerm2.value=document.searchAcctForm.strSearchTerm2.value+'^'+val;
					}
					else
					{
						document.searchAcctForm.searchType2.value=temp3;
						document.searchAcctForm.strSearchTerm2.value=val;
					}
					}
				}
				else
				{
					if(document.searchAcctForm.searchType2.value!='')
					{
						document.searchAcctForm.searchType2.value=document.searchAcctForm.searchType2.value+'^'+temp3;
						document.searchAcctForm.strSearchTerm2.value=document.searchAcctForm.strSearchTerm2.value+'^'+temp4;
					}
					else
					{
						document.searchAcctForm.searchType2.value=temp3;
						document.searchAcctForm.strSearchTerm2.value=temp4;
					}
				}
				
				temp1=temp1.substring(temp1.indexOf(temp3)+temp3.length+1);
				temp2=temp2.substring(temp2.indexOf(temp4)+temp4.length+1);
			}
			
		}
	}
}
/*WBDP-681 Modified to check for the values by substring as search type may contain multiple search types*/
function checkDateRange()
{
	if(document.searchAcctForm.searchType2.value.indexOf("bydaterange")!=-1)
	{
		if(!(document.searchAcctForm.startmth.value!=""&&document.searchAcctForm.startyear.value!=""&&document.searchAcctForm.endmth.value!=""&&document.searchAcctForm.endyear.value!=""))
			
		{
			d=document.getElementById("greater-error");
			d.style.display='block';
			return false;
		}
	}
}


function checkSearchTerm() 
  {	
  	 	 	
	 /*WBDP-256.Added condition for radio button*/ 	
 	if((document.searchAcctForm.allaccount.checked==true) 
		|| (document.searchAcctForm.subscribedaccount.checked==false   && document.searchAcctForm.allaccount.checked==false  
		 && document.getElementById('actvaccount').checked==false))
		//WBDP-902&& document.searchAcctForm.unsubscribeaccount.checked==false && document.getElementById('actvaccount').checked==false))
	  {
		document.searchAcctForm.allAcct.value = 1;
		 
   	  }
    else
	  {
		 document.searchAcctForm.allAcct.value = 0;
	  }
    if(document.searchAcctForm.activeaccount.checked==true && document.searchAcctForm.expiredaccount.checked==false 
		&& document.searchAcctForm.trialaccount.checked==false && document.searchAcctForm.allaccount.checked==false)
      {
	      document.searchAcctForm.activeAcct.value = 1;
		  document.searchAcctForm.expiredAcct.value = 0;
		  document.searchAcctForm.trialAcct.value = 0;
		  document.searchAcctForm.trialaccount.checked=false;
		  document.searchAcctForm.expiredaccount.checked=false;
		  document.searchAcctForm.allaccount.checked=false;
		  
		  
      }
    if(document.searchAcctForm.activeaccount.checked==false && document.searchAcctForm.expiredaccount.checked==true 
		&& document.searchAcctForm.trialaccount.checked==false && document.searchAcctForm.allaccount.checked==false)
      {
	     
	      document.searchAcctForm.activeAcct.value = 0;
		  document.searchAcctForm.expiredAcct.value = 1;
		  document.searchAcctForm.trialAcct.value = 0;
		  document.searchAcctForm.activeaccount.checked=false;
		  document.searchAcctForm.trialaccount.checked=false;
		  document.searchAcctForm.allaccount.checked=false;
		  
	   }
    if(document.searchAcctForm.activeaccount.checked==false && document.searchAcctForm.expiredaccount.checked==false 
		&& document.searchAcctForm.trialaccount.checked==true && document.searchAcctForm.allaccount.checked==false)
       {
	      document.searchAcctForm.activeAcct.value = 0;
		  document.searchAcctForm.expiredAcct.value = 0;
		  document.searchAcctForm.trialAcct.value = 1;
       }
    if(document.searchAcctForm.activeaccount.checked==false && document.searchAcctForm.expiredaccount.checked==true 
		&& document.searchAcctForm.trialaccount.checked==true && document.searchAcctForm.allaccount.checked==false)
       {
			document.searchAcctForm.activeAcct.value = 0;
	        document.searchAcctForm.expiredAcct.value = 1;
	        document.searchAcctForm.trialAcct.value = 1;
       }
     if(document.searchAcctForm.activeaccount.checked==true && document.searchAcctForm.expiredaccount.checked==false 
		 && document.searchAcctForm.trialaccount.checked==true && document.searchAcctForm.allaccount.checked==false)
       {
	         document.searchAcctForm.activeAcct.value = 1;
			 document.searchAcctForm.expiredAcct.value = 0;
	         document.searchAcctForm.trialAcct.value = 1;
       }

	  if(document.searchAcctForm.activeaccount.checked==false && document.searchAcctForm.expiredaccount.checked==false 
		 && document.searchAcctForm.trialaccount.checked==false && document.searchAcctForm.allaccount.checked==false) 
		  //WBDP-902&& document.searchAcctForm.unsubscribeaccount.checked==true)
       {
	         document.searchAcctForm.activeAcct.value = 0;
			 document.searchAcctForm.expiredAcct.value = 0;
	         document.searchAcctForm.trialAcct.value = 0;
			 //WBDP-902.902document.searchAcctForm.unSubscribedAcct.value = 1;
       }

       if(document.searchAcctForm.activeaccount.checked==true)
       {
	         document.searchAcctForm.activeAcct.value = 1;
       }
        if(document.searchAcctForm.expiredaccount.checked==true)
       {
	         document.searchAcctForm.expiredAcct.value = 1;
       }
        if(document.searchAcctForm.trialaccount.checked==true)
       {
	         document.searchAcctForm.trialAcct.value = 1;
       }

	//ENH-109 changes start here

	   /*WBDP-902if(document.searchAcctForm.unsubscribeaccount.checked==true)
	   {
	         
			var radiobtn = '';
					
			for (var i=0; i <document.searchAcctForm.searchby.length; i++)
			{
			if (document.searchAcctForm.searchby[i].checked)
				{
				radiobtn=document.searchAcctForm.searchby[i].value;
				}   
			}

			 if(radiobtn=='byadminemail' || radiobtn=='byproduct' || radiobtn=='uname' || radiobtn=='byip')
			 document.searchAcctForm.unSubscribedAcct.value = 0;
			 else
			 document.searchAcctForm.unSubscribedAcct.value = 1;
       } */
	   

	   //ENH-109 changes ends here
  }


function verifyIP (IPvalue)
  {
  	 errorString = "";
     theName = "IPaddress";
     var ipPattern = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
     var ipArray = IPvalue.replace(/^\s*|\s*$/g, "").match(ipPattern);
     var ip=0;
     if (IPvalue == "0.0.0.0")
        ip=1;
     if (ipArray == null)
        ip=1;
     else
      {
        for (i = 0; i < 4; i++) 
          {
             thisSegment = ipArray[i];
             if (thisSegment > 255)
              {
                ip=1;
                i = 4;
              }
             if ((i == 0) && (thisSegment > 255))
              {
                ip=1;
                i = 4;
              }
          }
       }
      extensionLength = 3;
     
     if (ip==1 && document.searchAcctForm.strSearchTerm.value!=" ")
       {
       	
          d=document.getElementById("search-ip-error");
          d.style.display = "block";
          UnameSpacediv = document.getElementById("UnameSpaceerror");
          if(UnameSpacediv!= null)
           {
	         UnameSpacediv.style.display='none';
	         UnameSpacediv.innerHTML='';
            }
           return true;
        }
     return false;
  }

function dropDown(answer , question)
  {
    var x = document.getElementById(answer);
    var y = document.getElementById(question);
    if(x.style.display == "none")
     {
        x.style.display ="";
        y.className = "selected";
     }
    else
     {
        x.style.display="none";
        y.className=""
     }
   }

 
 
//added for ENH-42:Print,email and save the search results
function printdata(view) 
{
	
	var baseHref=location.href;
	if (baseHref.indexOf("#") !=-1)
	baseHref=baseHref.substring(0,baseHref.indexOf("#"))+"&"+"view="+view;
	if (baseHref.indexOf("?") !=-1)
	baseHref+="&"+"view="+view;
	else
	baseHref+="?"+"view="+view;	
	document.AdmAcctResultsForm.action=baseHref;
	
	document.AdmAcctResultsForm.submit();
	
}

//Added for ENH-42:To sort the search results
function sortVal(sort,order) 
{
	document.searchForm.action="search?st=true&sort="+sort+"&order="+order;
	document.searchForm.submit();
}

//Added for BUG-268 Fix for 'Renew Subscription' not working properly for international accounts 
function changeURL()
{
  document.manageaccountform.master.value=document.manageaccountform.acct_id.value;
  document.manageaccountform.submit();
   
}
// BUG-268 Ends


// Changes for ENH-55 starts here : Added the validation for order search fields
function validateOrderField()
{
	var radiobtn = '';	
	for (var i=0; i <document.orderSearchForm.searchby.length; i++){
		if (document.orderSearchForm.searchby[i].checked){
			radiobtn=document.orderSearchForm.searchby[i].value;
			if(radiobtn=="byOrderNo" || radiobtn=="byOrderNotes" || radiobtn=="bySkuNo"){
				var st = document.orderSearchForm.strSearchTerm.value.replace(/^\s+|\s+$/g, "");
				if(st!=''){
					if(st.length<4){
						 d=document.getElementById("char-error");
				         d.style.display = "block";
				         e=document.getElementById("nosearch-error");
			         	 e.style.display = "none";
				         return false;
					}
				}else{
					 e=document.getElementById("char-error");
				     e.style.display = "none";
					 d=document.getElementById("nosearch-error");
			         d.style.display = "block";
			         return false;
				}
			}
			if(radiobtn=="byOrderAmt" && document.orderSearchForm.strSearchTerm.value==''){
				 d=document.getElementById("nosearch-error");
		         d.style.display = "block";
		         return false;
			}

			

			if(radiobtn=="byDateRange"){
				// Changed the date format to mm/dd/yyyy for BUG-490
				document.orderSearchForm.strSearchTerm.value = document.orderSearchForm.strMonth.value+"-"+document.orderSearchForm.strDay.value +"-"+document.orderSearchForm.strYear.value +" : "+ document.orderSearchForm.strMonth1.value+"-"+document.orderSearchForm.strDay1.value +"-"+document.orderSearchForm.strYear1.value;
				d=document.getElementById("char-error");
				d.style.display = "none";
				e=document.getElementById("nosearch-error");
				e.style.display = "none";
				// Changes for BUG-490 starts here
				//if(document.orderSearchForm.strDay.value +"-"+document.orderSearchForm.strMonth.value+"-"+document.orderSearchForm.strYear.value>document.orderSearchForm.strDay1.value +"-"+document.orderSearchForm.strMonth1.value+"-"+document.orderSearchForm.strYear1.value){
					// d=document.getElementById("greater-error");
				        // d.style.display = "block";
				        // document.orderSearchForm.searchby[5].checked=true;
				        // return false;
				//}
				// Added for BUG-490 : To compare the dates and display error message if date in first row is less than date in second row
				var myDate=new Date();
				myDate.setFullYear(document.orderSearchForm.strYear.value,document.orderSearchForm.strMonth.value-1,document.orderSearchForm.strDay.value);
				var myDate1=new Date();
				myDate1.setFullYear(document.orderSearchForm.strYear1.value,document.orderSearchForm.strMonth1.value-1,document.orderSearchForm.strDay1.value);
				if(myDate>myDate1){					
					d=document.getElementById("greater-error");
					d.style.display = "block";
					document.orderSearchForm.searchby[5].checked=true;
					return false;
				}
				// Changes for BUG-490 ends here
			}
		}
	}	
	checkOrderSearchTerm();
	
	document.orderSearchForm.action="ordersrch?st=true&order=true";
	document.orderSearchForm.submit();
}

function checkOrderSearchTerm() 
{	
	var radiobtn = '';
	for (var i=0; i <document.orderSearchForm.searchby.length; i++){
		if (document.orderSearchForm.searchby[i].checked){
		      radiobtn=document.orderSearchForm.searchby[i].value;
		}   
	}
	
	if(radiobtn=="byOrderNo" || radiobtn=="byOrderNotes" || radiobtn=="bySkuNo" || radiobtn=="byOrderAmt" || radiobtn=="byDateRange"){
		d=document.getElementById("char-error");
		d.style.display = "none";
		e=document.getElementById("nosearch-error");
		e.style.display = "none";
		f=document.getElementById("greater-error");
		f.style.display = "none";
	}

	if(radiobtn=="byDateRange"){
		// Changed the date format to mm/dd/yyyy for BUG-490
		document.orderSearchForm.strSearchTerm.value = document.orderSearchForm.strMonth.value+"-"+document.orderSearchForm.strDay.value +"-"+document.orderSearchForm.strYear.value +" : "+ document.orderSearchForm.strMonth1.value+"-"+document.orderSearchForm.strDay1.value +"-"+document.orderSearchForm.strYear1.value;
		d=document.getElementById("char-error");
		d.style.display = "none";
		e=document.getElementById("nosearch-error");
		e.style.display = "none";
	}
	else{
		// Changed the date format to mm/dd/yyyy for BUG-490
		if(document.orderSearchForm.strSearchTerm.value == document.orderSearchForm.strMonth.value+"-"+document.orderSearchForm.strDay.value +"-"+document.orderSearchForm.strYear.value +" : "+ document.orderSearchForm.strMonth1.value+"-"+document.orderSearchForm.strDay1.value +"-"+document.orderSearchForm.strYear1.value){
			document.orderSearchForm.strSearchTerm.value = " ";
		}
	}
	
	if(radiobtn=="bySalesRep"){
		document.orderSearchForm.strSearchTerm.value = document.orderSearchForm.strSalesRep.value;
		d=document.getElementById("char-error");
		d.style.display = "none";
		e=document.getElementById("nosearch-error");
		e.style.display = "none";
		f=document.getElementById("greater-error");
		f.style.display = "none";
	}
	else{
		if(document.orderSearchForm.strSearchTerm.value == document.orderSearchForm.strSalesRep.value){
			document.orderSearchForm.strSearchTerm.value = " ";
		}
	} 	 
	   
	document.orderSearchForm.searchType.value = radiobtn;
}

function populateVal(btnVal) 
{	
	if(btnVal=='salesrep' && document.orderSearchForm.strSalesRep.value!=""){
		document.orderSearchForm.searchby[4].checked=true;
		document.orderSearchForm.searchby[5].checked=false;
	}
	checkOrderSearchTerm();
}
// Changes for ENH-55 ends here

function validateQuickReportFields()
{
	// Modified for WBDP-10
	if(document.getElementById('defaultDD').style.display == 'block'){
		alert('Please select any of the radio-button');
		return false;
	}

	var selectType = document.quickReportsForm.selectedType.value;
	var selectElement = document.getElementById(selectType);
	var selectedValue = selectElement[selectElement.selectedIndex].text;
	var selectProduct = document.getElementById('productDD');
	var productValue = selectProduct[selectProduct.selectedIndex].value;
	
	// WBDP-703 - Additional values set in else condition for QuickReports		
	if(selectedValue=="-Select Date Range-" ){
		alert('Please select a value from the drop down list');
		return false;
	}
	else{
		document.quickReportsForm.strSearchTerm.value=selectedValue;
		document.quickReportsForm.strProductId.value=productValue;
		document.quickReportsForm.searchType2.value="byproduct";
		document.quickReportsForm.strSearchTerm2.value=productValue;		
	}
}


/*Added for WBDP-256.Search by Active Account.
 * On load of the search acctounts page,the active account search radio 
 * button gets selected,and the completeActt set to '1'
*/

function selectActiveAccount(){
	
		  if(document.getElementById('actvaccount') != null){
		  
		  document.getElementById('actvaccount').checked=true;
		
		  document.searchAcctForm.completeAcct.value = 1;
		  document.searchAcctForm.activeAcct.value = 0;
		  document.searchAcctForm.expiredAcct.value = 0;
		  document.searchAcctForm.trialAcct.value = 0;
		  document.searchAcctForm.unSubscribedAcct.value = 0;
		  document.searchAcctForm.allAcct.value = 0;
}
		  
}
	
// ENH-157 changes ends here

// Added for WBDP-10
// Added one more parameter searchType for WBDP-1339 & 1359
function populateReportTypes(idValue,totalTypes,searchType) 
{
	var n=0;	
	for(var k=1; k<=totalTypes; k++){
		if(k == idValue){
			document.getElementById('quickreport_type_'+k).checked = true;
			document.getElementById('defaultDD').style.display = 'none';
			document.getElementById('dd_'+k).style.display = 'block';
			document.quickReportsForm.searchType.value=document.getElementById('quickreport_type_'+k).value;
			document.quickReportsForm.selectedType.value='dd_'+k;
			//WBDP-1339 & 1359 Changed the sort value based on searchType 
			if(searchType == "byexpiring" || searchType == "bynewest") {
				document.quickReportsForm.sort.value='8';
			}
		}
		else{
			document.getElementById('quickreport_type_'+k).checked = false;
			document.getElementById('dd_'+k).style.display = 'none';
		}		
	}
	
}// WBDP-10 changes end here


/*Added for WBDP-902.Search by Managed Account(subscribed).
 * On load of the search accounts page,the Managed account search radio 
 * button gets selected.
 * Complete Acct is Active Acct(Now its Invoiced Acct)
 * subscribed accts is activeAcct(Now its Managed Acct)
*/

function selectManagedAccount(){
	
		  if(document.getElementById('subscribedaccount') != null){
		  
		  document.getElementById('subscribedaccount').checked=true;
		
		  document.searchAcctForm.completeAcct.value = 0;
		  document.searchAcctForm.activeAcct.value = 1;
		  document.searchAcctForm.expiredAcct.value = 0;
		  document.searchAcctForm.trialAcct.value = 0;
		  //Commented for WBDP-902 
		  document.searchAcctForm.unSubscribedAcct.value = 0;
		  document.searchAcctForm.allAcct.value = 0;
}
		  
}


