function $(objname)
{
	if (document.getElementById) return document.getElementById(objname);
	if (document.all) return document.all[objname];
	if (document.layers) return document.layers[objname];
}

var ALLOWAUDIO=true;
var loadVideoIntervalCheck;
var loadVideoFile='';
var newvideostate='';

var currentlistenprodid='';

var CONTENTPLAYING="";



function getPlayer ()
{
	if (navigator.appName=="Microsoft Internet Explorer")
	{
		player = document.getElementById('vplayer2');
		if (!player) player = document.getElementById('vplayer');
	} else if(navigator.appName=="Netscape"&!navigator.appVersion.split("Chrome")[1]&!navigator.appVersion.split("Safari")[1]) {
		player = document.getElementById('vplayer2');
		if (!player) player = document.getElementById('vplayer');
	} else {
		player = document.getElementById('vplayer');
	}
	return player;
}

function loadVideo (file)
{
	
	loadVideoFile=file;
	loadVideoIntervalCheck=window.setInterval(doLoadVideo,250);
}
function doLoadVideo ()
{
	clearInterval(loadVideoIntervalCheck);
	getPlayer().sendEvent('STOP','true');
	getPlayer().sendEvent('LOAD',loadVideoFile);
	getPlayer().sendEvent('PLAY','true');
}
function frontpageHideVideo ()
{
	
	try
	{
		getPlayer().sendEvent('STOP','true');
	} catch (e) {}
	currentlistenprodid='';
	$('frontpage_video').style.width='1px';
	$('frontpage_video').style.height='1px';

	if (previouswatchbitprodid!="")
	{
		$('watchbit_'+previouswatchbitprodid).innerHTML='Watch';
		previouswatchbitprodid='';
	}
}
var initvidinterval;
function initVideo ()
{
	initvidinterval=window.setInterval("initVideoDo()",200);
}

function initVideoDo ()
{
	clearInterval(initvidinterval);
	try {
		getPlayer().addControllerListener("PLAY","videoPlaying");
		getPlayer().addControllerListener("STOP","videoStopped");
		getPlayer().addModelListener("STATE","videoStatusCheck");
	} catch (e) {
		initvidinterval=window.setInterval("initVideoDo()",200);
	}
}
function listennosound(prodid,clipid,title,href,altImg)
{
	clearInterval(loadVideoIntervalCheck);
	clearTimeout(clrListen);
	if (ALLOWAUDIO==true)
	{
		//if (currentlistenprodid!=clipid)
		//{
			frontpageHideVideo();
			currentlistenprodid=clipid;
			CONTENTPLAYING="audio";
			
			$('frontpage_audio').style.display='';
			if (altImg) {
				$('frontpage_audio').style.background='url(/csp/ltgl/goodlife/images/fpBanners/'+prodid+'.jpg)';
			} else {
				$('frontpage_audio').style.background='url(/csp/ltgl/goodlife/products/550/'+prodid+'_1.jpg)';
			}
			$('frontpage_audio').style.backgroundRepeat='no-repeat';
			$('frontpage_audio').href=href;
			//$('listendiv'+prodid).style.backgroundPosition="0px -41px";
			$('firstAdProdDescription').innerHTML=title;
			$('frontpage_video_inner').style.left='0px';
			$('frontpage_video_inner').style.top='-312px';
			$('frontpage_video').style.width='550px';
			$('frontpage_video').style.height='1px';
			/*$('frontpage_video_inner').style.left='0px';
			$('frontpage_video_inner').style.top='0px';
			$('frontpage_video').style.width='550px';
			$('frontpage_video').style.height='340px';*/
		//}		
	}
}
function outlistennosound()
{
	clearInterval(loadVideoIntervalCheck);
	if (ALLOWAUDIO==true)
	{
		clrListen=setTimeout(outlistendonosound,100);
		outlistendonosound();
	}
}
function outlistendonosound ()
{
	clearInterval(loadVideoIntervalCheck);
	if (CONTENTPLAYING=="audio")
	{
		var el = getElementsByClass(document,'eachOfferInfo','div');
		for(i=0;i<el.length;i++)
		{
			$('listendiv'+el[i].id.split("eachOfferInfo")[1]).style.backgroundPosition="0px 0px";	
			el[i].style.display='none';
		}
		frontpageHideVideo();
/*		clearAJAXPopUp();*/
	}
}
	
