<!--
// ----------------------------------------------------
// DHTML Popup Scripts
// Copyright Original T Limited
// ----------------------------------------------------

var popCurrent = ""
var popLeft = 0
var popTop = 0
var popWidth = 0
var popHeight = 0
var popTime = 0

var flashContentHolder = ""

var IE = document.all?true:false
if (document.captureEvents) document.captureEvents(Event.MOUSEMOVE);

function popup(subobjstr, opt_position){



	if (document.getElementById){

		var subobj=document.getElementById(subobjstr)
		if (subobj.style.display!="block") {
			if (popCurrent != "") { popupclose(); } // close currently open popup
			subobj.style.filter="progid:DXImageTransform.Microsoft.alpha(opacity=0)";
			subobj.style.display="block";
			popCurrent = subobjstr
		} else {
			popupclose();
		}
		var pageWidth = document.body.offsetWidth
		xpos = (pageWidth/2) - (subobj.offsetWidth/2)
		var ypos=document.getElementById("popupBorder").offsetTop + 70
		subobj.style.left=xpos+"px"
		subobj.style.top=ypos+"px"
		popLeft=xpos
		popTop=ypos
		popWidth = subobj.offsetWidth
		popHeight = subobj.offsetHeight
		clearTimeout(popTime)
		popTime = setTimeout("captureMouseMovement()",500); // slight delay until clicks outside popup recognised
		if (IE) { fadeStart = setInterval("fadeInLayer('" + subobjstr + "')",5); }
		
		return false
	
	} else {
		return true
	}
}


function feedback(pageName) {

	popUpWindow("/shop/feedback.asp?page=" + pageName,100,100,500,600);
	
}

var popUpWin=0;

function popUpWindow(URLStr, left, top, width, height)

{

  if(popUpWin)

  {

    if(!popUpWin.closed) popUpWin.close();

  }

  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');

}



function fadeInLayer(str) {

	var obj=document.getElementById(str)
	var currOpacity = obj.filters.item('DXImageTransform.Microsoft.alpha').opacity
	if (currOpacity < 100) {
		obj.style.filter="progid:DXImageTransform.Microsoft.alpha(opacity=" + (currOpacity+10) + ")";
	} else {
		clearInterval(fadeStart);
	}
}
function getposOffset(overlay, offsettype){
	var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;
	var parentEl=overlay.offsetParent;
	while (parentEl!=null){
		totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
		parentEl=parentEl.offsetParent;
	}
	return totaloffset;
}

function captureMouseMovement() {
	if (popTime) {
		clearTimeout(popTime)
		popTime = 0
	}
	document.onclick=popupout
	if (document.captureEvents) document.captureEvents(Event.CLICK);
}

function popupout(e) {
	if (popCurrent != "") {
		var xMs = (IE)? event.clientX : e.pageX
		var yMs = (IE)? event.clientY : e.pageY
		popHeight = document.getElementById(popCurrent).offsetHeight
	
		if ((xMs < popLeft) || (xMs > (popLeft + popWidth)) || (yMs < popTop) || (yMs > (popTop + popHeight))) {
			popupclose();
			document.onclick="";
		}
	}
}

function popupclose(){
	if (popCurrent) { document.getElementById(popCurrent).style.display="none" }
	popCurrent = ""
	document.onclick="";
	if (popTime) {
		clearTimeout(popTime)
		popTime = 0
	}

}

var currentPopupHolder = "" // stored value used to populate div after ajax request

function getPopupData(divName, URL) {
	currentPopupHolder = divName
	processData(AJAXRequest("get", "/shop/ajax/" + URL, "", processData))
}

function processData (myAJAX) {
	document.getElementById(currentPopupHolder + "Content").innerHTML = "<div align='left'><img src='/images/timer.gif' width='30' height='30' /></div>"
    if (myAJAX.readyState == 4) {
        if (myAJAX.status == 200) {
            var response = myAJAX.responseText;
			document.getElementById(currentPopupHolder + "Content").innerHTML = response
			addContentLoaded(currentPopupHolder)
			//currentPopupHolder = ""
        } else {
            popupclose()
			alert("There was a problem retrieving the XML data:\n" + myAJAX.statusText);
        }
    }
}


function initialisePopups() {

	// initialise all popup windows
	
	// standard variables
	width = "650";
	height = "500";
	
	if ((BrowserDetect.OS == "Mac") && (BrowserDetect.browser == "Firefox")) { width = "510" };
	// test for mac firefox
	
	drawPopup("aboutus", "About Us", width, height);
	drawPopup("faqs", "Frequently Asked Questions", width, height);
	drawPopup("terms", "Terms & Conditions", width, height);
	drawPopup("privacy", "Privacy", width, height);
	drawPopup("security", "Security", width, height);
	drawPopup("shipping", "Shipping Info", width, height);
	drawPopup("contactus", "Contact Us", width, height);
	drawPopup("returns", "Returns Policy", width, height);
	drawPopup("stylehelp", "Help - Styles", width, height);
	drawPopup("previewhelp", "Help - Preview", width, height);
	drawPopup("makeitoriginalhelp", "Help - Make it Original", width, height);
	drawPopup("sizehelp", "Help - Size & Quantity", width, height);
	drawPopup("zoom", "Zoom", width, height);
	drawPopup("preview", "Info", width, height);
	drawPopup("basket", "Basket", width, height);
	drawPopup("welcome", "Welcome", width, height);
	drawPopup("baskethelp", "Help", width, height);
	

}

var contentLoaded = new Array()

function isContentLoaded(contentName) {
	for (i=0;i<contentLoaded.length;i++) {
		if(contentLoaded[i]==contentName) { return true }
	}
	return false
}
function addContentLoaded(contentName) {
	// check to see whether content already loaded
	if (!isContentLoaded(contentName)) {
		contentLoaded.push(contentName)
	}
}

