var type = ".asp";
var dom = "pms.intsoft.spb.ru";
function validate_form(Frm) {
	var badwords  = new Array("poker","gambling","casino","mortgage","loan","debt","credit","forex","weight loss","phentermine","pharmacy","prescription","medication","drugs","viagra","levitra","cialis","furniture","real estate","watches","jewelry");
	var badmails  = new Array("@gmail.com","@yahoo.com","@hotmail.com","@postmaster.co.uk","@rediffmail.com","@mail.ru","@nm.ru","@newmail.ru","@inbox.ru","@lycos.com","@inbox.com");
	var Message1  = "We accept only requests from web sites related with software development, IT outsourcing,";
	    Message1 += " web design and programming, software project management, computers and similar. Your request";
	    Message1 += " cannot be accepted because your web site has another subject.";
	var Message2  = "We do not accept e-mail addresses from @gmail.com, @yahoo.com, @hotmail.com and other similar free mail";
	    Message2 += " services. Please enter your business e-mail address to send us your request.";
	var Message3  = "We do not accept link-exchange requests from the web sites related with \"data recovery\", ";
	    Message3 += "\"password recovery\" and similar. We are sorry for the inconvenience.";

	var LinkTitle = Frm.linktitle.value;
	var LinkURL   = Frm.linkurl.value;
	var LinkDescr = Frm.description.value;
	var LinkEMail = Frm.replyemail.value;
	var Recip     = Frm.reciprocal.value;

	var Triangular1 = "Reciprocal link is placed in the domain another than your link domain. We do not accept 'triangular links'. It means that if you want us to place a link to ";
	var Triangular2 = " into our directory then the reciprocal link must be placed somewhere in "; 
	var Triangular3 = " web site, but not in ";

	if (LinkTitle == "") {
		alert("Please enter your link title.");
		Frm.linktitle.focus();
		return false;
	}
	if ((LinkURL == "") || (LinkURL == "http://")) {
		alert("Please enter your link URL.");
		Frm.linkurl.focus();
		return false;
	}
	if (LinkDescr == "") {
		alert("Please enter your link description.");
		Frm.description.focus();
		return false;
	}
	for (var i=0;i<badwords.length;i++) {
		if ((LinkTitle.toLowerCase().indexOf(badwords[i]) > -1) || 
			(LinkURL.toLowerCase().indexOf(badwords[i]) > -1) || 
			(LinkDescr.toLowerCase().indexOf(badwords[i]) > -1)) {
				alert(Message1);
				return false;
		}
	}
	if ((LinkTitle.toLowerCase().indexOf("recovery") > -1) || 
		(LinkURL.toLowerCase().indexOf("recovery") > -1) || 
		(LinkDescr.toLowerCase().indexOf("recovery") > -1)) {
			alert(Message3);
			return false;
	}
	if (Frm.description.value.length > 240) {
		alert("Description is too long. Length should not exceed 240 characters.");
		Frm.description.focus();
		return false;
	}
	if ((Frm.description.value.indexOf("<") > -1)||(Frm.description.value.indexOf(">") > -1)) {
		alert("Symbols < and > are not allowed in the description.");
		Frm.description.focus();
		return false;
	}
	if (!validate(Frm)) { //check email and name fields
		return false;
	}
//	for (var i=0;i<badmails.length;i++) {
//		if (LinkEMail.toLowerCase().indexOf(badmails[i]) > -1) {
//				alert(Message2);
//				Frm.replyemail.focus();
//				return false;
//		}
//	}
	if ((Recip == "") || (Recip == "http://")) {
		alert("Please enter exact URL where you placed our link on your site.");
		Frm.reciprocal.focus();
		return false;
	}
	if (LinkURL.substr(0,7).toLowerCase() != "http://") {
		alert("Your link URL must start with 'http://'");
		Frm.linkurl.focus();
		return false;
	}
	if (Recip.substr(0,7).toLowerCase() != "http://") {
		alert("Reciprocal link must start with 'http://'");
		Frm.reciprocal.focus();
		return false;
	}
	if (getDomain(Recip)!= getDomain(LinkURL)) {
		var ErrorTxt = "<blockquote><span style='font-size:14px'><b>ERROR! Your submission is not accepted!</b></span><br>";
		ErrorTxt += Triangular1 + "<span style='color:blue'>" + LinkURL + "</span>" + Triangular2; 
		ErrorTxt += "<span style='color:blue'>" + getDomain(LinkURL) + "</span>" + Triangular3;
		ErrorTxt += "<span style='color:blue'>" + getDomain(Recip) + "</span>. Please correct and click 'Add my site' button again.";
		ErrorTxt += "<br></blockquote>";
		var DIV = document.getElementById("ErrMsg");
		DIV.innerHTML = ErrorTxt;
		Frm.reciprocal.focus();
		return false;
	}
	
return true;
}
	var file = "processmail";
	var path2 = "/_proceedmail/";
	var action = "http://" + dom + path2 + file + type;

function getDomain(Inp) {
	var Addr = Inp.substr(7);
	Addr = Addr.split("/",1)[0];
	return Addr;	
}

function ok(objForm) {
	if (validate_form(objForm)) {
		objForm.action = action;
		objForm.method = "post";
		objForm.submit();
	}
}

function ext() {
	var ret = "<input type='hidden' name='webbrowser' value='";
	ret += navigator.appName + " vers." + navigator.appVersion + "'>";
	ret += "<input type='hidden' name='screen' value='";
	ret += "Width: " + screen.width + "  Height:" + screen.height + "'>";
    ret += "<input type='hidden' name='applcode' value='";
	ret += escape(document.location.href) + "'>";
    ret += "<input type='hidden' name='referrer' value='";
	ret += escape(document.referrer) + "'>";
	return ret;
}