function getCookie( name ) {
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
		return null;
	}
	if ( start == -1 ) return '';
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) 
		end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}

function popup(p,w,h){
	var left = (screen.availWidth/2) - (w/2);
	var top = (screen.availHeight/2) - (h/2);
	window.open(p,'Open','width='+w+',height='+h+',scrollbars=no,status=0, left='+left+', top='+top)
}
function checkForm(f) {
	var err='';
	//check name
	var name = f.yourName.value;
	if(name == '')
	{
		err +="Please enter your name";
		alert(err);
		f.yourName.focus();
		return false;
	}
	var email = f.email.value;

	if (email == ''){
		err += "Email address is not correct format, please enter a valid email address.";
		alert(err);
		f.email.focus();
		return false;
	}
	if (email.indexOf('@') <= 0 || email.indexOf('@') == email.length -1){	
		err += "- Invalid email\n- Please enter a valid email address";
	} else {
		var substr = email.substring(email.indexOf('@'),email.length);
		if (email.indexOf('.') <= 0) {	
			err += "- Invalid email \n- Please enter a valid email not a user login name";
		}
	}
	if (err != '') {
		alert(err);
		f.email.focus();
		return false;
	}
	//validate confirm email
	var confirmEmail = f.confirmEmail.value;
		if (confirmEmail == ''){
		err += "Confirm email address is not correct format, please enter a valid email address.";
		alert(err);
		f.confirmEmail.focus();
		return false;
	}
	if (confirmEmail.indexOf('@') <= 0 || confirmEmail.indexOf('@') == confirmEmail.length -1){	
		err += "- Invalid confirm email\n- Please enter a valid email address";
	} else {
		var substr = confirmEmail.substring(confirmEmail.indexOf('@'),confirmEmail.length);
		if (confirmEmail.indexOf('.') <= 0) {	
			err += "- Invalid confirm email \n- Please enter a valid email not a user login name";
		}
	}
	if(email != confirmEmail)
	{
		alert("Email and confirm email not match.");
		f.confirmEmail.focus();
		return false;
	}
	//check password
	var pass = f.password.value;
	if (pass=='') {
		alert('Please enter your password.');
		f.password.focus();
		return false;
	}
	var confirmpassword = f.confirmpassword.value;
	if(confirmpassword=='')
	{
		alert("Please enter confirm password.");
		f.confirmpassword.focus();
		return false;
	}
	if(pass != confirmpassword)
	{
		alert("Your password and confirm password not match.");
		f.confirmpassword.focus();
		return false;
	}
	//validate business name
	var businessname= f.businessName.value;
	if(businessname =='')
	{
		alert("Enter your business name.");
		f.businessname.focus();
		return false;
	}
	var phone = f.phone.value;
	if(phone=='')
	{
		alert("Please enter your business phone number.")	
		f.phone.focus();
		return false;
	}
	var street = f.street.value;
	if(street =='')
	{
		alert("Enter your address and street number.");
		f.street.focus();
		return false;
	}
	var location = f.location.value;
	if(location =='')
	{
		alert("Please enter your bussiness location or suburb or city.");
		f.location.focus();
		return false;
	}
	//check security
	var security = f.security.value;
	if(security =='')
	{
		alert("You must enter security code - 6 digit numbers.");
		f.security.focus();
		return false;
	}
		
	return true;
}
function showStatus() {
	window.status='http://www.megaclassified.com';
}
function checkTextBoxSearch (str) {
	var textVal = str.value;	
	if (textVal == '') {
		alert("Please enter a keyword to search.");
		str.focus();
		return false;
	}
	return true;
}


showStatus();
