function CreateObjArray() {
	var elements = new Array();
	for (var i = 0; i < arguments.length; i++) {
		var element = arguments[i];
		if (typeof element == 'string')
			element = document.getElementById(element);
		if (arguments.length == 1)
			return element;
		elements.push(element);
	}
	return elements;
}

function ToggleHomePageDivs(objs) {
	var i;
	for (i=0;i<objs.length;i++ ) {
		if (i == 0)
			objs[i].style.display = 'block';
		else
			objs[i].style.display = 'none';
	}
}

function ToggleArticleDivs(objs) {
	var i;
	for (i=0;i<objs.length;i++ ) {
		if (i == 0)
			objs[i].style.display = 'block';
		else
			objs[i].style.display = 'none';
	}
}

function ToggleAffiliateDivs(objs) {
	var i;
	for (i=0;i<objs.length;i++ ) {
		if (i == 0)
			objs[i].style.display = 'block';
		else
			objs[i].style.display = 'none';
	}
}

function ChangeSpanColor(objs)
{
	var i;
	for (i=0;i<objs.length;i++ ) {
		if (i == 0) {
			objs[i].style.background = '#d2e3ad';
			objs[i].style.padding = '6 6 2 6';
		}
		else {
			objs[i].style.background = '#e2eccd';
			objs[i].style.padding = '4 4 2 4';
		}
	}
}

