var emailExpression=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/; //xxx@xxxx.com
var alphanumericExpression = /^[0-9A-Za-z]+$/; //abc123 , abc, a23, 123
var alphanumeric_spaceExpression = /^[0-9a-zA-Z\s]+$/; //abc 123
var numericExpression = /^[0-9]+$/; //123
var alphaExpression = /^[a-zA-Z]+$/; //abc
var alpha_spaceExpression = /^[a-zA-Z\s]+$/; //abc abc
var alpha_numericExpression = /^[a-z]+[0-9]+|[0-9]+[a-z]+$/; //abc123
var descriptionExpression  = /([\<])([^\>]{1,})*([\>])/i; // no html format
var dollarExpression = /^((\$\d*)|(\$\d*\.\d{2})|(\d*)|(\d*\.\d{2}))$/;

function js_show_share()
{
	var share = document.getElementById('sideinfo');
	if(share.style.display == 'block')
	{
		$('#sideinfo').hide("blind");
	}
	else
	{
		$('#sideinfo').show("blind");
		share.style.display = 'block';
	}
}

function js_popup(pages,url)
{
	$('#result-loader').show();
	$.ajax({
		type:'POST',
		url: '../lib/function/popup.php',
		data:'pages='+pages+'&url='+url,
		success: function(results){
			$('#popinfo').html(results).show();
			popup('popinfo');
		},
		complete: function(){$('#result-loader').hide();}
		});
	return false;
}

function js_close_popup()
{
	document.getElementById('popbg').style.display = 'none';
	document.getElementById('popinfo').style.display = 'none';
}

/* SHARE */
function js_share(url,title,share)
{
	var features = 'status=1,location=0,menubar=0,resizable=1,scrollbars=1,width=650,height=600';
	if(share == 'facebook')
	{
		window.open('http://www.facebook.com/sharer.php?u='+ url +'&t='+ title,'',features);
	}
	else if(share == 'delicious')
	{
		window.open('http://del.icio.us/post?url='+ url +'&title='+ title,'',features);
	}
	else if(share == 'digg')
	{
		window.open('http://digg.com/submit?url='+ url +'&title='+ title,'',features);
	}
	else if(share == 'stumbleupon')
	{
		window.open('http://www.stumbleupon.com/submit?url='+ url +'&title='+ title,'',features);
	}
	else if(share == 'twitter')
	{
		window.open('http://twitter.com/share?url='+ url +'&text='+ title,'',features);
	}
	else if(share == 'myspace')
	{
		window.open('http://www.myspace.com/Modules/PostTo/Pages/?u='+ url +'&t='+ title,'',features);
	}
	else if(share == 'linkedin')
	{
		window.open('http://www.linkedin.com/shareArticle?mini=true&url='+ url +'&title='+ title,'',features);
	}
	else if(share == 'google')
	{
		window.open('http://www.google.com/bookmarks/mark?op=edit&bkmk='+ url +'&title='+ title,'',features);
	}
	else if(share == 'yahoo')
	{
		window.open('http://myweb.yahoo.com/myresults/bookmarklet?u='+ url +'&t='+ title,'',features);
	}
	else if(share == 'windowlive')
	{
		window.open('https://favorites.live.com/quickadd.aspx?marklet=1&mkt=en-us&url='+ url +'&title='+ title,'',features);
	}
	else if(share == 'googlebuzz')
	{
		window.open('http://www.google.com/buzz/post?url='+ url,'',features);
	}
	else if(share == 'yahoobuzz')
	{
		window.open('http://buzz.yahoo.com/buzz?targetUrl='+ url,'',features);
	}
	else if(share == 'technorati')
	{
		window.open('http://technorati.com/faves?add='+ url,'',features);
	}	
}

/* FEEDBACK */
function js_feedback(form)
{
	$('.error').hide();
	var error_num = 0;
	var name = $('#txtname').val();
	var email = $('#txtemail').val();
	var contact = $('#txtcontact').val();
	var description = $('#txtdescription').val();
	var type = "";
	
	for (var i = 0; i < document.getElementsByName('r_type').length; i++)
    {
		if (document.getElementsByName('r_type')[i].checked)
        {
            type = document.getElementsByName('r_type')[i].value;
        }
    }
	
    if(name == '')
    {
		$('#name_error').html('Please enter your name').show();
        error_num = 1;
    }
	
    if(email == '')
    {
		$('#email_error').html('Please enter your email address').show();
        error_num = 1;
    }
    else if(!emailExpression.test(email)) 
	{
		$('#email_error').html('Enter a valid e-mail, Invalid Email Address').show();
        error_num = 1;
	}
	
	if(contact == '')
    {
		$('#contact_error').html('Please enter your contact no').show();
        error_num = 1;
    }
	
	if(description == '')
    {
		$('#message_error').html('Please enter your feedback message').show();
        error_num = 1;
    }
	
	if(error_num == 0)
	{
		$('#result-loader').show();
		
		$.ajax({
			type: 'POST',
			url: '../lib/function/feedback.php',
			data: 'name='+name+'&email='+email+'&contact='+contact+'&description='+description+'&type='+type,		
			success: function(results){			
				$('#feedback').html(results).show();
			},
			complete: function(){$('#result-loader').hide();}
		});
	}
}

