
var Parentwindow = false;
var browser = navigator.appName.substring(0,8);
var version = parseInt(navigator.appVersion);
var bIsLetter = false;
var myWindow;

function keypressed(sMyses, sCUID, sCUSRVR) {
	//F2 = 113
	//F3 = 114
	var bValidKey;
	
	bValidKey = false;
	
	//alert(window.event.keyCode);
	
	//var pressedkey=/[a-zA-Z0-9\.\,\/]/ //detect alphanumeric keys 
	//if (pressedkey.test(String.fromCharCode(event.keyCode)) || event.keyCode == 81 || event.keyCode == 82)
	
	//if (event.keyCode == 81 || event.keyCode == 82)
	//	bIsLetter = true;

	if ((event.keyCode == 113 || event.keyCode == 114) && !bIsLetter) {
		top.document.location.href = '/ils/FunctionKey.aspx?key=' + event.keyCode + '&myses=' + sMyses + '&cuid=' + sCUID + '&cusrvr=' + sCUSRVR;
		bValidKey = true;
	}

	if ((event.keyCode == 113 || event.keyCode == 114) && bIsLetter)
		bIsLetter = false;
			
	if (bValidKey) {
		event.cancelBubble = true;
		event.keyCode = 0;
		return false;
	}
}

function CheckBarcodeShortcut (sQuery)
{
    // Note: sQuery from BasePage.BuildCommonQueryString().

    // Scan through the text inputs on a form and redirect if the text matches
    // a predetermined barcode shortcut.
    //
    // Note: In order to make this model work with multiple textboxes on
    //       the form, need to set the AutoPostBack="True" for each textbox
    //       that needs to recognize the predetermined shortcut barcode.

    var formobj = document.forms[0];
    var i;
    
    for (i = 0; i < formobj.length; i++)
    {
        if (formobj.elements[i].type == "text")
        {
            var test = formobj.elements[i].value;
            if ((test == "CMD1") ||
                (test == "CMD2") ||
                (test == "CMD3") ||
                (test == "CMD4") ||
                (test == "CMD5") ||
                (test == "CMD6"))
            {
                    formobj.elements[i].value = "";
                    top.document.location.href = '/ils/BarcodeShortcut.aspx?key=' + test + '&' + sQuery;
                    return false;
            }
        }
    }
    return true;
}

function goSelect(daform) {
	with(daform) {
		document.location=options[selectedIndex].value;       
	}
}

function back2Search(url)
{	
	window.location.href=url+"&focus=no";
}

function CloseFrame(oForm)
{
	parent.window.close();
}

function Logout(evt,sessionId,custId,custServer)
{  
	var savedURL;
	if (window.event.clientY < 0)
	{
		if ((custId.toLowerCase =='fidelity' || custId.toLowerCase =='tfidel') && custServer!='')
		{
			//savedURL=window.location.href;
			//url="SafariLogout.aspx?myses=" + sessionId + "&cuid=" + custId + "&cusrvr=" + custServer;	
			//window.location.href=url;
			//window.location.href=savedURL;
		}
	}
	return false;
}

function WhichActionOnEnter(evt, formobj, url, ncase)
{
    var charcode = (navigator.appName == "Netscape") ? evt.which : evt.keyCode
    if (charcode == 13)
	{
		WhichAction(formobj, url, ncase);
		return false;		
	}
}

// Create new function to fix problem with Classic pages after ET 9122 fix.
function WhichActionOnEnterClassic(evt, formobj, url, ncase)
{
    var charcode = (navigator.appName == "Netscape") ? evt.which : evt.keyCode
    if (charcode == 13)
	{
		WhichActionClassic(formobj, url, ncase);
		return false;		
	}
}

//this new function is created to address issue with 9122
//Because the value inside DS_List could be a db-pool-key
//, that does not belong to any one of checkboxes on current search-page
function CheckIfAnyDBSelected(formobj)
{
    if (formobj.DS_List == null)
    {
        return false;
    }
  
    var DSArray = formobj.DS_List.value.split(',');
   
	for (var i=0; i < DSArray.length; i++)
	{
		var DS_ID = DSArray[i];

		//Loop through all form element to see if this ID is a value of CheckBox
		for (var j=0; j<formobj.length; j++)
		{
		    if (formobj.elements[j].type == "checkbox" 
		        && formobj.elements[j].name.indexOf("HD") != -1)
	        {
	            if (formobj.elements[j].value == DS_ID)
	            {
	                //As long as one of the db-pool-key from DS_LIST is valid
	                //Can return true
	                return true;
	            }
	        }
		
		}
    }
    return false;
}

