/*
change made on 12/22/2005 by Vineetha to validate for 5 items to compare
*/

viewArray = new Array();

viewArray[0] = new Image;
viewArray[1] = new Image;
viewArray[2] = new Image;
viewArray[3] = new Image;
viewArray[4] = new Image;

viewArray[0].src = "images/shim.gif";
viewArray[1].src = "images/shim.gif";
viewArray[2].src = "images/shim.gif";
viewArray[3].src = "images/shim.gif";
viewArray[4].src = "images/shim.gif";

function window_onload()
{
    //alert(document.getElementById("hddpt").value);
}

function golist(url,winwidth,winheight)
{
	var list= open(url, "list", "width=" + winwidth + ",height=" + winheight + ",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes");
	list.opener.name = "opener";
}

// change made on 06/06/2006 by Preeti
function checkall(formname,checkname,thestate)
{
	eval("document.forms."+formname+".optins.checked = " + thestate)
	if (parseInt(document.getElementById("hddpt").value) == 8)
		{ eval("document.forms."+formname+".nls.checked = " + thestate) }
	var el_collection=eval("document.forms."+formname+"."+checkname)
	for (c=0; c<el_collection.length ;c++)
		el_collection[c].checked = thestate
}

function matrixcheck()
{
	switch(parseInt(document.getElementById("hddpt").value))
	{
	    case 5:
	    {
	        var i;
	        var j = 0;
	        var objCtrl;
	        objForm = document.matrix;
	        for (i = 0; i < objForm.elements.length; i++) 
	        {
		        objCtrl = objForm.elements[i];
		        if (objCtrl.checked == true) 
		        {
			        j++;
		        }
	        }
	        if (j == 0)  
	        {
	            alert("Please check the boxes next to the items you wish to compare.");
	            return false
	        }
	   }
	   break;
	   
	   case 4:
	   {
		    //^ ' change made on 04/09/2007 by Preeti to incorporate CME/CE search tool #
		    var i;
		    var j = 0;
		    var objCtrl;
		    objForm = document.matrix;
		    for (i = 0; i < objForm.elements.length; i++) 
		    {
			    objCtrl = objForm.elements[i];
			    if (objCtrl.checked == true) 
			    {
				    j++;
			    }
		    }
		    if (j == 0)  
		    {
			    alert("Please check the boxes next to the items you wish to compare.");
			    return false
			}
	   }
	   break;
	   
    }
}

function comparecheck()
{
	switch(parseInt(document.getElementById("hddpt").value))
	{
	    case 5:
	    {
	        var i;
	        var j = 0;
	        var objCtrl;
	        objForm = document.matrix;
	        for (i = 0; i < objForm.elements.length; i++) 
	        {
		        objCtrl = objForm.elements[i];
		        if (objCtrl.checked == true) 
		        {
			        j++;
		        }
	        }
	        if (j == 6)  
	        {
	            alert("No more than five items can be compared at once.");
	            return false
	        }
	   }
	   break;

	    case 4:
	    {
			var i;
			var j = 0;
			var objCtrl;
			objForm = document.matrix;
			for (i = 0; i < objForm.elements.length; i++) 
			{
				objCtrl = objForm.elements[i];
				if (objCtrl.checked == true) 
				{
					j++;
				}
			}
			if (j == 6)  
			{
				alert("No more than five items can be compared at once.");
				return false;
			}
	   }
	   break;

    }
}

function tools(type, passedcobrandid)
{
	switch(parseInt(document.getElementById("hddpt").value))
	{
	    case 5:
	    {
	        var i;
	        var j = 0;
	        var objCtrl;
	        objForm = document.matrix;
	        for (i = 0; i < objForm.elements.length; i++) 
	        {
		        objCtrl = objForm.elements[i];
		        if (objCtrl.checked == true) 
		        {
			        j++;
		        }
	        }
	        if (j == 0)  
	        {
		        alert("Please select at least one item.");
	        }
	        else
	        {
		        if (type == 'compare')
		        {
			        /*change made on 06/15/2005 by Preeti to rectify problem with co-brand page comparisons */
			        if (passedcobrandid == 1)
				        document.matrix.action= "/compare.asp";
			        else
				        document.matrix.action= "compare.asp";
			        document.matrix.method = "post";
			        document.matrix.target = "_self";
		        }
		        document.matrix.submit();
	        }
	   }
	   break;

	    case 4:
	    {
			var i;
			var j = 0;
			var objCtrl;
			objForm = document.matrix;
			for (i = 0; i < objForm.elements.length; i++) 
			{
				objCtrl = objForm.elements[i];
				if (objCtrl.checked == true) 
				{
					j++;
				}
			}
			if (j == 0)  
			{
				alert("Please select at least one item.");
			}
			else
			{
				if (type == 'compare')
				{
					/*change made on 06/15/2005 by Preeti to rectify problem with co-brand page comparisons */
					if (passedcobrandid == 1)
						document.matrix.action= "/compare.asp";
					else
						document.matrix.action= "compare.asp";
					document.matrix.method = "post";
					document.matrix.target = "_self";
				}
				document.matrix.submit()
			}
	   }
	   break;

    }
}