/* RECOMMEND */
function js_recommend_friend(form)
{
	$('.error').hide();
	var error_num = 0;
	var yourName = $('#txtYourName').val();
	var yourEmail = $('#txtYourEmail').val();
	var friend1Name = $('#friend1Name').val();
	var friend1Email = $('#friend1Email').val();
	var friend2Name = $('#friend2Name').val();
	var friend2Email = $('#friend2Email').val();
	var friend3Name = $('#friend3Name').val();
	var friend3Email = $('#friend3Email').val();
	var friend4Name = $('#friend4Name').val();
	var friend4Email = $('#friend4Email').val();
	var friend5Name = $('#friend5Name').val();
	var friend5Email = $('#friend5Email').val();
	var description = $('#txtdescription').val();
	var url = $('#hidurl').val();
    if(yourName == '')
    {
		$('#name_error').html('Please enter your name').show();
        error_num = 1;
    } 
    if(yourEmail == '')
    {
		$('#email_error').html('Please enter your email address').show();
        error_num = 1;
    }
    else if(!emailExpression.test(yourEmail)) 
	{
		$('#email_error').html('Enter a valid e-mail, Invalid Email Address').show();
        error_num = 1;
	}
	if(friend1Email != '')
	{
		if(!emailExpression.test(friend1Email))
		{
			$('#email1_error').html('Enter a valid e-mail, Invalid Email Address').show();
			error_num = 1;
		}
		if(friend1Name == '')
		{
			$('#name1_error').html('Please enter friend name').show();
        	error_num = 1;
		}
	}
	if(friend2Email != '')
	{
		if(!emailExpression.test(friend2Email))
		{
			$('#email2_error').html('Enter a valid e-mail, Invalid Email Address').show();
			error_num = 1;
		}
		if(friend2Name == '')
		{
			$('#name2_error').html('Please enter friend name').show();
        	error_num = 1;
		}
	}
	if(friend3Email != '')
	{
		if(!emailExpression.test(friend3Email))
		{
			$('#email3_error').html('Enter a valid e-mail, Invalid Email Address').show();
			error_num = 1;
		}
		if(friend3Name == '')
		{
			$('#name3_error').html('Please enter friend name').show();
        	error_num = 1;
		}
	}
	if(friend4Email != '')
	{
		if(!emailExpression.test(friend4Email))
		{
			$('#email4_error').html('Enter a valid e-mail, Invalid Email Address').show();
			error_num = 1;
		}
		if(friend4Name == '')
		{
			$('#name4_error').html('Please enter friend name').show();
        	error_num = 1;
		}
	}
	if(friend5Email != '')
	{
		if(!emailExpression.test(friend5Email))
		{
			$('#email5_error').html('Enter a valid e-mail, Invalid Email Address').show();
			error_num = 1;
		}
		if(friend5Name == '')
		{
			$('#name5_error').html('Please enter friend name').show();
        	error_num = 1;
		}
	}
	
	if(error_num == 0)
	{
		$('#result-loader').show();
		
		$.ajax({
			type: 'POST',
			url: '../lib/function/recommend.php',
			data: 'yourName='+yourName+'&yourEmail='+yourEmail+'&friend1Name='+friend1Name+'&friend1Email='+friend1Email
			+'&friend2Name='+friend2Name+'&friend2Email='+friend2Email
			+'&friend3Name='+friend3Name+'&friend3Email='+friend3Email
			+'&friend4Name='+friend4Name+'&friend4Email='+friend4Email
			+'&friend5Name='+friend5Name+'&friend5Email='+friend5Email+'&description='+description+'&url='+url,		
			success: function(results){			
				$('#recommend').html(results).show();
			},
			complete: function(){$('#result-loader').hide();}
		});
	}
}

function js_contact_us(form)
{
	$('.error').hide();
	var error_num = 0;
	
	var topic = form.seltopic.value;
	var company = $('#txtcompany').val();
	var name = $('#txtname').val();
	var mobile = $('#txtmobile').val();
	var phone = $('#txtphone').val();
	var fax = $('#txtfax').val();
	var email = $('#txtemail').val();
	var message = $('#txtmessage').val();
	var postcode = $('#txtpostcode').val();
	
	if(company == 'Fill in your company name')
	{
		company = '';
	}
	
	if(topic == '')
	{
		$('#topic_error').html("Topic cannot be empty").show();
		error_num = 1;
	}
	
	if(name == '' || name == 'Fill in your name')
	{
		$('#name_error').html("Contact person's name cannot be empty").show();
		error_num = 1;
	}
	
	if(message == '' || message == 'Fill in your message')
	{
		$('#message_error').html("Message cannot be empty").show();
		error_num = 1;
	}
	
	if(mobile == '' && phone == '' || mobile == 'Fill in your mobile no' && phone == 'Fill in your phone no')
	{
		$('#contact_error').html("At least one contact no is required").show();
		error_num = 1;
	}
	
	if(email == '' || email == 'Fill in your email address')
	{
		$('#email_error').html("Email cannot be empty").show();
		error_num = 1;
	}
	else if(!emailExpression.test(email))
	{
		$('#email_error').html("Invalid email format").show();
		error_num = 1;
	}
	
	if(mobile == 'Fill in your mobile no')
	{
		mobile = '';
	}
	
	if(phone == 'Fill in your phone no')
	{
		phone = '';
	}
	
	if(fax == 'Fill in your fax no')
	{
		fax = ''
	}
	
	if(error_num == 0)
	{
		$('#result-loader').show();
		
		$.ajax({
			type:'POST',
			url: 'lib/function/contact_us.php',
			data:'company='+company+'&name='+name+'&mobile='+mobile+'&phone='+phone+'&fax='+fax+'&email='+email+'&message='+message+'&topic='+topic,
			success: function(results){
				alert("Your inquiry was sent successfully, our staff will get back to you within 1 business day.")
				window.location.reload(true);
			},
			complete: function(){$('#result-loader').hide();}
			});
		return false;
	}
}

/*WHOIS*/
function js_whois_search(form)
{
	$('.error').hide();
	var error_num = 0;
	var domain = $('#txtdomain').val();
	var extention = form.selextention.value;
	
	if(domain == '')
	{
		$('#domain_error').html("Domain name cannot be empty").show();
		error_num = 1;
	}
	
	if(error_num == 0)
	{
		$('#result-loader').show();
		
		$.ajax({
			type:'POST',
			url: 'function/whois_search.php',
			data:'domain='+domain+'&extention='+extention,
			success: function(results){
				$('#whois_result').html(results).show();
			},
			complete: function(){$('#result-loader').hide();}
			});
		return false;
	}
}

