String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g, ""); }

function AboutRSS(){
var newURL="/shop/AboutRSS.asp";
var W = 460, H = 560, T = 20, L = window.screen.width - W - 20;
	rssWindow = window.open(newURL, 'rssWindow', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width='+W+',height='+H+',top='+T+',left='+L);
	rssWindow.focus();
}

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 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 = 500, 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 = 460, 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 STViewH(id,price){
var newURL="/shop/viewSTHaract.asp?id="+id+"&price="+price;
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 STViewPhoto(id,price){
var newURL="/shop/viewSTPhoto.asp?"+"id="+id+"&price="+price;
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 OpenWind(sURL,sWN,L,T,W,H){
	nwin=window.open(sURL,sWN,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width='+W+',height='+H+',top='+T+',left='+L);
	nwin.focus();
}
function GetAccess(cUrl){
	var W=620,H=document.body.clientHeight;
	OpenWind(cUrl,"AccessWind",5,5,W,H);
}
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 TogglePages(param) {
	var trs=document.getElementById('layer_'+param);
	var pictrs=document.getElementById('picture_'+param);
	if (trs.style.display == 'none') {
		pictrs.src='/images/mi.gif';
		trs.style.display = '';
	} else {
		pictrs.src='/images/pl.gif';
		trs.style.display = 'none';
	}
	return false;
}

function ListOfParticipants(id_auction, action){
var W = 750, H = 400, T = 20, L = window.screen.width - W - 20;
var newURL="/auction/iframe_list.asp?id_auction="+id_auction+"&action="+action;
        lostpWindow = window.open(newURL, '', '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 ViewAuctionCourse(id_lot, price_id){
var W = 850, H = 700, T = 20, L = window.screen.width - W - 20;
var newURL="/auction/ViewAuctionCourse.asp?LotID="+id_lot+"&PriceId="+price_id+"&Frame=bottom";
        lostpWindow = window.open(newURL, '', '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 set_span_value(id, val) {
	if (document.getElementById(id)) {document.getElementById(id).innerHTML = val;}
}

function get_span_value(id){
	if (document.getElementById(id)) {return document.getElementById(id).innerHTML;}
}
function isset(mixed_var) {
	var i = 0, argc = arguments.length, argv = arguments, set=true;

	for (i = 0; i< argc; i++){
		if( argv[i] === undefined ){
			set = false;
			break;
		}
	}
	return set;
}
