// JavaScript Document
// <meta http-equiv="Content-Type" content="text/html; charset=windows-1251">

isNS = (navigator.appName == 'Netscape');
isIE = (navigator.appName.indexOf('Microsoft') != -1);
isOP = (navigator.appName == 'Opera');
ns4 = (document.layers);
ie4 = (document.all && !document.getElementById);
ie5 = (document.all && document.getElementById);
ns6 = (!document.all && document.getElementById);

function BrowserInfo() {
  this.name = navigator.appName;
  this.codename = navigator.appCodeName;
  this.version = navigator.appVersion.substring(0,4);
  this.platform = navigator.platform;
  this.javaEnabled = navigator.javaEnabled();
  this.screenWidth = screen.width;
  this.screenHeight = screen.height;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function xGetElementById(e) {
	if(typeof(e)!='string') return e;
	if(document.getElementById) e=document.getElementById(e);
	else if(document.all) e=document.all[e];
	else e=null;
	return e;
}
function xInnerHtml(e,h){
	if(!(e=xGetElementById(e)) || !xStr(e.innerHTML)) return null;
	var s = e.innerHTML;
	if (xStr(h)) {e.innerHTML = h;}
	return s;
}
function xStr(s){
	for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])!='string') return false;}
	return true;
}

// za clienti
function popScreen (kod, filen) {
	var img = '../scripts/phpThumb/phpThumb.php?src=/snimki/' + filen + '.jpg&fltr[]=wmi|/pictures/watermark.png|BL';
	this['offer' + filen] = window.open ('/php/showPic.php?kod='+ kod + '&file=' + img, '_popscr', 'width=100, height=100, resizable=1');
	// window.open('/php/showPic.php?uid=< ?=$pic["uid"]?>','big_pic','toolbars=no, width=400, height=307').focus();
}

function loadPic(picID, hint) {
	var _img = xGetElementById('pic');
	var _name = "/scripts/phpThumb/phpThumb.php?src=/swf/assets/images/pf" + picID + ".jpg&w=211&h=71&zc=1&bg=CCCCCC";
	_img.src = _name;
	_img.alt = _img.title = hint;
}

// --- Window functions -------------------------
function openWindow(url, name) {
  popupWin = window.open(url, name, 'scrollbars=yes,resizable=yes,status=no,personal=no,menu=no,location=no,toolbar=no,left=20,top=20,width=770,height=500')
}

//example: openSizedWindow('http://www.mysite.com','myName','400','500');
function openSizedWindow(url, name, myHeight, myWidth) {
 popupWin = window.open(url, name, 'scrollbars=yes,resizable=yes,status=yes,personal=no,menu=no,location=no,toolbar=no,left=20,top=20,width=' +myWidth+',height='+myHeight+'');
}

function openSizedWindowPlain(url, name, myHeight, myWidth) {
 popupWin = window.open(url, name, 'scrollbars=no,resizable=no,status=no,personal=no,menu=no,location=no,toolbar=no,left=20,top=20,width=' +myWidth+',height='+myHeight+'');
}

function openSizedWindowUI(url, name, myHeight, myWidth) {
 popupWin = window.open(url, name, 'scrollbars=yes,resizable=yes,status=yes,personal=no,menubar=yes,location=yes,toolbar=yes,left=20,top=20,width=' +myWidth+',height='+myHeight+'');
}
// --- Window functions -------------------------


// still unused
function swap_img(img_src, img_txt) {
  var obj = document.getElementById('snimka');
  var obj2 = document.getElementById('img_tåxt');
	obj.src = img_src;
	obj2.innerHTML = img_txt; 
}

function crawler() {
	if (window.name!='sredna' && !((self.innerHeight == 0) && (self.innerWidth == 0))) top.location.replace('/');
}
function calcHeight_admin(koi) {
	var the_height=document.body.scrollHeight;
	var obj = parent.document.getElementById(koi);
	obj.style.height = (!isNS && !isOP) ? the_height : the_height+'px';
}

function calcHeight(koi) {
	crawler();
	var the_height=document.body.scrollHeight;
	var obj = parent.document.getElementById(koi);
	obj.style.height = (!isNS && !isOP) ? the_height : the_height+'px';
}

function sh_div(what) {
	 var i=0;
	 var coll = [];
	 while (document.getElementById('d'+ i)) {
	  coll[i] = document.getElementById('d'+ i);
		i++;
	 }
	obj = document.getElementById(what);
	var i=0;
	if (obj.className == 'off') {
		while (coll[i]) {
			coll[i].className = 'off';
			i++;
		} 
		obj.className = 'on';
	} else {
		obj.className = 'off';
	}
//	calcHeight('main_content');
}

// show pics
nSkladPics = 8; // br na kartinkite
nOfisPics = 8; // br na kartinkite
oWin = 0; // id na otv proz

function picShow2 (ID, what, lang) {
	var obekt = (what == undefined) ? 'ofis' : what;
	switch (obekt) {
		case 'ofis':	nPics = 11; break;
		case 'sklad':	nPics = 8; break;
		case 'tv':	nPics = 8; break;
		default:;
	}
	var l = (lang =='en') ? '_'+lang : '';
	if (oWin == 0 || this[obekt+ID].closed) {
		this[obekt+ID] = window.open ('show.htm?o='+obekt+'&amp;np='+nPics+'&amp;c='+ID+'&amp;l='+lang, obekt+ID, 'width=580, height=470, scrollbars=no');
	}
}