/*ECCOMMERCE*/
function js_eintro(pages)
{
	$('#result-loader').show();
		
	$.ajax({
		type:'POST',
		url: 'function/intro.php',
		data:'pages='+pages,
		success: function(results){
			$('#intro').html(results).show();
		},
		complete: function(){$('#result-loader').hide();}
		});
	return false;
}

function js_eregister(type)
{
	$('#result-loader').show();
		
	$.ajax({
		type:'POST',
		url: 'function/eregister.php',
		data:'type='+type,
		success: function(results){
			$('#div_esubscribe').html(results).show();
		},
		complete: function(){$('#result-loader').hide();}
		});
	return false;
}

function js_eplan(plan_id)
{
	$('#result-loader').show();
		
	$.ajax({
		type:'POST',
		url: 'function/eplan.php',
		data:'plan_id='+plan_id,
		success: function(results){
			$('#eplan_result').html(results).show();
		},
		complete: function(){$('#result-loader').hide();}
		});
	return false;
}

function js_transfer_domain(domain_name)
{
	$('#result-loader').show();
	
	$.ajax({
		type:'POST',
		url: 'function/etransfer.php',
		data:'domain_name='+domain_name,
		success: function(results){
			js_show_plan();
		},
		complete: function(){$('#result-loader').hide();}
		});
	return false;
}

function js_show_plan()
{
	document.getElementById('div_domain').style.display = 'none';
	document.getElementById('div_plan').style.display = 'block';
}

function js_hide_result()
{
	document.getElementById('domain_result').style.display = 'none';
	document.getElementById('div_plan').style.display = 'none';
}


function js_eregister_form(form,type,referral)
{
	$('.error').hide();
	var error_num = 0;
	
	if(type == 'personal')
	{
		var identity = $('#txtidentity').val();
		var contact1 = $('#txtcontact1').val();
		var contact2 = $('#txtcontact2').val();
	}
	else if(type == 'business')
	{
		var business = $('#txtbusiness').val();
		var register = $('#txtregister').val();
		var website = $('#txtwebsite').val();
		var resignation = $('#txtresignation').val();
		var office = $('#txtoffice').val();
		var ext = $('#txtext').val();
	}

	var salutation = form.selsalutation.value;
	var firstname = $('#txtfirst').val();
	var lastname = $('#txtlast').val();
	
	var country = form.selcountry.value;
	var currency = form.selcurrency.value;
	var address = $('#txtaddress').val();
	var address1 = $('#txtaddress1').val();
	var postcode = $('#txtpostcode').val();
	var city = $('#txtcity').val();
	var state = form.selstate.value;
	
	var fax = $('#txtfax').val();
	var email = $('#txtemail').val();
	var confirmemail = $('#txtconfirmemail').val();
	var password = $('#txtpassword').val();
	var confirmpassword = $('#txtconfirmpassword').val();
	var question = form.selquestion.value;
	var answer = $('#txtanswer').val();
	var businesscategory = form.selbusicategories.value;
	var about = $('#txtabout').val();
	var txtreligion = $('#txtreligion').val();
	var religion = '';
	var plan = "";
	var setup = "";
	
	for (var i = 0; i < document.getElementsByName('r_plan').length; i++)
    {
		if (document.getElementsByName('r_plan')[i].checked)
        {
            plan = document.getElementsByName('r_plan')[i].value;
        }
    }
	
	for (var i = 0; i < document.getElementsByName('r_setup').length; i++)
    {
		if (document.getElementsByName('r_setup')[i].checked)
        {
            setup = document.getElementsByName('r_setup')[i].value;
        }
    }
	
	for (var i = 0; i < document.getElementsByName('r_religion').length; i++)
    {
		if (document.getElementsByName('r_religion')[i].checked)
        {
            religion = document.getElementsByName('r_religion')[i].value;
        }
    }

	if(firstname == '' || firstname == 'Fill in your first name')
	{
		$('#first_error').html("First name cannot be empty").show();
		error_num = 1;
	}
	else if(!alpha_spaceExpression.test(firstname))
	{
		$('#first_error').html("Invalid First Name format").show();
		error_num = 1;
	}
	
	if(lastname == '' || lastname == 'Fill in your last name')
	{
		$('#last_error').html("Last name cannot be empty").show();
		error_num = 1;
	}
	else if(!alpha_spaceExpression.test(lastname))
	{
		$('#last_error').html("Invalid Last Name format").show();
		error_num = 1;
	}

	if(address == '' && address1 == '' || address == 'Fill in your address' && address1 == 'Fill in your address')
	{
		$('#address_error').html("Address cannot be empty").show();
		error_num = 1;
	}
	
	if(postcode == '' || postcode == 'Fill in your postal code')
	{
		$('#postcode_error').html("Postcode cannot be empty").show();
		error_num = 1;
	}
	
	if(city == '' || city == 'Fill in your city')
	{
		$('#city_error').html("City cannot be empty").show();
		error_num = 1;
	}
	else if(!alpha_spaceExpression.test(city))
	{
		$('#city_error').html("Invalid City format").show();
		error_num = 1;
	}
	
	if(email == '' || email == 'Fill in your login email')
	{
		$('#email_error').html("Email cannot be empty").show();
		error_num = 1;
	}
	else if(!emailExpression.test(email))
	{
		$('#email_error').html("Invalid email format").show();
		error_num = 1;
	}
	
	if(confirmemail != email)
	{
		$('#confirmemail_error').html("Email are not match").show();
		error_num = 1;
	}
	
	if(password == '')
	{
		$('#password_error').html("Password cannot be empty").show();
		error_num = 1;
	}
	
	if(confirmpassword != password)
	{
		$('#confirmpassword_error').html("Password are not match").show();
		error_num = 1;
	}

	if(answer == '' || answer == 'Fill in your security answer')
	{
		$('#answer_error').html("Security Answer cannot be empty").show();
		error_num = 1;
	}
	
	if(religion == 'Other' && txtreligion == '')
	{
		$('#religion_error').html("Religion cannot be empty").show();
		error_num = 1;
	}
	else if(!alpha_spaceExpression.test(txtreligion) && religion == 'Other')
	{
		$('#religion_error').html("Invalid religion format").show();
		error_num = 1;
	}
	
	if(about == '' || about == 'Fill in your answer where your hear webber.my')
	{
		about = '';
	}
	
	if(fax == '' || fax == 'Fill in your fax no')
	{
		fax = '';
	}
	
	if(address == 'Fill in your address')
	{
		address = '';
	}
	
	if(address1 == 'Fill in your address')
	{
		address1 = '';
	}
	
	if(!document.getElementById('chkagree').checked)
	{
		$('#agree_error').html("Please check the terms and conditions").show();
		error_num = 1;
	}
	
	if(type == 'personal')
	{
		if(identity == '' || identity == 'Fill in your identity no')
		{
			$('#identity_error').html("Identity No cannot be empty").show();
			error_num = 1;
		}
		if(contact1 == '' && contact2 == '' || contact1 == 'Fill in your first contact no' && contact2 == 'Fill in your second contact no')
		{
			$('#contact_error').html("At least one contact no is required").show();
			error_num = 1;
		}
		
		if(contact1 == 'Fill in your first contact no')
		{
			contact1 = '';
		}
		
		if(contact2 == 'Fill in your second contact no')
		{
			contact2 = '';
		}
		var data = 'type='+type+'&referral='+referral+'&salutation='+salutation+'&firstname='+firstname+'&lastname='+lastname+'&country='+country+'&currency='+currency+'&address='+address+'&address1='+address1+'&postcode='+postcode+'&city='+city+'&state='+state+'&fax='+fax+'&email='+email+'&confirmemail='+confirmemail+'&password='+password+'&confirmpassword='+confirmpassword+'&question='+question+'&answer='+answer+'&businesscategory='+businesscategory+'&about='+about+'&txtreligion='+txtreligion+'&religion='+religion+'&plan='+plan+'&identity='+identity+'&contact1='+contact1+'&contact2='+contact2;
	}
	else if(type == 'business')
	{
		if(business == '' || business == 'Fill in your business name')
		{
			$('#business_error').html("Business name cannot be empty").show();
			error_num = 1;
		}
		
		if(register == '' || register == 'Fill in your business registration no')
		{
			$('#register_error').html("Business registration no cannot be empty").show();
			error_num = 1;
		}
		
		if(website == '' || website == 'Fill in your business website')
		{
			website = '';
		}
		
		if(resignation == '' || resignation == 'Fill in your resignation')
		{
			$('#resignation_error').html("Resignation cannot be empty").show();
			error_num = 1;
		}
		
		if(office == '' || office == 'Fill in your office no')
		{
			$('#office_error').html("Office no cannot be empty").show();
			error_num = 1;
		}
		
		if(ext == '' || ext == 'Fill in your office ext no')
		{
			ext = '';
		}
		
		var data = 'type='+type+'&referral='+referral+'&salutation='+salutation+'&firstname='+firstname+'&lastname='+lastname+'&country='+country+'&currency='+currency+'&address='+address+'&address1='+address1+'&postcode='+postcode+'&city='+city+'&state='+state+'&fax='+fax+'&email='+email+'&confirmemail='+confirmemail+'&password='+password+'&confirmpassword='+confirmpassword+'&question='+question+'&answer='+answer+'&businesscategory='+businesscategory+'&about='+about+'&txtreligion='+txtreligion+'&religion='+religion+'&plan='+plan+'&business='+business+'&register='+register+'&website='+website+'&resignation='+resignation+'&office='+office+'&ext='+ext+'&setup='+setup;
	}
	
	if(error_num == 0)
	{
		$('#result-loader').show();
		
		$.ajax({
			type:'POST',
			url: 'function/eregistration.php',
			data:data,
			success: function(results){
				$('#right_con').html(results).show();
			},
			complete: function(){$('#result-loader').hide();}
			});
		return false;
	}
}