function cboTypeID_onChange(passedVal)
{
	switch(parseInt(document.getElementById("hddpt").value))
	{
	    case 5:
	    {
	        if (passedVal.value.indexOf(':0') > 0 )
	        {
		        if (parseInt(document.frmheadersearch.hddSearch.value) == 0)
		        {}
		        else
			        document.frmheadersearch.hddSearch.value = parseInt(document.frmheadersearch.hddSearch.value) - 1 ;
	        }
	        else
	        {
		        document.frmheadersearch.hddSearch.value = parseInt(document.frmheadersearch.hddSearch.value) + 1 ;
	        }
	   }
	   break;
	    case 4:
	    {
	        if (1 == 2)
	        {
	            alert("");
	        }
	    }
	    break;
    }
}

function cboArticleType_onChange()
{
	window.location.href = "articles.asp?HeaderID=<%=q_intHeaderID%>&ArticleType=" + cboArticleType[cboArticleType.selectedIndex].value;
}	


function isValid()
{
	switch(parseInt(document.getElementById("hddpt").value))
	{
	    case 8:
	    {
            //^' change made on 07/05/2007 by Preeti to replace specialty/discipline interests validation with newsletter type validation #
	        /*Function to validate all inputs before saving information to database*/
	        /* Check if mandatory inputs are empty */

	        if ( trim(document.frmMoreinfo.txtFname.value).length == 0 )
	        {
		        alert("Please enter the First Name.");
		        document.frmMoreinfo.txtFname.focus();
		        return false;
	        }

	        if ( trim(document.frmMoreinfo.txtLname.value).length == 0 )
	        {
		        alert("Please enter the Last Name.");
		        document.frmMoreinfo.txtLname.focus();
		        return false;
	        }

	        if ( trim(document.frmMoreinfo.txtAddr1.value).length == 0 )
	        {
		        alert("Please enter the Address Line 1.");
		        document.frmMoreinfo.txtAddr1.focus();
		        return false;
	        }

	        if ( trim(document.frmMoreinfo.txtCity.value).length == 0 ) 
	        {
		        alert("Please enter the City.");
		        document.frmMoreinfo.txtCity.focus();
		        return false;
	        }

	        if ( trim(document.frmMoreinfo.txtState.value).length == 0 )
	        {
		        alert("Please enter the State/Province.");
		        document.frmMoreinfo.txtState.focus();
		        return false;
	        }

	        if ( trim(document.frmMoreinfo.txtZip.value).length == 0 ) 
	        {
		        alert("Please enter the Zip/Postal Code.");
		        document.frmMoreinfo.txtZip.focus();
		        return false;
	        }

	        if ( Number(document.frmMoreinfo.cboCountryid[document.frmMoreinfo.cboCountryid.selectedIndex].value) == 0 )
	        {
		        alert("Please select a Country.");
		        document.frmMoreinfo.cboCountryid.focus();
		        return false;
	        }

	        if ( trim(document.frmMoreinfo.txtEmail.value).length == 0 )
	        {
		        alert("Please enter the E-mail Address.");
		        document.frmMoreinfo.txtEmail.focus();
		        return false;
	        }

	        // change made on 07/10/2006 by Preeti
	        if ((document.frmMoreinfo.txtEmail.value.indexOf('@') < 0) || ((trim(document.frmMoreinfo.txtEmail.value).charAt(trim(document.frmMoreinfo.txtEmail.value).length-4) != '.') && (trim(document.frmMoreinfo.txtEmail.value).charAt(trim(document.frmMoreinfo.txtEmail.value).length-3) != '.'))  || (trim(document.frmMoreinfo.txtEmail.value).indexOf(' ') > 0) || (trim(document.frmMoreinfo.txtEmail.value).indexOf(',') > 0) || (trim(document.frmMoreinfo.txtEmail.value).indexOf(';') > 0) || (trim(document.frmMoreinfo.txtEmail.value).indexOf('donotmail.com') > 0)) 
	        {
		        alert("Please enter a valid E-mail Address.");
		        document.frmMoreinfo.txtEmail.focus();
		        return false;
	        }

	        if ( trim(document.frmMoreinfo.txtInst.value).length == 0 )
	        {
		        alert("Please enter the Institution/Organization.");
		        document.frmMoreinfo.txtInst.focus();
		        return false;
	        }

	        if ( Number(document.frmMoreinfo.cboInsttypeid[document.frmMoreinfo.cboInsttypeid.selectedIndex].value) == 0 )
	        {
		        alert("Please select the Institution Type.");
		        document.frmMoreinfo.cboInsttypeid.focus();
		        return false;
	        }

	        if ( trim(document.frmMoreinfo.txtDept.value).length == 0 )
	        {
		        alert("Please enter the Department.");
		        document.frmMoreinfo.txtDept.focus();
		        return false;
	        }

	        if ( trim(document.frmMoreinfo.txtPhone.value).length == 0 )
	        {
		        alert("Please enter the Work Phone.");
		        document.frmMoreinfo.txtPhone.focus();
		        return false;
	        }

	        if ( Number(document.frmMoreinfo.cboPositionid[document.frmMoreinfo.cboPositionid.selectedIndex].value) == 0 ) 
	        {
		        alert("Please select Your Position.");
		        document.frmMoreinfo.cboPositionid.focus();
		        return false;
	        }

	        if ( Number(document.frmMoreinfo.cboContactmodeid[document.frmMoreinfo.cboContactmodeid.selectedIndex].value) == 0 )
	        {
		        alert("Please select the Preferred Mode of Contact.");
		        document.frmMoreinfo.cboContactmodeid.focus();
		        return false;
	        }

	        if ( Number(document.frmMoreinfo.cboTimelineid[document.frmMoreinfo.cboTimelineid.selectedIndex].value) == 0 )
	        {
		        alert("Please select the Purchase Time Frame.");
		        document.frmMoreinfo.cboTimelineid.focus();
		        return false;
	        }

	        //change made on 07/05/2007 by Preeti to replace validation for specialty/discipline interest with validation for newsletter type
	        // added on 06/06/2006 by Preeti to check if user has selected at least one specialty/discipline interest
	        // if he has chosen to receive optins
	        var tmp_nls = eval("document.forms.frmMoreinfo.chkNlTypeID");
	        if (document.frmMoreinfo.nls.checked == true || document.frmMoreinfo.optins.checked == true)
	        {
		        var strCheckedNLs; 
		        strCheckedNLs = false;
    		
		        for(count=0 ; count < tmp_nls.length ; count++)
		        {
			        if(tmp_nls[count].checked == true)
			        {
				        strCheckedNLs = true;
			        }
		        }
		        if (strCheckedNLs == false)
		        {
			        alert("Please select at least one Specialty/Discipline Interest.");
			        tmp_nls[0].focus();
			        return false;
		        }
	        }

	        return true;
	   }
	   break;
	   
	   case 59:
	   {
			if ( trim(document.frmMoreinfo.txtFname.value).length == 0 )
			{
				alert("Please enter the First Name.");
				document.frmMoreinfo.txtFname.focus();
				return false;
			}

			if ( trim(document.frmMoreinfo.txtLname.value).length == 0 )
			{
				alert("Please enter the Last Name.");
				document.frmMoreinfo.txtLname.focus();
				return false;
			}

			if ( trim(document.frmMoreinfo.txtEmail.value).length == 0 )
			{
				alert("Please enter the E-mail Address.");
				document.frmMoreinfo.txtEmail.focus();
				return false;
			}

			if ((document.frmMoreinfo.txtEmail.value.indexOf('@') < 0) || ((trim(document.frmMoreinfo.txtEmail.value).charAt(trim(document.frmMoreinfo.txtEmail.value).length-4) != '.') && (trim(document.frmMoreinfo.txtEmail.value).charAt(trim(document.frmMoreinfo.txtEmail.value).length-3) != '.'))  || (trim(document.frmMoreinfo.txtEmail.value).indexOf(' ') > 0) || (trim(document.frmMoreinfo.txtEmail.value).indexOf(',') > 0) || (trim(document.frmMoreinfo.txtEmail.value).indexOf(';') > 0) || (trim(frmMoreinfo.txtEmail.value).indexOf('donotmail.com') > 0)) 
			{
				alert("Please enter a valid E-mail Address.");
				document.frmMoreinfo.txtEmail.focus();
				return false;
			}

	        if ( Number(document.frmMoreinfo.cboPositionid[document.frmMoreinfo.cboPositionid.selectedIndex].value) == 0 ) 
	        {
		        alert("Please select Your Position.");
		        document.frmMoreinfo.cboPositionid.focus();
		        return false;
	        }

	        if ( Number(document.frmMoreinfo.cboCountryid[document.frmMoreinfo.cboCountryid.selectedIndex].value) == 0 )
	        {
		        alert("Please select a Country.");
		        document.frmMoreinfo.cboCountryid.focus();
		        return false;
	        }

			// check if user has selected at least one specialty/discipline interest if he has chosen to 
			// receive newsletters or optins
			if (frmMoreinfo.elements("optins").checked == true || frmMoreinfo.elements("nls").checked == true)
			{
				var strCheckedInterest; 
				strCheckedInterest = false;
			
				for(count=0 ; count < frmMoreinfo.elements("chkNlTypeID").length ; count++)
				{
					if(frmMoreinfo.elements("chkNlTypeID",count).checked == true)
					{
						strCheckedInterest = true;
					}
				}
				if (strCheckedInterest == false)
				{
					alert("Please select at least one Specialty/Discipline Interest.");
					frmMoreinfo.chkNlTypeID[0].focus();
					return false;
				}
			}
			return true;
	   }
	   break;
    }
}


