var arrResize = new Array("59316","3740")
var wnd = null;
var iPopupHeight = 320, iPopupWidth = 500;
var features = "height=" + iPopupHeight + ",width=" + iPopupWidth + ",channelmode=no,dependent=no,directories=no,fullscreen=0,location=0,menubar=no,resizable=no,scrollbars=0,status=1,toolbar=0,top=" + getYPosition(iPopupHeight) + ",left=" + getXPosition(iPopupWidth);
var featuresWithResize = "height=" + iPopupHeight + ",width=" + iPopupWidth + ",channelmode=no,dependent=no,directories=no,fullscreen=0,location=0,menubar=no,resizable=yes,scrollbars=1,status=1,toolbar=0,top=" + getYPosition(iPopupHeight) + ",left=" + getXPosition(iPopupWidth);
function openNewWindow(params){
var blnResize = false;
	for(var i = 0;i < arrResize.length; i++){	
		if(params.indexOf(arrResize[i]) >= 0){
			blnResize = true;
			i = arrResize.length;			
		}
	}
	var strTmpProperty = blnResize ? featuresWithResize :features;
	if(params){
		if((wnd!=null)&&(!wnd.closed)){
			wnd.close();
		}
		wnd=window.open(params,"RateWindow",strTmpProperty);
	}else{
		return;
}
}

function getXPosition(iWndWidth){
	var iX = 0;
	var iW = parseInt(screen.width);
	iWndWidth = ((iWndWidth == null) || (iWndWidth < 0 )) ? 0 : iWndWidth;
	if(iW > iWndWidth)	
		iX = Math.ceil((iW - iWndWidth) / 2);
	
	return iX;
}
function getYPosition(iWndHeight) {
	var iY = 0;
	var iH = parseInt(screen.height) - 24;	
	iWndHeight = ((iWndHeight == null) || (iWndHeight < 0 )) ? 0 : iWndHeight;
	if(iH > iWndHeight)
		iY = Math.ceil((iH - iWndHeight) / 2);	
		
	return iY;	
}


function Menu_openPopup(popupUrl, popupWidth, popupHeight) {
	var windowWidth  = null;
	var windowHeight = null;
	var windowLeft   = null;
	var windowTop    = null;
	var strFeatures  = '';
	
	if (navigator.userAgent.match(/gecko/i)) {
		windowWidth  = window.innerWidth;
		windowHeight = window.innerHeight;
		windowLeft   = screenX;
		windowTop    = screenY;
	} else {
		windowWidth  = document.body.offsetWidth;
		windowHeight = document.body.offsetHeight;
		windowLeft   = window.screenLeft;
		windowTop    = window.screenTop;
	}
	
	var popupLeft = parseInt(windowLeft + windowWidth/2 - popupWidth/2);
	var popupTop  = parseInt(windowTop + windowHeight/2 - popupHeight/2);
	
	if (popupWidth && popupHeight) {
		strFeatures = 'left=' + popupLeft + ',top=' + popupTop + ',width=' + popupWidth + ',height=' + popupHeight + ',scrollbars=1,resizable=0,toolbar=0,status=1,menubar=0';
	}
	
	window.open(popupUrl, 'soXes_popup', strFeatures);
}

function setNewLocale(){
	f = document.forms["form_locale"];
	if(window.location.search == ""){
		f.action = "index.php";
	}
	f.submit();
}

function changeNewsCategory(url){
	window.location = url;
}

function showNews(num){
	var loc = window.location;
	var prefix = (String(loc).indexOf("?") > -1 ? "&" : "?");
	window.location = loc + prefix + "news_id=" + num;
}

function returnToAllNews(newsNum){
	var loc = String(window.location);
	loc = loc.replace("&news_id=" + newsNum, "");
	loc = loc.replace("?news_id=" + newsNum, "");
	window.location = loc;
}

function showHiddenMenuItem(num){
	var a = window.location.href;
	var str = a.replace(/(active=m_)(\d+)/, "$1" + num);
	window.location = str;
}

//
//	onload handling
//
var _onload = new Array;

window.onload = function()
{

	for (var i = 0; i < _onload.length; i++)
	{
		_onload[i].call(this);
	}
};

//
//	marquee handling
//
var marquee = new Array;

_onload.push(function()
{
	for (var i = 0; i < marquee.length; i++)
	{
		marquee[i].start();
	}
});

//
//	'Esc' handling for popups
//
document.onkeypress = function(event)
{
	event = event || window.event;

	if (top.opener && event.keyCode == 27)
	{
		top.close();
	}
}

//
//	email decryption
//

