$().ready(function() 
{
	$("#frmNewsletter").validate(
	{
		errorLabelContainer: $("#divsmallerror"),
		rules: 
		{
			name: "required",
			surname: "required",
			email: {
				required: true,
				email: true
			},
			region: {required: true}
		},
		messages: 
		{
			name: "Please enter your name<br/>",
			surname: "Please enter your surname<br/>",
			email: "Please enter a valid email<br/>",
			region: "Please choose a region<br/>"
		}
	});	
	$("#frmSurvey").validate(
	{
		errorLabelContainer: $("#diverror"),
		rules: 
		{
			name: "required",
			surname: "required",
			mobile: "required",
			landline: "required",
			why_now: "required",
			why_not: "required",
			used_before: "required",
			email: {
				required: true,
				email: true
			},
			skip: {required: true},
			binge: {required: true},
			interested: {required: true}
		},
		messages: 
		{
			name: "Please enter your name<br>",
			surname: "Please enter your surname<br/>",
			email: "Please enter a valid email<br/>",
			mobile: "Please enter your mobile nr.<br/>",
			landline: "Please enter your landline nr.<br/>",
			interested: "Please answer Q1.<br/>",
			used_before: "Please answer Q3.<br/>",
			why_not: "Please answer Q4.<br/>",
			skip: "Please answer Q5.<br/>",
			binge: "Please answer Q6.<br/>",
			why_now: "Please answer Q7.<br/>"			
		}
	});
	$("#frmContactReq").validate(
	{
		errorLabelContainer: $("#diverror"),
		rules: 
		{
			name: "required",
			surname: "required",
			city: "required",
			phone_day: "required",
			phone_eve: "required",
			mobile: "required",
			email: {
				required: true,
				email: true
			},
			region: {required: true},
			best_time: {required: true},
			country: {required: true}
		},
		messages: 
		{
			name: "Please enter your name<br/>",
			surname: "Please enter your surname<br/>",
			email: "Please enter a valid email<br/>",
			region: "Please choose a region<br/>",
			city: "Please enter your city<br/>",
			phone_day: "Please enter your Phone (day)<br/>",
			phone_eve: "Please enter your Phone (eve)<br/>",
			mobile: "Please enter your mobile nr.<br/>",
			best_time: "Please choose a best time<br/>",
			country: "Please choose a country<br/>"
		}
	});
	$("#phone_day").mask("(9)99 999 9999");
	$("#phone_eve").mask("(9)99 999 9999");
	$("#mobile").mask("(9)99 999 9999");
	$("#landline").mask("(9)99 999 9999");
});

var countries = ['Malaysia','Ukraine','Venezuela','Turkey','Thailand','Taiwan','Switzerland','Slovak Republic','Singapore','Russian Federation','Poland','Philippines','Panama','Morocco','Mexico','Macau','Lithuania','Latvia','Korea','Japan','Jamaica','Israel','Indonesia','India','Iceland','Hong Kong','Estonia','Czech Republic','Cyprus','Croatia','Colombia','China','Chile','Brazil','Argentina','United States','South Africa','Botswana','Lesotho','Namibia','Swaziland','Australia','Canada','Ireland','Austria','Belgium','Denmark','France','Greece','Italy','Luxemburg','Nederland', 'Portugal','Spain','Sweden','Finland','New Zealand','England','Wales','Scotland'];
var codes = ['60','380','58','90','66','886','41','421','65','7','48','63','570','212','52','853','370','371','82','81','1','972','62','91','354','852','372','420','357','385','57','86','56','55','54','1','27','267','266','264','268','61', '1','353','43','32','45','33','30','39','352','31','351','34','46','358','64','44','44','44'];
function getCountryCode(selec) {ccode='';for (i = 0;i < 60; i++) {if (countries[i] == $('#'+selec).val()) {ccode = codes[i];}}return "+"+ccode;}

