// JavaScript Document

function buttonChange(obj, new_style) {
	if (new_style == "over") {
		obj.className = "buttonOver";
	}else{
		obj.className = "button";
	}
}

// help window
function helpWindow(screenwidth,screenheight,url,scroll) {
	var winl = ((screen.width - (screenwidth)) / 2)-12;
	var wint = ((screen.height - (screenheight)) / 2)-20;
	
	winprops = 'height='+screenheight+',width='+screenwidth+',top='+wint+',left='+winl+',scrollbars='+scroll+',toolbar=no';
	
	win = window.open('help/'+url, 'wallpaper', winprops);
}

function newWindow(screenwidth,screenheight,url,scroll) {
	var winl = ((screen.width - (screenwidth)) / 2)-12;
	var wint = ((screen.height - (screenheight)) / 2)-20;
	
	winprops = 'height='+screenheight+',width='+screenwidth+',top='+wint+',left='+winl+',scrollbars='+scroll+',toolbar=no';
	
	win = window.open(url, 'wallpaper', winprops); win.focus();
}

function paperOpen(screenwidth,screenheight,url,title) {
	var current_image = "wallpaper.php?id="+title+"&size="+screenwidth+"&style="+ url;
	if (screenwidth == "640") {
		screenheight = 480;
	}else if (screenwidth == "800") {
		screenheight = 600;
	}else if (screenwidth == "1024") {
		screenheight = 768;
	}else {
		screenheight = 864;
	}
	var winl = ((screen.width - (screenwidth)) / 2)-12;
	var wint = ((screen.height - (screenheight)) / 2)-20;
	
	winprops = 'height='+screenheight+',width='+screenwidth+',top='+wint+',left='+winl+',scrollbars="auto';
	
	win = window.open(current_image, 'wallpaper', winprops);

}


function doLogin() {
	if (document.getElementById('login_username').value == "username") {
				alert(":::: FOREVERFRIENDS MESSAGE :::: \n\nPlease type your foreverfriends username and password in the boxes provided");	
				return false;
	}else{
		if (document.getElementById('login_remember').checked) {
			if (window.confirm(":::FOREVERFRIENDS MESSAGE::: \n\nYour username and password will be stored on this computer\n\nIf this is a shared computer you may not want to use this option.\n\nIf you choose to be remembered, every time you visit foreverfriends.co.uk you will automatically be logged in.\n\nClick 'OK' to continue or Click 'CANCEL' to login normally\n\nPlease note: You can deactivate this feature at any time by clicking 'log out'.")) {
				return true;
			} else {
				document.getElementById('login_remember').checked = false;
				return true;
			}
		}else{
			return true;
		}
	}
}

function showWindow(win,width,height) {
	if (self.innerWidth) {
		var docWidth = self.innerWidth;
		var docHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientWidth) {
		var docWidth = document.documentElement.clientWidth;
		var docHeight = document.documentElement.clientHeight;
		var scrolldif = document.documentElement.scrollTop;
	}
	else if (document.body) {
		var docWidth = document.body.clientWidth;
		var docHeight =document.body.clientHeight;
		var scrolldif = document.body.scrollTop;
		
	}
	if (document.documentElement) {
		var scrolldif = document.documentElement.scrollTop;
		if (document.body.scrollTop > 0) {
			var scrolldif = document.body.scrollTop;
		}
	}
	

	var winl = ((docWidth - (width)) / 2)-12 ;
	var wint = ((docHeight - (height)) / 2)-20;
	//stop it running into the Flash menu
	if (scrolldif < 190) {
		scrolldif = 190;
	}else{
		scrolldif += 20;
	}
	if (document.layers) { 
		document.getElementById(win).left = winl;
		document.getElementById(win).top = scroldif;
	}else{
		document.getElementById(win).style.left = winl + "px";
		document.getElementById(win).style.top = scrolldif + "px";
	}
	
	document.getElementById(win).style.visibility = 'visible';
	
}

function closeWindow(win) {
	document.getElementById(win).style.visibility = 'hidden';
}

function launchPaper(paper,style,offset) {
			pap = document.getElementById(paper);
			if (pap.options[pap.selectedIndex].value ==  '' || pap.options[pap.selectedIndex].value ==  "Size") {
				alert("Please choose a wallpaper size from the dropdown menu");
			}else{
				paperOpen(pap.options[pap.selectedIndex].value,400,'' + style + '',offset);
				//pap.selectedIndex = 0;
			}
}