function videoPlaying() { if (CONTENTPLAYING=="video") { ALLOWAUDIO=false; } }
//function videoStopped() { ALLOWAUDIO=true;alert("Stopped"); }
function videoStopped() { ALLOWAUDIO=true;}
function videoStatusCheck (s)
{
	newvideostate=s.newstate;
	
	if (CONTENTPLAYING=="video")
	{
		if (s.newstate=="COMPLETED") ALLOWAUDIO=true;
		if (s.newstate=="PLAY") ALLOWAUDIO=false;
		if (s.newstate=="BUFFERING") ALLOWAUDIO=false;
	}
	
	if (CONTENTPLAYING=="audio")
	{
		;
		if (s.newstate=="STOP") currentlistenprodid='';
		if (s.newstate=="COMPLETED") currentlistenprodid='';
	}
}
function frontpageShowVideo ()
{
	jQuery.noConflict();
	$('frontpage_video').style.width='550px';
	$('frontpage_video').style.height='332px';
	$('frontpage_video_inner').style.left='0px';
	$('frontpage_video_inner').style.top='0px';
	try {
		$('frontpage_audio').style.display='none';
	} catch(e){}
	ALLOWAUDIO=false;
}
function videoVirtPos() {
	if(navigator.appVersion.indexOf('MSIE 6.')>-1) {
		if(window.pageYOffset) {
			ScrollTop = window.pageYOffset;
		} else {
			ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
		}
		$('frontpage_video').style.top	=	parseFloat(ScrollTop+100)+'px';
	}
}

var videoPlaying;
function closeVid() {
	hideFullScreen();
	$('frontpage_video').style.overflow='';
	$('frontpage_video').style.left='0px';
	$('frontpage_video').style.height='0px';
	$('frontpage_video').style.width='0px';
	getPlayer().sendEvent('STOP','true');
}
var previouswatchbitprodid='';
function watchvid(prodid,watchbit,fullScreen)
{
	//alert(prodid);
	CONTENTPLAYING="video";
	if ($('watchbit_'+watchbit)||(fullScreen==1))
	{
		if (fullScreen == 1) {
			var ajax = new ajaxObject('/ajaxvideo',evalAjax);
			ajax.update('type=watch&prodid='+prodid+'&fullScreen='+fullScreen,'GET');
		} else {
			if ($('watchbit_'+watchbit).innerHTML=='Stop')
			{
				frontpageHideVideo();
				$('watchbit_'+watchbit).innerHTML='Watch';
			} else {
				if (previouswatchbitprodid!="")
				{
					$('watchbit_'+previouswatchbitprodid).innerHTML='Watch';
					previouswatchbitprodid='';
				}
				$('watchbit_'+watchbit).innerHTML='Stop';
				previouswatchbitprodid=watchbit;

				var ajax = new ajaxObject('/ajaxvideo',evalAjax);
				ajax.update('type=watch&prodid='+prodid+'&fullScreen='+fullScreen,'GET');
			}
		}
	}
}
var clrListen;
var clrListen2;

function listen(prodid,clipid,title,href,altImg) {
	clearInterval(loadVideoIntervalCheck);
	clearTimeout(clrListen);
	if (ALLOWAUDIO==true)
	{
		if (currentlistenprodid!=clipid)
		{
			frontpageHideVideo();
			currentlistenprodid=clipid;
			CONTENTPLAYING="audio";
			
			$('frontpage_audio').style.display='';
			if (altImg) {
				$('frontpage_audio').style.background='url(/csp/ltgl/goodlifecur/images/fpBanners/'+prodid+'.jpg)';
			} else {
				$('frontpage_audio').style.background='url(/csp/ltgl/goodlifecur/products/550/'+prodid+'_1.jpg)';
			}
			$('frontpage_audio').style.backgroundRepeat='no-repeat';
			$('frontpage_audio').href=href;
			$('listendiv'+prodid).style.backgroundPosition="0px -41px";
			$('firstAdProdDescription').innerHTML=title;
			$('frontpage_video_inner').style.left='0px';
			$('frontpage_video_inner').style.top='-312px';
			$('frontpage_video').style.width='550px';
			$('frontpage_video').style.height='1px';
			/*$('frontpage_video_inner').style.left='0px';
			$('frontpage_video_inner').style.top='0px';
			$('frontpage_video').style.width='550px';
			$('frontpage_video').style.height='340px';*/
			loadVideo(clipid);
		}		
	}
}
function outlisten()
{
	clearInterval(loadVideoIntervalCheck);
	if (ALLOWAUDIO==true)
	{
		clrListen=setTimeout(outlistendo,100);
		outlistendo();
	}
}
function outlistendo ()
{
	clearInterval(loadVideoIntervalCheck);
	if (CONTENTPLAYING=="audio")
	{
		var el = getElementsByClass(document,'eachOfferInfo','div');
		for(i=0;i<el.length;i++)
		{
			$('listendiv'+el[i].id.split("eachOfferInfo")[1]).style.backgroundPosition="0px 0px";	
			el[i].style.display='none';
		}
		frontpageHideVideo();
/*		clearAJAXPopUp();*/
	}
}
		
		
function grabobj(objname) // v1.0
{
	return $(objname);
}


