///////////////////////////////////////////////////
// All Contents © Copyright The Glow Company Ltd //
///////////////////////////////////////////////////

// fix ie flicker bug
try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}


//image chooser script
function showimage(imagename, productref){
	document.getElementById("video_holder_" + productref).style.display="none";
	document.getElementById("video_holder_" + productref).innerHTML="";
	document.getElementById("image_" + productref).src=imagename;
	document.getElementById("image_holder_" + productref).style.display="block";
	}

//video player script
function showmovie(videoname, productref){
document.getElementById("image_holder_" + productref).style.display="none";
document.getElementById("video_holder_" + productref).style.display="block";
document.getElementById("video_holder_" + productref).innerHTML='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="320" height="252" id="videoPlayer" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="' + videoname + '" /><param name="quality" value="high" /><param name="bgcolor" value="#000000" /><embed src="' + videoname + '" quality="high" bgcolor="#000000" width="320" height="252" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
}

//video player script 2 (h.264)
function showmovie2(videoname, productref, preimage){
	document.getElementById("image_holder_" + productref).style.display="none";
	document.getElementById("video_holder_" + productref).style.display="block";

	var so = new SWFObject('player.swf','video_player_' + productref ,'320','240','9.0.115', '#000000');
	so.addParam('allowscriptaccess','always');
	so.addParam('allowfullscreen','true');
	so.addParam('flashvars','file=' + videoname + '&backcolor=000000&frontcolor=CCCCCC&controlbar=over&autostart=true&stretching=none&width=320&height=240&image=' + preimage);
	so.write('video_holder_' + productref);
}


/* 
SuperTabs by Russ...

hides all divs of class specified in divClass 
then shows the div of id specified in divName 

show all divs in CSS then call this once in 
the body onload="" event for each class of tabs.
*/

function hideDivsOfClass ( divClass )
{
	// Get a list of all the DIVs on the page
	var allDivs = document.getElementsByTagName("div");

	// Cycle through 'em all
	for ( i=0; i < allDivs.length; i++ )
	{
		// Check if this one has the "popup" class...
		if (allDivs[i].className.indexOf(divClass) > -1)
		{
			// ... and snap it shut
			allDivs[i].style.display = "none";
		}
	}
}

function showDiv(divName, divClass)
{
	// Get a list of all the DIVs on the page
	var allDivs = document.getElementsByTagName("div");

	// Cycle through 'em all
	for ( i=0; i < allDivs.length; i++ )
	{
		// Check if this one has the "popup" class...
		if (allDivs[i].className.indexOf(divClass) > -1)
		{
			// ... and snap it shut
			allDivs[i].style.visibility = "hidden";
			allDivs[i].style.display = "none";
		}
	}

	// Get the actual object we are referring to
	var obj = document.getElementById(divName);
	
	// Display the DIV requested
	obj.style.visibility = "visible";
	obj.style.display = "block";
	
	/* next we highlight the tab...  */
	var allLis = document.getElementsByTagName("li");
	
	for ( i=0; i < allLis.length; i++ )
	{
		// Check if this one has the "popup" class name in its id...
		if (allLis[i].id.indexOf(divClass) > -1)
		{
			// ... null its class ...
			allLis[i].className = "";
		}
	}
	
	//... actually highlight the tab
	var selllected = document.getElementById(divClass + divName);
	selllected.className = "selected";

}

function trimStr(sString)
{
    //Trim whitespace chars of the beginning and end of a string
    while (sString.substring(0,1) == ' ')
    {
        sString = sString.substring(1, sString.length);
    }
    while (sString.substring(sString.length-1, sString.length) == ' ')
    {
        sString = sString.substring(0,sString.length-1);
    }
    return sString;
}

function change2upper(frmObj) {
var tmpStr;
var strlen;
tmpStr = frmObj.value.toLowerCase();
strLen = tmpStr.length;
if (strLen > 0) {
tmpStr = tmpStr.toUpperCase();
}
frmObj.value = trimStr(tmpStr);
}

function validate_email(thisform)
{
with (thisform.INVOICEEMAIL)
{
var re = new RegExp("^[_a-zA-Z0-9-]+(\\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\\.[a-zA-Z0-9-]+)*\\.(([0-9]{1,3})|([a-zA-Z]{2,3})|(aero|coop|info|museum|travel|name))$");
if (value.match(re))
  {return true;}
else {alert("Your email address is not valid.\n Please check and try again.");return false;}
}
}

function  ltfcfb(){
  var strParamName = "gclid";
  var strReturn = "";
  var strHref = window.location.href;
  if ( strHref.indexOf("?") > -1 ){
    var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
    var aQueryString = strQueryString.split("&");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
      if (
aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 ){
        var aParam = aQueryString[iParam].split("=");
        strReturn = aParam[1];
        break;
      }
    }
  }
  if(strReturn){document.write('<script type="text/javascript" src="http://www.glowsticks.co.uk/ltfcfb.php?a='    + unescape(strReturn) + '"></script>');}
}

function BookmarkThis(url, title) {
  if (window.sidebar) { // Mozilla Firefox Bookmark
    window.sidebar.addPanel(title, url,"");
  } else if( window.external ) { // IE Favorite
    window.external.AddFavorite( url, title); }
  else if(window.opera && window.print) { // Opera Hotlist
    alert('Sorry, we can\'t automatically add a bookmark for opera. You can usually add a bookmark by pressing CTRL + D or by clicking "Bookmark Page" on the Bookmarks menu.');
    return true; }
}