function setFocus(formName,inputFieldName) {
	if(document.layers) {
		var inputField = eval("document." + formName + "." + inputFieldName);
		inputField.focus();
	} else if (document.all) {
		var inputField = eval("document.all['" + formName + "']." + inputFieldName);
		inputField.focus();
	} else {
		var inputField = eval("document.getElementById('" + formName + "')." + inputFieldName);
		inputField.focus();
	}

}

function clearForm() {
	document.topForm.txtTitle.value="";
}
								
function clearOrderForm(formName,inputFieldName) {
	if(document.layers) {
		var inputField = eval("document." + formName + "." + inputFieldName);
	} else if (document.all) {
		var inputField = eval("document.all['" + formName + "']." + inputFieldName);
	} else {
		var inputField = eval("document.getElementById('" + formName + "')." + inputFieldName);
	}
  	var i;
  	for (i = 0; i < inputField.length; i++) {
    	inputField[i].value = "";
    }
}

var agt=navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);
var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie4up  = (is_ie && (is_major >= 4));
var is_nav  = ((agt.indexOf('mozilla')!=-1) && !is_ie && (agt.indexOf('spoofer')==-1));
var is_nav4 = (is_nav && (is_major == 4));
var is_ns6 = (is_nav && (is_major >= 5));
// khtml triumvirate 
var is_khtml = (navigator.vendor == 'KDE')?true:false;
var is_konq = (navigator.vendor == 'KDE')||(document.childNodes)&&(!document.all)&&(!navigator.taintEnabled)?true:false;
var is_safari = (document.childNodes)&&(!document.all)&&(!navigator.taintEnabled)&&(!navigator.accentColorName)?true:false;
var is_omniweb45plus = (document.childNodes)&&(!document.all)&&(!navigator.taintEnabled)&&(navigator.accentColorName)?true:false;

function writeDate() {
var months=new Array(13);
months[1]="1";
months[2]="2";
months[3]="3";
months[4]="4";
months[5]="5";
months[6]="6";
months[7]="7";
months[8]="8";
months[9]="9";
months[10]="10";
months[11]="11";
months[12]="12";
var time=new Date();
var lmonth=months[time.getMonth() + 1];
var date=time.getDate();
var year=time.getYear();
if (year < 2000)    
year = year + 1900; 
document.write(lmonth + "/" + date + "/" + year);
}

function writeYear() {
var time=new Date();
var year=time.getYear();
if (year < 2000)    
year = year + 1900; 
document.write(year);
}
function writeBuildNumber() {
document.write("20050314.1.23");
}
function swapImages(name,bn,status){
	if (document.images && (preloadFlag == true)) {
    	loc=name + bn;
    	document[loc].src=eval(name+ bn + status +".src");
  	}
}

function openPopup(url,w,h) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
	if (url.indexOf('/GreatSource') != -1) {
		popupwin=window.open(url, 'Popup', 'width='+w+',height='+h+',scrollbars=yes,toolbar=no,menubar=no,location=no,titlebar=no,left='+winl+',top='+wint+',screenX='+winl+',screenY='+wint+',resizable=yes,alwaysRaised=yes');
  	} 
	else if (url.indexOf('/professionaldevelopment') != -1) {
		popupwin=window.open(url, 'Popup', 'width='+w+',height='+h+',scrollbars=yes,toolbar=no,menubar=no,location=no,titlebar=no,left='+winl+',top='+wint+',screenX='+winl+',screenY='+wint+',resizable=yes,alwaysRaised=yes');
  	} 
  	else {
		popupwin=window.open(url, 'Popup', 'width='+w+',height='+h+',scrollbars=yes,toolbar=yes,menubar=yes,location=yes,titlebar=yes,left='+winl+',top='+wint+',screenX='+winl+',screenY='+wint+',resizable=yes,alwaysRaised=yes');
  	}
  popupwin.focus();
}

function openInfoPopup(w,h,textToDisplay) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
  popupwin=window.open('/store/ProductCatalogController?cmd=LP&nextPage=GreatSource/popup.jsp', 'popupInfo', 'width='+w+',height='+h+',scrollbars=no,toolbar=no,left='+winl+',top='+wint+',screenX='+winl+',screenY='+wint+',resizable=yes,alwaysRaised=yes');
  popupwin.focus();
}
// FUNCTION TO DELETE COOKIES WRITTEN AT LOGIN - NEEDS TO HAVE cookies.js LOADED
// created by Tom Flaherty 11/09/2007
function submitLogout() {
	var Cookie1 = "ERIGHTS"  
	var Cookie2 = "ERIGHTSUSER"  
	if (!getCookieValue (Cookie1) && !getCookieValue (Cookie2)) {
		alert ('Cookie does not exist')
	}
	else {
		deleteCookie (Cookie1);
		deleteCookie (Cookie2);
		alert ("You have been logged out.");
    }
}
// FUNCTION TO SHOW EITHER LOGIN OR LOGOUT LINKS WITHIN STATIC HTML PAGES - NEEDS TO HAVE cookies.js LOADED
// created by Tom Flaherty 11/09/2007
function loginLogout() {
	var myCookieName = "ERIGHTS"
	if (getCookieValue (myCookieName)) {
		document.write ("<a href=\"/emeta/LogoutController?targeturl=/store/ProductCatalog/webdocs/GreatSource/logoff.jsp&amp;errorurl=/store/CustomerProfileController?cmd=LP&amp;nextPage=GreatSource/MyAccount.jsp&d&amp;ivision=G01\"><img src=\"/GreatSource/images/midbar_logout.gif\" alt=\"Logout\" border=\"0\"><\/a>")
	}
	else {
		document.write  ("<a href=\"/store/CustomerProfileController?cmd=LP&nextPage=GreatSource/MyAccount.jsp&amp;division=G01\" class=\"gstopblack11text\"><img src=\"/GreatSource/images/midbar_login.gif\" alt=\"Login/Register\"><\/a>");
	}
}

// function to open the special offers window
// added by Tom Flaherty 11/09/2007
function openPopupSpecialOffer(w,h) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
	popupwin=window.open('/offers/specialoffer.pdf', 'Popup', 'width='+w+',height='+h+',scrollbars=yes,toolbar=no,menubar=no,location=no,titlebar=no,left='+winl+',top='+wint+',screenX='+winl+',screenY='+wint+',resizable=yes,alwaysRaised=yes');
	popupwin.focus();
}




function openCatalog(theURL,winName) { 
	if (screen.width <= 800)
		{
			theURL = "/GreatSource/virtualpages/catalog/flipbook800.html" 
		}
	else {
			theURL = "/GreatSource/virtualpages/catalog/flipbook1024.html"
		}
	window.open(theURL,winName,"width=1004,height=670,resizable=no,scrollbars=no,status=no ");
}