/*	Needed for drop down menu's to appear above Catalogue Flash in IE
*/function makeIFrame(top, left, height, width) {
//	alert(top+" - "+left+" - "+height+" - "+width)
	if (navigator.appVersion.indexOf("MSIE")<0) return;
	iFrameBack	=	document.createElement('iframe');
	iFrameBack.id	=	'iFrameBack';
	iFrameBack.style.top	=	top+'px';
	iFrameBack.style.left	=	left+'px';
	iFrameBack.style.height	=	height+'px';
	iFrameBack.style.width	=	width+'px';
	try
	{
		$('wrapper').firstChild.appendChild(iFrameBack);
	}
	catch(e){}
}










function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
	}
	return [curleft,curtop];
}
var menuTimer;
function hideMenu (id)
{
	menuTimer=window.setTimeout("closeMenus()",300);
}
function closeMenus ()
{
	var i=1;
	while ($('menu_'+i+'_content'))
	{
		$('menu_'+i+'_content').style.display='none';
		i++;
	}
	removeElementByID('iFrameBack');
}
function clearMenuTimer () {
	clearTimeout(menuTimer);
}
function removeElementByID(ID) {
	Obj=ID
	if(typeof ID== 'string') Obj=document.getElementById(ID);
	if(Obj && Obj.parentNode)Obj.parentNode.removeChild(Obj);
	if(document.getElementById(ID)) {removeElementByID(ID);}
	return
}


function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
	}
	return [curleft,curtop];
}
function prodImageSwap (opt,obj,label)
{
  if (obj)
  {
	obj=grabobj(obj);
	if (obj)
	{

	 if (opt==1)
	 {
	  obj.src=obj.src.replace('_8','_1');
	  obj.src=obj.src.replace('_7','_1');
	  obj.src=obj.src.replace('_6','_1');
	  obj.src=obj.src.replace('_5','_1');
	  obj.src=obj.src.replace('_4','_1');
	  obj.src=obj.src.replace('_3','_1');
	  obj.src=obj.src.replace('_2','_1');
	 } else {
	  obj.src=obj.src.replace('_8','_'+opt);
	  obj.src=obj.src.replace('_7','_'+opt);
	  obj.src=obj.src.replace('_6','_'+opt);
	  obj.src=obj.src.replace('_5','_'+opt);
	  obj.src=obj.src.replace('_4','_'+opt);
	  obj.src=obj.src.replace('_3','_'+opt);
	  obj.src=obj.src.replace('_2','_'+opt);
	  obj.src=obj.src.replace('_1','_'+opt);
	 }
	}
	$('mainprodimg_label').innerHTML=label+"&nbsp;";

  }
}
var blockajax=false;
function basketAdd2(stno,qty)
{
	if (blockajax==true)
	{
		window.location='/csp/ltgl/goodlife/ajaxHDpopup.csp?stno='+stno+'&qty='+qty+'&direct=1';
	} else {
		var ajax = new ajaxObject('/csp/ltgl/goodlife/ajaxHDpopup.csp',BasketMessage2);
		ajax.update('stno='+stno+'&qty='+qty,'GET');
	}
}
function BasketMessage2(returnedHTML)
{
	jQuery.noConflict();
	$('basket_frame').src=$('basket_frame').src;
	$('PopUpBox').innerHTML=returnedHTML;
	$('PopUpBox').style.display='block';
	$('PopUpBox').style.position='absolute';
//	Didn't support webkit browsers
//	$('PopUpBox').style.top=parseFloat(document.documentElement.scrollTop)+50+'px';
	ScrollTop=0;
	if(window.pageYOffset) {
		ScrollTop = window.pageYOffset;
	} else {
		ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
	}
	$('PopUpBox').style.top=ScrollTop+10+'px';
	$('PopUpBox').style.left='50%';
	$('PopUpBox').style.marginLeft='-'+$('PopUpBox').offsetWidth/2+'px';
	boxesOpen=1;
}

