function IncludeJavaScript(jsFile) {
    document.write('<script type="text/javascript" src="'
    + jsFile + '"></scr' + 'ipt>');
}
//IncludeJavaScript("http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js");
if (typeof jQuery == 'undefined') { IncludeJavaScript("/includes/jquery.js"); }
IncludeJavaScript("/includes/behaviors.js");
IncludeJavaScript("/includes/jquery.ba-resize.min.js");
var winCounty;
var winProduct;
var winAlert;
var newwin;
var ProgressBarTimer;
var icountBar =0;
var pageTimeOut = false;
var winResList;
 
function setOverflow(divId) 
{	  
	var contentheight=0
	panel = document.getElementById(divId);
	if (!panel) 
		return;	
	 
	panel.style.overflow="auto"; 		
	if (document.getElementById("Logo1_tblIntlc"))	 
		contentheight = document.getElementById("Logo1_tblIntlc").offsetHeight;
    if (document.getElementById("AdjLogo1_divLogo"))
        contentheight = document.getElementById("AdjLogo1_divLogo").offsetHeight;	
		
	if (document.getElementById("MenuControl1WebMenu1_MainM"))
		contentheight += document.getElementById("MenuControl1WebMenu1_MainM").offsetHeight;
	if (document.getElementById("Footer1_tblFooter"))
		contentheight += document.getElementById("Footer1_tblFooter").offsetHeight;
	if (document.getElementById("AdjFooter1_tblFooter"))
		contentheight += document.getElementById("AdjFooter1_tblFooter").offsetHeight;		 
	if (document.getElementById("divPageHeader"))
		contentheight += document.getElementById("divPageHeader").offsetHeight;	
	if (document.getElementById("tblRequest"))
		contentheight += document.getElementById("tblRequest").offsetHeight;	
	
	if (document.getElementById("OtherContent")) {
		if (document.getElementById("OtherContent").length) {
			for (i=0;i<document.getElementById("OtherContent").length;i++) {
				contentheight += document.getElementById("OtherContent")(i).offsetHeight;
			}
		}
		else {
			contentheight += document.getElementById("OtherContent").offsetHeight;
		}
	}
	
	try {
			if (AdjustOverflowHeight) 
				contentheight += AdjustOverflowHeight;
		}
	catch(e) {
	}
	
	panel.style.height = document.body.clientHeight - contentheight - 30;
		
	//window.status = panel.style.height; 
	return document.body.clientHeight - contentheight - 30;
}

function GetMemberDir() {
	if (document.location.pathname.lastIndexOf("/") == document.location.pathname.length-1) {
		path = document.location.pathname + "members/";
	}
	else {
		i = document.location.pathname.lastIndexOf("/members/");
		path = document.location.pathname.substring(0,i) + "/members/";		
	}
	return path;
}

function WindowOpen(url,name,features) { 
 
	var mywin = window.open(url,name,features);	 
	if (!mywin) {
		alert("A window was blocked by your pop-up blocker software.\nOur site will not function correctly if pop-ups are blocked.\nPlease change your pop-up blocker settings to allow pop-ups for our site.");
	}
	else {
		mywin.focus()
	}
	return mywin;
}
 
function OpenProductInfo(ProductID) {			
	winProduct = WindowOpen(GetMemberDir() + 'ProductInfo.aspx?popup&ProductID=' + ProductID,'','resizable=yes,scrollbars=yes,' + CenterScreen(500,550))           
}

function OpenReleaseRequired() {
	winProduct = WindowOpen('/compliancedocs/releaserequired.aspx','','resizable=yes,scrollbars=yes,' + CenterScreen(300,550))
}

function OpenAlert(AlertID) {
   winAlert = WindowOpen('alert.aspx?alertid=' + AlertID,'','height=500,width=600,resizable=yes,scrollbars=yes')           
}	

function CountyInfo(State,ProductType) {
	winCounty = WindowOpen('SingleCountyPrice.aspx?State=' + State + '&SearchType=' + ProductType,'','height=530,width=650,resizable=yes,scrollbars=yes') 
}

