var img1 = new Image();
img1.src = "images/BtnPlay_mo.png";
img1.src = "images/BtnDL_mo.png";
img1.src = "images/1_btn_mo.gif";
img1.src = "images/2_btn_mo.gif";
img1.src = "images/3_btn_mo.gif";
img1.src = "images/4_btn_mo.gif";
img1.src = "images/5_btn_mo.gif";
img1.src = "images/BtnPlay_mo.png";
img1.src = "images/PlayOnlineTitle.gif";

function handleOver(obj,flag)   {
    var name = obj.src;
    var file = name.substring(0,name.lastIndexOf("."));
    var file = file.replace("_mo","");
    var ext = name.substring(name.lastIndexOf("."),name.length);
    var over = (flag==1) ? "_mo":"";
    var newfile = file+over+ext;
    obj.src = newfile;
}

function showGameFrame (titleImgSrc, gameUrl, type) {
	var width = document.documentElement.clientWidth;
	if(width<2000)  {
		var title = document.getElementById(type+"_frameTitle");
   		title.src = titleImgSrc;
		document.getElementById(type).style.display='block';
		document.getElementById(type).style.height = document.getElementsByTagName("body")[0].offsetHeight+"px";
		document.getElementById('fade').style.display = 'block';
		document.getElementById('fade').style.height = document.getElementsByTagName("body")[0].offsetHeight+"px";
		document.getElementById(type+"_frm").src = gameUrl;
		document.getElementById(type+"_frm").scrolling = "no";
	}else{
		location.href = gameUrl;
	}
}
 
function closeWindow()  {
     document.getElementById('gamePopup_big').style.display = 'none';
     document.getElementById('gamePopup_small').style.display = 'none';
     document.getElementById('fade').style.display='none'
     document.getElementById("gamePopup_big_frm").src = "about:blank";
     document.getElementById("gamePopup_big_frm").scrolling = "no";
     document.getElementById("gamePopup_small_frm").src = "about:blank";
     document.getElementById("gamePopup_small_frm").scrolling = "no";
}
function startGame() {
	showGameFrame("images/PlayOnlineTitle.gif", "gamePopup.html", 'gamePopup_big');
}

function Game_1() {
	showGameFrame("images/PlayOnlineTitle2.gif", "gamePopup_RPN.html", "gamePopup_small");
}

function Game_2() {
	showGameFrame("images/PlayOnlineTitle3.gif", "gamePopup_Stella.html", "gamePopup_small");
}

function Game_3() {
	showGameFrame("images/PlayOnlineTitle4.gif", "gamePopup_Gluttony3.html", "gamePopup_small");
}

function btnCloseOver (curEl) {
	curEl.src = "images/closeBtn_over.gif";	
}
function btnCloseOut (curEl) {
	curEl.src = "images/closeBtn_out.gif";	
}
 
function gotoScores()   {
	showGameFrame("images/PlayOnlineTitle5.gif", "leaderBoards.html", 'gamePopup_big');
}

function sendBtnOver (curEl) {
	curEl.src = "images/Send_btn_over.gif";
}
function sendBtnOut (curEl) {
	curEl.src = "images/Send_btn.gif";
}
 


var xmlhttp = false;



if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp = false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp = false;
	}
}
if (!xmlhttp) {
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
		}
	}
}

function activateField (curField) {
	var curStatus = curField.getAttribute("fieldStatus");
	if (curStatus == "0") {
		curField.value = "";
		curField.style.color = "#000000";
		curField.setAttribute("fieldStatus", "1");
	}
}
function sendMail (curBtn) {
	var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
	var emailField = document.getElementById("email");
	var emailStr = emailField.value;
	if (!filter.test(emailStr)) {
		alert('Please provide a valid email address');
		return false;
	}else{
		emailField.value = "Sending...";
		//emailField.style.color = "#000000";
		curBtn.disabled = true;
		sendMailRequest(emailStr);
	}
}

function sendMailRequest (emailStr) {
	xmlhttp.open("GET", "sendMail.aspx?email="+emailStr, true);
	xmlhttp.onreadystatechange = function () {
		if (xmlhttp.readyState == 4) {
			//if (xmlhttp.status == 200) {
				showEmailSent ();
				//alert(xmlhttp.responseText);
			//}else{
				//showEmailNotSent ();
			//}
		}
	}
	xmlhttp.send(null)
}
function showEmailSent () {
	var emailField = document.getElementById("email");
	var sendBtn = document.getElementById("sendBtn");
	emailField.value = "The e-mail was sent";
	emailField.style.color = "#0000FF";
	emailField.setAttribute("fieldStatus", "0");
	sendBtn.disabled = false;
}
function showEmailNotSent () {
	var emailField = document.getElementById("email");
	var sendBtn = document.getElementById("sendBtn");
	emailField.value = "The e-mail was not sent";
	emailField.style.color = "#FF0000";
	emailField.setAttribute("fieldStatus", "0");
	sendBtn.disabled = false;
}