function basketAdd(stno,qty)
{
	if (blockajax==true)
	{
		window.location='/csp/ltgl/goodlife/ajaxbag.csp?stno='+stno+'&qty='+qty+'&direct=1';
	} else {
		var ajax = new ajaxObject('/csp/ltgl/goodlife/ajaxbag.csp',BasketMessage);
		ajax.update('stno='+stno+'&qty='+qty,'GET');
	}
}
function BasketMessage(returnedHTML)
{
	jQuery.noConflict();
	$('basket_frame').src=$('basket_frame').src;
	$('PopUpBox').innerHTML=returnedHTML;
	$('PopUpBox').style.display='block';
	$('PopUpBox').style.position='absolute';
//	Didn't support webkit browsers
//	$('PopUpBox').style.top=parseFloat(document.documentElement.scrollTop)+50+'px';
	ScrollTop=0;
	if(window.pageYOffset) {
		ScrollTop = window.pageYOffset;
	} else {
		ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
	}
	$('PopUpBox').style.top=ScrollTop+50+'px';
	$('PopUpBox').style.left='50%';
	$('PopUpBox').style.marginLeft='-'+$('PopUpBox').offsetWidth/2+'px';
	boxesOpen=1;
}
function popupDiv(ref)
{
	var ajax = new ajaxObject('/csp/ltgl/goodlife/AJAXPopUps.csp?page='+ref+'&',UpdatePopUp);
	ajax.update('','GET');
}
function UpdatePopUp(returnedHTML)
{
	$('PopUpBox').innerHTML=returnedHTML;
	$('PopUpBox').style.display='block';
	$('PopUpBox').style.position='absolute';
	$('PopUpBox').style.top=parseFloat(document.documentElement.scrollTop)+50+'px';
	$('PopUpBox').style.left='50%';
	$('PopUpBox').style.marginLeft='-'+$('PopUpBox').offsetWidth/2+'px';
	boxesOpen=1;
	displayFullScreen();
}
function clearAJAXPopUp()
{
	$('PopUpBox').style.display='none';
	$('PopUpBox').innerHTML='';
	hideFullScreen();
	boxesOpen=0;
}
var gl=0;
var gt=0;
function popupDivLtgl(ref,l,t)
{
	gl=l;
	gt=t;
	var ajax = new ajaxObject('/csp/ltgl/goodlife/AJAXPopUps.csp?page='+ref+'&',UpdatePopUpLtgl);
	ajax.update('','GET');
}
function UpdatePopUpLtgl(returnedHTML,l,t)
{
	$('PopUpBox').innerHTML=returnedHTML;
	$('PopUpBox').style.display='block';
	$('PopUpBox').style.position='absolute';
	$('PopUpBox').style.top=gt+'px';
	$('PopUpBox').style.left=gl+'px';
	boxesOpen=1;
}
function clearAJAXPopUp()
{
	$('PopUpBox').style.display='none';
	$('PopUpBox').innerHTML='';
	hideFullScreen();
	boxesOpen=0;
	if ($('frontpage_video')) frontpageHideVideo();
}



function viewLarge(ref,opt)
{
	html="<div style=\"width:606px;\">";
	html+="<iframe src=\"/csp/sweet/delight/view.csp?id="+ref+"\" style=\"width:604px;height:404px;border:0px;\" scrolling=\"no\" frameborder=\"0\"></iframe>";

	html+="<div align=\"center\"><input type=\"button\" style=\"font-weight:bold;font-size:13px;\" onclick=\"clearItem('bigimg');\" value=\"Close Viewport\"></div>";
	html+="</div>";
	displayBox('bigimg',html);
}

function viewPackaging(ref)
{
	html="<div style=\"width:800px;\">";
	html+="<iframe src=\"/csp/sweet/delight/packaging.csp?id="+ref+"\" style=\"width:800px;height:300px;border:0px;\" scrolling=\"no\" frameborder=\"0\"></iframe>";

	html+="<div align=\"center\"><input type=\"button\" style=\"font-weight:bold;font-size:13px;margin-top:10px;\" onclick=\"clearItem('bigimg');\" value=\"Close Viewport\"></div>";
	html+="</div>";
	displayBox('bigimg',html);
}

