function display_(id) {
	 if (document.getElementById(id).style.display=='block') {
	         document.getElementById(id).style.display='none';
	 }
	 else if (document.getElementById(id).style.display=='none') {
	         document.getElementById(id).style.display='block';
	 }
	 return 1;
}

function openWin(pic,width_p,height_p,title_p) {
		  myWin= open("","picture","width="+width_p+",height="+height_p+",status=no,toolbar=no,menubar=no");
		  myWin.document.open();
		  myWin.document.write("<html><head><title>"+title_p);
		  myWin.document.write("</title></head><body style='margin:0px;padding:0px;'>");
		  myWin.document.write("<img src='"+pic+"' style='margin:0px;border:none;'>");
		  myWin.document.write("</body></html>");
		  myWin.document.close();  
}

function gotoindex() {
	self.location = ".";
}

function make_image(name, x, y, image) {

	document.images.preview.style.width=x;
	document.images.preview.style.height=y;
	document.images.preview.src=image;
}

function move_to(path) {
	document.forms.edit.url.value=path;
}

var tmid;
var tmid2;
var scrltp;
dom = (document.getElementById) ? 1 : 0;
ie = (navigator.appName != "Netscape" && document.all) ? 1 : 0;
opera = (navigator.appName == "Opera") ? 1 : 0;
netscape= (navigator.appName == "Netscape") ? 1 : 0;

var sPop2 = false;
var sPop1 = false;

function check_scroll(ob)
{
	if(document.getElementById('popLayer').style.display=="inline" 
			&& (document.getElementById('popLayer').style.overflow=="auto"||sPop1))
	{
		movePopup();
	}
}

function resize_popup(width,height, flag)
{
	// if(isNC4){
	// lr=layerFrom("popLayer",null)
	// }else{
	// lr=layer("popLayer",null)
	// }

	lr=layer('popLayer');

	lft=(getWindowWidth(false)/2)-width/2;
	tp=getScrollY()/*+(getWindowHeight(false)/2)-height/2*/;

	if(lft<0) lft=0;
	if(tp<0) tp=0;
	lr.moveTo(lft,tp);

	lar=document.getElementById('popLayer');

	if(opera||netscape) {width=width-20; height=height-20;}
	if(width<1) width=1;
	if(height<1) height=1;
	lar.style.width=width;
	if (flag)
		lar.style.height=height;
}

function resize_popup2(width,height, flag)
{
	// if(isNC4){
	// lr=layerFrom("popLayer",null)
	// }else{
	// lr=layer("popLayer",null)
	// }

	lr=layer('popLayer');

	lft=(getWindowWidth(false)/2)-width/2;
	tp=getScrollY()+(getWindowHeight(false)/2)-height/2;

	if(lft<0) lft=0;
	if(tp<0) tp=0;
	lr.moveTo(lft,tp);

	lar=document.getElementById('popLayer');

	if(opera||netscape) {width=width-20; height=height-20;}
	if(width<1) width=1;
	if(height<1) height=1;
	lar.style.width=width;
	if (flag)
		lar.style.height=height;
}


function hide_popup()
{
	sPop1=false;
	document.getElementById('popLayer').style.display='none';
	document.getElementById('popLayer').style.visibility='hidden';
	clearTimeout(tmid);
	tmid=false;
}

function show_contacts() 
{
	var width  = 200;
	var height = 200;

    scrltp=getScrollY(window);
    document.getElementById('popLayer').innerHTML='';
    document.getElementById('popLayer').style.display='none';
    document.getElementById('popLayer').style.visibility='hidden';

    resize_popup2(width,height, true);
    document.getElementById('popLayer').innerHTML=document.getElementById('popContacts2').innerHTML;
    document.getElementById('popLayer').style.display='inline';
	document.getElementById('popLayer').style.visibility='visible';
}


function show_box(url,width,height,scrl)
{
    scrltp=getScrollY(window);
    document.getElementById('popLayer').innerHTML='';
    document.getElementById('popLayer').style.display='none';
    document.getElementById('popLayer').style.visibility='hidden';
    document.getElementById('popLayer').style.overflow=(scrl)?'auto':'';

    resize_popup2(width,height);
    
    var ppm = new JsHttpRequest();

    ppm.onreadystatechange = function() 
    {
        if (ppm.readyState == 4) 
        {
            document.getElementById('popLayer').innerHTML=ppm.responseText;

            if(ppm.responseJS)
            {
                if(ppm.responseJS.width&&ppm.responseJS.height) 
                    resize_popup2(ppm.responseJS.width,ppm.responseJS.height);

                if(ppm.responseJS.scroll) 
                    document.getElementById('popLayer').style.overflow='auto';
            }
            document.getElementById('popLayer').style.display='inline';
            document.getElementById('popLayer').style.visibility='visible';
        }
    }
    ppm.open(null, url, true);
    ppm.send({q: 'a'});
}

function get_imagebox(id, w, h)
{	
    show_box('/ajax.php?action=get_bigimage&id='+id, w, h, false);
}


var colors = ["00b0ec", "04db1e", "fdb300", "fc00b8", "00a0fc", "ff7709", "00ca2b"];
var oldColor = "";

function changeColor(obj) {

    var i = Math.floor(Math.random() * colors.length); 
    oldColor = obj.style.color;
    obj.style.color = '#' + colors[i];
}

function resetColor(obj) {
    obj.style.color = oldColor;
}

function changeColorPink(obj) {

    oldColor = obj.style.backgroundColor;
    if (oldColor=="#ef2f72") obj.style.backgroundColor = "#54514f";
    else obj.style.backgroundColor = "#ef2f72";
}

function loadNewImage(url, w, h, name, id) {
	var obj = document.getElementById(id);
	var newimage = "<img src=\""+url+"\" width=\""+w+"px\" height=\""+h+"px\" alt=\""+name+"\" align=\"center\">";
	document.getElementById(id).innerHTML = newimage;
}