// JavaScript Document

/* ResetNumberDiv */

var opened_number = 'recipe1';

var myArr = new Array('recipe1','recipe2','recipe3');

//==================================================================================================================

/* clikNumberDiv */

function clickNumberReciepe(id)
{
	var addClass = "";
	
	for(i=0; i<myArr.length; i++)
	{
		if(id==myArr[i])
		{
			id_ind = i;
		}
	}
	
	if (id_ind == myArr.length-1)
	{
		addClass = "_last";
	}

	if (opened_number!=id)
	{
		if (opened_number==myArr[myArr.length-1])
		{
			document.getElementById(opened_number + '_link').className = 'sel_off_last';
		}
		else
		{
			document.getElementById(opened_number + '_link').className = 'sel_off';
		}
		document.getElementById(opened_number + '_box').style.display = 'none';
		document.getElementById(id + '_link').className = 'sel_on'+addClass;
		document.getElementById(id + '_box').style.display = 'block';
		opened_number=id;
	}
	else
	{ 
		document.getElementById(id + '_link').className = 'sel_on'+addClass;
		document.getElementById(id + '_box').style.display = 'block';
	}
}

//==========================================================================================*/

var opened_tab = 'recipetab1';
/*==========================================================================================*/

/* Click Recipe Tab */

function clickRecipeTab(id)
{

	if(opened_tab!=id)
	{
		document.getElementById(id + '_span').className = 'on';
		document.getElementById(id + '_list').className = 'active_list';
		document.getElementById(id).className = 'choosen_tab';
		document.getElementById(opened_tab + '_span').className = 'off';
		document.getElementById(opened_tab + '_list').className = 'normal_list';
		document.getElementById(opened_tab).className = 'normal_tab';
		document.getElementById(opened_tab + '_cnt').style.display = 'none';
		document.getElementById(id + '_cnt').style.display = 'block';

		opened_tab=id;
	}
	else
	{ 
		document.getElementById(id + '_span').className = 'on';
		document.getElementById(id + '_list').className = 'active_list';
		document.getElementById(id).className = 'choosen_tab';
		document.getElementById(id + '_cnt').style.display = 'block';
	}
}

/*==========================================================================================*/

/* Reset Main Tab */

function ResetMainTab(id_page)
{
	var pref = "url('images/maintab";
	var state  = "_off_";
	var suf_gif = ".gif')";

	for(i=1; i<11; i++)
	{
		document.getElementById('maintab'+ i).style.backgroundImage = pref+i+state+id_page+suf_gif;
	}
}

/*==========================================================================================*/

var opened_main_tab = '';

/* Click Main Tab */

function clickMainTab(id_tab, id_page, backgr_color, border_color, text_color)
{
	var pref = "url('images/";
	var state  = "_on_";
	var suf_gif = ".gif')";

	var pref1 = "url('images/backgr_maintabs_";
	var suf_jpg = ".jpg')";
	
	var name_icon = "icon_close_";
	var suf_png = ".png')";
	
	if(document.getElementById('baner_content').style.display == 'block')
	{	
		document.getElementById('baner_content').style.display = 'none';
		document.getElementById('id_base_maintabs').style.display = 'block';
		document.getElementById('id_base_maintabs').style.backgroundImage = pref1+id_page+suf_jpg;
		document.getElementById('id_base_maintabs').style.backgroundColor = backgr_color;
	}
	
	document.getElementById(id_tab).className = id_tab + '_on'; 
	document.getElementById(id_tab).style.backgroundImage = pref+id_tab+state+id_page+suf_gif;
	document.getElementById('maintab_cnt').style.display = 'block';
	document.getElementById('maintab_cnt').style.color = text_color;
	document.getElementById('id_container_maintabs').style.borderColor = border_color;
	
	document.getElementById('id_icon_close').style.backgroundImage = pref+name_icon+id_page+suf_png;

	opened_main_tab=id_tab;

	return opened_main_tab;
}

/*==========================================================================================*/

/* Close Main Tab */

function CloseMainTab(id_page)
{
	
	var pref = "url('images/";
	var state  = "_off_";
	var suf = ".gif')";
		
	if(document.getElementById('baner_content').style.display == 'none')
	{	
		document.getElementById('baner_content').style.display = 'block';
		document.getElementById('id_base_maintabs').style.display = 'none';
		document.getElementById(opened_main_tab).className = opened_main_tab + '_off';
		document.getElementById(opened_main_tab).style.backgroundImage =  pref+opened_main_tab+state+id_page+suf;
	}
}

/*==========================================================================================*/

/* clikNumberPage */

var opened_page = 'page1';
var t=setTimeout("true",30000);


function clickPageMagazine(i)
{
	id = "page"+i;
	if (opened_page!=id)
	{
		document.getElementById(opened_page + '_link').className = 'page_off';
		document.getElementById(opened_page + '_box').style.display = 'none';
		document.getElementById(id + '_link').className = 'page_on';
		document.getElementById(id + '_box').style.display = 'block';
		opened_page=id;
	}
	else
	{ 
		document.getElementById(id + '_link').className = 'page_on';
		document.getElementById(id + '_box').style.display = 'block';
	}
	
	i++;
	if (i > 4)
	{
		i = 1;
	}
	clearTimeout(t);
	t=setTimeout(function(){clickPageMagazine(i);},10000);
	
}

//==========================================================================================*/

/* Create Curve Block */

function CreateCurveBlock(id, backgr_color, border_color)
{
	document.getElementById(id).style.backgroundColor = backgr_color;
	document.getElementById(id).style.borderColor = border_color;
}

//==========================================================================================*/

/* Change TextColor */

function ChangeTextColor(id, text_color, count_elements)
{
	
	if(count_elements == 0)
	{
		document.getElementById('link_main_title_'+id).style.color = text_color;
	}
	else
	{
		
		for(i=1; i<=count_elements; i++)
		{
			if(i==1)
			document.getElementById('link_main_title_'+id+i).style.color = text_color;
			
			document.getElementById('sub_title_'+id+i).style.color = text_color;
		}
	}
}

//========================================================================================*/

/* Create Empty Div with background */

function CreateBackgrLineDiv(backgr, height_backgr, margin)
{
	var p1 = '<div class="base" style="background:'+backgr;
	var p2 = '';


	if(margin!='')
	{
		var p2 = '; '+margin;
	}
	
	var p3 = p1 + p2 +';"><img src="images/blank.gif" height="'+ height_backgr +'" alt="" /></div>';
		
	document.write(p3);
}

//========================================================================================*/

/* Accordeon */

function InitExpandCollapseValue(id_headerclass,id_contentclass,id_toggleclass,id_img1, id_img2)
{

		ddaccordion.init({
		headerclass: id_headerclass, //Shared CSS class name of headers group
		contentclass: id_contentclass, //Shared CSS class name of contents group
		collapseprev: true, //Collapse previous content (so only one open at any time)? true/false 
		defaultexpanded: [], //index of content(s) open by default [index1, index2, etc]. [] denotes no content.
		animatedefault: false, //Should contents open by default be animated into view?
		persiststate: true, //persist state of opened contents within browser session?
		toggleclass: ["", id_toggleclass], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
		togglehtml: ["prefix",id_img1, id_img2], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
		animatespeed: "fast", //speed of animation: "fast", "normal", or "slow"
		oninit:function(expandedindices){ //custom code to run when headers have initalized
			//do nothing
		},
		onopenclose:function(header, index, state, isclicked){ //custom code to run whenever a header is opened or closed
			//do nothing
		}
	})
}