function submit_onClick()
{
	switch(parseInt(document.getElementById("hddpt").value))
	{
	    case 8:
	    {
			/* function to validate all inputs and then save the record */
			document.getElementById("imgsubmit").disabled = true;
			if ( isValid() == true )
			{
				//return true;
				document.frmMoreinfo.submit();
			}
			else
			{
				document.getElementById("imgsubmit").disabled = false;
				return false;
			}
	   }
	   break;
	   case 1:
	   {
			var HP_strCheckedInterest; 
	        var tmp_nls = eval("document.forms.HP_nl.typeid");
			HP_strCheckedInterest = false;
			
			for(count=0 ; count < tmp_nls.length ; count++)
			{
				if(tmp_nls[count].checked == true)
				{
					HP_strCheckedInterest = true;
				}
			}

			if (HP_strCheckedInterest == false)
			{
				alert("Please select at least one E-mail alert.");
				tmp_nls[0].focus();
				return false;
			}

			if ( trim(document.HP_nl.email.value).length == 0 )
			{
				alert("Please enter your E-mail address.");
				document.HP_nl.email.focus();
				return false;
			}

			// additional E-mail validations added on 01/31/2005 by Preeti, 07/10/2006 by Preeti
			if ((document.HP_nl.email.value.indexOf('@') < 0) || ((trim(document.HP_nl.email.value).charAt(trim(document.HP_nl.email.value).length-4) != '.') && (trim(document.HP_nl.email.value).charAt(trim(document.HP_nl.email.value).length-3) != '.'))  || (trim(document.HP_nl.email.value).indexOf(' ') > 0) || (trim(document.HP_nl.email.value).indexOf(',') > 0) || (trim(document.HP_nl.email.value).indexOf(';') > 0) || (trim(document.HP_nl.email.value).indexOf('donotmail.com') > 0)) 
			{
				alert("Please enter a valid E-mail address.");
				document.HP_nl.email.focus();
				return false;
			}

			var i_streml = trim(document.HP_nl.email.value);
			var i_arrchk = i_streml.split("@");
			if ( i_arrchk.length > 2)
			{
				alert("Please enter a single valid E-mail address.");
				document.HP_nl.email.focus();
				return false;
			}

			document.HP_nl.submit();
	   }
	   break;

        case 59:// Forum user registration
        {
			document.getElementById("imgsubmit").disabled = true;
			if ( isValid() == true )
			{
				//return true;
				document.frmMoreinfo.submit();
			}
			else
			{
				document.getElementById("imgsubmit").disabled = false;
				return false;
			}
        }
        break;
    }
}

