// JavaScript Document
$(document).ready(rtaPageReady);

function rtaPageReady(){
	if(ctryCd == "AE"){
		$('#nationalLogo').attr("src", "../images/rta/nta_logo.gif");
	}
	
	if(location.href.indexOf('rta_index') > -1){
		var flashvars = {};
		flashvars.MdlCode = MdlCode;
		var params = {};
		params.wmode = "opaque";
		var attributes = {};
		attributes.id = "colorsshow";
		attributes.name = "colorsshow";
		swfobject.embedSWF("../flash/rta_Child-Safety-tvc.swf", "rta_flash", "558", "382", "9.0.0", false, flashvars, params, attributes);
	}
}

function isValidEmail(email){
	var reg = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	return reg.exec(email);
}// isValidEmail

function validate(){
	msg = "";
	
	if(document.getElementById("senderName").value == document.getElementById("senderName").defaultValue) {
		msg += "-Your name required\n";
	}

	if(document.getElementById("senderEmail").value == document.getElementById("senderEmail").defaultValue) {
		msg += "-Your email required\n";
	} else if(!isValidEmail(document.getElementById("senderEmail").value)) {
		msg += "-Your email is invalid\n";
	}
	
	if(document.getElementById("name").value == document.getElementById("name").defaultValue) {
		msg += "-Your friend's name required\n";
	}

	if(document.getElementById("email").value == document.getElementById("email").defaultValue) {
		msg += "-Your friend's email required\n";
	} else if(!isValidEmail(document.getElementById("email").value)) {
		msg += "-Your friend's email is invalid";
	}
	
	if(msg != ""){
		alert("Please pay attention to the following:\n--------------------------------------------\n"+msg);
		return false;
	} else {
		return true;
	}
	
	//(msg == "") ? return true; : alert(msg); return false;
}