/* WEBSITE */
function js_wintro(pages)
{
	$('#result-loader').show();
		
	$.ajax({
		type:'POST',
		url: 'function/intro.php',
		data:'pages='+pages,
		success: function(results){
			$('#intro').html(results).show();
		},
		complete: function(){$('#result-loader').hide();}
		});
	return false;
}

function js_wregister(type)
{
	$('#result-loader').show();
		
	$.ajax({
		type:'POST',
		url: 'function/wregister.php',
		data:'type='+type,
		success: function(results){
			$('#div_esubscribe').html(results).show();
		},
		complete: function(){$('#result-loader').hide();}
		});
	return false;
}

function js_wplan(plan_id)
{
	$('#result-loader').show();
		
	$.ajax({
		type:'POST',
		url: 'function/wplan.php',
		data:'plan_id='+plan_id,
		success: function(results){
			$('#eplan_result').html(results).show();
		},
		complete: function(){$('#result-loader').hide();}
		});
	return false;
}

function js_wregister_form(form,type,referral)
{
	$('.error').hide();
	var error_num = 0;
	
	if(type == 'personal')
	{
		var identity = $('#txtidentity').val();
		var contact1 = $('#txtcontact1').val();
		var contact2 = $('#txtcontact2').val();
	}
	else if(type == 'business')
	{
		var business = $('#txtbusiness').val();
		var register = $('#txtregister').val();
		var website = $('#txtwebsite').val();
		var resignation = $('#txtresignation').val();
		var office = $('#txtoffice').val();
		var ext = $('#txtext').val();
	}

	var salutation = form.selsalutation.value;
	var firstname = $('#txtfirst').val();
	var lastname = $('#txtlast').val();
	
	var country = form.selcountry.value;
	var currency = form.selcurrency.value;
	var address = $('#txtaddress').val();
	var address1 = $('#txtaddress1').val();
	var postcode = $('#txtpostcode').val();
	var city = $('#txtcity').val();
	var state = form.selstate.value;
	
	var fax = $('#txtfax').val();
	var email = $('#txtemail').val();
	var confirmemail = $('#txtconfirmemail').val();
	var password = $('#txtpassword').val();
	var confirmpassword = $('#txtconfirmpassword').val();
	var question = form.selquestion.value;
	var answer = $('#txtanswer').val();
	var businesscategory = form.selbusicategories.value;
	var about = $('#txtabout').val();
	var txtreligion = $('#txtreligion').val();
	var religion = '';
	var plan = "";
	var setup = "";
	
	for (var i = 0; i < document.getElementsByName('r_plan').length; i++)
    {
		if (document.getElementsByName('r_plan')[i].checked)
        {
            plan = document.getElementsByName('r_plan')[i].value;
        }
    }
	
	for (var i = 0; i < document.getElementsByName('r_setup').length; i++)
    {
		if (document.getElementsByName('r_setup')[i].checked)
        {
            setup = document.getElementsByName('r_setup')[i].value;
        }
    }
	
	for (var i = 0; i < document.getElementsByName('r_religion').length; i++)
    {
		if (document.getElementsByName('r_religion')[i].checked)
        {
            religion = document.getElementsByName('r_religion')[i].value;
        }
    }

	if(firstname == '' || firstname == 'Fill in your first name')
	{
		$('#first_error').html("First name cannot be empty").show();
		error_num = 1;
	}
	else if(!alpha_spaceExpression.test(firstname))
	{
		$('#first_error').html("Invalid First Name format").show();
		error_num = 1;
	}
	
	if(lastname == '' || lastname == 'Fill in your last name')
	{
		$('#last_error').html("Last name cannot be empty").show();
		error_num = 1;
	}
	else if(!alpha_spaceExpression.test(lastname))
	{
		$('#last_error').html("Invalid Last Name format").show();
		error_num = 1;
	}

	if(address == '' && address1 == '' || address == 'Fill in your address' && address1 == 'Fill in your address')
	{
		$('#address_error').html("Address cannot be empty").show();
		error_num = 1;
	}
	
	if(postcode == '' || postcode == 'Fill in your postal code')
	{
		$('#postcode_error').html("Postcode cannot be empty").show();
		error_num = 1;
	}
	
	if(city == '' || city == 'Fill in your city')
	{
		$('#city_error').html("City cannot be empty").show();
		error_num = 1;
	}
	else if(!alpha_spaceExpression.test(city))
	{
		$('#city_error').html("Invalid City format").show();
		error_num = 1;
	}
	
	if(email == '' || email == 'Fill in your login email')
	{
		$('#email_error').html("Email cannot be empty").show();
		error_num = 1;
	}
	else if(!emailExpression.test(email))
	{
		$('#email_error').html("Invalid email format").show();
		error_num = 1;
	}
	
	if(confirmemail != email)
	{
		$('#confirmemail_error').html("Email are not match").show();
		error_num = 1;
	}
	
	if(password == '')
	{
		$('#password_error').html("Password cannot be empty").show();
		error_num = 1;
	}
	
	if(confirmpassword != password)
	{
		$('#confirmpassword_error').html("Password are not match").show();
		error_num = 1;
	}

	if(answer == '' || answer == 'Fill in your security answer')
	{
		$('#answer_error').html("Security Answer cannot be empty").show();
		error_num = 1;
	}
	
	if(religion == 'Other' && txtreligion == '')
	{
		$('#religion_error').html("Religion cannot be empty").show();
		error_num = 1;
	}
	else if(!alpha_spaceExpression.test(txtreligion) && religion == 'Other')
	{
		$('#religion_error').html("Invalid religion format").show();
		error_num = 1;
	}
	
	if(about == '' || about == 'Fill in your answer where your hear webber.my')
	{
		about = '';
	}
	
	if(fax == '' || fax == 'Fill in your fax no')
	{
		fax = '';
	}
	
	if(address == 'Fill in your address')
	{
		address = '';
	}
	
	if(address1 == 'Fill in your address')
	{
		address1 = '';
	}
	
	if(!document.getElementById('chkagree').checked)
	{
		$('#agree_error').html("Please check the terms and conditions").show();
		error_num = 1;
	}
	
	if(type == 'personal')
	{
		if(identity == '' || identity == 'Fill in your identity no')
		{
			$('#identity_error').html("Identity No cannot be empty").show();
			error_num = 1;
		}
		if(contact1 == '' && contact2 == '' || contact1 == 'Fill in your first contact no' && contact2 == 'Fill in your second contact no')
		{
			$('#contact_error').html("At least one contact no is required").show();
			error_num = 1;
		}
		
		if(contact1 == 'Fill in your first contact no')
		{
			contact1 = '';
		}
		
		if(contact2 == 'Fill in your second contact no')
		{
			contact2 = '';
		}
		var data = 'type='+type+'&referral='+referral+'&salutation='+salutation+'&firstname='+firstname+'&lastname='+lastname+'&country='+country+'&currency='+currency+'&address='+address+'&address1='+address1+'&postcode='+postcode+'&city='+city+'&state='+state+'&fax='+fax+'&email='+email+'&confirmemail='+confirmemail+'&password='+password+'&confirmpassword='+confirmpassword+'&question='+question+'&answer='+answer+'&businesscategory='+businesscategory+'&about='+about+'&txtreligion='+txtreligion+'&religion='+religion+'&plan='+plan+'&identity='+identity+'&contact1='+contact1+'&contact2='+contact2;
	}
	else if(type == 'business')
	{
		if(business == '' || business == 'Fill in your business name')
		{
			$('#business_error').html("Business name cannot be empty").show();
			error_num = 1;
		}
		
		if(register == '' || register == 'Fill in your business registration no')
		{
			$('#register_error').html("Business registration no cannot be empty").show();
			error_num = 1;
		}
		
		if(website == '' || website == 'Fill in your business website')
		{
			website = '';
		}
		
		if(resignation == '' || resignation == 'Fill in your resignation')
		{
			$('#resignation_error').html("Resignation cannot be empty").show();
			error_num = 1;
		}
		
		if(office == '' || office == 'Fill in your office no')
		{
			$('#office_error').html("Office no cannot be empty").show();
			error_num = 1;
		}
		
		if(ext == '' || ext == 'Fill in your office ext no')
		{
			ext = '';
		}
		
		var data = 'type='+type+'&referral='+referral+'&salutation='+salutation+'&firstname='+firstname+'&lastname='+lastname+'&country='+country+'&currency='+currency+'&address='+address+'&address1='+address1+'&postcode='+postcode+'&city='+city+'&state='+state+'&fax='+fax+'&email='+email+'&confirmemail='+confirmemail+'&password='+password+'&confirmpassword='+confirmpassword+'&question='+question+'&answer='+answer+'&businesscategory='+businesscategory+'&about='+about+'&txtreligion='+txtreligion+'&religion='+religion+'&plan='+plan+'&business='+business+'&register='+register+'&website='+website+'&resignation='+resignation+'&office='+office+'&ext='+ext+'&setup='+setup;
	}
	
	if(error_num == 0)
	{
		$('#result-loader').show();
		
		$.ajax({
			type:'POST',
			url: 'function/wregistration.php',
			data:data,
			success: function(results){
				$('#right_con').html(results).show();
			},
			complete: function(){$('#result-loader').hide();}
			});
		return false;
	}
}