function NSEmailAlerts_submit_onClick()
{
	switch(parseInt(document.getElementById("hddpt").value))
	{
	    case 26:
	    {
			var strCheckedInterest; 
	        var tmp_nls = eval("document.forms.newsletter.typeid");
			strCheckedInterest = false;

			for(count=0 ; count < tmp_nls.length ; count++)
			{
				if(tmp_nls[count].checked == true)
				{
					strCheckedInterest = true;
				}
			}
			
			if (strCheckedInterest == false)
			{
				alert("Please select at least one E-mail alert.");
				tmp_nls[0].focus();
				return false;
			}

			if ( trim(document.newsletter.email.value).length == 0 )
			{
				alert("Please enter your E-mail address.");
				document.newsletter.email.focus();
				return false;
			}

			// additional E-mail validations added on 01/31/2005 by Preeti, 07/10/2006 by Preeti
			if ((document.newsletter.email.value.indexOf('@') < 0) || ((trim(document.newsletter.email.value).charAt(trim(document.newsletter.email.value).length-4) != '.') && (trim(document.newsletter.email.value).charAt(trim(document.newsletter.email.value).length-3) != '.'))  || (trim(document.newsletter.email.value).indexOf(' ') > 0) || (trim(document.newsletter.email.value).indexOf(',') > 0) || (trim(document.newsletter.email.value).indexOf(';') > 0) || (trim(document.newsletter.email.value).indexOf('donotmail.com') > 0)) 
			{
				alert("Please enter a valid E-mail address.");
				document.newsletter.email.focus();
				return false;
			}

			var v_streml = trim(document.newsletter.email.value);
			var v_arrchk = v_streml.split("@");
			if ( v_arrchk.length > 2)
			{
				alert("Please enter a single valid E-mail address.");
				document.newsletter.email.focus();
				return false;
			}

			//newsletter.submit();
			return true;
    }
    break;
    case 54://added on 03/14/2006 by Preeti to incorporate trade show newsletter sign-up page , change made on 07/10/2006 by Preeti
    {
		var strCheckedInterest; 
        var tmp_nls = eval("document.forms.frmTradeShow.interestid");
		strCheckedInterest = false;

		if ( trim(document.frmTradeShow.email.value).length == 0 )
		{
			alert("Please enter your E-mail address.");
			document.frmTradeShow.email.focus();
			return false;
		}

		if ((document.frmTradeShow.email.value.indexOf('@') < 0) || ((trim(document.frmTradeShow.email.value).charAt(trim(document.frmTradeShow.email.value).length-4) != '.') && (trim(document.frmTradeShow.email.value).charAt(trim(document.frmTradeShow.email.value).length-3) != '.'))  || (trim(document.frmTradeShow.email.value).indexOf(' ') > 0) || (trim(document.frmTradeShow.email.value).indexOf(',') > 0) || (trim(document.frmTradeShow.email.value).indexOf(';') > 0) || (trim(document.frmTradeShow.email.value).indexOf('donotmail.com') > 0)) 
		{
			alert("Please enter a valid E-mail address.");
			document.frmTradeShow.email.focus();
			return false;
		}

		var v_streml = trim(document.frmTradeShow.email.value);
		var v_arrchk = v_streml.split("@");
		if ( v_arrchk.length > 2)
		{
			alert("Please enter a single valid E-mail address.");
			document.frmTradeShow.email.focus();
			return false;
		}

		for(count=0 ; count < tmp_nls.length ; count++)
		{
			if(tmp_nls[count].checked == true)
			{
				strCheckedInterest = true;
			}
		}
		if (strCheckedInterest == false)
		{
			alert("Please select at least one specialty.");
			tmp_nls[0].focus();
			return false;
		}

		return true;
    }
    break;
    }
}

