/**
 * Project :	kTs
 * Copyright :	2005 
**/

function ChangeLanguage(page,lng) {
	location.href=page+'?lng='+lng;
}

function CheckDonations(form) {
if (isNaN(form.amount.value) || form.amount.value=='') {
	alert('Please, insert a valid amount (like 4 or 4.50)!');
	return false;
	}
return true;
}

function CheckPayments(form) {
var imei=form.imei_code.value;
if (isNaN(imei) || imei.length!=15) {
	alert('Please, insert a valid IMEI code of 15 numbers!');
	return false;
	}
return true;
}

function popUp(URL) {
	day = new Date();
	idtime = day.getTime();
	eval("page" + idtime + " = window.open(URL, '" + idtime + "', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=300,height=300,left=62,top=134');");
}

function CheckEmailValid(checkThisEmail) {
var myEMailIsValid = true;
var myAtSymbolAt = checkThisEmail.indexOf('@');
var myLastDotAt = checkThisEmail.lastIndexOf('.');
var mySpaceAt = checkThisEmail.indexOf(' ');
var myLength = checkThisEmail.length;


// at least one @ must be present and not before position 2
// @yellow.com : NOT valid
// x@yellow.com : VALID

if (myAtSymbolAt < 1 )
 {myEMailIsValid = false}


// at least one . (dot) afer the @ is required
// x@yellow : NOT valid
// x.y@yellow : NOT valid
// x@yellow.org : VALID

if (myLastDotAt < myAtSymbolAt)
 {myEMailIsValid = false}

// at least two characters [com, uk, fr, ...] must occur after the last . (dot)
// x.y@yellow. : NOT valid
// x.y@yellow.a : NOT valid
// x.y@yellow.ca : VALID

if (myLength - myLastDotAt <= 2)
 {myEMailIsValid = false}


// no empty space " " is permitted (one may trim the email)
// x.y@yell ow.com : NOT valid

if (mySpaceAt != -1)
 {myEMailIsValid = false}

if (myEMailIsValid == false) alert("Sorry, email is NOT valid!")

return myEMailIsValid
}
