
/***********************************************
* Show Hint script- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/
		
var horizontal_offset="-10px" //horizontal offset of hint box from anchor link

/////No further editting needed

var vertical_offset="5" //horizontal offset of hint box from anchor link. No need to change.
var ie=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
if (whichedge=="rightedge"){
var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset)
}
else{
var windowedge=ie && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
}
return edgeoffset
}

function showhint(menucontents, obj, e, tipwidth, codeID){
if ((ie||ns6) && document.getElementById("hintbox")){
dropmenuobj=document.getElementById("hintbox")
dropmenuobj.innerHTML=menucontents
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (tipwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=tipwidth
}
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
dropmenuobj.style.visibility="visible"
obj.onmouseout=function () { hidetip(); HidePromoCode(codeID); }
}
}

function hidetip(e){
dropmenuobj.style.visibility="hidden"
dropmenuobj.style.left="-500px"
}

function createhintbox(){
var divblock=document.createElement("div")
divblock.setAttribute("id", "hintbox")
document.body.appendChild(divblock)
}

if (window.addEventListener)
window.addEventListener("load", createhintbox, false)
else if (window.attachEvent)
window.attachEvent("onload", createhintbox)
else if (document.getElementById)
window.onload=createhintbox

function CopyValueAndOpenWin(codeID, urlAddress) {
	
	var localCodeID = codeID;
	var localUrlAddress = urlAddress;
	
	var elemObj = document.getElementById('ValueElem' + localCodeID);
	copy(elemObj);
	
	window.open(''+localUrlAddress+'','mywindow','width=' + screen.width + ',height=' + screen.height + ',resizable=yes,scrollbars=yes,toolbar=yes,location=yes,status=yes,menubar=yes');
}

function copy(inElement) {
  if (inElement.createTextRange) {
  	// IE
    var range = inElement.createTextRange();
    if (range)
      range.execCommand('Copy');
  } else {
  	// Other
  	/*
    var flashcopier = 'flashcopier';
    if(!document.getElementById(flashcopier)) {
      var divholder = document.createElement('div');
      divholder.id = flashcopier;
      document.body.appendChild(divholder);
    }
    document.getElementById(flashcopier).innerHTML = '';
    var divinfo = '<embed src="_clipboard.swf" FlashVars="clipboard='+encodeURIComponent(inElement.value)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
    document.getElementById(flashcopier).innerHTML = divinfo;    
    */
  }
}

function ShowPromoCode(codeID, passedPromoCode) {
	
	var localCodeID = codeID;
	var localPROMO = passedPromoCode;
	
	var promoDiv = document.getElementById('PromoCodeDiv' + localCodeID);
	if (promoDiv) {
		promoDiv.innerHTML = localPROMO;
	}
}

function HidePromoCode(codeID) {
	
	var localCodeID = codeID;
		
	var promoDiv = document.getElementById('PromoCodeDiv' + localCodeID);	
	//alert('PromoCodeDiv' + localCodeID);
	if (promoDiv) {		
		promoDiv.innerHTML = '&raquo; CLICK HERE &laquo;';
	}
}

function ShowCode(codeID) {
	
	var localPROMO = PromoCode;
	var localCodeID = codeID;
	var localURL = urlAddress;
	var localDisTEXT = discountText;
	var localImportURL = urlImportUrl;
	
	document.writeln('<style type="text/css">');

	document.writeln('#hintbox{ /*CSS for pop up hint box */');
	document.writeln('position:absolute;');
	document.writeln('top: 0;');
	document.writeln('background-color: lightyellow;');
	document.writeln('width: 150px; /*Default width of hint.*/ ');
	document.writeln('padding: 3px;');
	document.writeln('border:1px solid black;');
	document.writeln('font:normal 11px Verdana;');
	document.writeln('line-height:18px;');
	document.writeln('z-index:100;');
	document.writeln('border-right: 3px solid black;');
	document.writeln('border-bottom: 3px solid black;');
	document.writeln('visibility: hidden;');
	document.writeln('}');
	
	document.writeln('.hintanchor{ /*CSS for link that shows hint onmouseover*/');
	document.writeln('font-weight: bold;');
	document.writeln('color: navy;');
	document.writeln('margin: 0px;');
	document.writeln('cursor: pointer;');
	document.writeln('}');
	
	document.writeln('</style>');
	
	document.writeln('<input type="hidden" id="ValueElem' + localCodeID + '" value="' + localPROMO + '" />');
	var elemObj = document.getElementById('ValueElem' + localCodeID);
	if (document.all) {
		// IE
		var sHint = 'Click here and we will automatically copy the code to your clipboard and open the site in a new window, simply paste the code into the relevant box during checkout';
	} else {
		// Other
		var sHint = 'Click here to open the site, then write this code in the appropriate box';
	}
	
	document.writeln('<table width="152" border="0" cellpadding="0" cellspacing="0">');
	document.writeln('<tr>');
	document.writeln('<td height="72" style="" align="center" valign="top">');
	document.writeln('<div style="color:#CC0000; font-size:12px; padding:8px 0px 2px 0px; border:0px solid;" class="hintanchor" onclick="CopyValueAndOpenWin(\'' + codeID + '\', \'' + localURL + '\');" onMouseover="showhint(\'' + sHint + '\', this, event, \'150px\', \'' + codeID + '\'); ShowPromoCode(\'' + localCodeID + '\', \'' + localPROMO + '\');"><b>' + localDisTEXT + '</b></div>');
	document.writeln('<div style="color:#000000; font-size:11px; padding:2px 0px 2px 0px; border:0px solid;" class="hintanchor" onclick="CopyValueAndOpenWin(\'' + codeID + '\', \'' + localURL + '\');" onMouseover="showhint(\'' + sHint + '\', this, event, \'150px\', \'' + codeID + '\'); ShowPromoCode(\'' + localCodeID + '\', \'' + localPROMO + '\');"><b>Discount Code Available</b></div>');
	document.writeln('<div style="color:#CC0000; font-size:12px; padding:0px 2px 2px 2px; border:0px solid;" class="hintanchor" id="PromoCodeDiv' + localCodeID + '" onclick="CopyValueAndOpenWin(\'' + codeID + '\', \'' + localURL + '\');" onMouseover="showhint(\'' + sHint + '\', this, event, \'150px\', \'' + codeID + '\'); ShowPromoCode(\'' + localCodeID + '\', \'' + localPROMO + '\');">&raquo; CLICK HERE &laquo;</div>');	
	document.writeln('</td>');
	document.writeln('</tr>');
	document.writeln('</table>');
}

