function toggleDetails(strElement)	{
	if (document.getElementById(strElement).style.display == "none")	{
		document.getElementById(strElement).style.display = "block";
	}	else	{
		document.getElementById(strElement).style.display = "none";
	}
}

function validator()	{
	if (document.getElementById("keyword1").selectedIndex == 0) {
		alert('At Least One Keyword is Required');
		document.getElementById("keyword1").focus();
		return false;
	}
	if (document.getElementById("Comments").value == '')	{
		alert('Comments Are Required');
		document.getElementById("Comments").focus();
		return false;
	}
	return true;
}

function selectAll(strElementName)	{
	for (var intCounter	=	0; intCounter < document.getElementById(strElementName).options.length; intCounter++)	{
		document.getElementById(strElementName).options[intCounter].selected = true;
	}
	return false;
}

function showCheckout()	{
	if (document.getElementById('selectedItem').value == '')	{
		document.getElementById('btnSubmit').style.display = 'none';
	}	else	{
		document.getElementById('btnSubmit').style.display = 'block';
	}
}

function dynamicShowCheckout()	{
	document.getElementById('btnSubmit').style.display = 'block';
}

function GetCookie (name) { 
	var arg = name + "="; 
	var alen = arg.length; 
	var clen = document.cookie.length; 
	var i = 0; 
	while (i < clen) { 
		var j = i + alen; 
		if (document.cookie.substring(i, j) == arg)	{
			return getCookieVal (j); 
		}
		i = document.cookie.indexOf(" ", i) + 1; 
		if (i == 0) break; 
	} 
    return null; 
}

function getCookieVal (offset) { 
	var endstr = document.cookie.indexOf (";", offset); 
	if (endstr == -1) 	{
	    endstr = document.cookie.length; 
	}
    return unescape(document.cookie.substring(offset, endstr)); 
}

function getCookie(name)	{
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);

	if (begin == -1)	{
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	}	else	{
		begin += 2;
	}

	var end = document.cookie.indexOf(";", begin);
	if (end == -1)	{
		end = dc.length;
	}
	return unescape(dc.substring(begin + prefix.length, end));
}

function SetCookie (name, value) { 
	var argv = SetCookie.arguments; 
    var argc = SetCookie.arguments.length; 
    var expires = (argc > 2) ? argv[2] : null; 
    var path = (argc > 3) ? argv[3] : null; 
    var domain = (argc > 4) ? argv[4] : null; 
    var secure = (argc > 5) ? argv[5] : false; 
    document.cookie = name + "=" + escape (value); 
} 

function addToCart(strSerialNo)	{
	var cookieValue;
	cookieValue = GetCookie('selectedItem');
	if (document.getElementById('selectedItem').value != "")	{
		document.getElementById('selectedItem').value = document.getElementById('selectedItem').value + ",";
	}
	if (cookieValue != null)	{
		cookieValue += ",";
	}	else	{
		cookieValue = "";
	}
	
	document.getElementById(strSerialNo + 'add').style.display = 'none';
	document.getElementById(strSerialNo + 'remove').style.display = 'block';
	document.getElementById('selectedItem').value = document.getElementById('selectedItem').value + strSerialNo;
	document.cookie="selectedItem=" + cookieValue + strSerialNo;
	
	dynamicShowCheckout();
}

function removeFromCart(strSerialNo)	{
	var strSerialNos = document.getElementById('selectedItem').value.split(",");
	var strNewValue	= '';
	var cookieValue;
	cookieValue = GetCookie('selectedItem');
	
	for (intCounter = 0; intCounter <= (strSerialNos.length - 1); intCounter++)	{
		if (strSerialNo.replace(",", "") != strSerialNos[intCounter])	{
			strNewValue	+=	strSerialNos[intCounter] + ','
		}
	}

	document.getElementById('selectedItem').value = strNewValue;
	SetCookie("selectedItem", strNewValue);
	document.getElementById(strSerialNo + 'add').style.display = 'block';
	document.getElementById(strSerialNo + 'remove').style.display = 'none';
	dynamicShowCheckout();
}

function displayWarning()	{
	alert("You Will be Logged Out of the System in 5 minutes.\nPlease Save your Work to avoid the automatic logout.");
}

function setWarning()	{
	setTimeout('displayWarning()',900000);
}

