var show_e;
var show_img;

var flag=0;

var contentid;

function showHideElement(element_id) {
	var e = document.getElementById(element_id);
	if(e) {
		if(e.style.display == 'none') e.style.display = '';
		else e.style.display = 'none';
	}
}

function guestflash(name) {
	if(!contentid) {
		var img = document.getElementById('dummyflashimg' + name);
		var span = document.getElementById('dummyflashspan' + name);

		if(img && span) {
			var flashname = img.getAttribute('flashname');
			var width = img.getAttribute('width');
			var height = img.getAttribute('height');

			if(!width) width = img.getAttribute('flashwidth');
			if(!height) height = img.getAttribute('flashheight');

			AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width',width,'height',height,'src',flashname,'quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie',flashname );
		}
	}
}

function setflag(cur, flagname) {
	var status = cur.checked;

	var e = null;

	for(i=1;i<=1000;i++) {
		e = document.getElementById(flagname + i);
		if(!e) break;
		e.checked = status;
	}
}

function setRadio(radio, value) {
	for(var i=0;i<radio.length;i++) {
		if(radio[i].value == value) radio[i].checked = true;
	}
	return 0;
}

function itemTestForm(form) {
	var e = null;
	var res = '';
	var require;
	var mincount;
	var fieldname;

	if(form)
	for(var i=0;i<form.childNodes.length;i++) {
		e = form.childNodes[i];

		if(e.getAttribute) {
			require = e.getAttribute('require');
			mincount = e.getAttribute('mincount');
			fieldname = e.getAttribute('fieldname');

			if(require) {
				if((e.value==0)||(e.value=='')) {
					res = res + 'не заполнено поле ' + require + '\n';
				}
			}

			if(mincount) {
				if((e.value.length<mincount)) {
					res = res + 'неверное количество символов в поле ' + fieldname + '\n';
				}
			}

			res = res + itemTestForm(e);
		}
	}

	return res;
}

function testForm(form) {
	var e = null;
	var res = '';
	var require;
	var mincount;
	var fieldname;

	res = itemTestForm(form);

	if(res) {
		res = 'Не верно заполнены поля:\n' + res;
		alert(res);
		return false;
	}

	return true;
}

function confirmQuery(text, url) {
	if(confirm(text)) location.replace(url);
}

function setSelect(name, value) {
	e = document.getElementById(name);
	for(var i=0;i<e.length;i++) {
		if(e.options[i].value==value) e.selectedIndex = i;
	}
}

