var highlightBox = {
	'state':'off',
	'currentProduct':''
};
var productSet = {
	'weblink': {
		'fullname':'<strong>Priority Advert and web link</strong>',
		'state': 'off',
		'left':0,
		'top':298,
		'width':311,
		'height':102
	},
	'priorityAd': {
		'fullname':'<strong>Priority Advert</strong> (without a web link)',
		'state': 'off',
		'left':0,
		'top':402,
		'width':309,
		'height':97
	},
	'moreInfo': {
		'fullname':'<strong>Priority Advert Info Page</strong>',
		'state': 'off',
		'left':0,
		'top':501,
		'width':309,
		'height':101
	},
	'sitebilder': {
		'fullname':'<strong>Site Builder</strong>',
		'state': 'off',
		'left':0,
		'top':604,
		'width':309,
		'height':109
	},
	'lsl': {
		'fullname':'<strong>Local Sponsored Listings</strong>',
		'state': 'off',
		'left':0,
		'top':195,
		'width':309,
		'height':101
	},
	
	'lslCov': {
		'fullname':'<strong>Local Sponsored Listings</strong>',
		'state': 'off',
		'left':320,
		'top':235,
		'width':115,
		'height':127
	},
	
	'ppc': {
		'fullname':'<strong>Pay-per-click keywords</strong>',
		'state': 'off',
		'left':0,
		'top':145,
		'width':309,
		'height':48
	},
	
	'ppcCov': {
		'fullname':'<strong>Pay-per-click keywords</strong>',
		'state': 'off',
		'left':320,
		'top':140,
		'width':115,
		'height':85
	},
	
	
	'natBan': {
		'fullname':'<strong>National Banner adverts</strong>',
		'state': 'off',
		'left':7,
		'top':0,
		'width':277,
		'height':42
	},
	'natBanCov': {
		'fullname':'<strong>National Banner adverts</strong>',
		'state': 'off',
		'left':360,
		'top':0,
		'width':76,
		'height':42
	},
	'localAd': {
		'fullname':'<strong>Local Adverts</strong>',
		'state': 'off',
		'left':284,
		'top':0,
		'width':76,
		'height':42
	},
	'freeAd': {
		'fullname':'<strong>Free listings</strong>',
		'state': 'off',
		'left':0,
		'top':714,
		'width':309,
		'height':64
	},
	'weblinkCov': {
		'fullname':'<strong>Priority Advert and web link</strong>',
		'state': 'off',
		'left':320,
		'top':386,
		'width':115,
		'height':107
	}
};

function highlightProduct(linkObj){
	turnoffProducts();
	var prodName = linkObj.id.replace(/(Link|Map|Cov)$/,"");
	highlightBox['currentProduct'] = prodName;
	if(linkObj.id != "lslCovMap" && linkObj.id != "ppcCovMap" && linkObj.id != "natBanCovMap" && linkObj.id != "weblinkCovMap"){
			document.getElementById(prodName+"Link").parentNode.className = 'on';
	}
		else
	{
	var covprodName = prodName.replace(/(Cov)$/,"");
	document.getElementById(covprodName+"Link").parentNode.className = 'on';
	}
	document.getElementById('adViewer').style.left = (productSet[prodName]['left'] - 2)+'px';
	document.getElementById('adViewer').style.top = (productSet[prodName]['top'] - 2)+'px';
	document.getElementById('adViewer').style.width = (productSet[prodName]['width'])+'px';
	document.getElementById('adViewer').style.height = (productSet[prodName]['height'])+'px';
	
	document.getElementById('searchResViewer').style.left = (0 - productSet[prodName]['left'])+'px';
	document.getElementById('searchResViewer').style.top = (0 - productSet[prodName]['top'])+'px';
	
	document.getElementById('toolTip').style.left = (productSet[prodName]['left'] - 2)+'px';
	document.getElementById('toolTip').style.top = (productSet[prodName]['top'] - 37)+'px';
	
	document.getElementById('prodNameTip').innerHTML  = productSet[highlightBox['currentProduct']]['fullname'];
	document.getElementById('adViewer').style.display = '';
	document.getElementById('toolTip').style.display = '';
	highlightBox['state'] = 'on';
}
function turnoffProducts(prodName){
	document.getElementById('adViewer').style.display = 'none';
	document.getElementById('toolTip').style.display = 'none';
	//document.getElementById('searchResNormal').style.display = '';
	var adTypeList = document.getElementById('adTypeList');
  	var adTypeLinks = adTypeList.getElementsByTagName('a');
	for (var i = 0; i < adTypeLinks.length; i++) {
		var listTag = adTypeLinks[i].parentNode;
		listTag.className = '';
	}
	highlightBox['state'] = 'off';
}

function openPop(){
	closePops();
	var popUp = highlightBox['currentProduct']+'Pop';
	document.getElementById(popUp).style.display = '';
}
function updateTooltip(evt) {
	if(highlightBox['state'] == 'on'){
		mouseX=evt.pageX?evt.pageX:evt.clientX;
		mouseY=evt.pageY?evt.pageY:evt.clientY;
		document.getElementById('toolTip').style.left=mouseX + 15 ;
		document.getElementById('toolTip').style.top=mouseY + 15;  
		document.getElementById('prodNameTip').innerHTML  = productSet[highlightBox['currentProduct']]['fullname'];
	}
}
function getElementsByClassName(oElm, strTagName, strClassName){
    var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
    var arrReturnElements = new Array();
    strClassName = strClassName.replace(/\-/g, "\\-");
    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
    var oElement;
    for(var i=0; i<arrElements.length; i++){
        oElement = arrElements[i];      
        if(oRegExp.test(oElement.className)){
            arrReturnElements.push(oElement);
        }   
    }
    return (arrReturnElements)
}
function closePops(){
	var allPops = getElementsByClassName(document, '*', 'prodPop');
	for(var i=0; i<allPops.length; i++){
        allPops[i].style.display = 'none';
    }
}