function OpenWindow(url,width,height) { 
  newwin = WindowOpen(url,'','menubar=no,resizable=yes,scrollbars=yes,status=yes,' + CenterScreen(height,width));   
}

function CloseWindow(win) {
	//close window if exists and not already closed	
	if (win)
		if (!win.closed)
			win.close();
}

function page_onload() {	 
	
	if (document.getElementById("MenuControl1WebMenu1_MainM"))
		if (window.location.search.indexOf("popup") == -1)  {
			document.getElementById("MenuControl1WebMenu1_MainM").style.visibility="visible";
		}
		else {
			document.getElementById("MenuControl1WebMenu1_MainM").style.display = "none";
			document.getElementById("MenuTable").style.display = "none";
			}
 
	//document.title = "IntelliCorp";	
	                      
	window.setTimeout(page_timedout,1200000);	
	
	expires = new Date();
	expires.setTime(expires.getTime() + 1000 * 60 * 60 * 24 * 365); // add one year to it	
	
	SetCookie("ScreenRes",screen.width + 'x' + screen.height,expires,'/',null,null);
}

function page_timedout() {
	pageTimeOut = true;
}

function CenterScreen(height, width) {
		if (height > screen.availHeight) 
			height = screen.availHeight;
		if (width > screen.availWidth)
			width = screen.availWidth;
		      
		var top = (screen.availHeight - height - 60) / 2;
		var left = (screen.availWidth - width) / 2;
		 
		if (top < 0)
			top = 0;
		  
		if (left < 0) 
			left=0;
		 
		return ("Width=" + width + ",Height=" + height + ",Top=" + top + ",Left=" + left);
}

var MenuTimerID = 0;
var menuitem;
function MenuItemHover(mn, id, bOver) {
		menuitem = igmenu_getItemById(id);		
		if(bOver)
			MenuTimerID = setTimeout(MenuHoverTimer,500);
		else
			if (MenuTimerID != 0) {
				clearTimeout(MenuTimerID);				
				MenuTimerID = 0;
			}	
		
		return false;
}
function MenuHoverTimer() {
	//window.status = menuitem.getText();		 
}

function CriteriaPageOnBeforeUnload() {		 
	if (document.FieldPropertyChanged)
	    if (document.activeElement.className.indexOf('BypassUpdateCheck') == -1)
		    if (frmSubmitted != true)	
				return OnBeforeUnLoad_UserMessage;
}
//if (!(document.activeElement.tagName == 'INPUT' && document.activeElement.type == 'submit'))		

function GetUrlParm(parmname) {
 var parmvalue=""
 strQuery = document.location.search;
 
 parms = strQuery.split(parmname); 
  
 if (parms.length > 1) 
	parmvalue = parms[1].substr(1, parms[1].length - 1);	

 i = parmvalue.indexOf("&");
 if (i != -1) 
	parmvalue = parmvalue.substr(0,i);
			 
 return parmvalue;        
}

function CreateDOMObject() 
{
	var ProgIDs = ["MSXML2.DOMDocument.4.0","MSXML2.DOMDocument.3.0","MSXML2.DOMDocument","MSXML.DOMDocument","Microsoft.XmlDom" ];
	var objXML;
	
	for(i=0;i<ProgIDs.length;i++)
		{
			try 
			{				
				objXML = new ActiveXObject(ProgIDs[i]);							
				break;
			}
			catch (ex)
			{			
				 
			}
		}
	 
	return objXML;
}

function update_progressbar() {			
	try {		
		document.getElementById("divProgress").insertAdjacentHTML("beforeEnd","<span class=ProgressBar></span>");
		icountBar +=10;		
		
		if (icountBar >= 2960) { 
			document.getElementById("divProgress").innerHTML = "";
			icountBar = 0;
		}
		
		if (window.document.readyState != "loading") {
			window.clearInterval(TimerID);
			document.getElementById("divProgress").innerHTML = "";
		}
	}
	catch(e)
	{
	}
} 