function cmdUnsubscribe_onClick()
{
	document.frmRemove.submit();
}

function cmdCancel_onClick()
{
	switch(parseInt(document.getElementById("hddpt").value))
	{
	    case 32:
	    {
    		window.location.href = "http://www.medcompare.com/subhome.asp?headerid=<%=q_intHeaderID%>";
    	}
    	break;
    }
}

function cmdSubmit_onClick()
{
	switch(parseInt(document.getElementById("hddpt").value))
	{
	    case 24,66:
	    {
	        if (trim(document.frmSearch.search.value).length == 0) 
	        {
		        alert("Please enter a product or company name to search for.");
		        return false;
	        }
	        document.frmSearch.hddMode.value = "SEARCH";
        }
    	break;
    }
}

function DisplayMoreLink(passedDisplayOrder)
{
	switch(parseInt(document.getElementById("hddpt").value))
	{
	    case 24,66:
	    {
			/*Function to display 'more...' link */
			eval('spnMore' + passedDisplayOrder + '.style.display = ""');
        }
    	break;
    }
}

function cleanKeywords()
{
	var str;
	str = trim(frmSearch.search.value);
	str = replaceSubstring(str,"'","");
	//str = replaceSubstring(str,"(","");
	//str = replaceSubstring(str,")","");
	str = replaceSubstring(str,"[","");
	str = replaceSubstring(str,"]","");
	str = replaceSubstring(str,"{","");
	str = replaceSubstring(str,"}","");
	str = replaceSubstring(str,"=","");
	str = replaceSubstring(str,"+","");
	str = replaceSubstring(str,"!","");
	str = replaceSubstring(str,"@","");
	str = replaceSubstring(str,"#","");
	str = replaceSubstring(str,"$","");
	str = replaceSubstring(str,"%","");
	str = replaceSubstring(str,"^","");
	str = replaceSubstring(str,"*","");
	str = replaceSubstring(str,"_","");
	str = replaceSubstring(str,"&","");
	str = replaceSubstring(str," the ","");
	str = replaceSubstring(str,"-","");
	str = replaceSubstring(str,",","");
	str = replaceSubstring(str,"/","");
	//str = replaceSubstring(str,"\","");
	str = replaceSubstring(str,"     ","");
	str = replaceSubstring(str,"    ","");
	str = replaceSubstring(str,"   ","");
	str = replaceSubstring(str,"  ","");
}