function moveUp(strElementName)	{
	if (document.getElementById(strElementName).selectedIndex >= 1)	{
		var selectIndex	=	document.getElementById(strElementName).selectedIndex;

		var tempValue	=	document.getElementById(strElementName).options[selectIndex - 1].value;
		var tempText	=	document.getElementById(strElementName).options[selectIndex - 1].text;

		document.getElementById(strElementName).options[selectIndex - 1].value	= document.getElementById(strElementName).options[selectIndex].value;
		document.getElementById(strElementName).options[selectIndex - 1].text	= document.getElementById(strElementName).options[selectIndex].text;

		document.getElementById(strElementName).options[selectIndex].value	= tempValue;
		document.getElementById(strElementName).options[selectIndex].text	= tempText;
	}
}


function Querystring(qs)	{
	this.params = new Object()
	this.get=Querystring_get
	if (qs == null)	{
		qs=location.search.substring(1,location.search.length);
	}
	if (qs.length == 0)	{
		return;
	}

	qs = qs.replace(/\+/g, ' ');

	var args = qs.split('&');

	for (var i=0;i<args.length;i++)	{
		var pair = args[i].split('=');
		name = unescape(pair[0]);

		var value;
		if (pair.length == 2)	{
			value = unescape(pair[1]);
		}	else	{
			value = name;
		}

		this.params[name] = value;
	}
}

function Querystring_get(key, default_) {
	if (default_ == null)	{
		default_ = null;
	}
	
	var value=this.params[key];
	
	if (value==null)	{
		value=default_;
	}

	return value;
}

function showPage(strPage, intPage)	{
	var	qs	=	new	Querystring
	var	strAction	=	strPage;
	
	strAction		+=	"?pageNumber=" + intPage;
	
	if (qs.get("ContentLocation")	!=	null)	{
		strAction	+=	"&ContentLocation="	+	qs.get("ContentLocation")
	}
	
	if (qs.get("AvailableHardCopy") !=	null)	{
		strAction	+=	"&AvailableHardCopy=Yes";
	}
	
	if (qs.get("Category")		!=	null)	{
		strAction	+=	"&Category="		+	qs.get("Category");
	}

	if (qs.get("County")		!=	null)	{
		strAction	+=	"&County="		+	qs.get("County");
	}
	
	if (qs.get("Date")		!=	null)	{
		strAction	+=	"&Date="		+	qs.get("Date");
	}
	
	if (qs.get("Description")	!=	null)	{
		strAction	+=	"&Description="		+	qs.get("Description");
	}

	if (qs.get("InterestArea")	!=	null)	{
		strAction	+=	"&InterestArea="	+	qs.get("InterestArea");
	}
	
	if (qs.get("ISBN")		!=	null)	{
		strAction	+=	"&ISBN="		+	qs.get("ISBN");
	}
	
	if (qs.get("ISDN")		!=	null)	{
		strAction	+=	"&ISDN="		+	qs.get("ISDN");
	}

	if (qs.get("IU")		!=	null)	{
		strAction	+=	"&IU="			+	qs.get("IU");
	}

	if (qs.get("LName")		!=	null)	{
		strAction	+=	"&LName="		+	qs.get("LName");
	}

	if (qs.get("MaterialFormat")	!=	null)	{
		strAction	+=	"&MaterialFormat="	+	qs.get("MaterialFormat");
	}

	if (qs.get("MaterialType") 	!=	null)	{
		strAction 	+= 	"&MaterialType="	+	qs.get("MaterialType");
	}
	
	if (qs.get("Name")		!=	null)	{
		strAction	+=	"&Name="		+	qs.get("Name");
	}

	if (qs.get("OfficeLocation")	!=	null)	{
		strAction	+=	"&OfficeLocation="	+	qs.get("OfficeLocation");
	}
	
	if (qs.get("Presenter")		!=	null)	{
		strAction	+=	"&Presenter="	+	qs.get("Presenter");
	}
	
	if (qs.get("Search")	!=	null)	{
		strAction	+=	"&Search="		+	qs.get("Search");
	}

	if (qs.get("SortBy")		!=	null)	{
		strAction	+=	"&SortBy="		+	qs.get("SortBy");
	}
	
	if (qs.get("Sponsor")		!=	null)	{
		strAction	+=	"&Sponsor="		+	qs.get("Sponsor");
	}

	if (qs.get("Title")		!=	null)	{
		strAction	+=	"&Title="		+	qs.get("Title");
	}
	
	if (qs.get("Type")		!=	null)	{
		strAction	+=	"&Type="		+	qs.get("Type");
	}

    if (qs.get("Excludes") != null) {
        strAction += "&Excludes=" + qs.get("Excludes");
    }
	window.document.PaTTANForm.action=strAction;
	window.document.PaTTANForm.submit();
}

function noPostBack(sNewFormAction)	{
    window.document.PaTTANForm.action = sNewFormAction;
    window.document.PaTTANForm.__VIEWSTATE.name = 'NOVIEWSTATE';
	window.document.PaTTANForm.submit();
}