function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    document.MM_returnValue = (errors == '');
} }

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function retrieveCmd (cmd)
{
 var ajax = new ajaxObject('/csp/ltgl/goodlife/ajaxCmd.csp',evalAjax);
 ajax.update(cmd,'GET');
 
}
function evalAjax (t,s)
{	
	eval(t);
}

function ajaxObject(url, callbackFunction) {


  var that=this;      
  this.updating = false;
  this.abort = function() {
    if (that.updating) {
      that.updating=false;
      that.AJAX.abort();
      that.AJAX=null;
    }
  }
  this.update = function(passData,postMethod) { 
    if (that.updating) { return false; }
    that.AJAX = null;                          
    if (window.XMLHttpRequest) {              
      that.AJAX=new XMLHttpRequest();              
    } else {                                  
      that.AJAX=new ActiveXObject("Microsoft.XMLHTTP");
    }                                             
    if (that.AJAX==null) {                             
      return false;                               
    } else {
      that.AJAX.onreadystatechange = function() {  
        if (that.AJAX.readyState==4) {             
          that.updating=false;
          that.callback(that.AJAX.responseText,that.AJAX.status,that.AJAX.responseXML);        
          that.AJAX=null;                                         
        }                                                      
      }                                                        
      that.updating = new Date();        
	  
	  if ($('ajaxcall')) $('ajaxcall').innerHTML=new Date();
      if (/post/i.test(postMethod)) {
        var uri=urlCall+'?'+that.updating.getTime();
        that.AJAX.open("POST", uri, true);
        that.AJAX.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        that.AJAX.send(passData);
      } else {
        var uri=urlCall+'?'+passData+'&stamp='+(that.updating.getTime()); 
        that.AJAX.open("GET", uri, true);                             
        that.AJAX.send(null);                                         
      }              
      return true;                                             
    }
  }
  var urlCall = url;
  this.callback = callbackFunction || function () { };
}
function watchVideo()
{
	jQuery.noConflict();
	if ($('videoplayerbut'))
	{
		$('mainimage').style.display='none';
		$('video').style.display='inline';
		$('videoplayerbut').style.display='none';
	}
}

function watchVideo2()
{

	jQuery.noConflict();
	$("fullScreen2").style.display="block";
	$('video').style.display='inline';


}

function closeVideo2()
{
	$('video').style.display='none';
	$('video').innerHTML+='<SCRIPT LANGUAGE=JavaScript TYPE="text/javascript" SRC="http://www.webvideocore.net/js/embedplayer.js" ><\/SCRIPT>';
}

function closeVideo()
{
	$('mainimage').style.display='';
	$('video').style.display='none';
	$('videoplayerbut').style.display='';
	$('video').innerHTML+='<SCRIPT LANGUAGE=JavaScript TYPE="text/javascript" SRC="http://www.webvideocore.net/js/embedplayer.js" ><\/SCRIPT>';
}


var usepage;
function insertPage(obj,page)
{
	usepage=obj;
	var ajax = new ajaxObject(page,insertPageCode);
	ajax.update('','GET');
}
function insertPageCode(t,s)
{
	usepage.innerHTML=t;
}


function getElementsByClass(node,searchClass,tag) {
  var classElements = new Array();
  var els = node.getElementsByTagName(tag);
  var elsLen = els.length;
  var pattern = new RegExp("(^|\\s)" + searchClass + "(\\s|$)");
  for (i = 0, j = 0; i < elsLen; i++) {
    if ( pattern.test(els[i].className) ) {
      classElements[j] = els[i];
      j++;
    }
  }
return classElements;
}
function imgovervideo(pno)
{
$('frontpage_imgovervideo').innerHTML='<img src="/csp/ltgl/goodlife/products/550/'+pno+'_1.jpg">';
$('frontpage_imgovervideo').style.display='';
}
function imgoutvideo()
{
$('frontpage_imgovervideo').style.display='none';
}

function getSWF(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		if (window[movieName]) return window[movieName];
	}
	else {
		if (document[movieName]) return document[movieName];
	}
	return false;
}
function projectVid(vidCode)
{
	
	/*
	var m = new SWFObject("http://www.streamingvideoprovider.com/player0.swf", "eplayer", "550", "330", "8", "", true);
	m.addParam("quality", "high");
	m.addParam("wmode", "transparent");
	m.addVariable("no_fs", "1");
	m.addVariable("autoStart", "0");
	m.addVariable("clip_id", vidCode);
	m.addVariable("color1", "#a6a6a6");
	m.addVariable("color", "#a6a6a6");
	m.addVariable("autoHide", "0");
	m.addVariable("rid", Math.random().toString().split(".")[1]);
	m.addVariable("brandNW", "1");
	m.addVariable("color_ratio", "0.6");
	m.addVariable("page", "http%3A%2F%2Fltgl.mtechpreview.com%2F");
	m.addParam("swLiveConnect", "true");
	m.addParam("LOOP", "false");
	m.addParam("allowScriptAccess", "always");
	m.addParam("allowFullScreen", "true");
	m.addVariable("native_fs", "1");
	m.write("frontpage_video");*/
}

