// Make calls to other operations from this file. 


// fired at the end of the page once all html has loaded
function onDOMload () {
	if(typeof sIFR == "function"){
		switchFonts();
	};
	if(typeof buildTransitions == "function") {
		buildTransitions();
	};
	products_init();
	quantity_changer();
};

// fired once all content has loaded
function onPageLoad () {

};


function products_init() {
	//alert(flag)
	var page = new Array('testimonials','beneficial_effects', 'active_ingredients', 'application', 'exportable_info');
	for(var i = 0; i < page.length; i++) {
		var container = document.getElementById(page[i]+'_container');
		
		if(container) {
			if(container.id=='testimonials_container' && flag=='set')
			{
				//alert("hi")
				container.className = 'on';
			}
			else
			{
				container.className = 'off';
			}
				
			var href = document.getElementById(page[i]);
			setup_pop_open(href, container);
		}
	}
};


function setup_pop_open(href, container) {

	href.onclick = function() {
		if(container.className == 'off') {
			close_divs();
			container.className = 'on';
			href.className = 'on';
		} else {
			close_divs_full();
		}
		return false;
	}
}


function quantity_changer() {
	
	var selects = document.getElementsByTagName("select");
	for(var i = 0; i < selects.length; i++) {
		selects[i].onchange = function() {
			document.getElementById("basket_form").submit();
		}
	}
}


function close_divs() {
	//alert("hi in close divs")
	var page = new Array('testimonials','beneficial_effects', 'active_ingredients', 'application', 'exportable_info');
	for(var i = 0; i < page.length; i++) {
		var container = document.getElementById(page[i]+'_container');
		container.className = 'off';
		var href = document.getElementById(page[i]);
		href.className = 'other';
	}
	if(document.getElementById('ShowTestimonial'))
	{
		document.getElementById('ShowTestimonial').style.display='none';
	}	
}


function close_divs_full() {
	//alert("hi in close full divs")
	var page = new Array('testimonials','beneficial_effects', 'active_ingredients', 'application', 'exportable_info');
	for(var i = 0; i < page.length; i++) {
		var container = document.getElementById(page[i]+'_container');
		container.className = 'off';
		var href = document.getElementById(page[i]);
		href.className = 'off';
	}
	if(document.getElementById('ShowTestimonial'))
	{
		document.getElementById('ShowTestimonial').style.display='none';
	}	
}

document.onload = onPageLoad();