//change parent window URL and close self
function changeOpener(url) 
{
	if (window.opener == null || window.opener.closed) 
	{
		window.open(url, '', '');
		window.close();		
	} else 
	{
		window.opener.top.location.href = url;
		window.close();		
	}
}
//end of changeOpener

//change parent window URL 
function winOpener(url) 
{
	if (window.opener == null || window.opener.closed) 
	{
		window.open(url, '', '');
		window.opener.focus();	
	} else 
	{
		window.opener.top.location.href = url;
		window.opener.focus();
	}
}
//end of winOpener



//Check email validation
function check_email(email)
{
	var valid_at = "@";
	var valid_dot = ".";
	var valid_email = "abcdefghijklmnopqrstuvwxyz1235467890_@-.";
	if (email.value == '')
	{
		alert("Please fill in your email");
		email.focus();
		return false;
	} else 
	{
		has_at = false;
		has_dot = false;
		for (var i=0; i<email.value.length; ++i) 
		{
			temp = email.value.charAt(i);
			if (valid_email.indexOf(temp) == -1) 
			{
			    alert("Please enter a valid email address");
			    email.focus();
			    return false;
			}
			
			if (valid_at.indexOf(temp) != -1) 
			{
			   	has_at = true;
			}

			if (valid_dot.indexOf(temp) != -1) 
			{
			   	has_dot = true;
			}
		} 
		
		if (!has_at) 
		{
			alert("Please enter a valid email address");
			email.focus();
			return false;
		}
		
		if (!has_dot) 
		{
			alert("Please enter a valid email address.");
			email.focus();
			return false;
		}
	}
	return true;	
} 
//end of function checkEmail



function check_phone_num(num)
{
	var valid_phone = "1234567890- ";
	if (num.value == "")
	{
		alert("Please fill in contact number.");
		num.focus();
		return false;
		return true;
	}else
	{
		if (num.value.length != 8) {
					alert("Please fill in correct contact number.");
			   	num.focus();
			   	return false;
			}
		for (var i=0; i<num.value.length; i++)  //start for loop check contact_number validation
		{
			temp = num.value.charAt(i);
			//if (valid_phone.indexOf(temp) == -1){
			if ((i==0 && (temp == "1" || temp == "4" || temp == "0")) || valid_phone.indexOf(temp) == -1){
					alert("Please fill in correct contact number.");
			   	num.focus();
			   	return false;
				}
		} // end for loop
	}
	return true; 
}