// Набор служебный функций
var iexplorer = document.all    ? 1 : 0;
var netscape  = document.layers ? 1 : 0;
var searchfieldWidth = netscape ? 4 : 8;

//var WWWRootURL = "http://www.omskindustry.ru/";
//var baseUrl = "http://www.techtorg.ru/";
//var ShopUrl = "http://www.omskindustry.ru/shop/";

var BasketWind;
var ZakazWind;
var SupplyWind;

var DELIM  ='#';
var DELIM2 = '$';
var W = 750, H = 450, T = 20, L = 20;


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 Letter4Rabota(Num, idT, idO) {
var T = window.screen.height/2-H/2, L = window.screen.width/2-W/2;
	JobWind = window.open("/shop/writeletter4job.asp?idTovar=" + idT + "&idOwn=" + idO + "&rand='"+Math.random()+"'", 'JobWind', 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width='+W+',height='+H+',top='+T+',left='+L);
	JobWind.focus();
}

function FairBasket(parm){
	ZakazWind = 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);
	ZakazWind.focus();
}
function DoZakaz(Num, idT, idO) {
var szCookie=getCookie("items");
	setCookie("items", ( (szCookie.length>0) ? szCookie :("") ) + DELIM  + idT  + DELIM2 + "1" + DELIM2 + "0" + DELIM2 + idO + DELIM2);
	ZakazWind = 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);
	ZakazWind.focus();
}
function ShopBasket(parm){
	BasketWind = 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);
	BasketWind.focus();
}
function AddZakaz(Num, idT, idO) {
var szCookie=getCookie("basket");
	setCookie("basket", ( (szCookie.length>0) ? szCookie :("") ) + DELIM  + idT  + DELIM2 + "1" + DELIM2 + "0" + DELIM2 + idO + DELIM2);
	BasketWind = 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);
	BasketWind.focus();
}
//---------------------------------
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 ViewH4R(id){
var newURL="/shop/viewHaract4Rabota.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 ViewPhoto4R(id){
var newURL="/shop/viewPhoto4Rabota.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 ViewVideo(id){
var newURL="/shop/viewVideo.asp?"+"id="+id;
var W = 560, H = 500, T = 20, L = window.screen.width - W - 20;
	PhotoWindow = window.open(newURL, 'VideoWindow', '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;
	FirmWindow = 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);
	FirmWindow.focus();
}
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;
	LoginWindow = 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);
	LoginWindow.focus();
}
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)
{
	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();
}

