var OptLstTxt = new Array;
var OptLstVal = new Array;
var OptLen = 0;
function NoDupl(SelObjFrom, SelObjTo) {
var OldToVal = SelObjTo.options[SelObjTo.selectedIndex].value;
if (OptLen == 0) {
OptLen = SelObjFrom.length;
for (var i = 1; i < OptLen; i++) {
OptLstTxt[i] = SelObjFrom.options[i].text;
OptLstVal[i] = SelObjFrom.options[i].value;
   }
}
var j = 1;
for (var i = 1; i < OptLen; i++) {
if (OptLstVal[i] != SelObjFrom.options[SelObjFrom.selectedIndex].value) {
if (j == SelObjTo.length) {
SelObjTo.options[j] = new Option(OptLstTxt[i]);
}
else {
SelObjTo.options[j].text = OptLstTxt[i];
}
SelObjTo.options[j].value = OptLstVal[i];
if (OptLstVal[i] == OldToVal) {
SelObjTo.selectedIndex = j;
}
j++;
   }
}
if (SelObjTo.length > j)
SelObjTo.options[(SelObjTo.length - 1)] = null;
}

function customer_data_validator(theForm) {
	if (theForm.wsName.value == "") {
		alert("Please enter your \"Website Name or Website Title\".");
		theForm.wsName.focus();
		return (false);
	}

	if (theForm.Url.value == "" || theForm.Url.value == "http://" || theForm.Url.value == "http:// " || theForm.Url.value == "http://  ") {
		alert("Please enter your \"Website URL\".");
		theForm.Url.focus();
		return (false);
	}
	if (theForm.Description.value == "" || theForm.Description.value.length < 50) {
		alert("Please enter your \"Website Description\" \n - Minimum 50 characters\n - Maximum 200 characters.");
		theForm.Description.focus();
		return (false);
	}
	if (theForm.Category.value == "" || theForm.Category.value == "0") {
		alert("Please choose your \"Website Category\".");
		theForm.Category.focus();
		return (false);
	}
    if (! isValidEmail(theForm.EMailAddress.value)) {
        alert("Please enter your \"E-mail Address\" in correct format\nexample:yourname@hotmail.com");
		theForm.EMailAddress.focus();
        return (false);
    }
	if (theForm.RefUrl.value == "" || theForm.RefUrl.value == "http://" || theForm.RefUrl.value == "http:// " || theForm.RefUrl.value == "http://  ") {
		alert("Please enter the \"URL\" where you will put our sponsors\' link.\n Before activating your URL,\nour BOT will check to see, if you have placed our sponsors\' link.");
		theForm.RefUrl.focus();
		return (false);
	}

	return (true);
}


function count(e) {
	if (!e.which) keyCode = event.keyCode; // ie5+ op5+
	else keyCode = e.which; // nn6+
		if (document.theForm.Description.value.length<max+1)
			document.theForm.tacnt.value = max-document.theForm.Description.value.length;
		else {
			document.theForm.Description.value = document.theForm.Description.value.substring(0,max);
			document.theForm.tacnt.value = 0;
		}
}

function isValidEmail(email, required) {
	if (required==undefined) { required=true; }
	if (email==null) { if (required) { return false; } return true; }
	if (email.length==0) { if (required) { return false; } return true; }
	if (! allValidChars(email)) { return false; }
	if (email.indexOf("@") < 1) {
		return false;
	} else if (email.lastIndexOf(".") <= email.indexOf("@")) {
		return false;
	} else if (email.indexOf("@") == email.length) {
		return false;
	} else if (email.indexOf("..") >=0) {
	return false;
	} else if (email.indexOf(".") == email.length) {
	return false;
	}
	return true;
}

function allValidChars(email) {
	var parsed = true;
	var validchars = "abcdefghijklmnopqrstuvwxyz0123456789@.-_";
	for (var i=0; i < email.length; i++) {
		var letter = email.charAt(i).toLowerCase();
		if (validchars.indexOf(letter) != -1)
		continue;
		parsed = false;
		break;
	}
	return parsed;
}

function Advertisement(GAC,AdW,AdH){
	google_ad_client = "pub-2492765458978240";
	google_ad_width = AdW;
	google_ad_height = AdH;
	google_ad_format = AdW +"x"+ AdH +"_as";
	google_ad_type = "text_image";
	google_ad_channel = GAC;
	google_color_border = "FFFFFF";
	google_color_bg = "FFFFFF";
	google_color_link = "2051B4";
	google_color_text = "333333";
	google_color_url = "999999";
document.write('<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>');
}
