var thisLocation = parent.location.host;

var rootPath = "http://www.giftwareindex.com/"; //live site. Use absolute address as images are also in pages on quickquotes.giftwareindex.com

if (thisLocation.search(/\.local/) > -1) //intranet site
	rootPath = "http://giftwareindex.local/";

//if (thisLocation == ("uk106")) //uk106 site
//	rootPath = "/giftwareindex/version1/public/";

var imgarr = new Array(25)

imgarr[0]=new Image(); imgarr[0].src = rootPath + "images/home.gif";
imgarr[1]=new Image(); imgarr[1].src = rootPath + "images/home_hi.gif";
imgarr[2]=new Image(); imgarr[2].src = rootPath + "images/productsearch.gif";
imgarr[3]=new Image(); imgarr[3].src = rootPath + "images/productsearch_hi.gif";
imgarr[4]=new Image(); imgarr[4].src = rootPath + "images/companysearch.gif";
imgarr[5]=new Image(); imgarr[5].src = rootPath + "images/companysearch_hi.gif";
imgarr[6]=new Image(); imgarr[6].src = rootPath + "images/quickquotes.gif";
imgarr[7]=new Image(); imgarr[7].src = rootPath + "images/quickquotes_hi.gif";
imgarr[8]=new Image(); imgarr[8].src = rootPath + "images/getlisted.gif";
imgarr[9]=new Image(); imgarr[9].src = rootPath + "images/getlisted_hi.gif";
imgarr[10]=new Image(); imgarr[10].src = rootPath + "images/tellafriend.gif";
imgarr[11]=new Image(); imgarr[11].src = rootPath + "images/tellafriend_hi.gif";
imgarr[12]=new Image(); imgarr[12].src = rootPath + "images/contactus.gif";
imgarr[13]=new Image(); imgarr[13].src = rootPath + "images/contactus_hi.gif";
imgarr[14]=new Image(); imgarr[14].src = rootPath + "images/faq.gif";
imgarr[15]=new Image(); imgarr[15].src = rootPath + "images/faq_hi.gif";
imgarr[16]=new Image(); imgarr[16].src = rootPath + "images/map.gif";
imgarr[17]=new Image(); imgarr[17].src = rootPath + "images/map_hi.gif";
imgarr[18]=new Image(); imgarr[18].src = rootPath + "images/meet.gif";
imgarr[19]=new Image(); imgarr[19].src = rootPath + "images/meet_hi.gif";
imgarr[20]=new Image(); imgarr[20].src = rootPath + "images/free_quote.gif";
imgarr[21]=new Image(); imgarr[21].src = rootPath + "images/free_quote_hi.gif";
imgarr[22]=new Image(); imgarr[22].src = rootPath + "images/free_quote_static.gif";
imgarr[23]=new Image(); imgarr[23].src = rootPath + "images/clearanceboard.gif";
imgarr[24]=new Image(); imgarr[24].src = rootPath + "images/clearanceboard-over.gif";

function swap(imgref, imgto)
	{
	eval ('document.' + imgref + '.src = imgarr[' + imgto + '].src');
	return true;
	}

function optionTestIt()
	{
	optionTest = true;
	lgth = document.catForm.catSelector.options.length - 1;
	document.catForm.catSelector.options[lgth] = null;
	if (document.catForm.catSelector.options[lgth]) optionTest = false;
	var thisURL = window.location.href;
	//if (thisURL.indexOf("index.htm#")) populate('A');
	}

function populate(alpha)
	{
	if (!optionTest) return;
	//var box = document.forms[0].first;
	//var number = box.options[box.selectedIndex].value;
	var number = alpha;
	if (!number) return;
	var list = store[number];
	var box2 = document.catForm.catSelector;
	box2.options.length = 0;
	for(i=0;i<list.length;i+=2)
		{
		box2.options[i/2] = new Option(list[i],list[i+1]);
		}
	}

function go()
	{
	if (!optionTest) return;
	box = document.catForm.catSelector;
	destination = box.options[box.selectedIndex].value;
	if (destination) top.location.href = destination;
	}
	
function RecordClick(ClickID, ClickLocation, MemberID) {
	if (thisLocation.search(/\.local/) > -1 && ClickID == 9) {
		window.location.href = ClickLocation;
		}
	else {
		var strURL = "http://hitcounter.tarsus.co.uk/recordhit.asp?SiteID=6&IDType=" + ClickID + "&PageID=" + MemberID + "&SOK=1";
		strURL += "&URL=" + escape(window.document.URL);
		strURL += "&Referer=" + escape(window.document.referrer);
		strURL += "&BName=" + escape(navigator.appName);
		strURL += "&BVer=" + escape(navigator.appVersion);
		strURL += "&Goto="  + escape(ClickLocation);
		
		if ((ClickID == 8) || (ClickID == 15)) {
			window.open(strURL, "Giftware_Member", "").focus();
			} else {
			window.location.href = strURL;
			}
		}
	}

// Exit Popup Start

// CatArr not use for giftware at present as this popup is to appear on all 
//  category pages (cat_co_###.htm).
var catArr = new Array('782','448','394','426','361','1081','1095','208','216','613' );

var newWindow = null;

function closeWin(){
	if (newWindow != null){
		if(!newWindow.closed)
			newWindow.close();
	}
}

function pop(url, type, strWidth, strHeight){

//var url = '../noticeboard_notice.htm';
var type = 'console';
var strWidth = '430';
var strHeight = '300';

var data = new Cookie(document, "giftware_popup_quote", 30*8766);
var popupviewed = false;

function getCookieData()
{
	//Load any existing cookie containing previous address details of a posted form
	if (data.load())
	{
		popupviewed = data.popupviewed;

	}
}

function saveDataToCookie()
{
	data.popupviewed = true;
	data.store();
}

	getCookieData();
	if (!popupviewed) 
	{
	closeWin();
	
	if (type == "fullScreen"){
		strWidth = screen.availWidth - 10;
		strHeight = screen.availHeight - 160;
	}
	
	var tools="";
	if (type == "standard" || type == "fullScreen") tools = "resizable,toolbar=yes,location=yes,scrollbars=yes,menubar=yes,width="+strWidth+",height="+strHeight+",top=0,left=0";
	if (type == "console") tools = "resizable,toolbar=no,location=no,scrollbars=no,width="+strWidth+",height="+strHeight+",left=0,top=0";
	newWindow = window.open(url, 'newWin', tools);
	newWindow.focus();
	saveDataToCookie();
	}
}

function checkArray() {
	var myStr = window.location.href;
	var pageRef = myStr.substr(myStr.lastIndexOf('/')+8,myStr.lastIndexOf('.')-myStr.lastIndexOf('/')-8);

	for (var i=0; i<catArr.length; ++i)
		{
		if (catArr[i]==pageRef)
			pop();
		}
	}
// Exit Popup End


function openLink(oururl) {
	if (oururl) {
		window.open(oururl);
		return false;
		}
	}