function getSubCountries()
{
		
		$("#ccode0").remove();$("#ccode1").remove();$("#ccode2").remove();$("#ccode3").remove();$("#ccode4").remove();$("#ccode5").remove();$("#ccode6").remove();

		var icount = 0;
		$("#phone_day, #landline, #phone_eve, #mobile").each( function (i) 
		{
			if ($('#country').val() != null) $(this).before("<span id='ccode"+icount+"'>"+getCountryCode("country")+" </span>"); 
			icount = icount + 1;
		});
}
function getSubCountriesRegion(bigcountry,field)
{
	var text = "";
	var sel = document.getElementById(bigcountry);
	bigcountry = sel.value;
	var selbox = document.getElementById(field);
	selbox.options.length = 0;
	selbox.options[selbox.options.length] = new Option('--Select Country--','');
	if(bigcountry == "Southern Africa")
	{
		selbox.options[selbox.options.length] = new Option('South Africa','South Africa');
		selbox.options[selbox.options.length] = new Option('Botswana','Botswana');
		selbox.options[selbox.options.length] = new Option('Lesotho','Lesotho');
		selbox.options[selbox.options.length] = new Option('Namibia','Namibia');
		selbox.options[selbox.options.length] = new Option('Swaziland','Swaziland');
	}
	if(bigcountry == "United Kingdom")
	{
		selbox.options[selbox.options.length] = new Option('Ireland','Ireland');
		selbox.options[selbox.options.length] = new Option('England','England');
		selbox.options[selbox.options.length] = new Option('Wales','Wales');
		selbox.options[selbox.options.length] = new Option('Scotland','Scotland');
	}
	if(bigcountry == "European Union")
	{
		selbox.options[selbox.options.length] = new Option('Austria','Austria');
		selbox.options[selbox.options.length] = new Option('Belgium','Belgium');
		selbox.options[selbox.options.length] = new Option('Denmark','Denmark');
		selbox.options[selbox.options.length] = new Option('France','France');
		selbox.options[selbox.options.length] = new Option('Greece','Greece'); 
		selbox.options[selbox.options.length] = new Option('Italy','Italy');
		selbox.options[selbox.options.length] = new Option('Luxemburg','Luxemburg'); 
		selbox.options[selbox.options.length] = new Option('Nederland','Nederland'); 
		selbox.options[selbox.options.length] = new Option('Portugal','Portugal');
		selbox.options[selbox.options.length] = new Option('Spain','Spain');
		selbox.options[selbox.options.length] = new Option('Sweden','Sweden');
		selbox.options[selbox.options.length] = new Option('Finland','Finland');
	}
	if(bigcountry == "Australia")
	{
		selbox.options[selbox.options.length] = new Option('Australia','Australia');
	}
	if(bigcountry == "New Zealand")
	{
		selbox.options[selbox.options.length] = new Option('New Zealand','New Zealand');
	}
	if(bigcountry == "United States")
	{
		selbox.options[selbox.options.length] = new Option('United States','United States');
	}
	if(bigcountry == "Canada")
	{
		selbox.options[selbox.options.length] = new Option('Canada','Canada');
	}
	if(bigcountry == "Other Countries")
	{
		selbox.options[selbox.options.length] = new Option('Argentina','Argentina');
		selbox.options[selbox.options.length] = new Option('Brazil','Brazil');
		selbox.options[selbox.options.length] = new Option('Chile','Chile');
		selbox.options[selbox.options.length] = new Option('China','China');
		selbox.options[selbox.options.length] = new Option('Colombia','Colombia');
		selbox.options[selbox.options.length] = new Option('Croatia','Croatia');
		selbox.options[selbox.options.length] = new Option('Cyprus','Cyprus');
		selbox.options[selbox.options.length] = new Option('Czech Republic','Czech Republic');
		selbox.options[selbox.options.length] = new Option('Estonia','Estonia');
		selbox.options[selbox.options.length] = new Option('Hong Kong','Hong Kong');
		selbox.options[selbox.options.length] = new Option('Iceland','Iceland');
		selbox.options[selbox.options.length] = new Option('India','India');
		selbox.options[selbox.options.length] = new Option('Indonesia','Indonesia');
		selbox.options[selbox.options.length] = new Option('Israel','Israel');
		selbox.options[selbox.options.length] = new Option('Jamaica','Jamaica'); 
		selbox.options[selbox.options.length] = new Option('Japan','Japan');
		selbox.options[selbox.options.length] = new Option('Korea','Korea');
		selbox.options[selbox.options.length] = new Option('Latvia','Latvia');
		selbox.options[selbox.options.length] = new Option('Lithuania','Lithuania');
		selbox.options[selbox.options.length] = new Option('Macau','Macau');
		selbox.options[selbox.options.length] = new Option('Mexico','Mexico');
		selbox.options[selbox.options.length] = new Option('Morocco','Morocco');
		selbox.options[selbox.options.length] = new Option('Panama','Panama'); 
		selbox.options[selbox.options.length] = new Option('Philippines','Philippines');
		selbox.options[selbox.options.length] = new Option('Poland','Poland');
		selbox.options[selbox.options.length] = new Option('Russian Federation','Russian Federation'); 
		selbox.options[selbox.options.length] = new Option('Singapore','Singapore');
		selbox.options[selbox.options.length] = new Option('Slovak Republic','Slovak Republic');
		selbox.options[selbox.options.length] = new Option('Switzerland','Switzerland');
		selbox.options[selbox.options.length] = new Option('Taiwan','Taiwan');
		selbox.options[selbox.options.length] = new Option('Thailand','Thailand');
		selbox.options[selbox.options.length] = new Option('Turkey','Turkey');
		selbox.options[selbox.options.length] = new Option('Venezuela','Venezuela');
		selbox.options[selbox.options.length] = new Option('Ukraine','Ukraine');
		selbox.options[selbox.options.length] = new Option('Malaysia','Malaysia');
	}
		$("#ccode0").remove();$("#ccode1").remove();$("#ccode2").remove();$("#ccode3").remove();$("#ccode4").remove();$("#ccode5").remove();$("#ccode6").remove();

		var icount = 0;
		$("#phone_day, #landline, #phone_eve, #mobile").each( function (i) 
		{
			if ($('#country').val() != null) $(this).before("<span id='ccode"+icount+"'>"+getCountryCode("country")+" </span>"); 
			icount = icount + 1;
		});
}