var child_w;

function find(id)
{
	return document.getElementById(id);
}


function setText(id,text)
{
 	if (document.getElementById(id))
    {
		document.getElementById(id).innerText=text;
    }
}

function showObj(id)
{
 	if (document.getElementById(id))
    {
		document.getElementById(id).style.display='block';
    }
}

function hideObj(id)
{
 	if (document.getElementById(id))
    {
		document.getElementById(id).style.display='none';
    }
}

function swapObj(id)
{
 	if (document.getElementById(id))
    {
	 	if (document.getElementById(id).style.display=='none')
    	{
			showObj(id);
        } else {
			hideObj(id);
        }
    }
}


function SwapCPObj(name)
{
	SetCParam('visobj_'+name,1-GetCParam('visobj_'+name));
	VisCPObj(name,1);
}

function VisCPObj(name,def)
{
    if (!(GetCParam('visobj_'+name)==1)&&!(GetCParam('visobj_'+name)==0))
    {
		SetCParam('visobj_'+name,def);
    }
    if (GetCParam('visobj_'+name)==1)
    {
    	document.getElementById(name).style.display='block';
        document.getElementById('switcher_'+name).innerHTML='скрыть';
    } else {
    	document.getElementById(name).style.display='none';
        document.getElementById('switcher_'+name).innerHTML='показать';
    }
}

function SetCParam(param,value)
{
	Set_Cookie('param_'+param,value,new Date (2070, 01, 01),'/','','' );
//	Set_Cookie('param_'+param,value,'Thu, 01-Jan-2070 00:00:01 GMT','/','','');
}

function GetCParam(param)
{
	return Get_Cookie(param);
}

function Hover(isover) {
  var it = event.srcElement;
  if(it.parentElement.className == 'menu' && it.tagName == 'TD'
  && it.children.length && it.children(0).href) {
    it.style.cursor = isover ? 'hand' : 'default';
    window.status = isover ? it.children(0).href : '';
    //it.children(0).style.textDecorationUnderline = isover;
    it.children(0).style.color=isover?'#a090df':'#6040a0';
    it.style.backgroundColor=isover?'#f3f3f5':'#F5F5F5';
    if (event.type == 'click') location.href = it.children(0).href;
    }
  if(it.className == 'mainmenu' ) {
    it.style.color=isover?'#a090df':'#6040a0';
    //it.style.backgroundColor=isover?'#f3f3f5':'#F5F5F5';
    //if (event.type == 'click') location.href = it.children(0).href;
    }
  }


///////// cookie //////////

function Get_Cookie(name) {
    var start = document.cookie.indexOf(name+"=");
    var len = start+name.length+1;
    if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
    if (start == -1) return null;
    var end = document.cookie.indexOf(";",len);
    if (end == -1) end = document.cookie.length;
    return unescape(document.cookie.substring(len,end));
}

function Set_Cookie(name,value,expires,path,domain,secure) {
    document.cookie = name + "=" +escape(value) +
        ( (expires) ? ";expires=" + expires.toGMTString() : "") +
        ( (path) ? ";path=" + path : "") +
        ( (domain) ? ";domain=" + domain : "") +
        ( (secure) ? ";secure" : "");
}

function Delete_Cookie(name,path,domain) {
    if (Get_Cookie(name)) document.cookie = name + "=" +
        ( (path) ? ";path=" + path : "") +
        ( (domain) ? ";domain=" + domain : "") +
        ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}


////////////////////////////////

var column=new Array();
var hides=0;

function Init()
{
	//// показываем нужные столбцы ////
	for (i=1;i<=12;i++)
	{
		column[i]=Get_Cookie("show_column_"+i);
		displ=column[i]==1?"display:block":"display:none";
		document.styleSheets.tables.addRule("td.column_"+i,displ);
		document.getElementById("column_"+i).checked=column[i]==1?'on':'';
	}
}


//////////////////////////////////////

	function imgch(name,src)
	{
		if (act!=name) {
		document.images[name].src=src;
		}
	}
	function opn(url,width,height,namew)
	{
		if (namew=='') {namew='popup'};
		w=window.open(url,namew,"height="+height+",width="+width+",status=no,toolbar=no,menubar=no,location=no,resizable=1, scrollbars=1,toolbar=no,menubar=no, ");
		w.focus();
		return w;
	}

	function open_form(url)
	{
		child_w=opn(url,670,380,'s_form');
	}

	function open_form_small(url)
	{
		opn(url,200,70);
	}

	function reload1()
	{
		window.setTimeout('location.href=location.href;', 500);
	}

function swap(i)
{
  if (column[i]==1)
  {
  	document.styleSheets.tables.addRule("td.column_"+i,"display:none");
  	column[i]=0;
  	Set_Cookie("show_column_"+i,0);
  } else {
    document.styleSheets.tables.addRule("td.column_"+i,"display:block");
    column[i]=1;
    Set_Cookie("show_column_"+i,1);
  }

}



function SwapHide()
{
  if (hides==1)
  {
  	document.styleSheets.tables.addRule("tr.hide","display:none");
  	hides=0;
  } else {
  	document.styleSheets.tables.addRule("tr.hide","display:block");
  	hides=1;
  }
}

function SwapViz(id)
{
  obj=document.getElementById(id);
  if (obj.style.display=='none')
  {obj.style.display='block'} else {obj.style.display='none'}
}

function SwapVizImg(id,img_id,img_on,img_off)
{
  obj=document.getElementById(id);
  if (obj.style.display=='none')
  	{
    	obj.style.display='block';
        document.getElementById(img_id).src=img_on;
        Set_Cookie(id,'block',new Date (2070, 01, 01),'/','','');
    } else
    {
    	obj.style.display='none';
        document.getElementById(img_id).src=img_off;
        Set_Cookie(id,'none',new Date (2070, 01, 01),'/','','');
    }
}

// голосование

	function rec_plus(photo,hs)
    {
		frame1.location.href="/funct.php?action=rec_plus&id="+photo+"&hs="+hs;
    }

    function rec_minus(photo,hs)
    {
		frame1.location.href="/funct.php?action=rec_minus&id="+photo+"&hs="+hs;
    }

	function rec_plus_comment(photo,hs)
    {
		frame1.location.href="/funct.php?action=rec_plus_comment&id="+photo+"&hs="+hs;
    }

    function rec_minus_comment(photo,hs)
    {
		frame1.location.href="/funct.php?action=rec_minus_comment&id="+photo+"&hs="+hs;
    }

///////////////

	function ShowFPhoto(img,caption,author)
    {
        var ypos=event.y+document.body.scrollTop;
		var xpos=event.x+document.body.scrollLeft;
        float_photo.innerHTML="<img src='img' alt='caption'><br><b>caption</b>";
        float_photo.style.top=ypos+20;
        float_photo.style.left=xpos+20;
		float_photo.style.display='block';
    }
	function MoveFPhoto()
    {
        var ypos=event.y+document.body.scrollTop;
		var xpos=event.x+document.body.scrollLeft;
        float_photo.style.top=ypos+20;
        float_photo.style.left=xpos+20;
    }
    function HideFPhoto()
    {
		float_photo.style.display='none';
    }
/////////////
