// show|hide state
var old_color;
var new_color = "#eeffee";

function US1()
{
	var x = document.getElementById('country').value;
	var y = document.getElementById('stateus');
	if(x == 1) 
	{
		y.style.display='block';
	}
	else
	{
		y.style.display='none';
	}
}

function load(url, name, w, h, scroll)
{
	w += 32;
	h += 96;

	wleft = (screen.width - w) / 2;
	wtop = (screen.height - h) / 2;
	
	var win = window.open(url, name,
		'width=' + w + ', height=' + h + ', ' +
		'left=' + wleft + ', top=' + wtop + ', ' +
		'location=no, menubar=no, ' +
	    'resizable=no, status=no, toolbar=no, scrollbars='+scroll+', menubar=no');
	  	win.resizeTo(w, h);
		win.moveTo(wleft, wtop);
		win.focus();
}

function checkJavaScript()
{
	document.getElementById('forma').style.display = "block";
	document.getElementById('err').style.display = "none";
}

function checkAddPlug(f)
{
	if((f.fc_name.value == "")||(f.fc_description.value == ""))
	{
		//alert(f.fc_description.value);
		alert("Введите название и описание статьи");
		return false;
	}
	
	return true;
}

function highligth(obj)
{
	old_color = obj.style.background;
	obj.style.background =  new_color;
}

function unhighligth(obj)
{
	obj.style.background = old_color;
}

function please_reg()
{
	if (confirm('Зарегестрируйтесь! Вы получите доступ ко всем материалам, опубликованным на сайте!'))
	{
		document.location.href="?pid=reg";
	}
}


function getposOffset1(overlay, offsettype)
 {
  var totaloffset = (offsettype=="left") ? overlay.offsetLeft : overlay.offsetTop;
  var parentEl = overlay.offsetParent;
  
  while (parentEl!=null)
  {
   totaloffset = (offsettype=="left") ? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
   parentEl    = parentEl.offsetParent;
  }
  
  return totaloffset;
 }
 
function hide(id)
{
	document.getElementById(id).style.display = 'none;';
}

function pickImage(url, divp, cnt)
{
	document.getElementById('pic').value = url;
	for (i=0; i<cnt; i++)
	{
		named = "dpic" + i;
		//alert(named);
		dd = document.getElementById(named);
		dd.style.border = '#ffffff 1px solid';
	};
	//alert(document.getElementById(divp));
	document.getElementById(divp).style.border = '#ff5555 1px solid';
	previewLogo(url);
}

function previewLogo(url)
{
	document.getElementById('picLogo').src = url;
}

function previewSelfLogo(thiss)
{
	document.getElementById('picLogo').src = thiss.value;
}

////////////////
function switch_info(iid)
{
	name = "info" + iid;
	
	if(document.getElementById(name).style.display == 'none')
	{
		document.getElementById(name).style.display = 'block';
	}
	else
	{
		document.getElementById(name).style.display = 'none';
	}
}

function switch_all(cnt, state)
	{
		for(i=0; i<cnt; i++)
		{
			name = "info" + i;
			if(state)
			{
				document.getElementById(name).style.display = 'block';
			}
			else
			{
				document.getElementById(name).style.display = 'none';
			}
		}
	}

function ShowPhoto(id)
{
	name = "td" + id;
	document.getElementById(name).innerHTML = '<img src="../logo/' + id + '.jpg  "alt="Портрет" />';
}	

function add_height(id, incr, isadd)
{
	var inc = 0;
	if(isadd)
	{
		inc = 0 + incr;
	}
	else
	{
		inc = 0 - incr;
	}
	
	div = document.getElementById(id);
	
	curr_height = div.style.height;
	
	cur1 = curr_height.substring(curr_height.length-2, curr_height.length);
	cur2 = curr_height.substring(0, curr_height.length-2);
	
	new_height = parseInt(cur2) + inc;
	
	new_height = new_height + cur1;
	
	div.style.height = new_height;
	
	//alert(new_height);
}
