// Used functions - layers, objects, etc
// Copyright (C) 2004 Cyber Stream Technology s.r.o.

function browserCheck() {
	this.ver = navigator.appVersion;
	this.agent = navigator.userAgent.toLowerCase();
	this.dom = document.getElementById?1:0
	
	this.op5 = (this.agent.indexOf("opera 5")>-1 || this.agent.indexOf("opera/5")>-1) && window.opera 
	this.op6 = (this.agent.indexOf("opera 6")>-1 || this.agent.indexOf("opera/6")>-1) && window.opera   
	this.op7 = (this.agent.indexOf("opera 7")>-1 || this.agent.indexOf("opera/7")>-1) && window.opera   
	this.op = (this.op5 || this.op6 || this.op7);
	this.ie5 = (this.agent.indexOf("msie 5")>-1 && !this.op5 && !this.op6);
	this.ie55 = (this.ie5 && this.agent.indexOf("msie 5.5")>-1);
	this.ie6 = (this.agent.indexOf("msie 6")>-1 && !this.op5 && !this.op6);
	this.ie4 = (this.agent.indexOf("msie")>-1 && document.all &&!this.op5 &&!this.op6 &&!this.ie5&&!this.ie6);
	this.ie = (this.ie4 || this.ie5 || this.ie6);
	this.mac = (this.agent.indexOf("mac")>-1);
	this.ns6 = (this.agent.indexOf("gecko")>-1 || window.sidebar);
	this.ns4 = (!this.dom && document.layers)?1:0;
	this.ns = (this.ns4 || this.ns6);
	this.bw = (this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.op5 || this.op6 || this.op7);
	this.usedom = this.ns6; //Use dom creation
	this.reuse = this.ie || this.usedom; //Reuse layers
	this.px = this.dom&&!this.op5?"px":"";
	
	return this;
}

// check browser
bw = new browserCheck();
var browser = bw.bw;
var IEbrowser = bw.ie;
var NSbrowser = bw.ns;

/* function for onload event */
function FOnLoad()
{
	// check if exist function
	if (typeof(ShowError) == 'function')
		ShowError();
}

function IfNull(str) {
	if (str == '' || str == null)
		return true;
	else
		return false;
}

// define used functions
function isStrEmpty(strField) {
	for (var intLoop = 0; intLoop < strField.length; intLoop++)
		if (strField.charAt(intLoop) != " ") 
			return false;
	return true;
}

function FReset(sForm)
{
	var oForm = GetForm(sForm);
	if (oForm)
		oForm.reset();
}
		
function GetObj(name) {
	if (NSbrowser) {
		if (bw.ns6) return document.getElementById(name);
			else return document.layers[name];
	} else {
		return (bw.ie4?document.all(name):document.getElementById(name));
	}
}

function GetObjInFrame(nameFrame, name) {
	var objFrame = GetObjectFrame(nameFrame);
	if (objFrame)
	{
		if (NSbrowser) {
			if (bw.ns6) return objFrame.document.getElementById(name);
				else return objFrame.document.layers[name];
		} else {
			if (bw.ie4)
				return objFrame.document.all(name);
			else	
				return objFrame.document.getElementById(name);
		}
	}
}

function GetObjs(name) {
	if (NSbrowser) {
		if (bw.ns6) return document.getElementsByName(name);
			else return document.layers[name];
	} else {
		return (bw.ie4?document.all(name):document.getElementsByName(name));
	}
}

function GetObjectFrame(name) {
	// nacteni objektu z frame
	var objFrame = document.frames(name);
	return objFrame;
}

function GetObjStyle(obj) {
	if (NSbrowser) {
		if (bw.ns6) return obj.style;
			else return obj;
	} else {
		return obj.style;
	}
}

function GetForm(obj) {
	var oForm;
	if (NSbrowser) {
		oForm = eval('document.'+obj);
	}
	else {
		oForm = document.forms[obj];
	}
	return oForm
}

var iName2Close = "";
var bAutoHide = true;
function on(name,txt) {
	if (browser) {
		var nameX = name + 'a'
		document.images[name].src=eval(nameX).src;
		window.status = txt;
		document.pravda = true;
	}
}

