function showPopupWindow(url, w, h)
{
	var left = (screen.width-w)/2;
	var top = (screen.height-h)/2;
	if (url.indexOf("/print/") >= 0)
	{
		var name = 'REF';
		var value = window.location;
		var expires = 0;
		var path = '/';
		var secure = '';
		var today = new Date();
		today.setTime( today.getTime() );
		if (expires) expires = expires * 1000 * 60 * 60 * 24;
		var expires_date = new Date( today.getTime() + (expires) );
		document.cookie = name+'='+escape( value ) +
							( ( expires ) ? ';expires='
							+expires_date.toGMTString() : '' ) +
							( ( path ) ? ';path=' + path : '' ) +
							//( ( domain ) ? ';domain=' + domain : '' ) +
							( ( secure ) ? ';secure' : '' );
	}
	window.open(url, '_blank', 'left=' + left + ', top=' + top + ', status, resizable, scrollbars, menubar, toolbar, width=' + w + ', height=' + h);
}

function setCookieForPrintPage(name, value, expires, path, domain, secure)
{
    document.cookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
}

//=================================== Forum form switcher =================================
function switchForumFormBlock()
{
	var forum_form = document.getElementById('forum_form');
	var show_link = document.getElementById('show_link');
	var hide_link = document.getElementById('hide_link');
	if (forum_form != null)
	{
		if (forum_form.style.display == 'none')
		{
			forum_form.style.display = 'block';
			show_link.style.display = 'none';
			hide_link.style.display = 'inline';
		}
		else
		{
			forum_form.style.display = 'none';
			show_link.style.display = 'inline';
			hide_link.style.display = 'none';
		}
	}
}
//===================================/Forum form switcher =================================

//======================================= Tab switcher ====================================
function showListBlock(tab_num, tab_count)
{
	for (var i = 1; i <= tab_count; i++)
	{
		var tab = document.getElementById('tab_' + i);
		var list = document.getElementById('list_' + i);
		if (tab == null || list == null) continue;
		else if (tab_num == i)
		{
			tab.className = "active";
			list.style.display = 'block';
		}
		else
		{
			tab.className = "";
			list.style.display = 'none';
		}
	}
}
//=======================================/Tab switcher ====================================

//==================================== Corrector functions ================================
function openProductSelector()
{
	var productTypeValue = document.getElementById('product_type').value;
	var yearValue = document.getElementById('year').value;
	var issueIdValue = document.getElementById('issue_id').value;
	var w = 600;
	var h = 200;
	var left = (screen.width-w)/2;
	var top = (screen.height-h)/2;
	window.open('/corrector/product_selector.php?product_type=' + productTypeValue + '&year=' + yearValue + '&issue_id=' + issueIdValue + '&uid=' + Math.random(), '_blank', 'left=' + left + ', top=' + top + ', status, resizable, scrollbars, width=' + w + ', height=' + h);
}
//====================================/Corrector functions ================================

//================================= E-mail decoding functions =============================
function decodeMail(text) {
	var elements = reverseText(text).split('<~>');
	document.write(buildTag(elements[0], elements[1], elements[2]));
}

function buildTag(email, text, title) {
	return '<a href="mailto:' + email + '"' +
			((title) ? ' title="' + title + '"' : '') + '>' + 
			((text) ? text : email) + 
		'</a>';
}

function reverseText(text) {
	var str = '';
	for (var i = text.length - 1; i >= 0; i--) str += text.charAt(i);
	return str;
}
//=================================/E-mail decoding functions =============================