function documentClick(event) {
	event = event || window.event;
	
	var srcElement = event.target || event.srcElement;
	var string, code, res = '';
	
	while (srcElement && srcElement.tagName != 'A') {
		srcElement = srcElement.parentNode;
	}
	if (!srcElement) {
		return true;
	}
	
	var match = srcElement.href.match(/^mailto:(.+)/);
	
	if (!match) {
		return true;
	}
	string = unescape(match[1]);
	
	for (var i = 0; i < string.length; i++) {
		code = string.charCodeAt(i);
		if (code >= 8364) {
			code = 128;
		}
		res += String.fromCharCode(code - (3));
	}
	window.location = "mailto:" + res;
	
	srcElement.returnValue = true;
	
	if (event.cancelable) {
		event.preventDefault();
	}
	
	return false;	
}

if (is.ie) {
	document.attachEvent("onclick", documentClick);
} else {
	document.addEventListener('click', documentClick, false);
}

function preSubmit(event)
{
	event = event || window.event;

	var srcElement = event.target || event.srcElement;

	//
	//	Netscape trick
	//
	form = srcElement.form || srcElement;

	var elem, error;

	//
	//	check (checkbox|radio)group
	//
	var checkGroup = function(name)
	{
		var options = form.elements[name];
		var error = true;

		for (var i = 0; i < options.length; i++)
		{
			error &= !options[i].checked;
		}

		return error;
	}
	
	//
	//	walk through form elements
	//
	for (i = 0; i < form.length; i++)
	{
		elem  = form.elements[i];
		value = elem.value;

		//
		//	skip non-required fields
		//
		if (!elem.getAttribute("required"))
		{
			continue;
		}

		switch (elem.type)
		{
			case "checkbox":
			error = elem.name.match(/\[\]$/) ? checkGroup(elem.name) : !elem.checked;
			break;

			case "select-one":
			error = elem.selectedIndex == 0;
			break;

			case "radio":
			error = checkGroup(elem.name);
			break;

			case "submit":
			error = false;
			break;

			default:
			error = !value.match(/\S/);
		}
		

		if (error)
		{
			alert(messageCommon);
			elem.focus();
			return false;
		}

		//
		//	validate "email" fields
		//
		if (elem.className == "email" && !elem.value.match(/^[a-z0-9\.\-_\+]+@[a-z0-9\-_]+\.([a-z0-9\-_]+\.)*?[a-z]+$/i))
		{
			alert(messageEmail);
			elem.focus();
			return false;
		}
	}

	return true;
}

/*document.attachEvent("onclick", function(event){

event = event || window.event;

	var srcElement = event.target || event.srcElement;

	var string,  code, res = "";

	while (srcElement && srcElement.tagName != "A")
	{
		srcElement = srcElement.parentElement;
	}
	if (!srcElement) return true;

	var match = srcElement.href.match(/^mailto:(.+)/);
	if (!match) return true;
	string = match[1];
	for (var i = 0; i < string.length; i++){
		code = string.charCodeAt(i);
		if (code >= 8364) {code = 128}
		res += String.fromCharCode(code - (3));
	}
	window.location = "mailto:" + res;

	srcElement.returnValue = true;

	if (event.cancelable)
	{
		event.preventDefault();
	}

	return false;
});*/

