var aCh="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
var dCh="0123456789-";
var sCh="ÀÂÃÄÅÆÇÈÉÊËÌÍÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿŠŒŽšœžŸ'_`~()^&*+-|=<>,./\{}[] ";
var asCh=aCh + dCh + "!\"#$%&'()*+,-./:;<=>?@[\]^_`{}~";

function isAlphaNum(S) {
	var AlphaNum=aCh + dCh;
	for (var i=0; i < S.length; i++) {
		if (AlphaNum.indexOf(S.charAt(i)) == -1)
			return false;
	}
	return true;
}
function isASCII(S) {
	for (var i=0; i < S.length; i++) {
		if (asCh.indexOf(S.charAt(i)) == -1)
			return false;
	}
	return true;
}
function isName(S) {
	var cName=aCh + dCh + sCh;
	for (var i=0; i < S.length; i++) {
		if (cName.indexOf(S.charAt(i)) == -1)
			return false;
	}
	return true;
}
function isEmail(S) {
	var pass=0;
	if (window.RegExp) {
		var tempS="a";
		var tempReg=new RegExp(tempS);
		if (tempReg.test(tempS)) pass=1;
	}
	if (!pass)
		return (S.indexOf(".") > 2) && (S.indexOf("@") > 0);

	var r1=new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	var r2=new RegExp("^[a-zA-Z0-9\\.\\!\\#\\$\\%\\&\\'\\*\\+\\-\\/\\=\\?\\^\\_\\`\\{\\}\\~]*[a-zA-Z0-9\\!\\#\\$\\%\\&\\'\\*\\+\\-\\/\\=\\?\\^\\_\\`\\{\\}\\~]\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
	return (!r1.test(S) && r2.test(S));
}
function checkAdvertiseForm() {


	// Check Company Name
	cCNameError = "";
	if (document.DataEntry.CName.value.length<1) {
		cCNameError = "Company Name is empty.\n"; 
	} else {
		if (!isName(document.DataEntry.CName.value)){
			cCNameError = "Company Name is invalid. Please use 0-9, A-Z, "+sCh+"\n";
		} else {
			if (document.DataEntry.CName.value.length<4) { 
			cCNameError = "Company Name should be at least 4 characters.\n";
			}
		}
	}	
	
		cCAddress1Error = "";
	if (document.DataEntry.CAddress1.value.length<1) {
		cCAddress1Error = "Your Address is empty.\n"; 
	} else {
		if (!isName(document.DataEntry.CAddress1.value)){
			cCAddress1Error = "Your Address is invalid. Please use 0-9, A-Z, "+sCh+"\n";
		} else {
			if (document.DataEntry.CAddress1.value.length<4) { 
			cCAddress1Error = "Address should be at least 4 characters.\n";
			}
		}
	}	

	
		cCCityError = "";
	if (document.DataEntry.CCity.value.length<1) {
		cCCityError = "Your City is empty.\n"; 
	} else {
		if (!isName(document.DataEntry.CCity.value)){
			cCCityError = "Your City is invalid. Please use 0-9, A-Z, "+sCh+"\n";
		} else {
			if (document.DataEntry.CCity.value.length<4) { 
			cCCityError = "City should be at least 4 characters.\n";
			}
		}
	}	
	
	
		cCPhoneError = "";
	if (document.DataEntry.CPhone.value.length<1) {
		cCPhoneError = "Your Phone is empty.\n"; 
	} else {
		if (!isName(document.DataEntry.CPhone.value)){
			cCPhoneError = "Your Phone is invalid. Please use 0-9, A-Z, "+sCh+"\n";
		} else {
			if (document.DataEntry.CPhone.value.length<4) { 
			cCPhoneError = "Phone should be at least 4 digit.\n";
			}
		}
	}	

	// Check the Email
	cCEmailError = "";
	if (document.DataEntry.CEmail.value.length <1) { 
		cCEmailError = "Your Email address is empty.\n";
	}	
	else { 
		dmn = document.DataEntry.CEmail.value.substr(document.DataEntry.CEmail.value.indexOf("@")+1,document.DataEntry.CEmail.value.length);
		if((document.DataEntry.CEmail.value.indexOf("@")<1) ||(dmn.indexOf("@")>-1) || (dmn.indexOf(".")<1) || (dmn.indexOf(".")>dmn.length-2)) {
			cCEmailError = "Your CEmail address is invalid.\ne.g. : (Email@domainname.com).\n";
		}
	}
	
		cPNameError = "";
	if (document.DataEntry.PName.value.length<1) {
		cPNameError = "Your Name is empty.\n"; 
	} else {
		if (!isName(document.DataEntry.PName.value)){
			cPNameError = "Your Name is invalid. Please use 0-9, A-Z, "+sCh+"\n";
		} else {
			if (document.DataEntry.PName.value.length<4) { 
			cPNameError = "Name should be at least 4 characters.\n";
			}
		}
	}	
	
		cPPositionError= "";
	if (document.DataEntry.PPosition.value.length<1) {
		cPPositionError= "Your Position is empty.\n"; 
	} else {
		if (!isName(document.DataEntry.PPosition.value)){
			cPPositionError= "Your Position is invalid. Please use 0-9, A-Z, "+sCh+"\n";
		} else {
			if (document.DataEntry.PPosition.value.length<4) { 
			cPPositionError = "Position should be at least 4 characters.\n";
			}
		}
	}	
	
		cPPhoneError= "";
	if (document.DataEntry.PPhone.value.length<1) {
		cPPhoneError= "Your Phone is empty.\n"; 
	} else {
		if (!isName(document.DataEntry.PPhone.value)){
			cPPhoneError= "Your Phone is invalid. Please use 0-9, A-Z, "+sCh+"\n";
		} else {
			if (document.DataEntry.PPhone.value.length<4) { 
			cPPhoneError = "Phone should be at least 4 digit.\n";
			}
		}
	}	
	// Check the Email
	cPEmailError = "";
	if (document.DataEntry.PEmail.value.length <1) { 
		cPEmailError = "Your Email address is empty.\n";
	}	
	else { 
		dmn = document.DataEntry.PEmail.value.substr(document.DataEntry.PEmail.value.indexOf("@")+1,document.DataEntry.PEmail.value.length);
		if((document.DataEntry.PEmail.value.indexOf("@")<1) ||(dmn.indexOf("@")>-1) || (dmn.indexOf(".")<1) || (dmn.indexOf(".")>dmn.length-2)) {
			cPEmailError = "Your Email address is invalid.\ne.g. : (Email@domainname.com).\n";
		}
	}

	// Check Website Title
	//cATitleError = "";
	//if (document.DataEntry.ATitle.value.length <1) { cATitleError = "Your Website title is empty.\n"; }
	
	// Check the Website
	//cAUrlError = "";
	//if (document.DataEntry.AUrl.value.length>0) { 
	//	if(document.DataEntry.AUrl.value.indexOf(".")<1) {
		//	cAUrlError = "Your link URL is invalid.\ne.g. : (www.domainname.com).\n";
		//}
	//}
	
	cAUrlError = "";
	cATitleError = "";
	if (document.DataEntry.ATitle.value.length>0) { 
		if (!isName(document.DataEntry.ATitle.value)){
			cATitleError = "Website title is invalid. Please use 0-9, A-Z, "+sCh+"\n";
		}else{// Check the URL Link 
			if (document.DataEntry.AUrl.value.length>0) { 
				if(document.DataEntry.AUrl.value.indexOf(".")<1) {
					cAUrlError = "Your link URL is invalid.\ne.g. : (www.domainname.com).\n";
				}
			}
		}
	} else {
		if (document.DataEntry.AUrl.value.length>0) { 
			if(document.DataEntry.AUrl.value.indexOf(".")<1) {
				cAUrlError = "Your link URL is invalid.\ne.g. : (www.domainname.com).\n";
			}else{	// Check Website title
					if (document.DataEntry.ATitle.value.length <1) { 
						cATitleError = "Website title is empty.\n"; 
					} 
					}
				}
			}


	// Check the Category 
	cCategoryError = "";
	if (document.DataEntry.Category.value=="0") { 
		cCategoryError = "Category is not selected.\n";
	}
		// Check the Sub Category 
	cSubCategoryError = "";
	if (document.DataEntry.SubCategory.value=="0") { 
		cSubCategoryError = "Sub Category is not selected.\n";
	}

	
	cError = cCNameError + cCAddress1Error  + cCCityError + cCPhoneError + cCEmailError + cPNameError + cPPositionError + cPPhoneError + cPEmailError + cATitleError + cAUrlError + cCategoryError + cSubCategoryError;
	
	if (cError.length>0) { 
		alert("Sorry, but you haven\'t filled out all fields required.\n"+cError); 
		if (cCNameError.length>0) { document.DataEntry.CName.focus(); } else {
		if (cCAddress1Error.length>0) { document.DataEntry.CAddress1.focus(); } else {
		if (cCCityError.length>0) { document.DataEntry.CCity.focus(); } else {
		if (cCPhoneError.length>0) { document.DataEntry.cCPhone.focus();} else {
		if (cCEmailError.length>0) { document.DataEntry.CEmail.focus(); } else { 
		if (cPNameError.length>0) { document.DataEntry.PName.focus(); } else {
		if (cPPositionError.length>0) { document.DataEntry.PPosition.focus(); } else {
		if (cPPhoneError.length>0) { document.DataEntry.PPhone.focus(); } else {
		if (cPEmailError.length>0) { document.DataEntry.PEmail.focus(); } else {
		if (cATitleError.length>0) { document.DataEntry.ATitle.focus(); } else { 
		if (cAUrlError.length>0) { document.DataEntry.AUrl.focus(); } else { 
		if (cCategoryError.length>0) { document.DataEntry.Category.focus(); } else { 
		if (cSubCategoryError.length>0) { document.DataEntry.SubCategory.focus(); } } } } } } } } } } } } } 
	return false; 
	}
	if (!document.DataEntry.Understand.checked) { 
		alert("Please check the confirmation check box.\n");
		return false; 
	}
	document.DataEntry.submit();

}


var aLM = new Array();
var aDL1 = new Array();
var aLV = new Array();
var aDL2 = new Array();
aDL1[1] = "Category";		// Name of parent list box
aDL1[2] = "DataEntry";		// Name of form containing parent list box
aDL1[3] = "SubCategory";		// Name of child list box
aDL1[4] = "DataEntry";		// Name of form containing child list box
aDL1[5] = aLM;	// No need to do anything here

aLM[0] = "Accommodation";
aLM[1] = "Apartments";
aLM[2] = "Apartments";

aLM[3] = "Accommodation";
aLM[4] = "Boutique Hotels";
aLM[5] = "Boutique Hotels";

aLM[6] = "Accommodation";
aLM[7] = "Bungalows";
aLM[8] = "Bungalows";

aLM[9] = "Accommodation";
aLM[10] = "Cottages";
aLM[11] = "Cottages";

aLM[12] = "Accommodation";
aLM[13] = "Hotels";
aLM[14] = "Hotels";

aLM[15] = "Accommodation";
aLM[16] = "Resorts";
aLM[17] = "Resorts";

aLM[18] = "Accommodation";
aLM[19] = "Villas";
aLM[20] = "Villas";

aLM[21] = "Accommodation";
aLM[22] = "Others";
aLM[23] = "Others";

aLM[24] = "Activities";
aLM[25] = "Bowling & Billiard";
aLM[26] = "Bowling & Billiard";

aLM[27] = "Activities";
aLM[28] = "Golf";
aLM[29] = "Golf";

aLM[30] = "Activities";
aLM[31] = "Hiking & Cycling";
aLM[32] = "Hiking & Cycling";

aLM[33] = "Activities";
aLM[34] = "Theme Park";
aLM[35] = "Theme Park";

aLM[36] = "Activities";
aLM[37] = "Others";
aLM[38] = "Others";

aLM[39] = "Adventures";
aLM[40] = "Bungee Jumping";
aLM[41] = "Bungee Jumping";

aLM[42] = "Adventures";
aLM[43] = "Cruises";
aLM[44] = "Cruises";

aLM[45] = "Adventures";
aLM[46] = "Diving";
aLM[47] = "Diving";

aLM[48] = "Adventures";
aLM[49] = "Fishing";
aLM[50] = "Fishing";

aLM[51] = "Adventures";
aLM[52] = "Rafting";
aLM[53] = "Rafting";

aLM[54] = "Adventures";
aLM[55] = "Surfing";
aLM[56] = "Surfing";

aLM[57] = "Adventures";
aLM[58] = "Others";
aLM[59] = "Others";

aLM[60] = "Arts";
aLM[61] = "Painters";
aLM[62] = "Painters";

aLM[63] = "Arts";
aLM[64] = "Sculptors";
aLM[65] = "Sculptors";

aLM[66] = "Arts";
aLM[67] = "Musicians";
aLM[68] = "Musicians";

aLM[69] = "Arts";
aLM[70] = "Photographers";
aLM[71] = "Photographers";

aLM[72] = "Arts";
aLM[73] = "Gallery";
aLM[74] = "Gallery";

aLM[75] = "Arts";
aLM[76] = "Museum";
aLM[77] = "Museum";

aLM[78] = "Arts";
aLM[79] = "Arts Shop";
aLM[80] = "Arts Shop";

aLM[81] = "Arts";
aLM[82] = "Others";
aLM[83] = "Others";

aLM[84] = "Computers";
aLM[85] = "AntiVirus";
aLM[86] = "AntiVirus";

aLM[87] = "Computers";
aLM[88] = "Computer Shop";
aLM[89] = "Computer Shop";

aLM[90] = "Computers";
aLM[91] = "Computer Service Centre";
aLM[92] = "Computer Service Centre";

aLM[93] = "Computers";
aLM[94] = "Internet Café";
aLM[95] = "Internet Café";

aLM[96] = "Computers";
aLM[97] = "ISP";
aLM[98] = "ISP";

aLM[99] = "Computers";
aLM[100] = "Networking";
aLM[101] = "Networking";

aLM[102] = "Computers";
aLM[103] = "Security System";
aLM[104] = "Security System";

aLM[105] = "Computers";
aLM[106] = "SoftWare";
aLM[107] = "SoftWare";

aLM[108] = "Computers";
aLM[109] = "Telecommunication";
aLM[110] = "Telecommunication";

aLM[111] = "Computers";
aLM[112] = "Web & Graphic Design";
aLM[113] = "Web & Graphic Design";

aLM[114] = "Computers";
aLM[115] = "Wireless";
aLM[116] = "Wireless";

aLM[117] = "Computers";
aLM[118] = "Others";
aLM[119] = "Others";

aLM[120] = "Education";
aLM[121] = "Play Group";
aLM[122] = "Play Group";

aLM[123] = "Education";
aLM[124] = "Kindergarten";
aLM[125] = "Kindergarten";

aLM[126] = "Education";
aLM[127] = "Elementary/Junior High School";
aLM[128] = "Elementary/Junior High School";

aLM[129] = "Education";
aLM[130] = "High School";
aLM[131] = "High School";

aLM[132] = "Education";
aLM[133] = "College";
aLM[134] = "College";

aLM[135] = "Education";
aLM[136] = "University";
aLM[137] = "University";

aLM[138] = "Education";
aLM[139] = "Courses & Degrees";
aLM[140] = "Courses & Degrees";

aLM[141] = "Education";
aLM[142] = "International School";
aLM[143] = "International School";

aLM[144] = "Education";
aLM[145] = "Others";
aLM[146] = "Others";

aLM[147] = "Health Care";
aLM[148] = "Clinic";
aLM[149] = "Clinic";

aLM[150] = "Health Care";
aLM[151] = "Dentist";
aLM[152] = "Dentist";

aLM[153] = "Health Care";
aLM[154] = "Drugstore";
aLM[155] = "Drugstore";

aLM[156] = "Health Care";
aLM[157] = "Hospital";
aLM[158] = "Hospital";

aLM[159] = "Health Care";
aLM[160] = "Laboratorium";
aLM[161] = "Laboratorium";

aLM[162] = "Health Care";
aLM[163] = "Spa";
aLM[164] = "Spa";

aLM[165] = "Health Care";
aLM[166] = "Veterinary";
aLM[167] = "Veterinary";

aLM[168] = "Health Care";
aLM[169] = "Yoga & Meditation";
aLM[170] = "Yoga & Meditation";

aLM[171] = "Health Care";
aLM[172] = "Others";
aLM[173] = "Others";

aLM[174] = "MICE";
aLM[175] = "Meetings, Incentives, Conventions & Exhibitions";
aLM[176] = "Meetings, Incentives, Conventions & Exhibitions";

aLM[177] = "Night Life";
aLM[178] = "Bar & Club";
aLM[179] = "Bar & Club";

aLM[180] = "Night Life";
aLM[181] = "Discotheques";
aLM[182] = "Discotheques";

aLM[183] = "Night Life";
aLM[184] = "Karaoke & Music Lounge";
aLM[185] = "Karaoke & Music Lounge";

aLM[186] = "Night Life";
aLM[187] = "Others";
aLM[188] = "Others";

aLM[189] = "Real Estate";
aLM[190] = "Architecture";
aLM[191] = "Architecture";

aLM[192] = "Real Estate";
aLM[193] = "Building Materials";
aLM[194] = "Building Materials";

aLM[195] = "Real Estate";
aLM[196] = "Construction Service";
aLM[197] = "Construction Service";

aLM[198] = "Real Estate";
aLM[199] = "Electrical Engineering";
aLM[200] = "Electrical Engineering";

aLM[201] = "Real Estate";
aLM[202] = "Mechanical Engineering";
aLM[203] = "Mechanical Engineering";

aLM[204] = "Real Estate";
aLM[205] = "Real Estate Company";
aLM[206] = "Real Estate Company";

aLM[207] = "Real Estate";
aLM[208] = "Others";
aLM[209] = "Others";

aLM[210] = "Shopping";
aLM[211] = "Automotive";
aLM[212] = "Automotive";

aLM[213] = "Shopping";
aLM[214] = "Beauty & Fragrance";
aLM[215] = "Beauty & Fragrance";

aLM[216] = "Shopping";
aLM[217] = "Books & Magazines";
aLM[218] = "Books & Magazines";

aLM[219] = "Shopping";
aLM[220] = "Chemicals";
aLM[221] = "Chemicals";

aLM[222] = "Shopping";
aLM[223] = "Clothing & Accessories";
aLM[224] = "Clothing & Accessories";

aLM[225] = "Shopping";
aLM[226] = "Computers";
aLM[227] = "Computers";

aLM[228] = "Shopping";
aLM[229] = "Department Store";
aLM[230] = "Department Store";

aLM[231] = "Shopping";
aLM[232] = "Electronic & Phones";
aLM[233] = "Electronic & Phones";

aLM[234] = "Shopping";
aLM[235] = "Flowers & Gifts";
aLM[236] = "Flowers & Gifts";

aLM[237] = "Shopping";
aLM[238] = "Food";
aLM[239] = "Food";

aLM[240] = "Shopping";
aLM[241] = "Health & Personal Care";
aLM[242] = "Health & Personal Care";

aLM[243] = "Shopping";
aLM[244] = "Home & Garden";
aLM[245] = "Home & Garden";

aLM[246] = "Shopping";
aLM[247] = "Jewelry & Watches";
aLM[248] = "Jewelry & Watches";

aLM[249] = "Shopping";
aLM[250] = "Movie & DVDs";
aLM[251] = "Movie & DVDs";

aLM[252] = "Shopping";
aLM[253] = "Pets";
aLM[254] = "Pets";

aLM[255] = "Shopping";
aLM[256] = "Photo Studio";
aLM[257] = "Photo Studio";

aLM[258] = "Shopping";
aLM[259] = "Printing House";
aLM[260] = "Printing House";

aLM[261] = "Shopping";
aLM[262] = "Tools & Hardware";
aLM[263] = "Tools & Hardware";

aLM[264] = "Shopping";
aLM[265] = "Toys & Baby";
aLM[266] = "Toys & Baby";

aLM[267] = "Shopping";
aLM[268] = "Video Game";
aLM[269] = "Video Game";

aLM[270] = "Shopping";
aLM[271] = "Others";
aLM[272] = "Others";

aLM[273] = "Society";
aLM[274] = "Organizations";
aLM[275] = "Organizations";

aLM[276] = "Society";
aLM[277] = "Religion & Spirituality";
aLM[278] = "Religion & Spirituality";

aLM[279] = "Society";
aLM[280] = "Death Care";
aLM[281] = "Death Care";

aLM[282] = "Society";
aLM[283] = "Others";
aLM[284] = "Others";

aLM[285] = "Trading Company";
aLM[286] = "Bath & Bed";
aLM[287] = "Bath & Bed";

aLM[288] = "Trading Company";
aLM[289] = "Cargo";
aLM[290] = "Cargo";

aLM[291] = "Trading Company";
aLM[292] = "Handicraft";
aLM[293] = "Handicraft";

aLM[294] = "Trading Company";
aLM[295] = "Indoor Furniture";
aLM[296] = "Indoor Furniture";

aLM[297] = "Trading Company";
aLM[298] = "Outdoor Furniture";
aLM[299] = "Outdoor Furniture";

aLM[300] = "Trading Company";
aLM[301] = "Jewelry";
aLM[302] = "Jewelry";

aLM[303] = "Trading Company";
aLM[304] = "Home Wares";
aLM[305] = "Home Wares";

aLM[306] = "Trading Company";
aLM[307] = "Others";
aLM[308] = "Others";

aLM[309] = "Travel";
aLM[310] = "Airlines";
aLM[311] = "Airlines";

aLM[312] = "Travel";
aLM[313] = "Car Rental/Transportation";
aLM[314] = "Car Rental/Transportation";

aLM[315] = "Travel";
aLM[316] = "Travel Agent";
aLM[317] = "Travel Agent";

aLM[318] = "Travel";
aLM[319] = "Others";
aLM[320] = "Others";

aLM[321] = "Wedding & Salon";
aLM[322] = "Accessories";
aLM[323] = "Accessories";

aLM[324] = "Wedding & Salon";
aLM[325] = "Salon";
aLM[326] = "Salon";

aLM[327] = "Wedding & Salon";
aLM[328] = "Wedding & Event Organizer";
aLM[329] = "Wedding & Event Organizer";

aLM[330] = "Wedding & Salon";
aLM[331] = "Others";
aLM[332] = "Others";

aLM[333] = "Wine & Dine";
aLM[334] = "Bakery";
aLM[335] = "Bakery";

aLM[336] = "Wine & Dine";
aLM[337] = "Café";
aLM[338] = "Café";

aLM[339] = "Wine & Dine";
aLM[340] = "Liquor Shop";
aLM[341] = "Liquor Shop";

aLM[342] = "Wine & Dine";
aLM[343] = "Restaurant";
aLM[344] = "Restaurant";

aLM[345] = "Wine & Dine";
aLM[346] = "Others";
aLM[347] = "Others";


function checkAdvertiseForm2() {


	// Check Company Name
	cCNameError = "";
	if (document.DataEntry.CName.value.length<1) {
		cCNameError = "Company Name is empty.\n"; 
	} else {
		if (!isName(document.DataEntry.CName.value)){
			cCNameError = "Company Name is invalid. Please use 0-9, A-Z, "+sCh+"\n";
		} else {
			if (document.DataEntry.CName.value.length<4) { 
			cCNameError = "Name should be at least 4 characters.\n";
			}
		}
	}	
	
		cCAddress1Error = "";
	if (document.DataEntry.CAddress1.value.length<1) {
		cCAddress1Error = "Your Address is empty.\n"; 
	} else {
		if (!isName(document.DataEntry.CAddress1.value)){
			cCAddress1Error = "Your Address is invalid. Please use 0-9, A-Z, "+sCh+"\n";
		} else {
			if (document.DataEntry.CAddress1.value.length<4) { 
			cCAddress1Error = "Address should be at least 4 characters.\n";
			}
		}
	}	

	
		cCCityError = "";
	if (document.DataEntry.CCity.value.length<1) {
		cCCityError = "Your City is empty.\n"; 
	} else {
		if (!isName(document.DataEntry.CCity.value)){
			cCCityError = "Your City is invalid. Please use 0-9, A-Z, "+sCh+"\n";
		} else {
			if (document.DataEntry.CCity.value.length<4) { 
			cCCityError = "City should be at least 4 characters.\n";
			}
		}
	}	
	
	
		cCPhoneError = "";
	if (document.DataEntry.CPhone.value.length<1) {
		cCPhoneError = "Your Phone is empty.\n"; 
	} else {
		if (!isName(document.DataEntry.CPhone.value)){
			cCPhoneError = "Your Phone is invalid. Please use 0-9, A-Z, "+sCh+"\n";
		} else {
			if (document.DataEntry.CPhone.value.length<4) { 
			cCPhoneError = "Phone should be at least 4 digit.\n";
			}
		}
	}	
	
		cPNameError = "";
	if (document.DataEntry.PName.value.length<1) {
		cPNameError = "Your Name is empty.\n"; 
	} else {
		if (!isName(document.DataEntry.PName.value)){
			cPNameError = "Your Name is invalid. Please use 0-9, A-Z, "+sCh+"\n";
		} else {
			if (document.DataEntry.PName.value.length<4) { 
			cPNameError = "Name should be at least 4 characters.\n";
			}
		}
	}	
	
		cPPhoneError= "";
	if (document.DataEntry.PPhone.value.length<1) {
		cPPhoneError= "Your Phone is empty.\n"; 
	} else {
		if (!isName(document.DataEntry.PPhone.value)){
			cPPhoneError= "Your Phone is invalid. Please use 0-9, A-Z, "+sCh+"\n";
		} else {
			if (document.DataEntry.PPhone.value.length<4) { 
			cPPhoneError = "Phone should be at least 4 digit.\n";
			}
		}
	}	
	// Check the Email
	cPEmailError = "";
	if (document.DataEntry.PEmail.value.length <1) { 
		cPEmailError = "Your Email address is empty.\n";
	}	
	else { 
		dmn = document.DataEntry.PEmail.value.substr(document.DataEntry.PEmail.value.indexOf("@")+1,document.DataEntry.PEmail.value.length);
		if((document.DataEntry.PEmail.value.indexOf("@")<1) ||(dmn.indexOf("@")>-1) || (dmn.indexOf(".")<1) || (dmn.indexOf(".")>dmn.length-2)) {
			cPEmailError = "Your Email address is invalid.\ne.g. : (Email@domainname.com).\n";
		}
	}

	
	cError = cCNameError + cCAddress1Error  + cCCityError + cCPhoneError + cPNameError + cPPhoneError + cPEmailError;
	
	if (cError.length>0) { 
		alert("Sorry, but you haven\'t filled out all fields required.\n"+cError); 
		if (cCNameError.length>0) { document.DataEntry.CName.focus(); } else {
		if (cCAddress1Error.length>0) { document.DataEntry.CAddress1.focus(); } else {
		if (cCCityError.length>0) { document.DataEntry.CCity.focus(); } else {
		if (cCPhoneError.length>0) { document.DataEntry.cCPhone.focus();} else {
		if (cPNameError.length>0) { document.DataEntry.PName.focus(); } else {
		if (cPhoneError.length>0) { document.DataEntry.PPhone.focus(); } else {
		if (cPEmailError.length>0) { document.DataEntry.PEmail.focus(); } } } } } } } 
		   
	return false; 
	}
	document.DataEntry.submit();

}

function setDynaList(aDL){
 var oList1 = document.forms[aDL[2]].elements[aDL[1]];
 var oList2 = document.forms[aDL[4]].elements[aDL[3]];
 var arrList = aDL[5];
 clearDynaList(oList2);
 if (oList1.selectedIndex == -1){
  oList1.selectedIndex = 0;
 }
 populateDynaList(oList2, oList1[oList1.selectedIndex].value, arrList);
 return true;
}
 
function clearDynaList(oList){
 for (var i = oList.options.length; i >= 0; i--){
  oList.options[i] = null;
 }
 oList.selectedIndex = -1;
}
 
function populateDynaList(oList, nIndex, aArray){
oList[oList.length]= new Option("Please Select");
 for (var i = 0; i < aArray.length; i= i + 3){
  if (aArray[i] == nIndex){
   oList.options[oList.options.length] = new Option(aArray[i + 1], aArray[i + 2]);
  }
 }
 if (oList.options.length == 1){
  oList.options[oList.options.length] = new Option(":: No SubCategories Available ::");
 }
 oList.selectedIndex = 0; 
}

/*____________________________________________________________________________________________________________ */
/*
 | Browser object
 */
function ylib_Browser() {
 d=document;
 this.agt=navigator.userAgent.toLowerCase();
 this.major = parseInt(navigator.appVersion);
 this.dom=(d.getElementById)?1:0; // true for ie6, ns6
 this.ns=(d.layers);
 this.ns4up=(this.ns && this.major >=4);
 this.ns6=(this.dom&&navigator.appName=="Netscape");
 this.op=(window.opera? 1:0);
 this.ie=(d.all);
 this.ie4=(d.all&&!this.dom)?1:0;
 this.ie4up=(this.ie && this.major >= 4);
 this.ie5=(d.all&&this.dom);
 this.win=((this.agt.indexOf("win")!=-1) || (this.agt.indexOf("16bit")!=-1));
 this.mac=(this.agt.indexOf("mac")!=-1);
}

var oBw = new ylib_Browser();

/* begin new */
function ylib_getH(o) { return (oBw.ns)?((o.height)?o.height:o.clip.height):((oBw.op&&typeof o.style.pixelHeight!='undefined')?o.style.pixelHeight:o.offsetHeight); }
function ylib_setH(o,h) { if(o.clip) o.clip.height=h; else if(oBw.op && typeof o.style.pixelHeight != 'undefined') o.style.pixelHeight=h; else o.style.height=h; }
function ylib_getW(o) { return (oBw.ns)?((o.width)?o.width:o.clip.width):((oBw.op&&typeof o.style.pixelWidth!='undefined')?w=o.style.pixelWidth:o.offsetWidth); }
function ylib_setW(o,w) { if(o.clip) o.clip.width=w; else if(oBw.op && typeof o.style.pixelWidth != 'undefined') o.style.pixelWidth=w; else o.style.width=w; }
function ylib_getX(o) { return (oBw.ns)?o.left:((o.style.pixelLeft)?o.style.pixelLeft:o.offsetLeft); }
function ylib_setX(o,x) {
	if(oBw.ns) { 
		o.left=x;
	} else if(typeof o.style.pixelLeft != 'undefined') {
		o.style.pixelLeft=x;
	} else {
		thisPos = parseInt(x);			// preventing NS UNcaught Exception Error in strict.dtd mode: converting value to integer in case passed as string
		thisPos += "px";
		o.style.left = thisPos;
	}
}
function ylib_getY(o) { return (oBw.ns)?o.top:((o.style.pixelTop)?o.style.pixelTop:o.offsetTop); }
function ylib_setY(o,y) {
	if(oBw.ns) {
		o.top=y;
	} else if(typeof o.style.pixelTop != 'undefined') {
		o.style.pixelTop=y;
	} else {
		thisPos = parseInt(y);			// preventing NS UNcaught Exception Error in strict.dtd mode: converting value to integer in case passed as string
		thisPos += "px";
		o.style.top = thisPos;
	}
}
function ylib_getPageX(o) { var x=0; if(oBw.ns) x=o.pageX; else { while(eval(o)) { x+=o.offsetLeft; o=o.offsetParent; } } return x; }
function ylib_getPageY(o) { var y=0; if(oBw.ns) y=o.pageY; else { while(eval(o)) { y+=o.offsetTop; o=o.offsetParent; } } return y; }
function ylib_getZ(o) { return (oBw.ns)?o.zIndex:o.style.zIndex; }
/* end new */

function ylib_moveTo(o,x,y) { ylib_setX(o,x);ylib_setY(o,y); }
function ylib_moveBy(o,x,y) { ylib_setX(o,ylib_getPageX(o)+x);ylib_setY(o,ylib_getPageY(o)+y); }

function ylib_setZ(o,z) { if(oBw.ns)o.zIndex=z;else o.style.zIndex=z; }

function ylib_setClip(o) { }

function ylib_show(o,disp) { 
 (oBw.ns)? '':(!disp)? o.style.display="inline":o.style.display=disp;
 (oBw.ns)? o.visibility='show':o.style.visibility='visible';  
}
function ylib_hide(o,disp) { 
 (oBw.ns)? '':(arguments.length!=2)? o.style.display="none":o.style.display=disp;
 (oBw.ns)? o.visibility='hide':o.style.visibility='hidden';  
}

function ylib_setStyle(o,s,v) { if(oBw.ie5||oBw.dom) eval("o.style."+s+" = '" + v +"'"); }
function ylib_getStyle(o,s) { if(oBw.ie5||oBw.dom) return eval("o.style."+s); }

function ylib_getDocW() { }
function ylib_getDocH() { }

function ylib_addEvt(o,e,f,c){ if(o.addEventListener)o.addEventListener(e,f,c);else if(o.attachEvent)o.attachEvent("on"+e,f);else eval("o.on"+e+"="+f)}

function ylib_writeHTML(o,h) { 
 if(oBw.ns){var doc=o.document;doc.write(h);doc.close();return false;}
 if(o.innerHTML)o.innerHTML=h; 
}

// w - beforeBegin,afterBegin,beforeEnd,afterEnd
// width - for ns 4 only
function ylib_insertHTML(o,h,w) {
 if (oBw.op) return;
 if (o.insertAdjacentHTML) { 
  o.insertAdjacentHTML(w,h);
  return;
 }
 if (oBw.ns) {
  ylib_writeHTML(o,h);
  return;
 }
 // mozilla
 var r = o.ownerDocument.createRange();
	r.setStartBefore(o);
	var frag = r.createContextualFragment(h);
	ylib_insertObj(o,w,frag)
}


function ylib_insertObj(o,w,node) {
	switch (w){
	case 'beforeBegin':
		o.parentNode.insertBefore(node,o)
		break;
	case 'afterBegin':
		o.insertBefore(node,o.firstChild);
		break;
	case 'beforeEnd':
		o.appendChild(node);
		break;
	case 'afterEnd':
		if (o.nextSibling){
			o.parentNode.insertBefore(node,o.nextSibling);
		} else {
			o.parentNode.appendChild(node)
		}
		break;
	}
}

/*____________________________________________________________________________________________________________ */

function yreg_popLayer(div,href,offx,offy,bid) {
	var e = d.getElementById(div);
	if (e.className.indexOf('hiddenlayer') != -1) {
		// if current popup is hidden, make sure all others are hidden.
		yreg_hidePopLayers('div','showlayer','hiddenlayer');	
		yreg_setLayerLocation(div,href,offx,offy);		
		e.className = 'showlayer'; //show layer	
		//yreg_createBeacon(bid);
		yreg_macIERedraw();				  
	} else if (e.className.indexOf('showlayer') != -1) {
		e.className = 'hiddenlayer';		
		//yreg_removeBeacon(); 
		yreg_macIERedraw();
	} 
}
function yreg_hidePopLayers(elm,showclass,hideclass) {
	var elms = d.getElementsByTagName(elm);
	for (var i =  elms.length-1; i >=0; i--)	{
		if (elms[i].className.indexOf(showclass) != -1)	{
			// if a class contains 'showclass' set to 'hideclass'
			elms[i].className = hideclass;
		}
	}
}
function yreg_setLayerLocation(div,href,offx,offy) {
	var e = d.getElementById(div);
	//get position of link
	var x=ylib_getPageX(href);
	var y=ylib_getPageY(href);
	// check and set there is offset
	x= offx ? x + offx : x;
	y= offy ? y + offy : y;
	//move layer
	ylib_moveTo(e,x,y);
}
function yreg_macIERedraw() {
// redraw screen for Mac IE (bug #: 152029)
	if (oBw.mac &&  oBw.ie5) {
		document.body.style.backgroundColor = "red";
		document.body.style.backgroundColor = "white";
	}
}
//function yreg_createBeacon(bid) {
//	var r=Math.random();
//	e=d.getElementById('yregbcn');	
//	if (e) e.innerHTML='<img alt="Yahoo Image" width=1 height=1 border=0 src="https://pclick.internal.yahoo.com/p/s='+bid+'/lng=us/rand='+r+'"> '; // create beacon img
//}
//function yreg_removeBeacon() {
//  var	e=d.getElementById('yregbcn');	
//	if (e) e.innerHTML=''; // remove beacon img
//}