/*WEB HOSTING*/
function js_sub_hosting(product,plan,type)
{
	if(type != '')
	{
		window.location = 'https://webber.my/hosting/index.php?p=su&hp='+product+'&pp='+plan+'&pt='+type;
	}
	else
	{
		window.location = 'https://webber.my/hosting/index.php?p=su&hp='+product+'&pp='+plan;
	}
}

function js_hosting_receipt(id)
{
	window.open('https://webber.my/hosting/receipt_return.php?id='+id,'','status=1,location=0,menubar=0,scrollbars=1,width=650,height=600');
}

/*EMAIL*/
function js_sub_email(product,plan)
{
	window.location = 'https://webber.my/email/index.php?p=su&ep='+product+'&pp='+plan;
}

function js_email_receipt(id)
{
	window.open('https://webber.my/email/receipt_return.php?id='+id,'','status=1,location=0,menubar=0,scrollbars=1,width=650,height=600');
}

/*ESECURITY*/
function js_sub_security(certificate,package)
{
	window.location = 'https://webber.my/esecurity/index.php?p=subscribe&sc='+certificate+'&sp='+package;
}

function js_esecurity_receipt(id)
{
	window.open('https://webber.my/esecurity/receipt_return.php?id='+id,'','status=1,location=0,menubar=0,scrollbars=1,width=650,height=600');
}