function writeFlash(w, h, url) {
	document.write('<object id="flash_obj" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="' + w + '" height="' + h + '" id="final" align="middle">');
	document.write('<param name="allowScriptAccess" value="sameDomain" />');
	document.write('<param name="movie" value="' + url + '" />');
	document.write('<param name="loop" value="true" />');
	document.write('<param name="menu" value="false" />');
	document.write('<param name="quality" value="best" />');
	document.write('<param name="scale" value="noscale" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<param name="bgcolor" value="#000000" />');
	document.write('<embed src="' + url + '" loop="true" menu="false" quality="best" scale="noscale" wmode="transparent" bgcolor="#000000" width="' + w + '" height="' + h + '" name="final" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
}

function showFlashWin(x,y,flash,title) {
	if (flag == 1) {
		sw.close();
		flag=0;
	}

	//x = x + 20;
	//y = y + 20;


	eval("sw=window.open('',title,'top=20,left=220,width='+x+',height='+y+',scrollbars=no,resizable=no')");

	sw.document.write("<html><head><title>"+title);
	sw.document.write("</title></head><body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'>");
	sw.document.write("<center><table width='100%' height='100%' cellspacing=0 cellpadding=0 border=0><tr><td align=center>");
	sw.document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='"+x+"' height='"+y+"'><param name='movie' value='"+flash+"'><param name='quality' value='high'><embed src='"+flash+"' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='400' height='240'></embed></object>");
	sw.document.write("</td></tr></table>");
	sw.document.write("</center>");
	sw.document.write("</body></html>");
	sw.document.close();

	sw.focus();
	flag = 1;
}

function showwin(x,y,url) {
	showfoto(x, y, url);
}

var showing_image;
var showing_overlay;
var showing_closebtn;
var showing_printbtn;
var showing_image_alpha = 0;
var showing_preloader;
var showing_preloader_div;
var preloaderImagePosition = 0;
var preloaderIntervalID = 0;
var showing_isIE = (navigator.appVersion.indexOf('MSIE') > 0) ? true : false;

function showfoto(x, y, url, canprint) {
	if (window.editor && editor.element) return;

	var isIE = (navigator.appVersion.indexOf('MSIE') > 0) ? true : false;
	
	var pagesize = getPageSize();
	
	
	var onclick = function () {
		var i;
		if (window.showing_overlay) {
			for (i in document.body.childNodes) {
				if (document.body.childNodes.item(i) == showing_overlay)	
				document.body.removeChild(showing_overlay);
			}
			showing_overlay = null;
		}
		if (window.showing_preloader_div) {
			for (i in document.body.childNodes) {
				if (document.body.childNodes.item(i) == showing_preloader_div)	
				document.body.removeChild(showing_preloader_div);
			}
			showing_preloader_div = null;
		}
		if (window.showing_closebtn) {
			for (i in document.body.childNodes) {
				if (document.body.childNodes.item(i) == showing_closebtn)	
				document.body.removeChild(showing_closebtn);
			}
			showing_closebtn = null;
		}
		if (window.showing_printbtn) {
			for (i in document.body.childNodes) {
				if (document.body.childNodes.item(i) == showing_printbtn)	
				document.body.removeChild(showing_printbtn);
			}
			showing_printbtn = null;
		}
		if (window.showing_image) {
			for (i in document.body.childNodes) {
				if (document.body.childNodes.item(i) == showing_image)	
				document.body.removeChild(showing_image);
			}
			
			showing_image = null;
		}
		if (preloaderIntervalID) {
			clearInterval(preloaderIntervalID);
			preloaderIntervalID = 0;
		}
	}
	var onclickprint = function () {
		var sw=window.open('/print.php?src=' + url,'Печать','top=20,left=220,width=800,height=533,scrollbars=no,resizable=no');
		sw.focus();
	}
	
	showing_overlay = document.createElement('div');
	showing_overlay.id = 'showfoto-overlay';
	showing_overlay.className = 'fixed';
	showing_overlay.style.width = '100%';
	showing_overlay.style.height = '100%';
	showing_overlay.style.top = '0px';
	showing_overlay.style.left = '0px';
	showing_overlay.style.backgroundColor = '#000000';
	showing_overlay.style.zIndex = '1000';
	showing_overlay.onclick = onclick;
	document.body.appendChild(showing_overlay);
	
	showing_preloader = document.createElement('img');
	showing_preloader.style.display = 'block';
	showing_preloader_div = document.createElement('div');
	showing_preloader_div.className = 'fixed';
	showing_preloader_div.style.zIndex = '1001';
	showing_preloader_div.style.overflow = 'hidden';
	showing_preloader_div.onclick = onclick;
	showing_preloader_div.appendChild(showing_preloader);
	document.body.appendChild(showing_preloader_div);
	
	showing_preloader.onload = function () {
		showing_preloader.onload = null;
		showing_preloader.style.width = showing_preloader.width + 'px';
		showing_preloader.style.height = showing_preloader.height + 'px';
		showing_preloader_div.style.width = showing_preloader.width + 'px';
		showing_preloader_div.style.height = showing_preloader.width + 'px';
		showing_preloader_div.style.top = ((pagesize[3] - showing_preloader.width) / 2) + 'px';
		showing_preloader_div.style.left = ((pagesize[2] - showing_preloader.width) / 2) + 'px';
		
		if (isIE6()) {
			showing_preloader.src = '/img/spacer.gif';
			showing_preloader.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='img/preloader.png', sizingMethod='scale')";
		}
		
		
		preloaderIntervalID = setInterval('showPreloaderOnTimer('+showing_preloader.width+', '+showing_preloader.height+')', 60);
	}
	showing_preloader.src = 'img/preloader.png';
	
	
	
	if (isIE) {
		showing_overlay.style.filter ="progid:DXImageTransform.Microsoft.Alpha(opacity=50)";
	} else {
		showing_overlay.style.opacity = '0.5';
	}
	
	showing_image = document.createElement('img');
	showing_image.onload = function () {
		var imgwidth = showing_image.width;
		var imgheight = showing_image.height;
		
		if (pagesize[2] < showing_image.width + 30 || pagesize[3] < showing_image.height + 30) {
			imgwidth = pagesize[2] - 30;
			imgheight = showing_image.height * imgwidth / showing_image.width;
			if (imgheight > pagesize[3] - 30) {
				imgheight = pagesize[3] - 30;
				imgwidth = showing_image.width * imgheight / showing_image.height;
			}
			showing_image.style.width = Math.round(imgwidth) + 'px';
			showing_image.style.height = Math.round(imgheight) + 'px';
			//alert(showing_image.style.width + ' x ' + showing_image.style.height)
		}
	
		
		showing_image.className = 'fixed';
		showing_image.style.left = (pagesize[2] - imgwidth) / 2 + 'px';
		showing_image.style.top = (pagesize[3] - imgheight) / 2 + 'px';
		showing_image.style.border = '5px solid #FFF';
		showing_image.style.backgroundColor = "#FFF";
		showing_image.style.zIndex = '1001';
		showing_image_alpha = 0;
		document.body.appendChild(showing_image);
		
		
		showing_closebtn = document.createElement('img');
		showing_closebtn.style.width = '30px';
		showing_closebtn.style.height = '30px';
		if (isIE6()) {
			showing_closebtn.src = '/img/spacer.gif';
			showing_closebtn.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/img/close.png', sizingMethod='scale')";
		} else {
			showing_closebtn.src = '/img/close.png';
		}
		showing_closebtn.className = 'fixed';
		showing_closebtn.style.left = ((pagesize[2] + imgwidth) / 2 - 5) + 'px';
		showing_closebtn.style.top = ((pagesize[3] - imgheight) / 2 - 15) + 'px';
		showing_closebtn.style.cursor = 'pointer';
		showing_closebtn.style.zIndex = '1002';
		document.body.appendChild(showing_closebtn);
		
		
		showing_printbtn = document.createElement('img');
		showing_printbtn.style.width = '90px';
		showing_printbtn.style.height = '30px';
		if (isIE6()) {
			showing_printbtn.src = '/img/spacer.gif';
			showing_printbtn.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/img/print.png', sizingMethod='scale')";
		} else {
			showing_printbtn.src = '/img/print.png';
		}
		showing_printbtn.className = 'fixed';
		showing_printbtn.style.left = ((pagesize[2] + imgwidth) / 2 - 100) + 'px';
		showing_printbtn.style.top = ((pagesize[3] - imgheight) / 2 - 15) + 'px';
		showing_printbtn.style.cursor = 'pointer';
		showing_printbtn.style.zIndex = '1002';
		
		if (!canprint) showing_printbtn.style.display = 'none';
		
		document.body.appendChild(showing_printbtn);
		
		
		
		showing_image.onclick = onclick;
		showing_closebtn.onclick = onclick;
		showing_printbtn.onclick = onclickprint;
		
		myscroll();
		
		if (isIE) {
			showing_image.style.filter ="progid:DXImageTransform.Microsoft.Alpha(opacity=0)";
		} else {
			showing_image.style.opacity = '0';
			showing_closebtn.style.opacity = '0';
			showing_printbtn.style.opacity = '0';
		}
		
		showfotoontimer();
		showing_preloader_div.style.display = 'none';
		if (preloaderIntervalID) {
			clearInterval(preloaderIntervalID);
			preloaderIntervalID = 0;
		}
	}
	
	showing_image.src = url;
}