function off(name) {
	if (browser) {
		document.images[name].src=eval(name).src;
	  	window.status = " ";
		document.pravda = true;
	}
}

function RedefineTag2Html(str) {
	var strRet = "";
	strRet = str.replace(/</g, "&lt;");
	strRet = strRet.replace(/>/g, "&gt;");
	strRet = strRet.replace(/"/g, "&quot;");
	strRet = strRet.replace(/\\/g, "&#47;");
	strRet = strRet.replace(/\//g, "&#92;");
	strRet = strRet.replace(/\'/g, "\\'");
	return strRet;
}

function RedefineUrlString(str) {
	var strRet = "";
	strRet = str.replace(/&/g, "%26");
	strRet = strRet.replace(/ /g, "%20");
	strRet = strRet.replace(/\?/g, "%3F");
	
	return strRet;
}

function MergeUrlRequest(sUrl, sSUrl) {
	if (sSUrl != '' && sSUrl != '[surl]') {
		if (sUrl.indexOf('?') == -1 && sSUrl.indexOf('?') == -1) {
			// neexistuje ? - doplni se
			var sCond = '?';
		} else {
			// existuje ? - doplni se pouze &
			var sCond = '&';
			if (sSUrl.indexOf('?') != -1) {
				var sCond = '';
				if (sUrl.indexOf('?') != -1) {
					// je nutne odstraneni ? z retezce sec.url
					sSUrl = sSUrl.replace('?', '&');
				}
			}
			if (sSUrl.indexOf('&') != 1 && sUrl.indexOf('?')==(sUrl.length-1)) var sCond = '';
		}
		var sCompleteUrl = sUrl+sCond+sSUrl;
	} else
		var sCompleteUrl = sUrl;
	// vraceni hodnoty
	return sCompleteUrl
}

function GenerateTimeStamp() {
	var d = new Date();
	var s = d.getFullYear()+''+d.getMonth()+''+d.getDay()+''+d.getHours()+''+d.getMinutes()+''+d.getSeconds()+''+d.getMilliseconds();
	return s;
}

function ReturnModalOpen(sCompleteUrl, sTarget, sProperty, sTitleId) {
	// upravi se kompletni string tak aby bylo mozne pak danou stranku
	// jednoznacne otevrit pomoci iframe - je to kvuli spravnemu odesilani
	// hodnot pomoci modal okna
	sCompleteUrl = RedefineUrlString(sCompleteUrl);
	var strModal = strBase +'forms/modal.aspx?url='+ sCompleteUrl +'&titleid='+ sTitleId +'&timestamp='+GenerateTimeStamp();
	// provede se otevreni okna
	var newValue = window.showModalDialog(strModal, sTarget, sProperty);
	// vraceni hodnoty
	return newValue;
}


function ModalOpen(sUrl, sTarget, sProperty, sTitleId, sSUrl) {
	// definovani celkoveho url
	if (typeof(sSUrl) != 'undefined') {
		var sCompleteUrl = MergeUrlRequest(sUrl, sSUrl)
	} else
		var sCompleteUrl = sUrl;
	
	// vraceni hodnoty
	var newValue = ReturnModalOpen(sCompleteUrl, sTarget, sProperty, sTitleId)
	
	if (!IfNull(newValue)) {
		// refresh daneho okna
		switch (newValue) {
			case "0":
			case 0:
				// nic se neprovede
				break;
			case "1":
			case 1:
				// refresh okna
				document.location.reload();
				break;
			case "2":
			case 2:
				// provede se doplneni search=1 do parametru stranky
				var sActUrl = document.location.href;
				if (sActUrl.indexOf('?') == -1) {
					sActUrl += "?search=1";
				} else {
					sActUrl += "&search=1";
				}
				document.location.href = sActUrl;
				break;
			case "3":
			case 3:
				// nic se neprovede
				break;
			default:
				// klasicke zobrazeni stranky - dle definovaneho url
				document.location.href = newValue;
				break
		}
	}
}

function ConfirmDelete(sError, obj)
{
	if (obj)
	{
		var sBtnName = obj.name;
		var a = window.confirm(sError);
		if (a) {
			__doPostBack(sBtnName,'');
		}
		else {
			return false;
		}
	}
	else
		return false;
}

function UploadFile(aDir, sName)
{
	var url = strBaseRef +'forms/fileupload.aspx?return=1&dir='+aDir;
	var newValue = ReturnModalOpen(url, '_blank', 'dialogHeight:165px;dialogWidth:423px;center:yes;help:no;scroll:no;resizable:no;status:no', '1029');
	// ziskani objektu
	var obj = GetObj(sName);
	if (typeof(newValue) == 'undefined')
		return;
	if (obj && newValue!='' && newValue!='1')
		obj.value = newValue;
}

function ShowHiddenFindForm()
{
	var objFForm = GetObj('divFormFind');
	if (objFForm)
	{
		if (objFForm.style.display == "none")
			objFForm.style.display = "";
		else
			objFForm.style.display = "none";
	}
}

function GetSelectedItemFromSelect(obj)
{
	if (obj) {
		if (obj.length > 0) {
			var iIndex = obj.selectedIndex;
			if (iIndex > -1)
				return obj[iIndex];
		}
	}
}

function GetValueFromSelect(obj)
{
	var obj = GetSelectedItemFromSelect(obj);
	if (obj)
		return obj.value;
	return "";
}

function GetTextFromSelect(obj)
{
	var obj = GetSelectedItemFromSelect(obj);
	if (obj)
		return obj.text;
	return "";
}

function SetInputFromSelect(inputName, selectName, text)
{
	var objInp = GetObj(inputName);
	var objSel = GetObj(selectName);
	if (objInp && objSel)
	{
		var val = '';
		var valI = GetValueFromSelect(objSel)
		if (text) val = (valI>-1?GetTextFromSelect(objSel):'');
			else val = valI;
		// set value
		objInp.value = val;
	}
}

function GetReplacedCharForNumber()
{
	var oNum = new Number(0,1);
	if (oNum == 0)
		return ".";
	else
		return ",";
}
var sReplacedNumberChar = GetReplacedCharForNumber();

function ReturnFloat(value)
{
	if (value != "")
	{
		if (sReplacedNumberChar == '.')
			value = value.replace(',', '.');
		else
			value = value.replace('.', ',');
		return parseFloat(value);
	}
	return 0;
}

function RoundNumber(num)
{
	return RoundNumberCnt(num, 100);
}

function RoundNumberCnt(num, cnt)
{
	var oNum = new Number(num);
	return Math.round(oNum*cnt)/cnt;
}

function RoundDPH(dph)
{
	var iDph = parseInt(dph);
	var iNum = (dph / (100+iDph));
	var sNum = iNum.toString().substring(0,6);
	return parseFloat(sNum);
}

// ziskani indexu v poli
function GetIndex4Array(name)
{
	if (arrRelation.length > 0)
		for (i = 0; i < arrRelation.length; i++)
		{
			var sName = arrRelation[i][0];
			if (sName == name) 
			{
				return i;
			}
		}
	return -1;
}

// ziskani zaznamu
function GetValue4Array(name)
{
	var i = GetIndex4Array(name);
	
	// vraceni hodnoty
	if (i == -1)
		return null;
	else
		return arrRelation[i][1];
}

// nastaveni hodnoty pro combo
function SelectValueInCombo(obj, value)
{
	if (obj)
	{
		for(var i = 0; i < obj.options.length; i++) { 
			obj.options[i].selected = false;
			if (obj.options[i].value == value) {
				obj.options[i].selected = true;
			}
		}
	}
}

// vlozeni zaznamu
function SetValue2Array(name, value)
{
	var i = GetIndex4Array(name);
	if (i == -1)
	{
		// vlozeni hodnoty
		var _item = new Array(1);
		_item[0] = name;
		_item[1] = value;
		arrRelation.push(_item);
	}
	else
	{
		arrRelation[i][1] = value;
	}
}

//create pop up window (without anything)
function popUpWindow(URL, widthWindow, heightWindow) {
	day = new Date();
	id = day.getTime();
	positionLeft = ((screen.width - widthWindow) / 2);
	positionTop = ((screen.height - heightWindow) / 2);
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width="+ widthWindow +",height="+ heightWindow +",left="+ positionLeft +",top="+ positionTop +"');");
}

/* ---------------------------------------------------------------- */
/* from cstWebsite directly */

// on key down function
function event_onkeydown()
{
	switch (event.keyCode)
	{
		case 13:	//enter
		{
			// now get info about find form if exist and if is opened
			// if yes then click on the button in find form
			// 1. get find form object
			var formObj = GetObj('divFormFind');
			if (!formObj)
				break;
				
			if (formObj.style.display == "")
			{	
				__doPostBack('btnFind', '');
			}
			break;
		}
	}
}

// control enter
var btnSendForm = true;
function event_enter(event, btnName)
{
	switch (event.keyCode)
	{
		case 13:
		{
			// send form
			btnSendForm = false;
			if (btnName != '')
				__doPostBack(btnName, '');
			break;
		}
	}
}

// check event
function CheckEvent()
{
	return false;
}

function SendLogin(sPageUrl) {
	var theform = GetForm('loginform');
	if (theform)
	{
		var objUsr = this.document.getElementById('LoginForm_UserName');
		var objPsw = this.document.getElementById('LoginForm_Password');
		if (objUsr && objPsw)
		{
			theform[sUsrN].value = objUsr.value
			theform[sPswN].value = objPsw.value
			if (typeof(sPageUrl) != 'undefined')
				theform.PageUrl.value = sPageUrl;
			theform.submit();
		}
	}
}

var sLastName = "";
var sLastPass = "";
function ClearOnClick(obj)
{
	if (obj)
	{
		if (obj.name == 'LoginForm_UserName')
			sLastName = obj.value;
		else
			sLastPass = obj.value;
			
		obj.value = '';
	}
}

function FillOffClick(obj)
{
	if (obj)
	{
		if (obj.value == '')
		{
			if (obj.name == 'LoginForm_UserName')
				obj.value = sLastName;
			else
				obj.value = sLastPass;
		}
	}
}

function OpenCalendar(sObj, sType) {
	var obj;
	if (typeof(sObj)=='object')
		obj = sObj;
	else
		obj = GetObj(sObj);
		
	if (obj && IEbrowser) {
		var url = strBaseRef +'forms/calendar.aspx?type='+sType+'&val='+obj.value;
		var retValue = ReturnModalOpen(url,'_blank','dialogHeight:235px;dialogWidth:206px;center:yes;help:no;scroll:no;resizable:no;status:no', '1027');
		if (typeof(retValue)!='undefined') {
			// change return value
			var aVal = obj.value.split(' ');
			if (obj.value !='' && aVal[1]!='' && typeof(aVal[1])!= 'undefined') {
				obj.value = retValue +' '+ aVal[1];
			} else {
				var act = new Date();
				obj.value = retValue;
			}
		}
	}
}

function OpenLogin(open) {
	// open logon window
	window.open(strBaseRef +'forms/logon.aspx', '', 'height=160,width=280,status=no,toolbar=no,menubar=no,location=no,resizable=no,resizable=no,center=yes,top=300,left=300');
}

function OpenOneStoreStatus(url) {
	// open store status with one item
	window.open(url, 'storewin', 'width=650,height=105,toolbar=0,top=300,left=170,scrollbars=0');
}

function OpenStoreStatus(url) {
	// open store status
	window.open(url, 'storewin', 'width=650,height=200,toolbar=0,top=300,left=170,scrollbars=1');
}


function frmfocus(obj, txt) {(obj.value==txt)?obj.value='':obj.select();}
function frmblur(obj, txt) {(obj.value=='')?obj.value=txt:obj.value=obj.value;}

						
function ChangeCart(objId, id, pid, gid, ret, bUse)
{
	var sUrl = sChangeUrl;
	var gidR = -1;
	if (typeof(gid) != 'undefined')
		gidR = gid;
	var bUsed = 0;
	if (typeof(bUse) != 'undefined')
		bUsed = bUse;
	var retR = 0;
	if (typeof(gid) != 'undefined')
		retR = ret;
		
	if (sUrl != '')
	{
		var objInp = GetObj(objId);
		if (objInp)
		{
			if (objInp.value == "") objInp.value = "1";
			sUrl += "&cnt="+ objInp.value +"&pid="+ pid +"&tid="+ id +"&gid="+ gidR +"&bused="+ bUsed +"&ret="+ retR;
			document.location.href = sUrl;					
		}
	}
}

function DeleteFromCart(id, pid, gid, ret, bUse)
{
	var sUrl = sDeleteUrl;
	var gidR = -1;
	if (typeof(gid) != 'undefined')
		gidR = gid;
	var bUsed = 0;
	if (typeof(bUse) != 'undefined')
		bUsed = bUse;
	var retR = 0;
	if (typeof(gid) != 'undefined')
		retR = ret;
		
	if (sUrl != '')
	{
		sUrl += "&pid="+ pid +"&tid="+ id +"&gid="+ gidR +"&bused="+ bUsed +"&ret="+ retR;
		document.location.href = sUrl;				
	}
}

function FitPic() 
{
	var arrTemp=self.location.href.split("?");
	var picUrl = ((arrTemp.length>0)?arrTemp[1]:"").split("=")[1];
	var NS = (navigator.appName=="Netscape")?true:false;
	iWidth = (NS)?window.innerWidth:document.documentElement.clientWidth;
	iHeight = (NS)?window.innerHeight:document.documentElement.clientHeight;
	
	iWidth = document.images[0].width - iWidth;
	iHeight = document.images[0].height - iHeight;
	
	window.resizeBy(iWidth+40, iHeight+80);
	self.focus();
};


/*
* aaLert v1.0
* by Cyber Stream Technology s.r.o.
*/
function aLert(message, buttons, options) {
	this.message_ = message;
	this.buttons_ = buttons;
	this.defaultButton_ = options.defaultButton || this.buttons_[0];
	this.icon_ = options.icon || null;
}

aLert.prototype.display = function() {
	var body = document.getElementsByTagName ('BODY')[0];
	var pageScroll = getPageScroll();
	var pageSize = getPageSize();

	//create the overlay if necessary
	var overlay = document.getElementById('lertOverlay');
	if(!overlay) {
		var overlay = document.createElement("div");
		overlay.setAttribute('id','lertOverlay');
		overlay.style.display = 'none';
		body.appendChild(overlay);
	}

	//position and show the overlay
	overlay.style.height=pageSize[1]+'px';
	overlay.style.display='block';

	//create the container if necessary
	var container = document.getElementById('lertContainer');
	if(!container) {
		var container = document.createElement("div");
		container.setAttribute('id','lertContainer');
		container.style.display = 'none';
		body.appendChild(container);
	}

	//position and show the container
	container.style.top = ( pageScroll[1] + (pageSize[3] / 5) ) + 'px';
	container.style.display = 'block';

	//create the window
	var win = document.createElement('div');
	win.setAttribute('id','lertWindow');

	//create the optional icon
	if(this.icon_ != null) {
		var icon = document.createElement('img');
		icon.setAttribute('src',this.icon_);
		icon.setAttribute('id','lertIcon');
		icon.setAttribute('alt','');
		win.appendChild(icon);
	}

	//create the message space
	var message = document.createElement('p');
	message.setAttribute('id','lertMessage');
	message.innerHTML = this.message_;
	win.appendChild(message);

	//create the button space
	var buttons = document.createElement('div');
	buttons.setAttribute('id','lertButtons');

	var oldKeyDown = document.onkeydown;

	//add each button
	for(i in this.buttons_) {
		var button = this.buttons_[i];
		if(button.getDom) {
			var domButton = button.getDom(function() {
				container.style.display = 'none';
				overlay.style.display = 'none';
				document.onkeydown=oldKeyDown;
				container.innerHTML = '';
				button.onclick_;
			},this.defaultButton_);
			buttons.appendChild(domButton);
		}
	}
	win.appendChild(buttons);

	document.onkeydown = this.keyboardControls;

	//append the window
	container.appendChild(win);
}

aLert.prototype.keyboardControls = function(e) {
	if (e == null) { keycode = event.keyCode; } // ie
	else { keycode = e.which; } // mozilla
	if(keycode==13) { document.getElementById('lertDefaultButton').onclick(); }
}

function aLertButton(label, event, options) {
	this.label_ = label;
	this.onclick_ = event;
	this.eventClick = function() {};
}

aLertButton.prototype.getDom = function(eventCleanup,defaultButton) {
	var button = document.createElement('a');
	button.setAttribute('href','#');
	button.className = 'lertButton';
	if(this == defaultButton) button.setAttribute('id','lertDefaultButton');
	button.innerHTML = this.label_;

	var eventOnclick =  this.onclick_;
	button.onclick = function() {
		eventCleanup();
		eventOnclick();
	}
	this.eventClick = button.onclick;
	return button;
}

//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll)
	return arrayPageScroll;
}

// -----------------------------------------------------------------------------------

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){

	var xScroll, yScroll;

	if (window.innerHeight && window.scrollMaxY) {
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}

	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
	return arrayPageSize;
}


/* functions for create aLert and make action */
/*  -- drop cart */
function DropCart(tYes, tNo, tQuestion) {
	var yes = new aLertButton(tYes, function() {
			document.location.href = strBaseRef +'forms/savecart.aspx?action=deleteall';
	});

	var no = new aLertButton(tNo, function() {
			               
	});

	var message = tQuestion;
	var dropCartALert = new aLert(
		message,
		[yes,no],
		{
			icon: rootImage +'alert/dialog-warning.gif',
				defaultButton:no
		});

	dropCartALert.display();
}

/*  -- logout */
function LogoutUser(tCancel, tLeave, tEmpty, tOrder, tQuestion, tQuestionLogout, tYes) {
	var cart = document.getElementById('cartId');
	var bLogout = false;
	if (!bCartFull)
		bLogout = true;
	
	var leave = new aLertButton(tLeave, function() {
		document.location.href = strBaseRef +'forms/logout.aspx';
	});

	var empty = new aLertButton(tEmpty, function() {
		document.location.href = sCartDeleteAllUrl;
	});

	var order = new aLertButton(tOrder, function() {
		document.location.href = sCartDetailUrl;
	});

	var cancel = new aLertButton(tCancel, function() {
	});

	var message = tQuestion;
	if (bLogout)
	{
		if (typeof(tQuestionLogout) != 'undefined')
			message = tQuestionLogout;
		if (typeof(tYes) != 'undefined')
			leave.label_ = tYes;
	}
	
	if (bLogout)
	{
		var logoutALert = new aLert(
			message,
			[leave,cancel],
			{
				icon: rootImage +'alert/dialog-warning.gif'
			});
	}
	else
	{
		var logoutALert = new aLert(
			message,
			[order,empty,leave,cancel],
			{
				icon: rootImage +'alert/dialog-warning.gif'
			});
	}
	logoutALert.display();
}

/*  -- login */
function LoginALert(tLeave, tEmpty, tOrder, tQuestion) {
	var leave = new aLertButton(tLeave, function() {
	});

	var empty = new aLertButton(tEmpty, function() {
		document.location.href = strBaseRef +'forms/savecart.aspx?action=deleteall';
	});

	var order = new aLertButton(tOrder, function() {
		document.location.href = sCartDetailUrl;
	});

	var message = tQuestion;
	var loginALert = new aLert(
		message,
		[order,empty,leave],
		{
			icon: rootImage +'alert/dialog-warning.gif'
		});

	loginALert.display();
}

/* finding functions */
function SelectFindForm() {
	if (arrayFoundedValues)
		for(var i = 0; i < arrayFoundedValues.length; i++) { 
			var sName = arrayFoundedValues[i][0];
			var sValue = arrayFoundedValues[i][1];
			var obj = GetObj(sName);
			if (obj) 
				switch (obj.type) {
					case "select-one":
						SelectValueInCombo(obj, sValue);
						break;
					case "text":
					case "hidden":
						obj.value = sValue;
						break;
					case "checkbox":
						obj.checked = true;
					default:
						break;
				}
		}
}

// reset function
function ResetFindForm() {
	FReset('MainForm');
}


function SendMainForm(send, id)
{
	if (send == true)
	{
		__doPostBack(id, '');
	}
	else
		return false;
}

/* finding functions */
function SendDetermination(ButtonName) {
	if (typeof(arrDeterminationInputs) == 'undefined')
		return;
	if (typeof(iDeterminationId) == 'undefined')
		return;
	
	// get determ. inputs
	var aDets = arrDeterminationInputs.split(',');
	var sLink = "";
	for (var i = 0; i < aDets.length; i++) { 
		var sName = aDets[i];
		var obj = GetObj(sName);
		var sValue = "";
		if (obj) 
			switch (obj.type) {
				case "select-one":
					sValue = GetValueFromSelect(obj)
					break;
				case "text":
				case "hidden":
					sValue = obj.value;
					break;
				default:
					break;
			}
			
		// set link
		sLink += "&"+ sName +"="+ sValue;
	}
	// set link
	sLink = sDeterminationUrl +"&id="+ iDeterminationId +"&btn="+ ButtonName + sLink;
	document.location.href = sLink;
}

function GetArrayFromInputs(name, arr)
{
	var ss = '';
	var tabs = document.getElementsByTagName('input');
	for (var i=0; i < tabs.length; i++)
	{
		var tab = tabs[i];
		var tabName = tab.name;
		ss += '|'+ tabName +'\n';
		
		if (tabName.indexOf(name) > 0)
			arr[arr.length] = tabName;
	}
	
	// return array
	return arr;
}

function DisableInputsInArray(arr, dis, vColor, dColor, check)
{
	for (var i=0; i < arr.length; i++)
	{
		var name = arr[i];
		var obj = GetObj(name);
		DisableInput(obj, dis, '', vColor, dColor, check);
	}
}

function FillInputsInArray(arr, value)
{
	for (var i=0; i < arr.length; i++)
	{
		var name = arr[i];
		var obj = GetObj(name);
		if (obj)
		{
			obj.value = value;
		}
	}
}

function DisableInput(obj, dis, value, vColor, dColor, check)
{
	var bCheck = false;
	if (typeof(check) != 'undefined')
		bCheck = check;
	
	if (obj)
		if (dis)
		{
			var bBlock = true;
			if (bCheck)
				if (obj.value != '')
					bBlock = false;
			
			if (bBlock)
			{
				obj.value = '';
				obj.disabled = true;
				obj.style.background = dColor;
			}
		}
		else
		{
			obj.value = value;
			obj.disabled = false;
			obj.style.background = vColor;
		}
}

function FillInputInArray(arr, objValueName, obj, index, vColor, dColor)
{
	// get value
	var objValue = GetObj(objValueName);
	var val = '';
	if (objValue)
		val = objValue.value;
	// find right obj
	for (var i=0; i < arr.length; i++)
	{
		var name = arr[i];
		var objInp = GetObj(name);
		if (objInp)
		{
			var sInd = "_"+ index;
			var sNam = objInp.name.substring(obj.name.lastIndexOf('_'));
			if (sNam == sInd)
			{
				DisableInput(objInp, !obj.checked, val, vColor, dColor);
			}
		}
	}
}

function SetTransfer(arr, inpName)
{
	var objs = GetObjs(inpName);
	var _arr = arr.split(',');
	for (var i=0; i < objs.length; i++)
	{
		var inp = objs[i];
		var inpId = inp.id;
		inp.disabled = true;
		
		if (_arr.length > 0)
		{
			for (var x=0; x < _arr.length; x++)
			{
				var val = _arr[x];
				if (val == inp.value)
					inp.disabled = false;
			}
		}
		
		if (inp.disabled == true && inp.checked == true)
			inp.checked = false;
	}
}