function resizeBanner()
{
//alert (window.innerWidth);
if (document.getElementById('body') < 1000){document.getElementById('body').style.width="1000px";} 
var bannerWidth=(document.getElementById('wrapper').clientWidth-550) + "px";
document.getElementById('under_header_text_in').style.width=bannerWidth;

}

function clearInpt (inpid, inpvalue, type)
		{
			var inpid=document.getElementById(inpid);
			if (type=='focus')
			{
				if (inpid.value==inpvalue) inpid.value='';
			}
			else if (type=='blur')
			{
				if(inpid.value=='') inpid.value=inpvalue;
			}
		}
		
function searchForm_main()
{
	var world = getObj("search").value;
	world = encodeURIComponent(world);
	
	window.location.href = "/news/show/search/word/" + world + "/";
}
		
function searchSiteForm_main()
{
	var world = getObj("search_site").value;
	world = encodeURIComponent(world);
	
	window.location.href = "/main/show/search/word/" + world + "/";
}
		
function searchForumForm_main()
{
	var world = getObj("search_site").value;
	world = encodeURIComponent(world);
	
	window.location.href = "/forum/show/search/word/" + world + "/";
}

var system = 0;
function enterSystem_main(type)
{
	if (type == "block") system = 2;
	else system--;
	if (!type) type = "none";
	if (system == 0 && type == "none") getObj("enter_system_block").style.display = type;
	else if(type == "block") getObj("enter_system_block").style.display = type;
}

function getObj(id)
{
	return document.getElementById(id);
}

function getPrintContent()
{
	return Content_Print;
}

var Content_Print;
function printContent_main()
{
	var Content = getObj("content_right_2").innerHTML;
	var ElementP = getElementPosition("content_right_2");
	
	var width = getWindowScrollSize().x - 290;
	var height = getWindowScrollSize().y - 300;
	Content = Content.replace(/\<script.*>.*\<\/script>/, "");
	Content = Content.replace(/\<object.*>.*\<\/object>/, "");

	Content = "<div style='padding: 10px; font-size: 15px; color: #666666; '><img src='/images/img/logo.gif' alt='SIGNIFER Online' width='200' height='67' /><br/><div style='margin-top: 20px;'>http://signifer.com.ua</div></div><br/><hr style='width: 100%; text-align:left;' /><br/><h2>" + document.title + "</h2>" + Content;
	//win.document.getElementById("content_print").innerHTML = Content;
	Content_Print = Content;
	
	NewWindow("/main/show/print/title/" + document.title + "/", "mywindow", width, height, "yes", "center", "yes", "yes");
	
	/*width_block = ElementP.width;
	height_block = ElementP.height;
	
	doing = "block";

	display("loader_div", doing);
	display("loader_content", doing);
	display("loader_iframe", doing);
	getObj("loader_content").style.background = "white";
	
	if (doing == "block") {
		var win_width =  getWindowScrollSize().x * 1 - 17;
		var win_height = getWindowScrollSize().y * 1;
		var win_heightWindos = getWindowScrollSize().windowHeight * 1;
		var scrollTop = (window.pageYOffset || document.documentElement.scrollTop || 0) * 1;

		setSize("loader_div", win_width, win_height);
		setSize("loader_iframe", win_width, win_height);
		setSize("loader_content", width_block, height_block);
		setOpacity("loader_div", 1);
		getObj("loader_div").style.visibility = "";
	
		var width_content = -80;
		var height_content = (win_heightWindos / 2) + scrollTop - (height_block / 2);

		setPosition("loader_content", "50px", width_content + "px");
	}
	Content = "<div style='padding: 10px; font-size: 15px; color: #666666; '><img src='/images/img/logo1.gif' alt='SIGNIFER Online' width='200' height='67' /><br/><div style='margin-top: 20px;'>http://signifer.ua</div></div><hr style='width: 75%' /><br/>" + Content;
	//Content = Content + "<div style='padding: 20 0px; margin-top: 20px;'><input style='width: 200px; height: 20px;' type='button' value='Print' /></div>";
	getObj("loader_content").innerHTML = Content;
	
	print(getObj("loader_content"));*/
}

function openStartPage()
{
	NewWindow("/main/show/startpage/", "mywindow", 650, 500, "yes", "center", "no", "yes");
}


function display(id, type)
{
	document.getElementById(id).style.display = type;
}

function setOpacity(id, value)
{
	var Obj = getObj(id);
	var ieValue = value * 100;
	Obj.style.filter = "alpha(opacity=" + ieValue + ")";
	Obj.style.mozOpacity = value;
	Obj.style.opacity = value;
}

function setSize (name, width, height)
{
	document.getElementById(name).style.width = width + "px";
	document.getElementById(name).style.height = height + "px";
}
	
function setPosition(name, top, left)
{
	document.getElementById(name).style.top = top;
	document.getElementById(name).style.left = left;
}

