String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g, ""); }

function IsFillPassport() {
var validity = true;
	with (document.frmPassport) {
		if (UserLogin.value.trim() == '')		validity = false;
		if (UserPassword.value.trim() == '')	validity = false;
	}
	if (!validity) alert("Не все ключевые поля заполнены");
	return validity;
}
function GetSelOKP(){
var W = 460, H = 560, T = 20, L = window.screen.width - W - 20;
var newURL="/shop/findokp.asp";
	okpWindow = window.open(newURL, 'okpWindow', 'toolbar=yes,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width='+W+',height='+H+',top='+T+',left='+L);
	okpWindow.focus();
}
//---------------------------------
function FairBasket(parm){
	window.open("/shop/zakaz.asp?rand='"+Math.random()+"'", 'ZakazWind', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width='+W+',height='+H+',top='+T+',left='+L);
}
function DoZakaz(Num, idT, idO) {
var szCookie=getCookie("items");
	setCookie("items", ( (szCookie.length>0) ? szCookie :("") ) + DELIM  + idT  + DELIM2 + "1" + DELIM2 + "0" + DELIM2 + idO + DELIM2);
	window.open("/shop/zakaz.asp?rand='"+Math.random()+"'", 'ZakazWind', 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width='+W+',height='+H+',top='+T+',left='+L);
}
function ShopBasket(parm){
	window.open("/shop/basket.asp?rand='"+Math.random()+"'", 'BasketWind', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width='+W+',height='+H+',top='+T+',left='+L);
}
function AddZakaz(Num, idT, idO) {
var szCookie=getCookie("basket");
	setCookie("basket", ( (szCookie.length>0) ? szCookie :("") ) + DELIM  + idT  + DELIM2 + "1" + DELIM2 + "0" + DELIM2 + idO + DELIM2);
	window.open("/shop/basket.asp?rand='"+Math.random()+"'", 'BasketWind', 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width='+W+',height='+H+',top='+T+',left='+L);
}
function AddContentZakaz(Num, idT, idO) {
var szCookie=getCookie("basket");
	setCookie("basket", ( (szCookie.length>0) ? szCookie :("") ) + DELIM  + idT  + DELIM2 + "1" + DELIM2 + "0" + DELIM2 + idO + DELIM2);
	window.open("/shop/content_basket.asp?rand='"+Math.random()+"'", 'BasketWind', 'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=no,width='+W+',height='+H+',top='+T+',left='+L);
}


//---------------------------------
function DoOffer(idT, mSumma, mNDS, mPriznNDS) {
	removeCookie("supply");
	setCookie("supply",DELIM  + idT  + DELIM2 + "1" + DELIM2 + mSumma + DELIM2 + mNDS + DELIM2 + mPriznNDS + DELIM2);
	window.open("/shop/supply.asp?rand='"+Math.random()+"'&idT="+idT, 'SupplyWind', 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width='+W+',height='+H+',top='+T+',left='+L);
}
function ViewH(id){
var newURL="/shop/viewHaract.asp?id="+id;
var W = 460, H = 300, T = 20, L = window.screen.width - W - 20;
	haractWindow = window.open(newURL, 'haractWindow', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width='+W+',height='+H+',top='+T+',left='+L);
	haractWindow.focus();
}
function ViewPhoto(id){
var newURL="/shop/viewPhoto.asp?"+"id="+id;
var W = 460, H = 460, T = 20, L = window.screen.width - W - 20;
	PhotoWindow = window.open(newURL, 'PhotoWindow', 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width='+W+',height='+H+',top='+T+',left='+L);
	PhotoWindow.focus();
}
function ViewFirm(id,kw){
var newURL="/shop/firm.asp?skl=" + id + "&word='" + kw + "'";
var W = 650, H = 450, T = window.screen.height/2-H/2, L = window.screen.width/2-W/2;
	window.open(newURL, 'FirmWindow', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width='+W+',height='+H+',top='+T+',left='+L);
}
function ViewPlace(id)
{
var newURL="/shop/firmAbout.asp?skl=" + id;
var W = 350, H = 250, T = window.screen.height/2-H/2, L = window.screen.width/2-W/2;
	window.open(newURL, 'FirmWindow', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width='+W+',height='+H+',top='+T+',left='+L);
}
function details()
{
var W = 450, H = 400, T = 20, L = window.screen.width - W - 20;
var newURL="/shop/helpSeek.asp";
	detWindow = window.open(newURL, 'detWindow', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width='+W+',height='+H+',top='+T+',left='+L);
	detWindow.focus();
}
function UserLostPassw(){
var W = 450, H = 400, T = 20, L = window.screen.width - W - 20;
var newURL="/shop/lostpassw.asp";
	lostpWindow = window.open(newURL, 'lostpWindow', 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width='+W+',height='+H+',top='+T+',left='+L);
	lostpWindow.focus();
}
function DoLogin(){
var newURL="/login.asp";
var W = 480, H = 300, T = window.screen.height/2-H/2, L = window.screen.width/2-W/2;
	window.open(newURL, 'LoginWindow', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width='+W+',height='+H+',top='+T+',left='+L);
}
function GetSelGRNTI(){
var W = 460, H = 560, T = 20, L = window.screen.width - W - 20;
var newURL=ShopUrl+"findgrnti.asp";
	grntiWindow = window.open(newURL, 'grntiWindow', 'toolbar=yes,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width='+W+',height='+H+',top='+T+',left='+L);
	grntiWindow.focus();
}
function setCookie(name, value, expires, path, domain, secure) {
var path="/";
var curCookie = name + "=" + value +
		((expires) ? "; expires=" + expires.toGMTString() : "") +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "");
	document.cookie = curCookie;
}
function getCookie(name) {
var prefix = name + "="
var cookieStartIndex = document.cookie.indexOf(prefix)
	if (cookieStartIndex == -1)
		return "";
	var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
	if (cookieEndIndex == -1)
		cookieEndIndex = document.cookie.length
	return document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex)
}
function removeCookie(name, path, domain) {
var dtend=new Date();
var path="/";
	dtend.setTime(dtend.getTime()-1);
	if (getCookie(name))
		document.cookie = name + "=" + ((path) ? "; path=" + path : "")+((domain) ? "; domain=" + domain : "") +"; expires="+dtend.toGMTString();
}
function showCookie(){
	alert(unescape(document.cookie));
}

function checkEmail(obj,err_title)
{
return true;

var re = new RegExp("^[\\w\\.\\-]+\\@[\\w\\.\\-]+\\.[A-Za-z]{2,4}$");
var re2 = new RegExp("\\.{2,}");

	if( re.test(obj.value) && !re2.test(obj.value) ) {
		return true;
	}
	else
	{
		alert("В поле \""+err_title+"\" введен неправильный адрес электронной почты!");
		obj.focus();
	}
	return false;
}

function GetHtmlCode(){
var W = 500, H = 400, T = 20, L = window.screen.width - W - 20;
var newURL="http://www.sibindustry.ru/sendbtn.asp";
	sendlogoWindow = window.open(newURL, 'sendlogoWindow', 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width='+W+',height='+H+',top='+T+',left='+L);
	sendlogoWindow.focus();
}
