//************************************************
// popURL()
//************************************************
function popURL(URL, NAME, W, H) {
	
    // Options
	WX       = (screen.availWidth  - W) * 0.5;
	WY       = (screen.availHeight - H) * 0.5;
	FEATURES = "";
	FEATURES = FEATURES + "height=" + H + ", width=" + W + ", left=" + WX + ", top=" + WY + ", screenX=" + WX + ", screenY=" + WY;
	FEATURES = FEATURES + ", location=no, menubar=no, resizable=no, scrollbars=yes, status=yes, toolbar=no";
	
	// Open popup window
	window.open(URL, NAME, FEATURES);
	
} // popURL


//************************************************
// focusSearch()
//************************************************
function focusSearch() {
	
	if (document.search_game.src.value == "search game ...") {
		document.search_game.src.value = "";
	}
	
} // focusSearch


//************************************************
// contactUs()
//************************************************
function contactUs() {
	
	URL = document.footer.BASE_URL.value + "contact.php";
    popURL(URL, "contact", 350, 425);
	
} // contactUs



//************************************************
// sendToFriend()
//************************************************
function sendToFriend(MEDIATYPE, MEDIAID) {
	
	URL = "sendToFriend.php?mediatype=" + MEDIATYPE + "&mediaid=" + MEDIAID;
    popURL(URL, "sendToFriend", 350, 500);
	
} // sendToFriend



//*************************************************************
// setImage()
//*************************************************************
function setImage(imgName, imgURL) {
	
	if(document.images) {
    	document.images[imgName].src =imgURL;
	}
	
}


//************************************************
// setDivHtml()
//************************************************
function setDivHtml(DIV, HTML) {
	
	var el = (document.getElementById)? document.getElementById(DIV): (document.all)? document.all[DIV]: (document.layers)? document.layers[DIV]: null;
  	if (!el) return;
	
  	//var cntnt = '<div class="info">' + HTML + '</div>';
	var cntnt = HTML;
	
  	if (typeof el.innerHTML != "undefined") {
    	el.innerHTML = cntnt;
  	} else if (document.layers) {
   		el.document.write(cntnt);
   		el.document.close();
  	}
	
} // setDivHtml


//************************************************
// submitSendGame()
//************************************************
function submitSendGame() {
	
	// EMAIL
	if (!checkEmail(document.sendToFriend.sendToEmail1.value)) {return;}
	
	
	// FIRSTNAME
	if (document.sendToFriend.yourName.value.length == 0) {
		alert("Please enter your name.");
		return;
	}
	
	// Submit form
	document.sendToFriend.submit();
	
} // soumettre


//************************************************
// submitContactUs()
//************************************************
function submitContactUs() {
	
	// EMAIL
	if (!checkEmail(document.contact_us.yourEmail.value)) {return;}
	
	// Submit form
	document.contact_us.submit();
	
} // soumettre


//************************************************
// checkEmail()
//************************************************
function checkEmail(VAL) {
	
	if (VAL.length == 0) {
		alert("Please specify an email address.");
		return false;
	}
	
	if (VAL.indexOf("@") == -1) {
		alert("Please specify a valid email address.");
		return false;
	}
	
	return true;
	
} // checkEmail