<!--
function SetURLParam(newkey, newvalue){
	newkey = newkey.toLowerCase();
	var URL = newurl;
	if (!URL) URL = location.href;

	var paramadded = false;
	var newparamstr = '';

	var leftpartofURL = URL.split("?")[0];
	var oldparamstr = URL.split("?")[1];
	if (oldparamstr){
		var params = oldparamstr.split("&");
		for (var i=0; i<params.length; i++){
			var pair = params[i].split("=");
			var key=pair[0];
			var value=pair[1];
			
			if (key.toLowerCase() == newkey) {	// замена существующего параметра
				value = newvalue;
				paramadded = true;
			}

			if (newparamstr == ''){
				newparamstr += key + "=" + value;
			} else {
				newparamstr += "&" + key + "=" + value;
			}
		}
	} else {								// если строка вида /news, то сделать из нее /news/, чтобы потом прибавить ?dfsf=sdfsd
		if (leftpartofURL.substring(leftpartofURL.length-1, 1) != "/"){
			leftpartofURL += "/";
		}
	}

	if (!paramadded){						// добавление параметра если он не обнаружен в URL
		if (newparamstr == ''){
			newparamstr += newkey + "=" + newvalue;
		} else {
			newparamstr += "&" + newkey + "=" + newvalue;
		}
	}
	location.href = leftpartofURL + "?" + newparamstr;
}

function getCookie(name) {
	var prefix = name + "=";
	var cookieStartIndex = document.cookie.indexOf(prefix);
	if (cookieStartIndex == -1) return null;
	var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length);
	if (cookieEndIndex == -1) cookieEndIndex = document.cookie.length;
	return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}

function setCookie(name, value, expires, path, domain) {
	if (!path) path='/';

	if (!domain){ 
		domain = location.href;
		var re = /https?:\/\/(www\.)?(.*?)(\/|$)/i;
		if (re.test(domain)){
			domain = RegExp.$2;
		}

		if (domain.indexOf(/\./) == -1) domain = "";
	}
	if (expires == 'permanent'){
		expires = 'Fri, 25 Dec 2099 23:59:59 GMT';
	} else {
		((expires) ? "; expires=" + expires.toGMTString() : "");
	}
	var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires : "") + ((domain) ? "; domain=" + domain : "") + "; path=" + path;
	document.cookie = curCookie;
}

function delCookie(name)
{
	document.cookie = name + "=; expires=Fri, 31 Dec 1999 23:59:59 GMT; path=/";
}

function logout(){
	delCookie('login');
	delCookie('password');
	location.reload();
}
// -->

// Start of verification forms messages from the site 

function Validate(theForm) {
	if (document.images) {		
		if (theForm.first_name.value=="") {
			alert("Enter Your First Name!");
			theForm.first_name.focus();
			theForm.first_name.select();
			return false;
		}		
		if (theForm.last_name.value=="") {
			alert("Enter Your Last Name!");
			theForm.last_name.focus();
			theForm.last_name.select();
			return false;
		}		
		if (theForm.phone.value=="") {
			alert("Enter Your Phone!");
			theForm.phone.focus();
			theForm.phone.select();
			return false;
		}
    	if (!isEmail(theForm.email.value)) {
    		theForm.email.focus();
    		theForm.email.select();
    		return false;
    	}
		if (theForm.question.value=="") {
			alert("Enter a question or comment!");
			theForm.question.focus();
			theForm.question.select();
			return false;
		}
	}			
	return true;
}

function isEmail(strEmail) {
	var letters="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_-";
	var numbers="0123456789";
	var name="";
	var server="";
	var strings=new Array();

	if (strEmail=="") {
		alert("Enter Email!");
		return false;
	}

	strings=strEmail.split("@");
	if (strings.length==1) {
		alert("E-Mail must contain the @ character!");
		return false;
	} else if (strings.length==2) {
		name=strings[0];
		server=strings[1];
	} else {
		alert("E-Mail must contain only one symbol @!");
		return false;
	}
	
	if (!isValid(name,letters+numbers+"._-")) {
		alert("Incorrect E-Mail address");
		return false;
	}
	
	strings=server.split(".");
	if (strings.length<2) {
		alert("Second-level domain name must be present in the E-Mail!");
		return false;
	}

	for (i=0;i<strings.length;i++) {
		if (!isValid(strings[i],letters+numbers)) {
			alert("Invalid characters in the E-Mail Address!");
			return false;
		}
	}
	
	return true;
	
}

function isValid(what,chars) {
	if (what=="") {
		return false;
	}
	bool1=false;
	for (count1=0; (count1<what.length)&&(!bool1);count1++) {
		bool2=false;
		for (count2=0; (count2<chars.length)&&(!bool2);count2++) {
			if (what.charCodeAt(count1)==chars.charCodeAt(count2)) {
				bool2=true;
			}
		}
		if (!bool2) {
			bool1=true;
		}
	}
	return !bool1;
}

// Completion of verification forms messages from the site