//================================== Photo library functions ==============================
	//================================= New window openers ================================
	function openVoteWin(wUri, wName, wWidth, wHeight, wScroll, wMenu) {
		var scrollBars = (wScroll!=0) ? 1 : 0;
		var menuBars = (wMenu) ? 1 : 0;
		var positionLeft = (screen.width - wWidth)/2;
		var positionTop = (screen.height - wHeight)/2;
		var myW = window.open(wUri,wName,'width='+wWidth+',height='+wHeight+',top='+positionTop+',left='+positionLeft+',location=0,menubar='+menuBars+',resizable=0,scrollbars='+scrollBars+',status=0,titlebar=0,toolbar=0,directories=0,hotkeys=0')
		myW.focus();
	}
	
	function openWin(wUri, wName, wWidth, wHeight, wScroll, wMenu) {
		var scrollBars = (wScroll!=0) ? 1 : 0;
		var menuBars = (wMenu) ? 1 : 0;
		var positionLeft = (screen.width - wWidth)/2;
		var positionTop = (screen.height - wHeight)/2;
		var myW = window.open(wUri,wName,'width='+wWidth+',height='+wHeight+',top='+positionTop+',left='+positionLeft+',location=0,menubar='+menuBars+',resizable=0,scrollbars='+scrollBars+',status=0,titlebar=0,toolbar=0,directories=0,hotkeys=0')
		myW.focus();
	}
	
	function openWinResize(wUri, wName, wWidth, wHeight, wScroll, wMenu, wResize) {
		var scrollBars = (wScroll!=0) ? 1 : 0;
		var menuBars = (wMenu) ? 1 : 0;
		var reSizable = (wResize) ? 1 : 0;
		var positionLeft = (screen.width - wWidth)/2;
		var positionTop = (screen.height - wHeight)/2;
		var myW = window.open(wUri,wName,'width='+wWidth+',height='+wHeight+',top='+positionTop+',left='+positionLeft+',location=0,menubar='+menuBars+',resizable='+reSizable+',scrollbars='+scrollBars+',status=0,titlebar=0,toolbar=0,directories=0,hotkeys=0')
		myW.focus();
	}
	
	
	function openWinblur(wUri, wName, wWidth, wHeight, wScroll, wMenu) {
		var scrollBars = (wScroll!=0) ? 1 : 0;
		var menuBars = (wMenu) ? 1 : 0;
		var positionLeft = (screen.width - wWidth)/2;
		var positionTop = (screen.height - wHeight)/2;
		var myW = window.open(wUri,wName,'width='+wWidth+',height='+wHeight+',top='+positionTop+',left='+positionLeft+',location=1,menubar='+menuBars+',resizable=1,scrollbars='+scrollBars+',status=1,titlebar=1,toolbar=1,directories=1,hotkeys=1')
		myW.blur();
	}
	
	function openWinFull(wUri, wName, wWidth, wHeight, wScroll, wMenu) {
		var scrollBars = (wScroll!=0) ? 1 : 0;
		var menuBars = (wMenu) ? 1 : 0;
		var positionLeft = (screen.width - wWidth)/2;
		var positionTop = (screen.height - wHeight)/2;
		var myW = window.open(wUri,wName,'width='+wWidth+',height='+wHeight+',top='+positionTop+',left='+positionLeft+',location=1,menubar='+menuBars+',resizable=1,scrollbars='+scrollBars+',status=1,titlebar=1,toolbar=1,directories=1,hotkeys=1')
		myW.focus();
	}
	//=================================/New window openers ================================
	//================================== "PNG"-functions ==================================
	function iepng(imgObj){
	if(ismsie6x()){
		imgObj.onload=null;
		imgObj.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ imgObj.src+ "',sizingMethod='scale')";
		imgObj.src='/img/void.gif';
		}
	}
	
	function iepngbg(objId,png,mthd){
		if(ismsie6x()){
			if(document.getElementById(''+ objId)){
				var obj=document.getElementById(''+ objId);
				var mthd=(mthd)?mthd:"image";
				obj.style.backgroundImage='none';
				obj.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ png+ "',sizingMethod='"+ mthd+ "')";
			}
		}
	}
	
	function ismsie6x(){
		var result=false;
		var useragent=navigator.userAgent;
		var platform=navigator.platform;
		if(useragent.indexOf('MSIE')>=0 && platform.indexOf('Win')>=0 && !window.opera){
			var re=/MSIE ([0-9]+)\./;
			var version=useragent.match(re)[1];
			if(parseInt(version)>=6) result=true;
		}
		return result;
	}
	//==================================/"PNG"-functions ==================================	
//==================================/Photo library functions ==============================