function WhichAction(formobj,url,ncase)
{	
    var isDBSelected = CheckIfAnyDBSelected(formobj);
   
	switch (ncase){		
		case 1:
			if (!isDBSelected)
			{
				alert("Please select one or more databases and try again!");
				return;
			}
			else if ((formobj.sterm1==null ||  trim(formobj.sterm1.value) == '' || formobj.sterm1.value == ' ' ||formobj.sterm1.value.indexOf('*') == 0 || formobj.sterm1.value.indexOf('*') == 1) &&
				 (formobj.sterm2==null || trim(formobj.sterm2.value) == '' || formobj.sterm2.value == ' ' ||formobj.sterm2.value.indexOf('*') == 0 || formobj.sterm2.value.indexOf('*') == 1) && 
				 (formobj.sterm3==null || trim(formobj.sterm3.value) == '' || formobj.sterm3.value == ' ' ||formobj.sterm3.value.indexOf('*') == 0 || formobj.sterm3.value.indexOf('*') == 1))
			{
				formobj.sterm1.focus();
				alert("Please enter a valid search term!");				
				return;
			}				
			break;
		case 2:			
			if (( (formobj.sterm1==null || trim(formobj.sterm1.value) == '') && (formobj.sterm2==null || trim(formobj.sterm2.value) == '') && (formobj.sterm3==null || trim(formobj.sterm3.value) == '')) ||( (formobj.sterm1==null || formobj.sterm1.value == ' ') && (formobj.sterm2==null || formobj.sterm2.value == ' ') && (formobj.sterm3==null || formobj.sterm3.value == ' ')))
			{
				formobj.sterm1.focus();
				alert("Please enter a search criteria and try again!");
				return;
			}	
			break;
		case 3: //for alpha browse to accept space.
			if (!isDBSelected)
			{
				alert("Please select one or more databases and try again!");
				return;
			}
			else if (formobj.sterm1==null || trim(formobj.sterm1.value) == '' || formobj.sterm1.value.indexOf('*') == 0 || formobj.sterm1.value.indexOf('*') == 1)
			{
				formobj.sterm1.focus();
				alert("Please enter a valid search term!");				
				return;
			}				
			break;	
		default:	
			formobj.action = url;
			formobj.submit();
		break;
		
		}
		
	if (formobj.DS_List!=null &&  formobj.DS_List.value!='')
	{	
		formobj.action = url;
		formobj.submit();
	}
	return;	
	
}

function WhichActionClassic(formobj,url,ncase)
{	
	switch (ncase){		
		case 1:
			if ((formobj.sterm1==null ||  trim(formobj.sterm1.value) == '' || formobj.sterm1.value == ' ' ||formobj.sterm1.value.indexOf('*') == 0 || formobj.sterm1.value.indexOf('*') == 1) &&
				 (formobj.sterm2==null || trim(formobj.sterm2.value) == '' || formobj.sterm2.value == ' ' ||formobj.sterm2.value.indexOf('*') == 0 || formobj.sterm2.value.indexOf('*') == 1) && 
				 (formobj.sterm3==null || trim(formobj.sterm3.value) == '' || formobj.sterm3.value == ' ' ||formobj.sterm3.value.indexOf('*') == 0 || formobj.sterm3.value.indexOf('*') == 1))
			{
				formobj.sterm1.focus();
				alert("Please enter a valid search term!");				
				return;
			}				
			break;
		case 2:			
			if (( (formobj.sterm1==null || trim(formobj.sterm1.value) == '') && (formobj.sterm2==null || trim(formobj.sterm2.value) == '') && (formobj.sterm3==null || trim(formobj.sterm3.value) == '')) ||( (formobj.sterm1==null || formobj.sterm1.value == ' ') && (formobj.sterm2==null || formobj.sterm2.value == ' ') && (formobj.sterm3==null || formobj.sterm3.value == ' ')))
			{
				formobj.sterm1.focus();
				alert("Please enter a search criteria and try again!");
				return;
			}	
			break;
		case 3: //for alpha browse to accept space.
			if (formobj.sterm1==null || trim(formobj.sterm1.value) == '' || formobj.sterm1.value.indexOf('*') == 0 || formobj.sterm1.value.indexOf('*') == 1)
			{
				formobj.sterm1.focus();
				alert("Please enter a valid search term!");				
				return;
			}				
			break;	
		default:	
			formobj.action = url;
			formobj.submit();
		break;
		
		}
		
	if (formobj.DS_List!=null &&  formobj.DS_List.value!='')
	{	
		formobj.action = url;
		formobj.submit();
	}
	return;	
	
}