function GetParentElement(elem, parentTag) {
			if (elem.parentElement)
				if (elem.parentElement.tagName == parentTag) {
					return elem.parentElement;
				}
				else {
					return GetParentElement(elem.parentElement,parentTag);
				}
		}
		
function GetChildElement(elem,childTag) {
	var childelem = null;
	
	if (elem.children)
		for (i=0;i<elem.children.length;i++) {
			if (elem.children(i).tagName == childTag) {
				childelem = elem.children(i);						 
			}
			else {
				childelem = GetChildElement(elem.children(i),childTag);
			}
			
			if (childelem) 
				break;
		}		
	
	return childelem; 
			
}
function AbsoluteTop(object) {   
	var iTop=0;
	if (object.tagName != "BODY") {			    	     
		iTop = AbsoluteTop(object.offsetParent) + object.offsetTop;
	}    
	return iTop;
} 

function GetCollection(element) {
	//return the element if it is a collection, otherwise return element in array
	//this solves the problem of referring to document.all(elementname)
	//if there is only one element with that id present, document.getElementById(elementname) returns the object
	//if more than one element present, document.all(elementname) returns a collection
	//this routine makes it possible to treat it always as a collection or array, simplifying coding
	var items;
	try {
		if (element.length) {
			items = element;
		}
		else {
			items = new Array(element);
		}		
	}
	catch(e) {
	
	}	
	
	return items; 								
}

function OpenResultList(url) {     
  winResList = WindowOpen(url,'ResultList','menubar=no,resizable=yes,scrollbars=yes,status=no,' + CenterScreen(500,800));   
  winResList.focus();
}
function dropdownlist_onkeydown() {
 
    if ( event.keyCode == "8" ) 
      window.event.returnValue = false;

  }

function dob_onkeydown() {
	//this routine detects a paste operation (ctrl+v) and checks the clipboard for data in a dob format
	//it then sets the dob field to the value in the clipboard
		var DOB = new Array();
		
		try {
			if (window.event.keyCode == 86 && window.event.ctrlKey) {		
				clipData = window.clipboardData.getData("Text");
				reDOB = /\d{1,2}\/\d{1,2}\/\d{2,4}/;
				if (reDOB.test(clipData)) {
					DOB = clipData.split("/");									
				}
				else {
					reDOB = /\d{1,2}-\d{1,2}-\d{2,4}/;
					if (reDOB.test(clipData)) {								 		 
						DOB = clipData.split("-");							 
					}				
				}
			
				if (DOB.length == 3) {
					if (DOB[2].length == 2) 
						DOB[2] = "19" + DOB[2];
				
					if (DOB[0].length == 1) 
						DOB[0] = "0" + DOB[0];
						
					if (DOB[1].length == 1) 
						DOB[1] = "0" + DOB[1];
				
					dobID = document.activeElement.id;
					i = dobID.lastIndexOf("_");			
					if (i != -1) {
						dobID = dobID.substr(0,i+1);									
					}
					else {
						dobID = "ddl";
					}
					
					if (document.getElementById(dobID + "DOBMonth")) {
						document.getElementById(dobID + "DOBMonth").value = DOB[0];
						document.getElementById(dobID + "DOBDay").value = DOB[1];
						document.getElementById(dobID + "DOBYear").value = DOB[2];
					}
					
				}	
				
			}
		}
		catch(e) {
		}

}

function NewWindow(mypage,myname,w,h,scroll){
		LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
		TopPosition = (screen.height) ? (screen.height-h)/2 : 0;

		settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
		win = window.open(mypage,myname,settings)
		win.focus()
}

function SetCookie (name,value,expires,path,domain,secure) {
       document.cookie = name + "=" + escape(value)
   + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
        ((path) ? "; path=" + path : "") 
        //((domain) ? "; domain=" + domain : "") +
        //((secure) ? "; secure" : "");
}

function ShowHelp() {
	NewWindow('/help/default.aspx','help',550,450,'yes');
}

function Trim(val) 