function js_esecurity(form)
{
	$('.error').hide();
	var error_num = 0;
	
	var domain = $('#txtdomain').val();
	var name = $('#txtname').val();
	var company = $('#txtcompany').val();
	var address = $('#txtaddress').val();
	var city = $('#txtcity').val();
	var postcode = $('#txtpostcode').val();
	var contact = $('#txtcontact').val();
	var email = $('#txtemail').val();
	var captcha = $('#txtcaptcha').val();
	var state = form.selstate.value;
	var country = form.selcountry.value;
	var term = form.selterm.value;
	var certificate = '';
	var package = '';
	var addon = '';
	for (var i = 0; i < document.getElementsByName('r_package').length; i++)
    {
		if (document.getElementsByName('r_package')[i].checked)
        {
            package = document.getElementsByName('r_package')[i].value;
        }
    }
	
	for (var i = 0; i < document.getElementsByName('r_certificate').length; i++)
    {
		if (document.getElementsByName('r_certificate')[i].checked)
        {
            certificate = document.getElementsByName('r_certificate')[i].value;
        }
    }
	
	for (var i = 0; i < document.getElementsByName('chk_addon').length; i++)
    {
		if (document.getElementsByName('chk_addon')[i].checked)
        {
            addon = document.getElementsByName('chk_addon')[i].value;
        }
    }
	
	if(certificate == '')
	{
		$('#certificate_error').html("Select a SSL certificate").show();
		error_num = 1;
	}
	
	if(package == '')
	{
		$('#package_error').html("Select a SSL package").show();
		error_num = 1;
	}
	
	if(domain == '' || domain == 'Fill in your domain name')
	{
		$('#domain_error').html("Domain name cannot be empty").show();
		error_num = 1;
	}
	
	if(name == '' || name == 'Fill in your full name')
	{
		$('#name_error').html("Full name cannot be empty").show();
		error_num = 1;
	}
	
	if(company == '' || company == 'Fill in your company name')
	{
		$('#company_error').html("Company name cannot be empty").show();
		error_num = 1;
	}
	
	if(address == '' || address == 'Fill in your address')
	{
		$('#address_error').html("Address cannot be empty").show();
		error_num = 1;
	}
	
	if(city == '' || city == 'Fill in your city')
	{
		$('#city_error').html("City cannot be empty").show();
		error_num = 1;
	}
	
	if(postcode == '' || postcode == 'Fill in your postcode')
	{
		$('#postcode_error').html("Postcode cannot be empty").show();
		error_num = 1;
	}
	
	if(contact == '' || contact == 'Fill in your contact number')
	{
		$('#contact_error').html("Contact numbber cannot be empty").show();
		error_num = 1;
	}
	
	if(email == '' || email == 'Fill in your email address')
	{
		$('#email_error').html("Email address cannot be empty").show();
		error_num = 1;
	}
	else if(!emailExpression.test(email))
	{
		$('#email_error').html("Invalid email format").show();
		error_num = 1;
	}
	
	if(captcha == '')
	{
		$('#captcha_error').html("Security Code cannot be empty").show();
		error_num = 1;
	}
	
	if(error_num == 0)
	{
		$('#result-loader').show();
		
		$.ajax({
			type:'POST',
			url: 'function/registration.php',
			data:'domain='+domain+'&name='+name+'&company='+company+'&address='+address+'&city='+city+'&postcode='+postcode+'&contact='+contact+'&email='+email+'&captcha='+captcha+'&state='+state+'&country='+country+'&term='+term+'&certificate='+certificate+'&package='+package+'&addon='+addon,
			success: function(results){
				$('#right_con').html(results).show();
			},
			complete: function(){$('#result-loader').hide();}
			});
		return false;
	}

}