// the following means all shops see the same intro
// but check to see if any welcome message exists, and if so, don't populate with the default message.
if (introText == "") {
	introText = "<div style='font-weight:normal'><p style='font-size:20px; font-family:Arial, sans serif; font-weight:bold'>IT'S YOUR LIFE. WEAR IT.</p><p><strong>Come on, you had a brilliant time.  You’ve got the memories, you’ve got the photos. (Unfortunately, someone else has probably got the video.)</strong></p><p>But never mind – this is your chance to commemorate a brilliant time with a brilliant T-shirt, designed instantly, on-line, by brilliant you.</p><p>Choose your size: men’s, women’s, kids’, even babies’. Choose the colour and style that suits you best. Add to our logo your own, immortal words - names, dates, places – whatever will keep your memories alive until the day your shirt disintegrates. (Then you’ll just have to come back!)</p<p>Of course we will move heaven and earth to get your items to you as quickly as possible.</p><p>To check out available styles, colours and logos, just <a href=\"javascript:popupclose()\">close this window.</a></p><p>Happy shopping.</p></div>"
}

function showPopup(linkName) {
// find popup element
// test to see if ajax request made for current state and load if not

	//GB_showCenter(linkName, '/shop/ajax/' + linkName + '.asp?itemID=' + findElementPair("itemID"), 450, 600)
	var aw = window.open('/shop/ajax/' + linkName + '.asp?itemID=' + findElementPair("itemID"),'infoWindow','width=600,height=400,scrollbars=yes');
	aw.focus();
	
/*	popup(linkName)
	if (linkName == "basket") {
		document.getElementById("basketContent").innerHTML = "<div align='left'><img src='/images/timer.gif' width='30' height='30' /></div>"
		getPopupData(linkName,linkName + ".asp?id=" + Math.random())
		return
	}
	if (linkName == "preview") {
		document.getElementById("previewContent").innerHTML = "<div align='left'><img src='/images/timer.gif' width='30' height='30' /></div>"
		getPopupData(linkName,linkName + ".asp?itemID=" + findElementPair("itemID"))
		return
	}
	
	if (linkName == "welcome") {
		document.getElementById("welcomeContent").innerHTML = introText
		return
	}
	
	if (!isContentLoaded(linkName)) {
		getPopupData(linkName,linkName + ".asp")
	}
*/
	return true
}

function showPopupZoom(imageRef) {

	popup("zoom")

	// load zoomed logo into popup window
	document.getElementById("zoomContent").innerHTML = "<div align='left'><img src='/images/timer.gif' width='30' height='30' /></div>"
	document.getElementById("zoomContent").innerHTML = "<div style=\"position:relative;height:380px;margin-right: 5px; padding-right: 10px;OVERFLOW: auto; font-weight:normal; background-color: #F1F1F1;\"><div align=\"center\"><div id=\"flashcontentzoom\" style=\"padding:0px; margin:0px;\"></div></div>"

		var so = new SWFObject("/partners/logos/" + imageRef, "myFlashZoom", "400", "360", "8", "#FFFFFF");
		so.addParam("quality", "high");
		so.addParam("wmode", "transparent");
		so.addParam("allowScriptAccess", "sameDomain");
		so.write("flashcontentzoom");
		//alert("/partners/images/" + imageRef)
	//getPopupData("zoom","zoom" + ".asp?id=" + imageRef)
	return
	
}

function drawPopup(divName, title, width, zIndex) {

	// prepare standard popup panel
	var divStr = "";
	divStr += "<div class=\"sec\" id=\"" + divName + "\" style=\"position:absolute; display:none; width: " + width + "px; padding: 8px; z-index:"+ zIndex + ";\"><b class=\"b1\"></b><b class=\"b2\"></b><b class=\"b3\"></b><b class=\"b4\"></b><div class=\"boxcontent\"><p style=\"float:right\"><a class=\"sec\" href=\"javascript:popupclose()\">[X] CLOSE</a>&nbsp;&nbsp;</p><p align=\"left\">" + title.toUpperCase() + "</p></div>"
	divStr += "<div class=\"raised\"><div class=\"boxcontent\"><div id=\"" + divName + "Content\" style=\"background-color:#FFFFFF; color:#000000; padding-top:5px;\"></div>";
	divStr += "</div><b class=\"b4b\"></b><b class=\"b3b\"></b><b class=\"b2b\"></b><b class=\"b1b\"></b></div></div>";
	document.writeln(divStr);

//	divStr += "<div class=\"raised\" id=\"" + divName + "\" style=\"position:absolute; display:none; width: " + width + "px; padding: 8px; z-index:"+ zIndex + ";\"> <b class=\"b1\" style=\"background-color:" + cssSback + "\"></b><b class=\"b2\" style=\"background-color:" + cssSback + "\"></b><b class=\"b3\" style=\"background-color:" + cssSback + "\"></b><b class=\"b4\" style=\"background-color:" + cssSback + "\"></b>";
//	divStr += "<div class=\"boxcontent\"><div style=\"background-color:" + cssSback + "; color:#FFFFFF\"><p align=\"left\" class=\"sec\">" + title.toUpperCase() + "</p>";
//    divStr += "<div id=\"" + divName + "Content\"></div>";
//	divStr += "</div><b class=\"b4b\"></b><b class=\"b3b\"></b><b class=\"b2b\"></b><b class=\"b1b\"></b></div>";
//	document.writeln(divStr);
	// Javascript for close button below
	// <a href=\"javascript:popupclose();\"><img src=\"/images/buttons/close_but.gif\" alt=\"Close\" width=\"16\" height=\"16\" border=\"0\" align=\"right\" /></a>
}

// -->