{

  while ((val.substring(0, 1) == ' ') || (val.substring(0, 1) == '\n') || (val.substring(0, 1) == '\r'))

  {

    val = val.substring(1, val.length);

  }

 

  while ((val.substring(val.length - 1, val.length) == ' ') || (val.substring(val.length - 1, val.length) == '\n') || (val.substring(val.length - 1, val.length) == '\r'))

  {

    val = val.substring(0, val.length - 1);

  }

  return val;

}
function BrowserCheck() {
    var returnval = '';
    //var returnval = ($.browser.msie ? 'msie' : ($.browser.mozilla ? 'mozilla' : ($.browser.opera ? 'opera' : ($.browser.safari ? 'safari' : ($.browser.webkit ? 'webkit' : 'unknown browser'))))) + ' ' + parseFloat($.browser.version).toString() + '<br/>';
	
	try {
	    if (($.browser.msie && parseFloat($.browser.version) >= 6) || ($.browser.mozilla && parseFloat($.browser.version) >= 1.9)) {
	        //IE 6 or above, or Firefox 3 or above; we're good
	    } else {
	        returnval += 'This web site works best with Internet Explorer 6+, or FireFox 3.x+. Use of any other browser may cause pages to not display properly.';
	    }
	}
	catch(e) {
		//do nothing
	}
	
	return returnval;
}		 

var oPopup;
var timer;
function ShowReleaseRequired(chkbox,accountFax) {	
	var FaxNo = '216-450-5301';
	
	reEduEmp = /edu|emp/i;       //look for edu or emp checkbox
	 
	if (reEduEmp.test(chkbox.id)) {
		FaxNo = '216-450-5247';
	}
	
	if (accountFax != '') {
		FaxNo = accountFax;
	}
	
	if (navigator.userAgent.indexOf('MSIE') == -1) {	
		if (chkbox.checked) {
			alert("You will need to fax a signed authorization to " + FaxNo + " before your search will be processed.\n Do you have a signed release?");
			}
	} else {
		var oPopupBody;	

		try {	 				
			oPopup = window.createPopup();
			oPopupBody = oPopup.document.body;
		}
		catch(x) {
		}		
		
		if (chkbox.checked) {									
			oPopupBody.style.backgroundColor = "#FFFFCC";
			oPopupBody.style.border = "solid #FFCC66 1px";    
			oPopupBody.innerHTML = "<div align=center><b>Signed Release Required&nbsp;</b><img src='/images/close.jpg' style=position:relative;left:25 onclick='window.parent.oPopup.hide()' style='cursor:hand'></div>"						
					
			oPopupBody.innerHTML += " You will need to fax a signed authorization to " + FaxNo + " before your search will be processed. Do you have a signed release? ";
			oPopup.show(0, 20, 250, 110, document.activeElement);
			window.setTimeout("oPopup.hide()",4000);
		}
	}

}
function ShowReleaseOnMouseover(accountFax) 
{	
	var FaxNo = '216-450-5301';
	if (navigator.userAgent.indexOf('MSIE') == -1) 
	{	
		alert("You will need to fax a signed authorization to " + FaxNo + " before your search will be processed.\n Do you have a signed release?");
	} 
	else 
	{
		var oPopupBody;	
		try {	 				
			oPopup = window.createPopup();
			oPopupBody = oPopup.document.body;
		}
		catch(x) 
		{
		}		
		oPopupBody.style.backgroundColor = "#FFFFCC";
		oPopupBody.style.border = "solid #FFCC66 1px";    
		oPopupBody.innerHTML = "<div align=center><b>Signed Release Required&nbsp;</b><img src='/images/close.jpg' style=position:relative;left:25 onclick='window.parent.oPopup.hide()' style='cursor:hand'></div>";						
					
		oPopupBody.innerHTML += " You will need to fax a signed authorization to " + FaxNo + " before your search will be processed. Do you have a signed release? ";
		oPopup.show(0, 20, 250, 110, document.activeElement);
		window.setTimeout("oPopup.hide()",8000);
		
	}
}