function trim(s) {
  while (s.substring(0,1) == ' ') {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') {
    s = s.substring(0,s.length-1);
  }
  return s;
}

function ChangeScreen(url)
{
	var formobj;
	if (document.forms[0]? true : false){
		formobj = document.forms[0];
	}else{
		formobj = parent.MainFrame.document.forms[0];
	 }
	formobj.action = url;
	formobj.submit();
	return;		
}

/*
activateActiveX
---------------
Purpose:  Dynamically replace any elements that will be affected by the new security feature in IE6/IE7 that requires a user to click certain types of elements to activate them before use.

Usage:  Include this file in the <head></head> section of your html document using the following...
	<script language="JScript" type="text/jscript" src="activateActiveX_onload.js"></script>


Since this script is in response to a software patent lawsuit, I feel it necessary to state the following...	

License:
activateActiveX is Copyright (C) 2006 Jason Baker (therippa AT gmail.com). It is available as open source code from:
http://therippa.blogspot.com

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details http://www.gnu.org/licenses/gpl.html
*/

function CheckForActiveX() {
	//Determine browser, we only need this for Internet Explorer
	if (navigator.appName == "Microsoft Internet Explorer") {
		
		//Array of elements to be replaced
		var arrElements = new Array(3);
		arrElements[0] = "object";
		arrElements[1] = "embed";
		arrElements[2] = "applet";
	
		
		//Loop over element types
		for (n = 0; n < arrElements.length; n++) {
		
			//set object for brevity
			replaceObj = document.getElementsByTagName(arrElements[n]);
			
			//loop over element objects returned
			for (i = 0; i < replaceObj.length; i++ ) {
			
				//set parent object for brevity
				parentObj = replaceObj[i].parentNode;
				
				//grab the html inside of the element before removing it from the DOM
				newHTML = parentObj.innerHTML;
				
				//remove element from the DOM
				parentObj.removeChild(replaceObj[i]);
				
				//stick the element right back in, but as a new object
				parentObj.innerHTML = newHTML;
			
				}
			}
		}
	}



function Loadfunction(formobj,sCase)
{
	CheckForActiveX();
	if (formobj.sterm1? true : false)
	{
		formobj.sterm1.focus();
	}
}


function PreloadImages()
{

	
image1 = new Image();
image1.src = "images/Tff_Light.gif";

image2 = new Image();
image2.src = "images/searching_flash.gif";
}


function openWin(url,winname,h,w) {

	window.open(url,winname,'width='+w+',height='+h+',top='+(screen.height-h)/2+',left='+(screen.width-w)/2+',directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,titlebar=no,toolbar=no');

}

function openWinWithToolBar(url,winname,h,w) {

	window.open(url,winname,'width='+w+',height='+h+',top='+(screen.height-h)/2+',left='+(screen.width-w)/2+',directories=1,location=1,menubar=1,resizable=1,scrollbars=1,status=0,titlebar=0,toolbar=1');

}

