// JavaScript Document
var photoTags = new Object();  //used for keeping track of hot spot tags on popup photos

function overstate(img)
{
	img.src = img.src.replace(/\.(\w\w\w)$/, "_over.$1");
}

function outstate(img)
{
	img.src = img.src.replace(/_over\./, ".");
}

function strrev(inp) { 
  var outp = ""

  for (i = 0; i <= inp.length; i++) { 
    outp = inp.charAt (i) + outp 
  } 

  return outp;
} 

function writemail(user, domain, tld)
{
	var garbage = "!Fjji68@Mfmki#";
	var at = garbage.charAt(7);
	var nothing = "";
	var eadd = user + at + domain;
	eadd = eadd + "." + strrev(tld);
	document.write("<a href='mai");
	document.write(nothing + "lto");
	document.write(":"+eadd+"' class='emailLinks'>");
	document.write(eadd + "</a>");
}

function sendmail(user, domain, tld)
{
	var garbage = "!Fjji68@Mfmki#";
	var at = garbage.charAt(7);
	var nothing = "";
	var eadd = user + at + domain;
	eadd = eadd + "." + strrev(tld);
	loc = "mai";
	loc = loc + "lto";
	loc = loc + ":" + eadd;
	document.location.href = loc;
}
						
var r = null;
function loadPreview(id, name, url)
{
	if (r == null) r = new Request.HTML({link:'cancel', update:'previewpane'});
	$('previewpane').empty();
	r.get("/productpreview.php?id="+id+"&name="+encodeURIComponent(name)+"&link="+encodeURIComponent(url));
}

function unloadPreview()
{
	$('previewpane').set('html', '<div style="width:100%;height:100%;background-color:#FFF"></div>');
}

//showPopupFrame shows the popup window with the "View Colors" area loaded into it.
//The window needs to be included in the HTML - as it is at the bottom of productdetail_body.php
function showPopupFrame(src, width, height)
{
	if (!SqueezeBox) console.log('Unable to show Popup: SqueezeBox has not been initialized on this page.');
	else {
		options = {handler:'iframe', size:{}};
		if (typeof(width) != "undefined") options.size.x = width + 10;
		if (typeof(height) != "undefined") options.size.y = height + 10;
		SqueezeBox.open(src, options);
	}
}

//toggleDisplay toggles the display state of the element designated by elementID
function toggleDisplay(elementID)
{
	var elem = $(elementID);
	if ((!elem.offsetHeight) || (elem.offsetHeight == 0))
		elem.style.display = "block";
	else
		elem.style.display = "none";
}

function show(elementID)
{
	$(elementID).style.display = "block";
}

function hide(elementID)
{
	$(elementID).style.display = "none";
}