function popup_page(url, width, height) {
	popup_win = window.open(url, "", "resizable=1,scrollbars=1,toolbar=0,location=0,directories=0,status=1,menubar=0,width="+width+",height="+height);
	popup_win.focus();
}

function popup_url(url) {
	popup_win = window.open(url, "", "resizable=1,scrollbars=1,toolbar=0,location=0,directories=0,status=1,menubar=0");
	popup_win.focus();
}

function popup_imgurl(imgurl, width, height) {
	p_width = width + 40
	p_height = height + 70
	
	popup_win = window.open("_popup_imgurl.php?imgurl=" + imgurl + "&width=" + width + "&height=" + height, "",
		"resizable=1,scrollbars=1,toolbar=0,location=0,directories=0,status=1,menubar=0,width="+p_width+",height="+p_height);
	popup_win.focus();
}

function popup_img(img_id, width, height){
	width += 150
	height += 220
	
	if (width > 800) width = 800
	if (height > 600) height = 600
//	if (width < 320) width = 320
//	if (height < 200) height = 200

	popup_win = window.open("_popup_img.php?img_id=" + img_id, "img_" + img_id, "resizable=1,scrollbars=1,toolbar=0,location=0,directories=0,status=0,menubar=0,width="+width+",height="+height)
	popup_win.focus()
}

function popup_bo(bo_href) {
	popup_win = window.open("/backoffice/" + bo_href);
	popup_win.focus();
}


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

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 layer_isopened(nr) {
	ret = 0
	layer_nr = MM_findObj("layer_" + nr)
//	alert ("layer_open(" + nr + "): " + layer_nr)
	if (layer_nr != null) {
		if (layer_nr.style.display == 'inline') ret = 1
	}
	return ret
}

function layer_open(nr) {
	layer_nr = MM_findObj("layer_" + nr)
//	alert ("layer_open(" + nr + "): " + layer_nr)
	if (layer_nr != null) layer_nr.style.display = 'inline'

	layer_opened_nr = MM_findObj("layer_opened_nr")
	if (layer_opened_nr != null) layer_opened_nr.value = nr
//	alert ("layer_opened_nr: " + layer_opened_nr.value)
}

function layer_close(nr) {
	layer_nr = MM_findObj("layer_" + nr)
//	alert ("layer_close(" + nr + "): " + layer_nr)
	if (layer_nr != null) layer_nr.style.display = 'none'

	layer_opened_nr = MM_findObj("layer_opened_nr")
	if (layer_opened_nr != null) layer_opened_nr.value = 0
}

function layer_switch(nr) {
	for (i = 1; i <= layers_total; i++) {
	    if (i == nr) {
	    	if (layer_isopened(i)) {
	    		layer_close(i)
	    	} else {
	    		layer_open(i)
	    	}
	    } else {
	    	layer_close(i)
	    }
	}
}

function layer_switch_forceopened(nr) {
	for (i = 1; i <= layers_total; i++) {
	    if (i == nr) layer_open(i)
	    else layer_close(i)
	}
}

function focus_itname(it_name) {
	vitem = MM_findObj(it_name)
	vitem.focus()
}

function swap(image, over){
if (document.images){
	document.images[image].src = "img/" + image + (over ? "_over" : "_normal") + ".gif";
	document.images[image + "_shadow"].src = "img/" + image + "_shadow" + (over ? "_over" : "_normal") + ".gif";
	}
}

function swap_class(id, cl){
	var div = document.getElementById(id).style;
	div = "out";
}


function print_area_on() {
	var div = document.getElementById("content");
	div.style.border = "1px dashed #575757";
	div.style.margin = "10px";
}

function print_area_off() {
	var div = document.getElementById("content")
	div.style.border = "0px solid #575757";
	div.style.margin = "11px";
}