function getContactFlash() {
	document.write("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\"550\" height=\"500\">");
	document.write("<param name=\"movie\" value=\"user_files/flash/map.swf\">");
	document.write("<param name=\"quality\" value=\"high\">");
	document.write("<embed src=\"user_files/flash/map.swf\" menu=false quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"550\" height=\"500\"></embed></object>");
}
function strech() {

	var ua = navigator.userAgent.toLowerCase();
	isIE = (ua.indexOf("msie") != -1 && ua.indexOf("opera") == -1);
	isOpera = (ua.indexOf("opera") != -1);
	isGecko = (ua.indexOf("gecko") != -1);
	isSafari = (ua.indexOf("safari") != -1);
	isKonqueror = (ua.indexOf("konqueror") != -1);
	
if(isIE == true && $.browser.version == 6){}
else {
	
	/* fixed by Vitaly 30.09.2009 >>> */	

	domFooter = document.getElementById("footer")
	var diff = document.body.offsetHeight - (domFooter.offsetTop + domFooter.offsetHeight)
	
	
	domContent = document.getElementById("content")
	
	//var h = domContent.offsetHeight + diff - 5;
	var h = domContent.offsetHeight  - 5;
	/*var h = domContent.offsetHeight + diff + 100;*/
	domContent.style.height = h +25+"px";
//alert(domContent.style.height);
	//alert(domContent.offsetHeight + diff - 56);
	
	
	
	domContener = document.getElementById("contener")
	//document.getElementById("leftSideImg").style.height = domContener.offsetHeight + 6 + "px"
	//document.getElementById("rightSideImg").style.height = domContener.offsetHeight + 6 + "px"
	var principaltab = document.getElementById("principaltab");
	
	if(principaltab)
	{
		principaltab.style.height = (h-50) + "px";
	}

	var tagCloudTagsContainerClassic = document.getElementById("tagCloudTagsContainerClassic");
	
	if(tagCloudTagsContainerClassic)
	{
		//alert("exists");
		
		if(isIE == true && $.browser.version == 8)
		{
			tagCloudTagsContainerClassic.style.height = (h-138-20)+ "px"; // last value 152
			
		}
		else if(isIE == true && $.browser.version == 7)
		{
			tagCloudTagsContainerClassic.style.height = (h-128-60) + "px";
			//tagCloudTagsContainerClassic.style.height = principaltab.style.height;
			//alert(domContent.style.height);
			//alert(tagCloudTagsContainerClassic.style.height);
			 
		 // last value 152
		}
		
		else
		{
			tagCloudTagsContainerClassic.style.height = (h-137-20) + "px";
		}
		
	}	
		//FF tagCloudTagsContainerClassic.style.height = (h-119) + "px";
	
		//IEtagCloudTagsContainerClassic.style.height = (h-140) + "px";
	}
	 	
	
	
	
	
/* Without scrolling in content part (clear inline style in <div id="content" style="height: 290px; overflow: auto;">) */
/*	
	domFooter = document.getElementById("footer")
	var diff = document.body.offsetHeight - (domFooter.offsetTop + domFooter.offsetHeight)
	
	domContener = document.getElementById("contener")

	if (diff > 0){
		domContener.style.height = domContener.offsetHeight + diff - 11 + 'px' // 11px - #div.separator
		document.getElementById("leftSideImg").style.height = domContener.offsetHeight + 6 + "px"
		document.getElementById("rightSideImg").style.height = domContener.offsetHeight + 6 + "px"
	}
	else{
		document.getElementById("leftSideImg").style.height = domContener.offsetHeight + 6 + "px"
		document.getElementById("rightSideImg").style.height = domContener.offsetHeight + 6 + "px"
	}

/* <<< *** */
	
	
/*	
	var height 		   = parseInt(document.body.clientHeight);
	var contenerHeight = 652+30;
	var imgHeight	   = 647;
	var footer 		   = 53;
	var ie6newHeight   = 0;
	var ie6r   		   = 0;

	var newHeight = height - 210 - 75;
	if ( newHeight < 300 ) {
		newHeight = 300;
	}
	
	var sideBg    = height - 26 - 75;
	if ( is.ie6 ) {
		ie6newHeight  = 8;
	}
	document.getElementById("content").style.height      = newHeight - ie6newHeight + "px";
	document.getElementById("leftSide").style.height     = sideBg + "px";
	document.getElementById("rightSide").style.height    = sideBg + "px";
	if ( is.ie6 ) {
		if ( newHeight == 300 ) {
			document.getElementById("leftSideImg").style.height  = "480px";
			document.getElementById("rightSideImg").style.height = "480px";
		}
		else {
			document.getElementById("leftSideImg").style.height  = height - 15 - 75 - ie6newHeight + "px";
			document.getElementById("rightSideImg").style.height = height - 15 - 75 - ie6newHeight + "px";
		}
		document.getElementById("separator").style.marginTop = "-10px";
	}
	else {
		if ( newHeight == 300 ) {
			document.getElementById("leftSideImg").style.height  = "480px";
			document.getElementById("rightSideImg").style.height = "480px";
		}
		else {
			document.getElementById("leftSideImg").style.height  = "100%";
			document.getElementById("rightSideImg").style.height = "100%";
		}
	}
	*/
}


     function spreadEvenly(parent_box_id, kids_tag, num_kids_consider){
		
     	var parentBox = document.getElementById(parent_box_id)
     	var kids_tag_U = kids_tag.toUpperCase()
     	var considerNodes = new Array()
		var kids_width = 0
		var k = 0
     	for (var i=0; i<parentBox.childNodes.length; i++){
			if (parentBox.childNodes[i].tagName.toUpperCase() == kids_tag_U && k<num_kids_consider){
				considerNodes.push(parentBox.childNodes[i])
				kids_width += parentBox.childNodes[i].offsetWidth
				k++
			}
		}     	
		
		var free_space_whole = parentBox.offsetWidth - kids_width
		var free_space_kid
		for (var i=k-1; i>=0; i--){
				free_space_kid = Math.ceil(free_space_whole / (i+1))
			//considerNodes[i].style.paddingRight = free_space_kid - 1 + 'px' // 1 - because left-border is 1px //no need this script in current design
				free_space_whole -= free_space_kid
		}
	}
