function popup(path,x,y){
        win= open(path,"win","toolbar=no,location=no,directories=no,"+
        "status=no,scrollbars=yes,resizable=no,"+
        "copyhistory=no,width="+x+",height="+y);
}
function confirmDelete() { //подтверждение удаления пользователя
	return window.confirm('Delete?');
};

function FormPath(w,h){
        k= document.vote.elements.length;
        for (i=1;i<k;i++){
                if (document.vote.elements[i].checked){
                        CheckElem= document.vote.elements[i].value;
                        break;
                }
        }
        param="/cgi-bin/vote/tigvote.cgi?action=submit&file="+document.vote.file.value+"&tigvote="+CheckElem;
        popup(param,w,h);
}

function process_page(){
	$(document).ready(function() {

		// add svg background
		var chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
		var ua = window.navigator.userAgent;
		var msie = ua.indexOf ( "MSIE " );
		var ieVer = parseInt (ua.substring (msie+5, ua.indexOf (".", msie )), 10);

		if( '\v'!='v' && ieVer > 8 ){
			$('#svg_bg_place').append('<div class="body-background"><object data="http://www.rage-online.ru/img/radial.svg" type="image/svg+xml" style="background-color: #000000; width: 100%; height: 600px;" wmode="transparent"></object></div>');
		}

		//process footer maillist inputs
		$('#footer_subscribe_input').focus(function() {
			if($(this).attr('value') == 'email адрес'){
				$(this).attr('value','');
			}
		});
		$('#footer_subscribe_input').blur(function() {
			if($(this).attr('value') == ''){
				$(this).attr('value','email адрес');
			}
		});
		$('#footer_subscribe_submit').click(function(){
			var type = $('#footer-subscribe_radio_sub').attr('checked')? $('#footer-subscribe_radio_sub').attr('value') : $('#footer-subscribe_radio_unsub').attr('value') ;
			popup('/maillist/index.php?sub=go&email='+$('#footer_subscribe_input').attr('value')+'&type='+type,400,320);
		});
		$('#footer-subscribe_radio_sub').click(function(){
			$('#footer_subscribe_submit').attr('value', 'подписаться');
		})
		$('#footer-subscribe_radio_unsub').click(function(){
			$('#footer_subscribe_submit').attr('value', 'отписаться');
		})



	});

}


function ro_countdown() {

	future = new Date("Feb 24 2012 02:00:00");
	now = new Date();

	timeZone = -now.getTimezoneOffset()/60;
	daysHours = ((future - now) / 1000 / 60 / 60) + timeZone;
	days = daysHours / 24;
	days = Math.floor(days);

	// count after deadline
	if( days < 0 ) {

		daysHours = ((now - future) / 1000 / 60 / 60) - timeZone;
		days = daysHours / 24;
		days = Math.floor(days);

		diffMS = (now - future) - 6*1000*60*60;
		diff = new Date();
		diff.setTime( diffMS );

		hours = diff.getHours();
		minutes = diff.getMinutes();
		seconds = diff.getSeconds();

		$('#album_a_countdown').text('Альбом вышел');

		// count before deadline
	} else {

		diffMS = future - now;
		diff = new Date();
		diff.setTime( diffMS );
		hours = diff.getHours();
		minutes = diff.getMinutes();
		seconds = diff.getSeconds();

	}

	// add leading zeros
	minutes = (minutes < 10) ? '0'+minutes : minutes;
	hours = (hours < 10) ? '0'+hours : hours;
	seconds = (seconds < 10) ? '0'+seconds : seconds;

	day_name = 'дней';
	days = '' + days;
	day_cut = days.substr(days.length-1);
	if(!day_cut){
	day_cut = days;
	}
	if( day_cut == 2 || day_cut == 3 || day_cut == 4 ){
		day_name = 'дня';
	}
	if( day_cut == 1 ){
		day_name = 'день';
	}
	
	// create output string
	o = days + ' ' + day_name + ', ' + hours+':'+minutes+':'+seconds;

	// append data to DOM
	$('#album_a_count_time').html(o);

	// make loop
	setTimeout("ro_countdown()", 1000);

}