function changeView(x) 
{
	document.images["prodView"].src = viewArray[x].src;
}

function validateFields()		// added by Vineetha on 11/30/2005 to validate Contact Us page
{
	if (trim(document.contact.comments.value == "")) {
		alert("Please enter your comments."); 
		document.contact.comments.focus();
		return false; }

	if (trim(document.contact.name.value == "")) {
		alert("Please enter your name."); 
		document.contact.name.focus();
		return false; }

	if (trim(document.contact.email.value == "")) {
		alert("Please enter your E-mail address."); 
		document.contact.email.focus();
		return false; }

	// change made on 07/10/2006 by Preeti
	if ((document.contact.email.value.indexOf('@') < 0) || ((trim(document.contact.email.value).charAt(trim(document.contact.email.value).length-4) != '.') && (trim(document.contact.email.value).charAt(trim(document.contact.email.value).length-3) != '.'))  || (trim(document.contact.email.value).indexOf(' ') > 0) || (trim(document.contact.email.value).indexOf(',') > 0) || (trim(document.contact.email.value).indexOf(';') > 0) || (trim(document.contact.email.value).indexOf('donotmail.com') > 0)) 
	{
		alert("Please enter a valid E-mail address.");
		document.contact.email.focus();
		return false;
	}
	return true;
}
			
function form_onsubmit()
{	
	switch(parseInt(document.getElementById("hddpt").value))
	{
		case 4:
		{
	        document.frmheadersearch.hddSearch.value = 0;
	        for (i = 1; i < 10; i++)
	        {
		        if (eval("document.frmheadersearch.cboTypeID_"+i))
		        {
			        if (eval("document.frmheadersearch.cboTypeID_"+i+"[document.frmheadersearch.cboTypeID_"+i+".selectedIndex].value").indexOf(':0') > 0)
			        {
				        if (1 ==2)
				        {
				        if (parseInt(document.frmheadersearch.hddSearch.value) == 0)
				        {}
				        else
					        document.frmheadersearch.hddSearch.value = parseInt(document.frmheadersearch.hddSearch.value) - 1 ;
				        }
			        }
			        else
			        {
				        document.frmheadersearch.hddSearch.value = parseInt(document.frmheadersearch.hddSearch.value) + 1 ;
			        }
		        }
	        }
	        if (parseInt(document.frmheadersearch.hddSearch.value) == 0 )
		        return false;
	        else
		        return true;
		}
        break;
    }
}

