<!--
/*
+-----------------------------------------------------------------------+
| Site: Calvary Chapel Kirov | main JavaScript functions                |
+-----------------------------------------------------------------------+
| version 1.08                                                          |
+-----------------------------------------------------------------------+
| Copyright (c) 2007 Calvary Chapel Kirov                               |
+-----------------------------------------------------------------------+
| Author: Aleksey Shihov [a.shihov@gmail.com]                           |
+-----------------------------------------------------------------------+
| Created:     22.03.2007 20:14                                         |
+-----------------------------------------------------------------------+
| Last change: 21.11.2008 17:26:13                                      |
+-----------------------------------------------------------------------+
| Description:                                                          |
+-----------------------------------------------------------------------+
*/

shutterOnload = function(){shutterReloaded.Init();}

/* AntiSpam */
function email (link,login,serv){
	if (link == 1)
		eml = "<a href=\"mailto:"+login+"@"+serv+"\">" + login +  "@" + serv + "</a>";
	else 
		eml = login +  "@" + serv;
document.write (eml);
}

/* HideLayer */
function hide(elemId){ 
	var t=document.getElementById(elemId); 
	if (t.style.display == 'none'){t.style.display= "block";}
	else 	{t.style.display= "none";}
}

/* PopUpWindow */
var popUpWin=0;
function popUpWindow(URLStr, width, height, resize){
	if (!width){width = 400;}
	if (!height){height = 300;}
	if (!resize){resize = "yes";}
	if (resize == 'yes'){
		attributes = "scrollbars=yes,resizable=yes,copyhistory=yes";
	}else{
		attributes = "scrollbars=0,resizable=0,copyhistory=0";
	}	
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  var left = (screen.width/2) - width/2;
  var top = (screen.height/2) - height/2;
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=0,location=0,directories=0,status=0,menubar=0,'+attributes+',width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
  popUpWin.focus();
  window.location=window.location;
}

/* PollForm */
function open_vote(){
	poll_id = document.pollform.poll_id.value;
	q = poll_id + "/" + get_radio_value( document.pollform.answer ) + "/";
	wnd = popUpWindow(''+site_url+'/poll/vote/'+q+'',240,100,'no');
}
function open_rating(){
	rating_id = document.pollform.rating_id.value;
	rating_selected = document.pollform.rating.value;
	q = rating_id + "/" + rating_selected + "/";
	wnd1 = popUpWindow(''+site_url+'/reading/rating/'+q+'',240,100,'no');
}
function get_radio_value( obj ) {
	var i=0; var q=0;
    while((i<obj.length)&&(obj[i].checked!=1)) {i++;}
   	if (i!=obj.length) q =obj[i].value;
	return q;
}

function NextBibleQuote(value){
    var req = new JsHttpRequest();
		$('quote').innerHTML = LNG_wait;
		
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
        		//$('debug').innerHTML = req.responseText;
            $('quote').innerHTML = req.responseJS.q_quote;
        }
    }
    req.caching = false;
    req.open('POST', site_url + '/biblequote/', true);
    req.send( { q: '' } );
}

function PollSend(send_type){
	new Effect.SlideUp('poll_ajax_block',{duration:0.4,queue: 'front',afterFinish:function(){if($('poll_loading').style.display == 'none'){$('poll_loading').show();}}});
	var req = new JsHttpRequest();
	
	if(!send_type){
		var send_type = 'vote';
	}
	
	req.onreadystatechange = function(){
		if (req.readyState == 4) {
			//$('debug').innerHTML = req.responseText;
			$('poll_ajax_block').innerHTML = req.responseJS.q_poll_body
			new Effect.SlideDown('poll_ajax_block',{queue: 'end',duration:0.4,beforeFinish:function(){$('poll_loading').hide();}});
			new Insertion.After('poll_ajax_block', '<p class="small"><i>' + req.responseJS.q_total_votes + '</i></p>');
		}
	}
	
	req.caching = false;
	var poll_id = document.getElementById('poll_id').value;
	if(send_type == 'res'){
		var query = poll_id + '/0/';
	}else{
		var query = poll_id + "/" + get_radio_value( document.poll_ajax_block.answer ) + "/";
	}

	req.open('POST', site_url + '/poll/vote/' + query, true);
	req.send( { q: '' } );

	//document.getElementById('poll_button').disabled = 'disabled';
}

function poll_confirm_result(){
	Modalbox.show('<p><b>Внимание!</b><br />После просмотра результатов Вы не сможете проголосовать в данном опросе. Пожалуйста подтвердите свое решение.</p><div class="w_confirm_link"><a href="javascript:void(0);" onclick="Modalbox.hide();PollSend(\'res\');return false;">Подтвердить</a> | <a href="javascript:void(0);" onclick="Modalbox.hide();return false;">Отменить</a></div>', {title: 'Оповещение', overlayClose: false, width: 420, autoFocusing: false})
}

window.onload = function(){
  /* $('jf').innerHTML = '<a href="http://cckirov.com/redirect/?q=http%3A%2F%2Fwww.jesus-freaks.ru%2F" target="_blank" title="Сайт христианской группы &quot;Jesus Freaks&quot;" hreflang="ru">Jesus Freaks</a>'; */
}

//-->