function showPreloaderOnTimer(width, height) {
	preloaderImagePosition += width;
	if (preloaderImagePosition >= height) preloaderImagePosition = 0;
	if (showing_preloader) showing_preloader.style.marginTop = '-' + preloaderImagePosition + 'px';
	
}

function showfotoontimer() {
	showing_image_alpha = showing_image_alpha + 5;
	
	if (showing_isIE) {
		showing_image.style.filter ="progid:DXImageTransform.Microsoft.Alpha(opacity="+showing_image_alpha+")";
	} else {
		showing_image.style.opacity = showing_image_alpha / 100;
		showing_closebtn.style.opacity = showing_image_alpha / 100;
		showing_printbtn.style.opacity = showing_image_alpha / 100;
	}
	
	if (showing_image_alpha < 100) {
		setTimeout('showfotoontimer()', 30);
	}
}

function getPageSize() {
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {     
	    xScroll = window.innerWidth + window.scrollMaxX;
	    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
	    if(document.documentElement.clientWidth){
	         windowWidth = document.documentElement.clientWidth; 
	    } else {
	         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 = xScroll;          
	} else {
	    pageWidth = windowWidth;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
	return arrayPageSize;
}

function showflash(page,x,y)
{
	eval("sf=window.open(Name=\""+page+"\",\"FLASH\",\"top=20,left=220,width="+x+",height="+y+",scrollbars=no,resizable=no\")")
}

function domenu(id,e,img) {
	if(id == pageid) {
		e = document.getElementById(e);
		img = document.getElementById(img);
		if(e&&img) {
			//show(e,img);
			show_e = e;
			show_img = img;
		} else alert("Ошибка");
	}
	return 0;
}

function showmenu() {
	if(show_e && show_img) show(show_e, show_img);
}

function catalog_bask(zena,count) {
	if(document.getElementById('catalog_count')) catalog_count.innerText = count;
	if(document.getElementById('catalog_zena')) catalog_zena.innerText = zena;
}

var ArrayBaskId = new Array();

function parce_baskinfo() {
	var s = document.getElementById('baskinfo').innerHTML;
	listID = s.split(';');
	for (var i = 0; i < listID.length; i++) {
		if(listID[i] != "") {
			m = listID[i].split(':');
			ArrayBaskId[m[0]] = m[1];
		}
	}
}

function catalog_check(id,e) {
	if(ArrayBaskId[id]!=null) {
		e = document.getElementById(e);
		/*if(e) e.checked = "true";
		else e.checked = "false";*/
		if(e) e.value = ArrayBaskId[id];
	}
}

function catalog_buy(cost,id,e,fast) {
	e = document.getElementById(e);
	//ordertype = document.getElementById(ordertype);

	if(e==null) alert("Ошибка скрипта");

	//check = e.checked;
	colbuy = e.value;
	if(colbuy=="") colbuy = 0;
	

	JsHttpRequest.query(
        './buy.php',
        { 'id': id, 'colbuy' : colbuy, 'fast':fast},
        function(responseJS, responseText) {
			
            // This function is called on data ready (readyState=4).
            // Write result to page element ($_RESULT become responseJS).
            /*document.getElementById('result').innerHTML =
                '<b>MD5("'+responseJS.q+'")</b> = ' +
                '"' + responseJS.md5 + '"<br> ';
            // Write debug information too (output become responseText).
            document.getElementById('debug').innerHTML = responseText;*/
			
			if (responseJS.ok) {
				if (responseJS.error) {
					alert(responseJS.error);
					return;
				}
				if (responseJS.redirect) {
					location.href = './'+responseJS.redirect;
					return;
				}
				if (responseJS.basket) document.getElementById('basket-div').innerHTML = responseJS.basket;
				alert('Товар добавлен в корзину');
				
			}
        },
        true // true = disable caching
    );
	
	
	//location.href='./buy.php?id=' + id + '&colbuy=' + colbuy;
	return;
}

function catalog_buy_fast(cost,id,e) {
	e = document.getElementById(e);
	//ordertype = document.getElementById(ordertype);

	if(e==null) alert("Ошибка скрипта");

	//check = e.checked;
	colbuy = e.value;
	if(colbuy=="") colbuy = 0;

	location.href='./buy.php?fast=1&id=' + id + '&colbuy=' + colbuy;
	return;

	if(window.showModalDialog==null) {
		location.href='./?act=buy&page=' + id + '&colbuy=' + colbuy;
		return;
	}

	/*if(document.frames('doframe')) document.frames('doframe').location.href='./?act=buy&frame=1&id=' + id;
	else location.href='./?act=buy&id=' + id;*/

	if(document.getElementById('catalog_count')) count = catalog_count.innerText;
	if(document.getElementById('catalog_zena')) oldzena = catalog_zena.innerText;

	if(zena==null) zena = 0;
	if(count==null) count = 0;

	oldcol = 0;
	if((ArrayBaskId[id]!=null)&&(ArrayBaskId[id]!=0)) {
		oldcol = ArrayBaskId[id];
		if(colbuy==0) {
			count--;
		}
	} else {
		if(colbuy>0) count++;
	}
	ArrayBaskId[id] = colbuy;

	cost = parseInt(zena) * colbuy + parseInt(oldzena) - parseInt(zena) * oldcol;

	catalog_bask(cost,count);

	window.showModalDialog('./?act=buy&frame=1&page=' + id + '&colbuy=' + colbuy, '', 'menubar=no,directories=no,location=no,toolbar=no,scrollbars=no,status=no,resizable=no,height=15,width=350,dialogWidth:350px; dialogHeight:15px');
}

function catalog_col_keypres(id,onewcol,zena,ocol,ordertype) {
	if(event.keyCode==13) catalog_modify(id,onewcol,zena,ocol,ordertype);
	if((event.keyCode<48)||(event.keyCode>57)) event.keyCode = 0;
}

function catalog_newcol_keypres(zena,id,text_buy,ordertype) {
	if(event.keyCode==13) catalog_buy(zena,id,text_buy,ordertype);
	if((event.keyCode<48)||(event.keyCode>57)) event.keyCode = 0;
}

function catalog_modify(id,onewcol,zena,ocol,ordertype) {
	onewcol = document.getElementById(onewcol);
	ocol = document.getElementById(ocol);
	ordertype = document.getElementById(ordertype);

	if((onewcol==null)||(ocol==null)||(ordertype==null)) alert('Ошибка определения ID. \n Ваш браузер не поддрердивает JavaScript');

	if(ordertype.checked) ot = 1;
	else ot = 0;

	newcol = onewcol.value;
	if(newcol=="") newcol = 0;
	oldcol = ocol.value;
	ocol.value = newcol;

	/*var sum = document.all.catalog_sum.innerText;
	var nalcurs = document.all.catalog_nalcurs.innerText;
	var beznalcurs = document.all.catalog_beznalcurs.innerText;
	var nalitogo = document.all.catalog_nalitogo.innerText;
	var beznalitogo = document.all.catalog_beznalitogo.innerText;

	sum = parseInt(sum,10) + zena*(newcol-oldcol);
	nalitogo = parseInt(nalitogo,10) + zena*(newcol-oldcol)*nalcurs;
	beznalitogo = parseInt(beznalitogo,10) + zena*(newcol-oldcol)*beznalcurs;

	document.all.catalog_sum.innerText = sum;
	document.all.catalog_nalitogo.innerText = nalitogo;
	document.all.catalog_beznalitogo.innerText = beznalitogo;

	onewcol.select();

	if(document.all.doframe) document.all.doframe.src='./?act=modify&fast=1&id=' + id + '&center=buy&newcol='+newcol;
	else location.href='./?act=modify&id=' + id + '&center=buy&newcol='+newcol;*/

	location.href='./?act=modify&id=' + id + '&center=buy&newcol='+newcol+'&ordertype='+ot;
}

// Создание массива для хранения ссылок на дочерние окна.
/* Каждый член данного массива будет окном объекта, созданного
ниже с использованием метода createWindow. */
var windows = new Array();

function newWindow(url, wname) {
// Конструктор для окна
/* Данная функция может быть вызвана только функцией
   createWindow, которая приведена ниже. */
var features = "";
if (null != arguments[2])
   features = arguments[2];
return window.open(url, wname, features);
}

function createWindow(url, wname) {
// Добавление окна в семейство окон.
var features = arguments[2] == null ? "" : arguments[2];
windows[wname] = new newWindow(url, wname, features);
windows[wname].focus();
}

function closeWindows() {
// Закрытие всех окон, открытых методом addWindow.
/* Для закрытия окна вызывается его метод close. */
/* Данная функция может быть вызвана в ходе события onunload
   для автоматического закрытия всех открытых окон.  */
for (w in windows)
   if (!windows[w].closed)
	  windows[w].close();
}

function onEndSort(event, ui) {
	var m_pos = [];
	for(var i=0;i<$('.sortitem').length;i++) {
		var e = $('.sortitem').eq(i);
		var node_id = e.attr('nodeid');
		m_pos.push(node_id);
	}
	
	if(m_pos.length > 0) {
		
		var ajaxhider = document.getElementById('ajaxhider');
		if(ajaxhider) {
			ajaxhider.style.display='';
		}
		
	 	JsHttpRequest.query(
	        '/ajax/setpos.php',
	        { m_pos: m_pos },
	        function(responseJS, responseText) {
	        	var ajaxhider = document.getElementById('ajaxhider');
				if(ajaxhider) {
					ajaxhider.style.display='none';
				}
	        	
	        	if(responseText) alert(responseText);
	            if(!responseJS.ok) alert('Ошибка установки позиции');
	        },
	        true
	    );
	}
}

var g_isie6 = 0;

function isIE6() {
	if(g_isie6) {
	 	if(g_isie6 == 1) return true;
	 	else if(g_isie6 == 2) return false;
	}
	
	var browser=navigator.appName;
	var b_version=navigator.appVersion;
	
	var re = new RegExp('; MSIE 6\.*;', "gim");

	if(b_version.search(re) != -1) {
		g_isie6 = 1;
		return true;
	} else {
		g_isie6 = 2;
		return false;
	}
}

function myscroll() {
	if(isIE6()) {
		var top = self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
		var left = self.pageXOffset || (document.documentElement && document.documentElement.scrollLeft) || (document.body && document.body.scrollLeft);
		var m_fixed_elements = getElementsByClass('fixed');
		for(i=0;i<m_fixed_elements.length;i++) {
			var fixedtop = m_fixed_elements[i].getAttribute('fixedtop');
			if(!fixedtop) {
				fixedtop = parseInt(m_fixed_elements[i].style.top);
				if (!fixedtop) fixedtop = 0;
				if (fixedtop == 0) fixedtop = 'zero';
				m_fixed_elements[i].setAttribute('fixedtop', fixedtop);
			}
			if (!fixedtop) fixedtop = 0;
			if (fixedtop == 'zero') fixedtop = 0;
			m_fixed_elements[i].style.top = (fixedtop + top) + 'px';
			
			
			var fixedleft = m_fixed_elements[i].getAttribute('fixedleft');
			if(!fixedleft) {
				fixedleft = parseInt(m_fixed_elements[i].style.left);
				if (!fixedleft) fixedleft = 0;
				if (fixedleft == 0) fixedleft = 'zero';
				m_fixed_elements[i].setAttribute('fixedleft', fixedleft);
			}
			if (!fixedleft) fixedleft = 0;
			if (fixedleft == 'zero') fixedleft = 0;
			m_fixed_elements[i].style.left = (fixedleft + left) + 'px';
		}

	}
}

window.onscroll = myscroll;

window.onunload=closeWindows;