var IFrameObj; // our IFrame object
function callToServer(passedobject, passedURL) 
{
  if (document.getElementById(passedobject).style.display == 'none')
  { document.getElementById(passedobject).style.display = '';}
 
  if (!document.createElement) 
  {
    return true;
  };
  var IFrameDoc;
  var URL = passedURL;
  if (!IFrameObj && document.createElement) 
  {
    // create the IFrame and assign a reference to the
    // object to our global variable IFrameObj.
    // this will only happen the first time 
    // callToServer() is called
   try 
   {
      var tempIFrame=document.createElement('iframe');
      tempIFrame.setAttribute('id','RSIFrame');
      tempIFrame.style.border='0px';
      tempIFrame.style.width='0px';
      tempIFrame.style.height='0px';
      IFrameObj = document.body.appendChild(tempIFrame);
      
      if (document.frames) 
      {
        // this is for IE5 Mac, because it will only
        // allow access to the document object
        // of the IFrame if we access it through
        // the document.frames array
        IFrameObj = document.frames['RSIFrame'];
      }
    } 
    catch(exception) 
    {
      // This is for IE5 PC, which does not allow dynamic creation
      // and manipulation of an iframe object. Instead, we'll fake
      // it up by creating our own objects.
      iframeHTML='\<iframe id="RSIFrame" style="';
      iframeHTML+='border:0px;';
      iframeHTML+='width:0px;';
      iframeHTML+='height:0px;';
      iframeHTML+='"><\/iframe>';
      document.body.innerHTML+=iframeHTML;
      IFrameObj = new Object();
      IFrameObj.document = new Object();
      IFrameObj.document.location = new Object();
      IFrameObj.document.location.iframe = document.getElementById('RSIFrame');
      IFrameObj.document.location.replace = function(location) 
      {
        this.iframe.src = location;
      }
    }
  }
  
  if (navigator.userAgent.indexOf('Gecko') !=-1 && !IFrameObj.contentDocument) 
  {
    // we have to give NS6 a fraction of a second
    // to recognize the new IFrame
    setTimeout('callToServer()',10);
    return false;
  }
  
  if (IFrameObj.contentDocument) 
  {
    // For NS6
    IFrameDoc = IFrameObj.contentDocument; 
  } 
  else if (IFrameObj.contentWindow) 
  {
    // For IE5.5 and IE6
    IFrameDoc = IFrameObj.contentWindow.document;
  } 
  else if (IFrameObj.document) 
  {
    // For IE5
    IFrameDoc = IFrameObj.document;
  } 
  else 
  {
    return true;
  }
  
  if (IFrameDoc.location.href.indexOf(URL) <= 0)
  {
      IFrameDoc.location.replace(URL);
  }
  return false;
}

function InsertSearchTermIntoFormAction()
{//used in drawheader.asp
	if (ValidateSearch())
	{
		document.getElementById('vldSearch').style.visibility = "hidden";
		
		var searchBox = document.getElementById("txtSearch");
		var formAction = document.form1.action;
		//formAction = formAction.replace('{0}',escape(searchBox.value)); //doesn't work when back button pressed, therefore need to do it long way
		var starSearchString = formAction.indexOf('searchtext=');
		var endSearchString = formAction.lastIndexOf('&') + 1;
		var searchQueryString = formAction.substring(starSearchString, endSearchString );
		
		var startNewSearchString = searchQueryString .indexOf('=');
		var endNewSearchString = searchQueryString .indexOf('&') + 1;
		var previousSearchTerm = searchQueryString.substring(startNewSearchString, endNewSearchString);

		var newQuerySearchString = searchQueryString .replace(previousSearchTerm, '=' + searchBox.value + '&');

		formAction = formAction.replace(searchQueryString, newQuerySearchString);
		document.form1.action = formAction;
		return true;
	}
	else
	{
		document.getElementById('vldSearch').style.visibility = "";
		return false;
	}
}
function ValidateSearch()
{//used in drawheader.asp
	var searchBox = document.getElementById("txtSearch");
	if (trim(searchBox.value) == "")
	{
		return false;
	}
	else
	{
		return true;
	}
}