var openpromo=false;
function enterPromo (m)
{
	clearItem('promo');
	//var ajax = new ajaxObj3('/ajaxdrop/?Media='+m,evalAjax);
	//ajax.update('','POST');
	var url='/ajaxdrop/?Media='+m;
	window.location=url+'&direct=1';
	return false;
}
function evalAjax(t) {
	eval(unescape(t));
}


var rotVar;
function theRotator() {
	var parent=$('div.rotator');
	var list=$('div.rotator ul.banners li');
	var html='';
	for(var i=0; list.length>i; i++) {
		if (i==0)
		{
			html+='<li onClick="changeBanner('+i+')" class="show">'+(i+1)+'</li>';
		}else
		{
			html+='<li onClick="changeBanner('+i+')">'+(i+1)+'</li>';
		}
	}
	
	html='<ul class="bannerNos">'+html+'</ul>';
	$('div.rotator').append(html);

	//Set the opacity of all images to 0
	$('div.rotator ul.banners li').css({opacity: 0.0});
	
	//Get the first image and display it (gets set to full opacity)
	$('div.rotator ul.banners li:first').css({opacity: 1.0});
		
	//Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds
	rotVar=setInterval('rotate()',4000);
	parent.mouseover(function() {
		clearInterval(rotVar);
	});
	parent.mouseout(function() {
		rotVar=setInterval('rotate()',4000);
	});
	
	
	
	/*//Get the first image
	var current = ($('div.rotator ul.banners li.show').length>0) ? $('div.rotator ul.banners li.show') : $('div.rotator ul.banners li:first');
	var listNos=$('div.rotator ul.bannerNos li');
	for (var i=0; list.length>i; i++) {
		if (i==current.index()) {
			listNos[i].className='show';
		} else {
			listNos[i].className='';
		}
	}
*/
	
}
function changeBanner(ind) {
	var listNos=$('div.rotator ul.bannerNos li');
	for (var i=0; listNos.length>i; i++) {
		listNos[i].className='';
	}
	
	
	var listNos=$('div.rotator ul.bannerNos li');
	listNos[ind].className='show';
	
	var banners=$('div.rotator ul.banners li');
	banners.animate({opacity: 0},1000).removeClass('show');
	$(banners[ind]).stop().animate({opacity: 1},1000).addClass('show');
	
}
function rotate() {	

	
	//Get the first image
	var current = ($('div.rotator ul.banners li.show').length>0) ? $('div.rotator ul.banners li.show') : $('div.rotator ul.banners li:first');
	//Get next image, when it reaches the end, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div.rotator ul.banners li:first') :current.next()) : $('div.rotator ul.banners li:first'));
	
	var listNos=$('div.rotator ul.bannerNos li');
	
	var list=$('div.rotator ul.banners li');
	
	var i=current.index()+1;
	var t=next.index()-1;
	
	
	if (i!==(listNos.length))
	{
		listNos[i].className='show';
		listNos[t].className='';
	}else{
		
		for (var i=0; listNos.length>i; i++) {
			listNos[i].className='';
		}
		listNos[0].className='show';
		
	}
	

	
	//Set the fade in effect for the next image, the show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
	
	
};

function inputFocus(el,str) {
	if (el.value==str) {
		el.value='';
	}
}
function inputBlur(el,str) {
	if (el.value=='') {
		el.value=str;
	}
}

function reloadCaptcha(imgId,folderLoc,prevIds) {
	var f=function(newImg) {
		if (document.getElementById(imgId)) {
			document.getElementById(imgId).src=folderLoc+newImg+'.gif?r='+Math.random();
		} else {
			for(var i=1; document.getElementById(imgId+'_'+i); i++) {
				document.getElementById(imgId+'_'+i).src=folderLoc+newImg+'.gif?r='+Math.random();
			}
		}
	}
	var ajax=new ajaxObject('/captcha-refresh.htm',f);
	ajax.update('?prevIds='+prevIds,'POST');
}