function SendArticleToAFriend(intArticleID) {
	var h = 530;
	var w = 400;
	var iMyWidth;
	var iMyHeight;
	
	//half the screen width minus half the new window width (plus 5 pixel borders).
	iMyWidth = (window.screen.width/2) - (w/2 + 10);
	//half the screen height minus half the new window height (plus title and status bars).
	iMyHeight = (window.screen.height/2) - (h/2 + 50);
	
	//Open the window.
	var win = window.open("/services/emailarticletoafriend.asp?ArticleID=" + intArticleID, "email", "status=no,height=" + h + ",width=" + w + ",resizable=yes,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",toolbar=no,menubar=no,scrollbars=no,location=no,directories=no");
	win.focus();
	return false;
}
	
function PrintArticle(intArticleID) {
	var h = 500;
	var w = 650;
	var iMyWidth;
	var iMyHeight;
	
	//half the screen width minus half the new window width (plus 5 pixel borders).
	iMyWidth = (window.screen.width/2) - (w/2 + 10);
	//half the screen height minus half the new window height (plus title and status bars).
	iMyHeight = (window.screen.height/2) - (h/2 + 50);
	
	//Open the window.
	var win = window.open("/services/printarticle.asp?ArticleID=" + intArticleID, "print", "status=yes,height=" + h + ",width=" + w + ",resizable=yes,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",toolbar=no,menubar=no,scrollbars=yes,location=no,directories=no");
	win.focus();
	return false;
}

function SendAffiliateToAFriend(intAffiliateID) {
	var h = 530;
	var w = 400;
	var iMyWidth;
	var iMyHeight;
	
	//half the screen width minus half the new window width (plus 5 pixel borders).
	iMyWidth = (window.screen.width/2) - (w/2 + 10);
	//half the screen height minus half the new window height (plus title and status bars).
	iMyHeight = (window.screen.height/2) - (h/2 + 50);
	
	//Open the window.
	var win = window.open("/services/emailaffiliatetoafriend.asp?AffiliateID=" + intAffiliateID, "email", "status=no,height=" + h + ",width=" + w + ",resizable=yes,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",toolbar=no,menubar=no,scrollbars=no,location=no,directories=no");
	win.focus();
	return false;
}

function PrintAffiliate(intAffiliateID) {
	var h = 500;
	var w = 650;
	var iMyWidth;
	var iMyHeight;
	
	//half the screen width minus half the new window width (plus 5 pixel borders).
	iMyWidth = (window.screen.width/2) - (w/2 + 10);
	//half the screen height minus half the new window height (plus title and status bars).
	iMyHeight = (window.screen.height/2) - (h/2 + 50);
	
	//Open the window.
	var win = window.open("/services/printaffiliate.asp?AffiliateID=" + intAffiliateID, "print", "status=yes,height=" + h + ",width=" + w + ",resizable=yes,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",toolbar=no,menubar=no,scrollbars=yes,location=no,directories=no");
	win.focus();
	return false;
}

function toggleVisibility(id) {
	var obj = document.getElementById(id);
	if (obj.style.display == 'block' || obj.style.display == '')
		obj.style.display = 'none';
	else
		obj.style.display = 'block';
	return false;
}

function WriteLayer(ID, sText) { 
	document.getElementById(ID).innerHTML = sText;
} 

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}

/*
function PrintArticle()
{
	window.print();
	return false;
}
*/

function ShowVidDiv(galleryName, increment)
{
	var showDiv, hideDiv
	var myDiv, totDiv
	
	myDiv = eval('myDiv = ' + galleryName + 'currVidDiv + increment');
	totDiv = eval(galleryName + 'totVidDiv');

	eval(galleryName + 'currVidDiv = ' + myDiv);

	if (myDiv < 1) {
		eval( galleryName + 'currVidDiv = ' + galleryName + 'totVidDiv');
		hideDiv = galleryName + 'videoDiv1';
		showDiv = galleryName + 'videoDiv' + totDiv
	} else if (myDiv > totDiv) {
		eval( galleryName + 'currVidDiv = 1');
		hideDiv = galleryName + 'videoDiv' + totDiv;
		showDiv = galleryName + 'videoDiv1'
	} else
	{
		if (increment == 1) {
			hideDiv = galleryName + 'videoDiv' + (myDiv - 1);
			showDiv = galleryName + 'videoDiv' + myDiv
		}
		else {
			hideDiv = galleryName + 'videoDiv' + (myDiv + 1);
			showDiv = galleryName + 'videoDiv' + myDiv
		}

	}
	
	new Effect.Fade(hideDiv);
	new Effect.Appear(showDiv, { delay: 1 });
	
	

	SetNavDots(galleryName);
}

function ShowImgDiv(galleryName, increment)
{
	var showDiv, hideDiv
	var myDiv, totDiv
	
	myDiv = eval('myDiv = ' + galleryName + 'currImgDiv + increment');
	totDiv = eval(galleryName + 'totImgDiv');

	eval(galleryName + 'currImgDiv = ' + myDiv);

	if (myDiv < 1) {
		eval( galleryName + 'currImgDiv = ' + galleryName + 'totImgDiv');
		hideDiv = galleryName + 'ImageDiv1';
		showDiv = galleryName + 'ImageDiv' + totDiv
	} else if (myDiv > totDiv) {
		eval( galleryName + 'currImgDiv = 1');
		hideDiv = galleryName + 'ImageDiv' + totDiv;
		showDiv = galleryName + 'ImageDiv1'
	} else
	{
		if (increment == 1) {
			hideDiv = galleryName + 'ImageDiv' + (myDiv - 1);
			showDiv = galleryName + 'ImageDiv' + myDiv
		}
		else {
			hideDiv = galleryName + 'ImageDiv' + (myDiv + 1);
			showDiv = galleryName + 'ImageDiv' + myDiv
		}

	}

	new Effect.Fade(hideDiv);
	new Effect.Appear(showDiv, { delay: 1 });
}

function FadeAppear(fadeObj, appearObj)
{
	new Effect.Fade(fadeObj);
	new Effect.Appear(appearObj, { delay: 1 });
}
function SetNavDots(galleryName)
{
	var imgs,i, re;
	// loop through all images of the document
	imgs=document.getElementsByTagName('img');
	re = new RegExp(galleryName + 'video-nav');

	for(i=0;i<imgs.length;i++)
	{
		// test if the class 'roll' exists
		//if(/video-nav/.test(imgs[i].name))
		if(re.test(imgs[i].name))
		{
			if(imgs[i].name == galleryName + 'video-nav' + eval(galleryName + 'currVidDiv'))
				imgs[i].src = '/img/video_on.gif';
			else
				imgs[i].src = '/img/video_off.gif';
		}
	}
}

function changeCurrentImageText(container, totalImages, increment)
{
	var currentImage
	currentImage = eval(document.getElementById(container).innerHTML)
	
	if (currentImage == 1 && increment == -1)
		currentImage = totalImages;
	else if (currentImage == totalImages && increment == 1)
		currentImage = 1;
	else
		currentImage = currentImage + increment;
	document.getElementById(container).innerHTML = currentImage
}

function closeWindow()
{
	if(navigator.appName=='Microsoft Internet Explorer') {
		this.focus();self.opener = this;self.close(); }
	else { window.open('','_parent',''); window.close(); }
}

function showbonuses(thechosenone) {
      var bonuses = document.getElementsByTagName("div");
            for(var x=0; x<bonuses.length; x++) {
                  name = bonuses[x].getAttribute("name");
                  if (name == 'bonuses') {
                        if (bonuses[x].id == thechosenone) {
                        bonuses[x].style.display = 'block';
                  }
                  else {
                        bonuses[x].style.display = 'none';
                  }
            }
      }
}

function show_dollar() { showbonuses('bonus_dollar'); }
function show_pound() { showbonuses('bonus_sterling'); }
function show_euro() { showbonuses('bonus_euro'); }

function show_bonustab(thechosenone)
{
	var tabs = document.getElementsByTagName("div");
	var lis = document.getElementsByTagName("li");
	for(var x=0; x<tabs.length; x++)
	{
		name = tabs[x].getAttribute("name");
		if (name == 'bonus_tab')
		{
			if (tabs[x].id == 'bonus_' + thechosenone)
			{
				tabs[x].style.display = 'block';
			}
			else
			{
				tabs[x].style.display = 'none';
			}
		}
	}

	for(var x=0; x<lis.length; x++)
	{
		name = lis[x].getAttribute("name");
		if (name == 'bonus_li')
		{
			if (lis[x].id == 'li_' + thechosenone)
			{
				lis[x].className = 'bonus_active';
			}
			else
			{
				lis[x].className = '';
			}
		}
	}
}