function getWindowScrollSize(pDoc)
{
	var xScroll, yScroll;
       if (window.innerHeight && window.scrollMaxY) {
               xScroll = document.body.scrollWidth;
               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 if (document.documentElement && document.documentElement.scrollHeight > document.documentElement.offsetHeight){ // Explorer 6 strict mode
               xScroll = document.documentElement.scrollWidth;
               yScroll = document.documentElement.scrollHeight;
       } else { // Explorer Mac...would also work in Mozilla and Safari
               xScroll = document.body.offsetWidth;
               yScroll = document.body.offsetHeight;
       }
       var windowWidth, windowHeight;
       if (self.innerHeight) { // all except Explorer
               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 = windowWidth;
       } else {
               pageWidth = xScroll;
       }
       return {x:pageWidth, y:pageHeight, windowWidth:windowWidth, windowHeight:windowHeight, xScroll:xScroll, yScroll:yScroll};
}
	
function getElementPosition(elemId)
{
    var elem = document.getElementById(elemId);
	
    var w = elem.offsetWidth;
    var h = elem.offsetHeight;
	
    var l = 0;
    var t = 0;
	
    while (elem)
    {
        l += elem.offsetLeft;
        t += elem.offsetTop;
        elem = elem.offsetParent;
    }

    return {"left":l, "top":t, "width": w, "height":h};
}

function absPosition(obj) {
      var x = y = 0;
      while(obj) {
            x += obj.offsetLeft;
            y += obj.offsetTop;
            obj = obj.offsetParent;
      }
      return {x:x, y:y};
}

var win=null;
function NewWindow(mypage,myname,w,h,scroll, pos, menubar, toolbar){

if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}

settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=yes,directories=yes,status=yes,menubar='+menubar+',toolbar='+toolbar+',resizable=yes';

win = window.open(mypage, myname, settings);

}



function setColorTable_main(obj)
{
	obj.style.background = '#ffffff';
	obj.style.color = 'black';
	
	var elements = obj.getElementsByTagName("td");
	
	for(i = 0; i < elements.length; i++){
		elements[i].style.color = 'black';
		if (elements[i].className == "green") elements[i].style.color = "#0C9B16";
		if (elements[i].className == "red") elements[i].style.color = "#C00000";
	}
}

function setColorTableSelect_main(obj)
{
	obj.style.background = '#A40000';
	obj.style.color = 'white';
	
	var elements = obj.getElementsByTagName("td");
	
	for(i = 0; i < elements.length; i++){
		elements[i].style.color = "white";
	}
}

function openBlock_main(name)
{
	var Obj = getObj(name).style.display;
	if (Obj == "none") getObj(name).style.display = "block";
	else getObj(name).style.display = "none";
}

function setValue(id, values)
{
	var Obj = getObj(id);
	Obj.value = values;
}

function infoSetDate_main(link)
{
	var start_date = encodeURIComponent(getObj("input_start_date").value);
	var end_date = encodeURIComponent(getObj("input_end_date").value);
	
	link = "/start_date/" + start_date + "/end_date/" + end_date + "/" + link;
	
	window.location.href = link;
}

var image_src = "";
function selectPeriod_main(id, key, link, ul)
{
	if (!link) link = "mini-image-main";
	if (!ul) ul = "periods_ul";

	var elem = getObj(ul);
	var template_element = elem.getElementsByTagName("li");
	var count = template_element.length;

	for (i = 0; i < count; i++) {
		template_element[i].className = "pasive";
	}
	
	getObj(ul + "_" + id).className = "act";
	
	image_src = "/chart/show/"+ link +"/period/" + key + "/";
	image_src += "rand/" + randomNumber(1, 9999) + "/";
	
	getObj("image_ux").style.display = "none";
	
	ChartImage = new Image;
	ChartImage.onload = getImageUx_main;
	ChartImage.src = image_src;
}

function getImageUx_main()
{
	getObj("image_ux").src = image_src;
	getObj("image_ux").style.display = "block";
}

function activate_main()
{
	var login = encodeURIComponent(getObj("login").value);
	var code = encodeURIComponent(getObj("code").value);
	var link = "/users/show/activate/login/" + login + "/code/" + code + "/";
	
	window.location.href = link;
}

function echoBaner(name, width, height)
{
	var flash = "";
	flash += '<object codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+ width +'" height="'+ height +'" align="middle">';
	flash += '<param name="allowScriptAccess" value="sameDomain" />';
	flash += '<param name="movie" value="'+ name +'" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="'+ name +'" quality="high" bgcolor="#ffffff" width="'+ width +'" height="'+ height +'" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	flash += '</object>';
	
	document.write(flash);
}

function reloadCapcha_form(name, obj)
{
	if (!name) name = "capcha_img";
	
	getObj(name).src = "/users/show/capcha/" + randomNumber(1, 9999) + randomNumber(1, 9999) + "/";
	//$("img", obj).attr("src", "/images/spinner.gif");
	
	return false;
}

function randomNumber (m,n)
{
  m = parseInt(m);
  n = parseInt(n);
  return Math.floor( Math.random() * (n - m + 1) ) + m;
}