﻿//var base = "http://andypc2/LNOF/";
var base = "http://www.henpartyaccessories.com/";
var url = window.location.toString();
if(url.indexOf("andypc") != -1)
{
    base = "http://andypc2/HenPartyAccessories/";
}
else if (url.indexOf("chrispc") != -1) {
    base = "http://chrispc/HenPartyAccessories/";
}
else if (url.indexOf("e-volve") != -1) {
    base = "http://hpa.e-volve.co.uk/";
}
else
{
    if(url.indexOf("https:") != -1)
    {
	    base = base.replace("http:","https:");
    }
}


// Initializes a new instance of the StringBuilder class
// and appends the given value if supplied
function StringBuilder(value)
{
    this.strings = new Array("");
    this.append(value);
}
// Appends the given value to the end of this instance.
StringBuilder.prototype.append = function (value)
{
    if (value)
    {
        this.strings.push(value);
    }
}
// Clears the string buffer
StringBuilder.prototype.clear = function ()
{
    this.strings.length = 1;
}
// Converts this instance to a String.
StringBuilder.prototype.toString = function ()
{
    return this.strings.join("");
}


var offsetfrommouse = [15,15]; //image x,y offsets from cursor position in pixels. Enter 0,0 for no offset
var displayduration = 0; //duration in seconds image should remain visible. 0 for always.
var currentimageheight = 5;	// maximum image size.

if (document.getElementById || document.all){
	document.write('<div id="CssPopUp">');
	document.write('</div>');
}
function gettrailobj()
{
	if (document.getElementById)
		return document.getElementById("CssPopUp").style
	else if (document.all)
		return document.all.trailimagid.style
}

function gettrailobjnostyle()
{
	if (document.getElementById)
		return document.getElementById("CssPopUp")
	else if (document.all)
		return document.all.trailimagid
}
function truebody()
{
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}
function showtrail(title,description)
{
	document.onmousemove=followmouse;
	var newHTML = new StringBuilder();
	newHTML.append('<div class="CssRollOver">');
	newHTML.append('<b>' + title + '</b><br /><br />');
	newHTML.append(description + '<br />');
	newHTML.append('</div>');
	gettrailobjnostyle().innerHTML = newHTML.toString();
	gettrailobj().visibility="visible";
}
function showtrail2(title,description)
{
	document.onmousemove=followmouse;
	var newHTML = new StringBuilder();
	newHTML.append('<div class="CssRollOver2">');
	newHTML.append('<b>' + title + '</b><br /><br />');
	newHTML.append(description + '<br />');
	newHTML.append('</div>');
	gettrailobjnostyle().innerHTML = newHTML.toString();
	gettrailobj().visibility="visible";
}
function hidetrail(){
	gettrailobj().visibility="hidden"
	document.onmousemove=""
	gettrailobj().left="-500px"
}
function followmouse(e){

	var xcoord=offsetfrommouse[0]
	var ycoord=offsetfrommouse[1]

	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)

	if (typeof e != "undefined"){
		if (docwidth - e.pageX < 300){
			xcoord = e.pageX - xcoord - 286; // Move to the left side of the cursor
		} else {
			xcoord += e.pageX;
		}
		if (docheight - e.pageY < (currentimageheight + 110)){
			ycoord += e.pageY - Math.max(0,(110 + currentimageheight + e.pageY - docheight - truebody().scrollTop));
		} else {
			ycoord += e.pageY;
		}

	} else if (typeof window.event != "undefined"){

		if (docwidth - event.clientX < 300){
			xcoord = event.clientX + truebody().scrollLeft - xcoord - 286; // Move to the left side of the cursor
		} else {
			xcoord += truebody().scrollLeft+event.clientX
		}
		if (docheight - event.clientY < (currentimageheight + 110)){
			ycoord += event.clientY + truebody().scrollTop - Math.max(0,(110 + currentimageheight + event.clientY - docheight));
		} else {
			ycoord += truebody().scrollTop + event.clientY;
		}
	}

	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.max(truebody().scrollHeight, truebody().clientHeight) : Math.max(document.body.offsetHeight, window.innerHeight)
	if(ycoord < 0) { ycoord = ycoord*-1; }
	gettrailobj().left=xcoord+"px"
	gettrailobj().top=ycoord+"px"

}

function ShowShopTerms()
{
	var url = base + "ShopTerms.aspx";
	zzz = window.open(url,"","width=600,height=600,scrollbars=yes,left=0,top=0");
	zzz.focus();
}

