function checkSuccess() {
	if (window.location.search != "") {
		
		longueur = window.location.search.length - 1;
		data = window.location.search.substr(1,longueur);
		
		donnees = data.split("&");
		urlvar = new Array();
		urlvarnum = new Array();
		for (var i=0; i < donnees.length; i++) {
			position = donnees[i].indexOf("=");
			variable = donnees[i].substr(0,position);
			pos = position + 1;
			valeur = decodeURI(donnees[i].substr(pos,donnees[i].length));

			if (variable=="status") {
				if (valeur=="success") {
					alert("you have entered the competition.");
					
				} else {
					alert("an arror occured please try again later");
				}
			}
			location.href = location.href.substring(0,location.href.length-(longueur+1));
		}
	}
}

function isEmpty(inputStr) { 
    	if ( null == inputStr || "" == inputStr ) { 
    		return true; 
    	} 
    	return false; 
    }
    
function isEmail(string) {
	if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
		return true;
	else
		return false;
}

function validate(isPopup)	{
	if (isPopup) {
		strFirst = document.getElementById("first-popup").value;
		strLast = document.getElementById("last-popup").value;
		strEmail = document.getElementById("email-popup").value;
		strEmailCf = document.getElementById("emailcf-popup").value;
	} else {
		strFirst = document.getElementById("first").value;
		strLast = document.getElementById("last").value;
		strEmail = document.getElementById("email").value;
		strEmailCf = document.getElementById("emailcf").value;
	}
	
	if (isEmpty(strFirst)) {
		alert("Enter first name.");
		return false;
	}
	
	if (isEmpty(strLast)) {
		alert("Enter last name.");
		return false;
	}
	
	if (!isEmail(strEmail))
	{
		alert("Enter a valid email address.");
		return false;
	} 
	
	if (strEmail!=strEmailCf)
	{
		alert("Email confirmation Error.");
		return false;
	} 
	
	document.getElementById("backurl").value = location.href;
	
	if (isPopup) {
		document.getElementById("first").value = strFirst;
		document.getElementById("last").value = strLast
		document.getElementById("email").value = strEmail;
		document.getElementById("emailcf").value = strEmailCf
		if (document.getElementById("news-popup").value!=null) {
			document.getElementById("news").value = document.getElementById("news-popup").value;
		}
	}
	document.subcriptionform.submit();
}