/* EMARKETING */
function js_emarketing(form)
{
	$('.error').hide();
	var error_num = 0;

	var website = $('#txtwebsite').val();
	var description = $('#txtdescription').val();
	var keyword = $('#txtkeyword').val();
	var salutation = form.selsalutation.value;
	var firstname = $('#txtfirst').val();
	var lastname = $('#txtlast').val();
	var company = $('#txtcompany').val();
	var contact1 = $('#txtcontact1').val();
	var contact2 = $('#txtcontact2').val();
	var fax = $('#txtfax').val();
	var email = $('#txtemail').val();
	var question = form.selquestion.value;
	var answer = $('#txtanswer').val();
	var captcha = $('#txtcaptcha').val();
	var package = '';
	for (var i = 0; i < document.getElementsByName('chkpackage').length; i++)
    {
		if (document.getElementsByName('chkpackage')[i].checked)
        {
            package = package + document.getElementsByName('chkpackage')[i].value + ' | ';
        }
    }
	
	if(package == '')
	{
		$('#plan_error').html("At least 1 plan is required").show();
		error_num = 1;
	}
	
	if(firstname == '' || firstname == 'Fill in your first name')
	{
		$('#first_error').html("First name cannot be empty").show();
		error_num = 1;
	}
	else if(!alpha_spaceExpression.test(firstname))
	{
		$('#first_error').html("Invalid First Name format").show();
		error_num = 1;
	}
	
	if(lastname == '' || lastname == 'Fill in your last name')
	{
		$('#last_error').html("Last name cannot be empty").show();
		error_num = 1;
	}
	else if(!alpha_spaceExpression.test(lastname))
	{
		$('#last_error').html("Invalid Last Name format").show();
		error_num = 1;
	}
	
	if(email == '' || email == 'Fill in your contact email')
	{
		$('#email_error').html("Email cannot be empty").show();
		error_num = 1;
	}
	else if(!emailExpression.test(email))
	{
		$('#email_error').html("Invalid email format").show();
		error_num = 1;
	}
	
	if(website == '' || website == 'Fill in your website url')
	{
		$('#website_error').html("Website url cannot be empty").show();
		error_num = 1;
	}
	
	if(description == '' || description == 'Fill in your website description')
	{
		$('#description_error').html("Website description cannot be empty").show();
		error_num = 1;
	}
	
	if(answer == '' || answer == 'Fill in your security answer')
	{
		$('#answer_error').html("Security Answer cannot be empty").show();
		error_num = 1;
	}
	
	if(captcha == '')
	{
		$('#captcha_error').html("Security Code cannot be empty").show();
		error_num = 1;
	}
	
	if(fax == '' || fax == 'Fill in your fax no')
	{
		fax = '';
	}
	
	if(contact1 == '' && contact2 == '' || contact1 == 'Fill in your first contact no' && contact2 == 'Fill in your second contact no')
	{
		$('#contact_error').html("At least one contact no is required").show();
		error_num = 1;
	}
		
	if(contact1 == 'Fill in your first contact no')
	{
		contact1 = '';
	}
		
	if(contact2 == 'Fill in your second contact no')
	{
		contact2 = '';
	}
	
	if(company == '' || company == 'Fill in your company name')
	{
		company = '';
	}
		
	if(keyword == '' || keyword == 'Fill in the keyword you want to place at your website')
	{
		keyword = '';
	}
		
	if(error_num == 0)
	{
		$('#result-loader').show();
		
		$.ajax({
			type:'POST',
			url: 'function/registration.php',
			data:'website='+website+'&description='+description+'&keyword='+keyword+'&salutation='+salutation+'&firstname='+firstname+'&lastname='+lastname+'&company='+company+'&contact1='+contact1+'&contact2='+contact2+'&fax='+fax+'&question='+question+'&answer='+answer+'&captcha='+captcha+'&email='+email+'&package='+package,
			success: function(results){
				$('#right_con').html(results).show();
			},
			complete: function(){$('#result-loader').hide();}
			});
		return false;
	}
}