function OpenWindow(sURL,sWinName,iWidth,iHeight,y,x)
{
	sURL = sURL.replace(/\#amp#/g, "%26");
	sURL = sURL.replace(/\#apos#/g, "%27");
	myWindow = window.open(sURL,sWinName,"width="+iWidth+",height="+iHeight+",top="+y+",left="+x+",resizable=1,scrollbars=1");
	myWindow.focus();
}


function OpenNewWindow(sURL,sWinName,iWidth,iHeight,y,x)
{
    if (myWindow!=null)myWindow.close();
	sURL = sURL.replace(/\#amp#/g, "%26");
	sURL = sURL.replace(/\#apos#/g, "%27");
	myWindow = window.open(sURL,sWinName,"width="+iWidth+",height="+iHeight+",top="+y+",left="+x+",resizable=1,scrollbars=1");
	myWindow.focus();
}


function OpenWindowWithToolBar(sURL,sWinName,iWidth,iHeight,y,x)
{    
	//myWindow = window.open(sURL,sWinName,"width="+iWidth+",height="+iHeight+",top="+y+",left="+x+",resizable=1,scrollbars=1,toolbar=1,menubar=1");	
	myWindow = window.open(sURL, sWinName,"width="+iWidth+",height="+iHeight+",top="+y+",left="+x+",resizable=1,scrollbars=1,directories=1,location=1");
	myWindow.focus();
}

function OpenWindowWithAddressBar(sURL,sWinName,iWidth,iHeight,y,x)
{
	myWindow = window.open(sURL,sWinName,"width="+iWidth+",height="+iHeight+",top="+y+",left="+x+",resizable=1,scrollbars=1,toolbar=1,location=1");
	myWindow.moveTo(x,y);
	myWindow.resizeTo(iWidth,iHeight);	
	myWindow.focus();
}

function CheckAll(oForm, bCheck)
{
	for (i=0; i<oForm.QualCheckBox.length; i++)
	{
		if (oForm.QualCheckBox!=null)
			oForm.QualCheckBox[i].checked = bCheck;
		if (oForm.QualIMaterialCheckBox!=null)
			oForm.QualIMaterialCheckBox[i].checked = bCheck;
	}
}


function AddToCart(formobj,whichCart)
{	
	formobj.WhichCart.value = whichCart;
	formobj.action = window.location.href;
	formobj.submit();
	return;	
}

function AddToList(formobj,whichCart, custURL)
{	
	formobj.WhichCart.value = whichCart;
	formobj.action = window.location.href;
	formobj.submit();

    var urlBib = "Bibliography/AddToList.aspx?" + custURL;
    OpenWindow(urlBib, 'AddToList', 450, 200, 150, 60);

	return;	
}

function CheckOnEnter(evt, formobj, url)
{

    var charcode = (navigator.appName == "Netscape") ? evt.which : evt.keyCode
    if (charcode == 13)
    {
		formobj.action = url;
		formobj.submit();
		return false
	}
	return true
}


function ChangeVisibility(ID,Visibility)
{

	if (document.getElementById)
	{
		menuObj = document.getElementById(ID).style;
	}else
	{
		menuObj = eval("document." + ID);
	}
	
	menuObj.visibility = Visibility;

}


function GetCurrentValue(sImageName)
{
	if (document.forms[0]? true : false){
		return document.forms[0][sImageName].value;
	}
	else if (parent.opener.document.forms[0]? true : false){
		return parent.opener.document.forms[0][sImageName].value;		
	}	
}


function OpenAPopupWindow(wurl)
{
	PopupAWindows(wurl,"ILLPart",560,400,100,25,"yes","yes");
	Parentwindow.focus();
}


function PopupAWindows(URL,sName,W,H,X,Y,rz,sb)
{
var sWinSize;
    sWinSize = "width=" + W + ",height=" + H + ",left=" + X + ",top=" + Y + ",ScreenX=" + X + ",ScreenY=" + Y+",resizable="+rz+",scrollbars="+sb;
	{Parentwindow = window.open(URL, sName, sWinSize);};
	
}

function AddThisItemToCart(sUrl,sName,sLink)
{
	parent.HiddenFrame.location = sUrl + "?name=" + sName + sLink;
	if (browser != "Netscape" || version > 4)
	{
		DisplayAppropriateDropdownMenu();
	}
}

function DisplayAppropriateDropdownMenu()
{
	if (document.getElementById("NaviBarDropdownMenu")? true : false) 
	{
		if (document.getElementById("RemoveFromCart").style.display == "none"){
			document.getElementById("RemoveFromCart").style.display = ""		
			document.getElementById("AddToCart").style.display = "none"
		}else{
			document.getElementById("RemoveFromCart").style.display = "none"		
			document.getElementById("AddToCart").style.display = ""		
		}		
	}
}


function checkDate(oField) {
	var cDate = oField.value.replace( /[\W\D\s]/gi, '' ); // delete all	characters different from numbers
	if( cDate.length == 8 ) {
		var cMonth = cDate.substring(0,2); // month extraction
		var cDay = cDate.substring(2,4); // day extraction
		var cYear = cDate.substring(4); // year extraction
		if( cDay.match(/^([0-2]?\d|3[01])$/) &&	cMonth.match(/^(0?\d|1[0-2])$/)	&& cYear.match(/^[1-9]\d\d\d$/) ) {
			oField.value = cMonth+'/'+cDay+'/'+cYear; // you can change the	separator as you want!
		} else {
			alert( 'Insert a valid date' ); // problems in pattern	matching of some `piece' of date...
			oField.focus();
		}
	} else {
		alert( 'Please enter date in mm/dd/yyyy format.' ); //  Date lenght is not 8 (without separator)
	}
}


function stripOutParam(url,paramName)
{
	var begpos,endpos,shref,tmpstr;
	shref = url;
	begpos = shref.indexOf(paramName);
	if (begpos == -1)
		shref = url;
	else 
	{
		shref = shref.substring(0,begpos-1);
	}
	return shref;
}

function CloseAllFolders()
{
	var imgPath;
	var count=0;
	var k=0;
	
	for (i=0; i< document.images.length; i++)
	{
		if (document.images[i].name.indexOf("Img") >= 0)
		    count++;
	}
	
	if ((navigator.appName == "Netscape") && (navigator.appVersion.charAt(0) < "5"))
	{
		var myUrl=document.location.href;
		myUrl=myUrl.toLowerCase();
		myUrl=stripOutParam(myUrl,"oitems=");
		myUrl=stripOutParam(myUrl,"mode=");
		
		ChangeScreen(myUrl);
	}
	else
	{
		for (k=1; k<=count; k++)
		{
			imgPath = document.images["Img"+k].src;
			i = imgPath.indexOf("images/");
			imgPath = imgPath.substr(i);
			
			if (imgPath.indexOf("Open") != -1)
			{		
				document.images["Img"+k].src = imgPath.replace("Open","Close");
				document.getElementById("Node"+k).style.display = "none";		
			}	
		}
	}
}

function ResouceTree(idx,myUrl)
{
	var imgName = "Img" + idx;
	var idName = "Node" + idx;
	var bOpen;
	
	if (document.images[imgName].src.indexOf("Close") != -1)
		bOpen = true;	
	else
	{
		bOpen = false;
		idx = "0";
	}
	
	// for Netscape 4.7
	if (bOpen)
		sMode = "&mode=open";
	else
		sMode = "&mode=close";
		
		
	var count = 0;
	var openItems="";
	var openFolder=0;
	for (i=0; i< document.images.length; i++)
	{
		if (document.images[i].name.indexOf("Img") >= 0)
		    count++;
	}	
		
	if ((navigator.appName == "Netscape") && (navigator.appVersion.charAt(0) < "5"))
	{
		for (k=1; k<=count; k++)
		{
			imgPath = document.images["Img"+k].src;
			i = imgPath.indexOf("images/");
			imgPath = imgPath.substr(i);
			if (imgPath.indexOf("Open") != -1)
			{					
				if (imgName!="Img"+k)openFolder++;
				if ((openFolder<CK_AllowOpen&&imgName!="Img"+k)||CK_AllowOpen==0)								
				{
					openItems+=k+",";																			
				}
			}	
		}
		//document.location.href = ChangeScreen(myUrl +  "&idx="+idx+sMode);
		ChangeScreen(myUrl +  "&idx="+idx+sMode+"&allow="+CK_AllowOpen+"&oitems="+openItems);
	}

	// for IE, Netscape 5 and up
	// close all nodes

	
	for (k=1; k<=count; k++)
	{
		imgPath = document.images["Img"+k].src;
		i = imgPath.indexOf("images/");
		imgPath = imgPath.substr(i);
		
		if (imgPath.indexOf("Open") != -1)
		{
			if (imgName!="Img"+k)openFolder++;
			if ((openFolder>=CK_AllowOpen||imgName=="Img"+k)&&CK_AllowOpen!=0)
			{
				document.images["Img"+k].src = imgPath.replace("Open","Close");
				document.getElementById("Node"+k).style.display = "none";
			}
		}	
	}

	
	// open node
	if (bOpen)
	{
		imgPath = document.images[imgName].src;
		i = imgPath.indexOf("images/");
		imgPath = imgPath.substr(i);

	
		if (document.getElementById(idName).style.display == "none")
		{
			document.images[imgName].src = imgPath.replace("Close","Open");
			document.getElementById(idName).style.display = "block";
		}
	}
	//else
	//{
	//	imgPath = document.images[imgName].src;
	//	i = imgPath.indexOf("images/");
	//	imgPath = imgPath.substr(i);

	
	//	if (document.getElementById(idName).style.display == "block")
	//	{
	//		document.images[imgName].src = imgPath.replace("Open","Close");
	//		document.getElementById(idName).style.display = "none";
	//	}
	//}
}

function ShiftImg(name, bOn)
{
	imgPath = document.images[name].src;
	i = imgPath.indexOf("images/");
	imgPath = imgPath.substr(i);

	switch (bOn)
	{
		case true:
			imgPath = imgPath.replace("Off","On");
			document.images[name].src = imgPath;
			break;
			
		case false:
			imgPath = imgPath.replace("On","Off");
			document.images[name].src = imgPath;
			break;
	}
}

function FormatToPrint()
{
	var addedUrl = document.forms[0].special.value;
	var sURL = window.location.href + "&print=true" + addedUrl;
	myWindow = window.open(sURL,"FormatToPrint","width=600,height=400,top=250,left=200,resizable=1,scrollbars=1,toolbar=1");
	myWindow.focus();
}

function SortVersoHLDBy(sortBy)
{

	var begpos,endpos,shref,tmpstr;
	shref = document.location.href;
	begpos = shref.indexOf("sby=");
	if (begpos == -1)
		shref += "&sby=" + sortBy;
	else 
	{
		tmpstr = shref.substring(begpos,shref.length)
		endpos = tmpstr.indexOf("&");
		if (endpos == -1)
		{
			shref = shref.substring(0,begpos - 1) + "&sby=" + sortBy;
		}
		else
		{
			shref = shref.substring(0,begpos-1);
			tmpstr = tmpstr.substring(endpos,tmpstr.length);
		    shref += "&sby="+sortBy+tmpstr;
		}
	}
	document.location.href = shref;
}

/*
function Highlight(obj,bYes)
{
	if (bYes)
	{
		obj.style.backgroundColor = "#BCCD8F";
	}else
	{
		obj.style.backgroundColor = "";
	}

}

function MenuHighlight(obj,bYes)
{
	if (bYes)
	{
		obj.style.backgroundColor = "#CEDFA2";
	}else
	{
		obj.style.backgroundColor = "";
	}

}
*/


function MenuHighlight(obj,bYes)
{
	if (bYes)
	{
		obj.className = "bgBarHighLight";

	}else
	{
		obj.className = "bgBar";
	}

}

function Highlight(obj,bYes)
{
	if (bYes)
	{
		obj.className = "bgBarHighLight";
	}else
	{
		obj.className = "bgRowLight";
	}

}

function Tree(idx)
{
	var imgName = "Img" + idx;
	var idName = "Node" + idx;
	var bOpen;
	var status;
	
	if (document.images[imgName].src.indexOf("Plus") != -1)
	{
		bOpen = true;
		status = "open";
	}
	else
	{
		bOpen = false;
		status = "close";
	}
	
	// for Netscape 4.7
	if ((navigator.appName == "Netscape") && (navigator.appVersion.charAt(0) < "5"))
	{
			var begpos,endpos,shref,tmpstr;
			shref = document.location.href;
			begpos = shref.indexOf("idx=");
			if (begpos == -1)
				shref += "&idx=" + idx;
			else 
			{
				tmpstr = shref.substring(begpos,shref.length)
				endpos = tmpstr.indexOf("&");
				if (endpos == -1)
				{
					shref = shref.substring(0,begpos - 1) + "&idx=" + idx;
				}
				else
				{
					shref = shref.substring(0,begpos-1);
					tmpstr = tmpstr.substring(endpos,tmpstr.length);
				    shref += "&idx="+idx+tmpstr;
				}
			}
			document.location.href = shref;
	}

	// for IE, Netscape 5 and up
	// close this node

	document.images["Img"+idx].src = "images/IconPlusOff.gif";
	document.getElementById(idName).style.display = "none";
	

	
	// open node
	if (bOpen)
	{
		imgPath = document.images[imgName].src;
		i = imgPath.indexOf("images/");
		imgPath = imgPath.substr(i);
	
		if (document.getElementById(idName).style.display == "none")
		{
			document.images[imgName].src = imgPath.replace("Plus","Minus");
			document.getElementById(idName).style.display = "block";
		}
	}
}



function RefreshParentWindow()
{
    var popupUrl = parent.location.href;
	parent.window.close();
	var parentUrl = parent.opener.location.href;
	
	//alert('parentUrl - ' + parentUrl);
	
	if (parentUrl.indexOf('CBBResult.aspx') > -1)
	{
	    if (parentUrl.toUpperCase().indexOf('W=B') > -1)
	    {
	        //do nothing
	    }
	    else
	    {
	        //alert('popupUrl - ' + popupUrl);	    
	    
	        if (popupUrl.toUpperCase().indexOf('DOWNLOADPAGE.ASP') > -1)
	            parent.opener.refreshAllHasCartCBBFromPopup();    
	        else
	            parent.opener.refreshSingleCBBFromPopup();
        }
	}    
    else	    
	    parent.opener.location = parentUrl;
	
}



function chkPasswords() {

	var sPass1 = document.forms[0].pwd.value.toUpperCase();
	var sPass2 = document.forms[0].VerifyPass.value.toUpperCase();
	
	sPass1.replace(/^\s+/,'').replace(/\s+$/,'')
	sPass2.replace(/^\s+/,'').replace(/\s+$/,'')
	
	if ((1 > sPass1.length) || (1 > sPass2.length)){		
		alert('Passwords cannot be blank.');
		return false;
	}
	else {
		if (sPass1 != sPass2) {
			alert('Passwords do not Match.');
			return false;
		}
		else {
			if (sPass1.length > 20) {
				alert('Passwords cannot be more than 20 characters.');
				return false;
			}
			else {
				var j=0;
				for (var i=0;i<sPass1.length;i++) {if (sPass1.charAt(i) == ' ') {j++;}}
				if (j > 0) {
					alert('Password cannot contain spaces.');
					return false;
				}
				else {
					document.forms[0].submit();					
				}
			}
		}
	}
}
			
function getTotalChars(s,c) //s=a string, c = char to search, returns nr of occiurences
 {
  return j;
 }
 
 
 function GetHelp()
 {
	if (document.forms[0].helpFile)
	{
		fileName=document.forms[0].helpFile.value;
		if (fileName != "")
			OpenWindow("Helps/"+fileName,"Help",500,450,0,0);	
	}
 }

function ShiftImage(sImgName,sSrcValue,bOn)
{	
	if (document.images[sImgName] ? true : false)
		{	
			if (bOn)
				document.images[sImgName].src = "images/" + sSrcValue + "_On.gif";
			else
				document.images[sImgName].src = "images/" + sSrcValue + ".gif";
		}
}

function Collapse(id, imgName)
{
	if (document.getElementById(id).style.display == "none")
	{
		var objImg = eval("document." + imgName);
		objImg.src = "images/ArroOpen.gif";
		document.getElementById(id).style.display = "";
	}
	else
	{
		var objImg = eval("document." + imgName);
		objImg.src = "images/ArroClose.gif";
		document.getElementById(id).style.display = "none";
	}
	
}

function ClearNewQualifiersR(url)
{

if (document.forms[0].QYear) {
	document.forms[0].QYear.value = '';
}

if (document.forms[0].QMediaDsp) {
	document.forms[0].QMedia.value = 'Any';
}

 myWindow = window.open(url,'clearQualifiers',"width=100,height=100,top=10,left=10,resizable=0,scrollbars=0");
}


var BrowserDetectObject = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetectObject.init();





