var hand = new Array();
var hand_action = new Array();
var hand_active = 0;
var hand_next = 0;
var hand_array = new Array();
var hand_start = 1;

function openVerMenu(mid){
	if ($('vsubmenu_'+mid).style.display=='none'){
		$('vsubmenu_'+mid).style.display='';
		saveOpenedMenu(mid,1);
	}else{
		$('vsubmenu_'+mid).style.display='none';
		saveOpenedMenu(mid,0);
	}
}
function saveOpenedMenu(mid,stat){
	var url = saveMenuScript+'?mid='+mid+'&stat='+stat+'';

	new Ajax.Request(url, {
	  method: 'get',
	  onSuccess: function(transport) {
	    void(0);
	  }
	});
}

function ssMainPromo(ss_id, self_called) {
	if (hand_action[ss_id] == 'start' && self_called != true) {
		clearTimeout(hand[ss_id]);
		hand_action[ss_id] = 'stop';
		hand[ss_id] = setTimeout('ssMainPromo("'+ss_id+'", false);', 6000);
	}else {
		hand_action[ss_id] = 'start';
		hand_active=hand_next;
		if(hand_next == hand_array.length-1)
			hand_next=0;
		else
			hand_next++;
		hide_divMainPromo(hand_array[hand_active]);
		Effect.toggle($('mainPromoSlideTxt_'+hand_array[hand_next]).id,'appear',{ from: 0, to: 1});
		Effect.toggle($('mainPromoSlideImage_'+hand_array[hand_next]).id,'appear',{ from: 0, to: 1});
		($('mainPromoSlideNav_'+hand_array[hand_next]).parentNode).parentNode.id='activeMainPromo';
		hand[ss_id] = setTimeout('ssMainPromo("'+ss_id+'", true);', 6000);
	}
}
function hide_divMainPromo(id){
	Effect.Fade($('mainPromoSlideTxt_'+id).id, { duration: 1.0, from: 1, to: 0});
	Effect.Fade($('mainPromoSlideImage_'+id).id, { duration: 1.0, from: 1, to: 0});
	($('mainPromoSlideNav_'+id).parentNode).parentNode.id='';
	//$('bg_'+x.id).className = 'main_block_bg_nonact';
	return true;
}
function hide_div2MainPromo(id){
	//Effect.Fade($('mainPromoSlideTxt_'+id).id, { duration: 1.0, from: 1, to: 0});
	//Effect.Fade($('mainPromoSlideImage_'+id).id, { duration: 1.0, from: 1, to: 0});
	$('mainPromoSlideTxt_'+id).hide();
	$('mainPromoSlideImage_'+id).hide();
	($('mainPromoSlideNav_'+id).parentNode).parentNode.id='';
	//$('bg_'+x.id).className = 'main_block_bg_nonact';
	return true;
}
function openMainPromo(id){
	for (i=0;i<$$('div.mainPromoSlide').length; i++) {
		var divID=$$('div.mainPromoSlide')[i].id;
		var tmp=divID.split('_');		
		if($('mainPromoSlideTxt_'+tmp[1]).style.display != 'none' && id != tmp[1]){
			hide_div2MainPromo(tmp[1]);
		}
	}
	//Effect.toggle($('mainPromoSlideTxt_'+id).id,'appear',{ from: 0, to: 1});
	//Effect.toggle($('mainPromoSlideImage_'+id).id,'appear',{ from: 0, to: 1});
	$('mainPromoSlideTxt_'+id).show();
	$('mainPromoSlideImage_'+id).show();
	($('mainPromoSlideNav_'+id).parentNode).parentNode.id='activeMainPromo';
	clearTimeout(hand['mainPromo']);
	hand_start=0;
}
function slide_divMainPromo(){
	if(hand_start == 1){
		for (i=0;i<$$('div.mainPromoSlide').length; i++) {
			var divID=$$('div.mainPromoSlide')[i].id;
			var tmp=divID.split('_');
			hand_array[i]=tmp[1];
		}
		if(hand_active == 0){
			hand_active=-1;
			hand_next=0;
		}
		ssMainPromo('mainPromo',false);
	}
}




function ss(ss_id, str_id, cur_el, self_called, firstime) {
	if (hand_action[ss_id] == 'start' && self_called != true) {
		clearTimeout(hand[ss_id]);
		hand_action[ss_id] = 'stop';
		hand[ss_id] = setTimeout('ss("'+ss_id+'", "'+str_id+'", "0");', 6000);
	}else {
		hand_action[ss_id] = 'start';
		var tmp = str_id.split('|');
		if(!firstime) {
			tmp.splice(0,1);
		}else{	
			hand[ss_id] = setTimeout('ss("'+ss_id+'", "'+str_id+'", "'+(parseInt(cur_el)+1)+'", true);', 6000);
			return;
		}
		hide_div(tmp[cur_el]-1);
		if(tmp[cur_el] != 'undefined'){
			Effect.toggle(tmp[cur_el],'appear');
			if (cur_el < tmp.length-1){
				if(!self_called) {
					hand[ss_id] = setTimeout('ss("'+ss_id+'", "'+str_id+'", "'+(parseInt(cur_el)+1)+'", true);', 100);
				}else{
					hand[ss_id] = setTimeout('ss("'+ss_id+'", "'+str_id+'", "'+(parseInt(cur_el)+1)+'", true);', 6000);
				}
			}else{
				hand[ss_id] = setTimeout('ss("'+ss_id+'", "'+str_id+'", "0", true);', 6000);
			}
		}
	}
}
function hide_div(){
	var q;
	for (i=0; x=document.getElementById('foo'+i); i++) {
		if(x.style.display != 'none')
			Effect.toggle(x.id,'appear');
	}
	return true;
}
function open(div_id){
	for (i=0; x=document.getElementById('foo'+i); i++) {
		if(x.style.display == ''){
			if(x.id === div_id) return;
			Effect.toggle(x.id,'appear');
		}
	}
	Effect.toggle(div_id,'appear');
}
function slide_div(){	
	var q;
	var arr='';
	for (i=0; x=document.getElementById('foo'+i); i++) {
		arr += '|'+x.id;
	}
	ss('1', arr, 0, false, 1);
}

function ajax_sendnews(url, container, value) {
	if(value != ''){
		new Ajax.Request(url,{
			method: 'post',
			parameters:{ email:value },
			onSuccess: function(response){
				$(container).innerHTML = response.responseText;
			}
		});
	}
}
function showDiv(id){
	if($(id).style.display == "none")
		$(id).show();
	else
		$(id).hide();
	return false;
}
function FquestionSubmit(id,container){
	new Ajax.Request('?question',{
			method: 'post',
			parameters: $(id).serialize(true),
			onSuccess: function(response){
				if(response.responseText == 1){
					$(container).remove();
					$("questionFalse").remove();
					$("questionTrue").show();
				}else{
					$("questionFalse").show();
				}
			}
		});
}

function produceOpenTab(tab){
	var newActive=$(tab.id);
	var tabActive=$($$('div.activeTab')[0].id);
	tabActive.removeClassName('activeTab');
	tabActive.addClassName('nonActiveTab');
	$(tabActive.id+'_content').hide();
	
	newActive.removeClassName('nonActiveTab');
	newActive.addClassName('activeTab');
	$(newActive.id+'_content').show();
	
	return true;	
}