/*Support*/
function js_support(form,pages)
{
	$('.error').hide();
	var error_num = 0;
	
	var name = $('#txtname').val();
	var email = $('#txtemail').val();
	var contact = $('#txtcontact').val();
	var subject = $('#txtsubject').val();
	var message = $('#txtmessage').val();
	
	if(name == '')
	{
		$('#name_error').html("Full name cannot be empty").show();
		error_num = 1;
	}
	
	if(contact == '')
	{
		$('#contact_error').html("Contact cannot be empty").show();
		error_num = 1;
	}
	
	if(email == '')
	{
		$('#email_error').html("Email cannot be empty").show();
		error_num = 1;
	}
	else if(!emailExpression.test(email))
	{
		$('#email_error').html("Invalid email format").show();
		error_num = 1;
	}
	
	if(subject == '')
	{
		$('#subject_error').html("Subject cannot be empty").show();
		error_num = 1;
	}
	
	if(message == '')
	{
		$('#message_error').html("Message cannot be empty").show();
		error_num = 1;
	}
	
	if(pages != 'others')
	{
		var priority = form.selpriority.value;
		var website = $('#txtwebsite').val();
		
		if(website == '')
		{
			$('#website_error').html("Website URL cannot be empty").show();
			error_num = 1;
		}
		
		var pages_data = 'priority='+priority+'&website='+website;
	}
	
	if(pages != 'others' && pages != 'emarketing' && pages != 'escurity')
	{
		var package = form.selpackage.value;
		var package_data = 'package='+package
	}
	
	if(pages == 'website' || pages == 'ecommerce')
	{
		var login = $('#txtlogin').val();
		
		if(login == '')
		{
			$('#login_error').html("Login email cannot be empty").show();
			error_num = 1;
		}
		var data = 'login='+login;
	}
	
	if(pages == 'hosting')
	{
		var ip = $('#txtip').val();
		var root_login = $('#txtrlogin').val();
		var root_pass = $('#txtpassword').val();
		var cp_login = $('#txtclogin').val();
		var cp_pass = $('#txtcpassword').val();
		var domain = $('#txtdomain').val();
		
		if(ip == '')
		{
			$('#ip_error').html("IP address cannot be empty").show();
			error_num = 1;
		}
		
		if(root_login == '')
		{
			$('#rlogin_error').html("Root login cannot be empty").show();
			error_num = 1;
		}
		
		if(root_pass == '')
		{
			$('#password_error').html("Root password cannot be empty").show();
			error_num = 1;
		}
		
		var data = 'ip='+ip+'&root_login='+root_login+'&root_pass='+root_pass+'&cp_login='+cp_login+'&cp_pass='+cp_pass+'&domain='+domain;
	}
	
	if(error_num == 0)
	{
		$('#result-loader').show();
		
		$.ajax({
			type:'POST',
			url: 'function/submit.php',
			data:'name='+name+'&contact='+contact+'&email='+email+'&subject='+subject+'&message='+message+'&pages='+pages+'&'+data+'&'+package_data+'&'+pages_data,
			success: function(results){
				$('#right_con').html(results).show();
			},
			complete: function(){$('#result-loader').hide();}
			});
		return false;
	}
}
/* OTHERS */

function js_textbox_limit(txt,maxv,minv)
{
	if(txt.value > maxv)
	{
		txt.value = maxv;
	}
	else if(txt.value == '')
	{
		txt.value = '';
	}
	else if(txt.value < minv)
	{
		txt.value = minv;
	}
}

function js_change_region(value)
{
	var country_code = value;
	$('#result-loader').show();
	
	$.ajax({
		type:'POST',
		url: '../lib/function/change_state.php',
		data:'country_code='+country_code,
		success: function(results){
			$('#div_state').html(results).show();
		},
		complete: function(){$('#result-loader').hide();}
		});
	return false;

}

function js_check_email(email)
{
	$('.error').hide();
	$('#email_check').hide();
	var error_num = 0;
	if(email == '' )
	{
		$('#email_error').html("Email cannot be empty").show();
		error_num = 1;
	}
	else if(!emailExpression.test(email))
	{
		$('#email_error').html("Invalid email format").show();
		error_num = 1;
	}
	
	if(error_num == 0)
	{
		$('#result-loader').show();
	
		$.ajax({
			type:'POST',
			url: '../lib/function/email_check.php',
			data:'email='+email,
			success: function(results){
				$('#email_check').html(results).show();
			},
			complete: function(){$('#result-loader').hide();}
			});
		return false;
	}
}

function eFocus(field,defaultvalue)
{
	if(field.value == defaultvalue)
	{
		field.value ='';
	}
	field.style.color = "#000";
}

function eBlur(field,defaultvalue)
{
	if (field.value == '')
	{
		field.value = defaultvalue;
		field.style.color = "#999";
	}
	else if(field.value != defaultvalue)
	{
		field.style.color = "#000";
	}
	else
	{
		field.style.color = "#999";
	}
}

function deFocus(field,defaultvalue)
{
	if(field.value == defaultvalue)
	{
		field.value ='';
	}
	field.style.color = "#fff";
}

function deBlur(field,defaultvalue)
{
	if (field.value == '')
	{
		field.value = defaultvalue;
		field.style.color = "#ccc";
	}
	else if(field.value != defaultvalue)
	{
		field.style.color = "#fff";
	}
	else
	{
		field.style.color = "#ccc";
	}
}

function KeyPress(evt) 
{
  var evt = (evt) ? evt : ((event) ? event : null);
  var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
  if ((evt.keyCode == 13) && (node.type=="text"))  {return false;}
}

document.onkeypress = KeyPress; 


function blanket_size(popUpDivVar) 
{
	var window_height = 0;
  	if( typeof( window.innerWidth ) == 'number' ) 
	{
		//Non-IE
		window_height = window.innerHeight;
  	} 
	else if( document.documentElement && (document.documentElement.clientHeight )) 
	{
		//IE 6+ in 'standards compliant mode'
		window_height = document.documentElement.clientHeight;
  	} 
  	else if( document.body && (document.body.clientHeight ) ) {
		//IE 4 compatible
		window_height = document.body.clientHeight;
  	}

	var popUpDiv = document.getElementById(popUpDivVar);
	var height = popUpDiv.offsetHeight;
	
	height = height/2;
	window_height = window_height/2; 
	
	popUpDiv_height = window_height - height; 
	
	popUpDiv.style.top = popUpDiv_height + 'px';
}

function window_pos(popUpDivVar) 
{
	var window_width = 0;
  	if( typeof( window.innerWidth ) == 'number' ) 
	{
		//Non-IE
		window_width = window.innerWidth;
  	} 
	else if( document.documentElement && ( document.documentElement.clientWidth)) 
	{
		//IE 6+ in 'standards compliant mode'
		window_width = document.documentElement.clientWidth;
  	} 
  	else if( document.body && ( document.body.clientWidth) ) {
		//IE 4 compatible
		window_width = document.body.clientWidth;
  	}
	
	var popUpDiv = document.getElementById(popUpDivVar);
	var width = popUpDiv.offsetWidth;
	
	window_width = window_width/2;
	width = width/2;
	
	popUpDiv_width = window_width - width;
	
	popUpDiv.style.left = popUpDiv_width + 'px';
}

function popup(windowname) 
{
	document.getElementById('popbg').style.display = 'block';
	document.getElementById(windowname).style.display = 'block';
	blanket_size(windowname);
	window_pos(windowname);	
}
