/* ---------------------------------------------------------------------
COPYRIGHT LINCS MEDIA LTD. ALL RIGHTS RESERVED.
ALL CODE IS FULLY PROTECTED BY COPYRIGHT LAWS AND INTERNATIONAL TREATY
PROVISIONS AND IS CONSIDERED A TRADE SECRET BELONGING TO THE COPYRIGHT HOLDER.

ANY UNAUTHORIZED REPRODUCTION OR DISTRIBUTION OF THIS CODE IN PART
OR IN ITS ENTIRETY IS STRICTLY PROHIBITED.
----------------------------------------------------------------------*/

function check_option(product_id, cat_id, loc)
{	
	if(product_id == '-')
	{
		alert('Please select an option from the menu.');
		document.getElementById("option").focus();
	}
	else
	{
		if(cat_id > 0)
		{
			product_id = cat_id + '/' + product_id;
		}

		document.location = 'http://www.sportsbikeshop.co.uk/motorcycle_parts/' + loc + '/' + product_id;
	}
}

function search_submit()
{
	term = document.getElementById("search_term_head").value;
	
	if(term == '')
	{
		term = '_';
	}

	document.location = 'http://www.sportsbikeshop.co.uk/motorcycle_parts/search/' + term;
}

function openSignup(close)
{
	winWidth = 800;
	winHeight = 750;
	xPos = (screen.width - winWidth) / 2;
	yPos = 100;
	signUp = window.open('http://join.sportsbikeshop.co.uk','signup_window','toolbar=0,menubar=0,scrollbars=yes,scrolling=auto,status=0,resizable=0,top=' + yPos + ',left=' + xPos + ',width=' + winWidth + ',height=' + winHeight);
	signUp.blur();
	if(close == 'true')
	{
		signUp.window.close();
	}
	window.focus();
}

ns = ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >= 3));
ie = ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4));

function openWindow(url, width, height, x, y)
{
	if ((ns))window.open(url,"displayWindow","toolbar=no,width=" + width + ",height=" + height + ",left=" + x + ",top=" + y + ",directories=no,status=no,scrollbars=yes,resizable=yes,menubar=no");
	if ((ie))window.open(url,"displayWindow","type=fullWindow,toolbar=no,width=" + width + ",height=" + height + ",left=" + x + ",top=" + y + ",directories=no,status=no,scrollbars=yes,resizable=yes");
}

function sendQuery(loc)
{
	if(loc == 'home')
	{
		term = query_home.value.toUpperCase();
	}
	else
	{
		term = query.value.toUpperCase();
	}
	term = term.replace(' ', '+');
	loc = 'http://www.sportsbikeshop.co.uk/motorcycle_parts/login/' + term
	document.location = loc;
}

function showhide(layer_ref)
{
	if(document.all)
	{
		if(eval( "document.all." + layer_ref + ".style.display") == 'none')
		{
			state = 'block';
			tab = 'tab_details_hide'
		}
		else
		{
			state = 'none';
			tab = 'tab_details'
		}
		eval( "document.all." + layer_ref + ".style.display = state");
		if(layer_ref == 'box_details')
		{
			document.images["tab_details"].src = "http://www.sportsbikeshop.co.uk/images/" + tab + ".gif";
		}
	}
	if(document.layers)
	{
		if(document.layers[layer_ref].display == 'none')
		{
			state = 'block';
			tab = 'tab_details_hide'
		}
		else
		{
			state = 'none';
			tab = 'tab_details'
		}
		document.layers[layer_ref].display = state;
		if(layer_ref == 'box_details')
		{
			document.images["tab_details"].src = "http://www.sportsbikeshop.co.uk/images/" + tab + ".gif";
		}
	}
	if(document.getElementById && !document.all)
	{ 
		hza = document.getElementById(layer_ref);
		if(hza.style.display == 'none')
		{
			state = 'block';
			tab = 'tab_details_hide'
		}
		else
		{
			state = 'none';
			tab = 'tab_details'
		}
		hza.style.display = state;
		if(layer_ref == 'box_details')
		{
			document.images["tab_details"].src = "http://www.sportsbikeshop.co.uk/images/" + tab + ".gif";
		}
	}
}

function favorites()
{
	logFav = new Image();
	logFav.src = "http://www.sportsbikeshop.co.uk/bookmark.php";
	
	var url = 'http://www.sportsbikeshop.co.uk/#BOOKMARK';
	var title = 'SPORTSBIKESHOP';
	
	if(window.sidebar)
	{
		window.sidebar.addPanel(title, url, "");
	}
	else if( window.external )
	{
		window.external.AddFavorite( url, title);
	}
	else if(window.opera && window.print)
	{
		return true;
	}
}


function externalLinks()
{   
	if(!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for(var i=0; i < anchors.length; i++)
	{
		var anchor = anchors[i];
		if(anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
		{
			anchor.target = "_blank";
		}
	}   
}

addthis_pub = 'sportsbikeshop';

var dom = (document.getElementById) ? true : false;
var ns5 = (!document.all && dom || window.opera) ? true: false;
var ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
var ie4 = (document.all && !dom) ? true : false;
var nodyn = (!ns5 && !ie4 && !ie5 && !dom) ? true : false;

var origWidth, origHeight;

if(nodyn){ event = "nope"; }

var tipFollowMouse = false;
var offX = 20;
var offY = 12;
var tipWidth = '150px'; 
var tipBgColor = '#ffffff';
var tipFontColor = '#000000';
var tipFontFamily = 'Verdana, arial, helvetica, sans-serif';
var tipFontSize = '11px';
var tipBorderColor = '#336699';

var startStr = '<table width="' + tipWidth + '"><tr><td align="center" width="100%"><img src="';
var midStr = '" border="0"></td></tr><tr><td align="center" valign="top">';
var endStr = '</td></tr></table>';

var tooltip, tipcss;

function initTip()
{
	if(nodyn) return;
	tooltip = (ie4)? document.all['tipDiv']: (ie5||ns5)? document.getElementById('tipDiv'): null;
	tipcss = tooltip.style;
	if(ie4||ie5||ns5)
	{
		tipcss.width = tipWidth;
		tipcss.fontFamily = tipFontFamily;
		tipcss.fontSize = tipFontSize;
		tipcss.color = tipFontColor;
		tipcss.backgroundColor = tipBgColor;
		tipcss.borderColor = tipBorderColor;
		tipcss.borderWidth = '2px';
		tipcss.padding = '4px';
		tipcss.borderStyle = 'solid';
	}
}

var t1,t2;
var tipOn = false;

function doTooltip(evt, imgUrl, prodTitle)
{
	if(!tooltip) return;
	if(t1) clearTimeout(t1);
	if(t2) clearTimeout(t2);
	tipOn = true;
	
	curBgColor = tipBgColor;
	curFontColor = tipFontColor;

	if(ie4||ie5||ns5)
	{
		var tip = startStr + imgUrl + midStr + '<span style="font-family:' + tipFontFamily + '; font-size:' + tipFontSize + '; color:' + curFontColor + ';">' + prodTitle + '</span>' + endStr;
		tipcss.backgroundColor = curBgColor;
	 	tooltip.innerHTML = tip;
	}
	
	positionTip(evt);
}

function positionTip(evt)
{
	standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body
	mouseX = (ns5)? evt.pageX: window.event.clientX + standardbody.scrollLeft;
	mouseY = (ns5)? evt.pageY: window.event.clientY + standardbody.scrollTop;
		
	var tpWd = (ie4||ie5)? tooltip.clientWidth: tooltip.offsetWidth;
	var tpHt = (ie4||ie5)? tooltip.clientHeight: tooltip.offsetHeight;
	
	var winWd = (ns5)? window.innerWidth-20+window.pageXOffset: standardbody.clientWidth+standardbody.scrollLeft;
	var winHt = (ns5)? window.innerHeight-20+window.pageYOffset: standardbody.clientHeight+standardbody.scrollTop;

	tipcss.left = '630px';
	tipcss.top = mouseY-(tpHt/2)+"px";
	
	t1 = setTimeout("tipcss.visibility='visible'", 100);
}

function hideTip()
{
	if(!tooltip) return;
	t2 = setTimeout("tipcss.visibility='hidden'", 100);
	tipOn = false;
}

function initPage()
{
	initTip();
	externalLinks();
}

window.onload = initPage;

document.write('<div id="tipDiv" style="position:absolute; visibility:hidden; z-index:100;"></div>');