// JavaScript Document
show = true;
news_show = true;
function menuAnimation() {
	if(show) {
	$('#sub_menu_container').animate ( {
		width:145
	},'slow');
	show = false;
	}
	else {
		$('#sub_menu_container').animate ( {
			width:0
		},'slow');
		show = true;
	}
}
function subMenuAnimation(id) {
	if(document.getElementById(id) != null) {
	$('#'+id).slideDown('slow');
	}
}
function subMenuHide(id) {
	if(document.getElementById(id) != null) {
	$('#'+id).slideUp('slow');
	}
}
function newsAnimation(article_id) {
		id = parseInt(article_id);
		setTimeout("$('#news_content').fadeOut()",5000);
		setTimeout("$('#read_more').fadeOut()",5000);
		setTimeout("document.getElementById('news_content').innerHTML = news["+id+"]",500);
		setTimeout("$('#news_content').fadeIn()",500);
		setTimeout("$('#read_more').fadeIn()",500);
		if(id+1 == array_number)
			id = 0;
		else
			id = article_id + 1;
		a_id = id;
		return setTimeout("newsAnimation("+id+")",6000);
}
function newsLink() {
	article_id = article_ids[a_id];
	window.location = 'news.php?article_id='+article_id;
}
function mainPagesImages(number) {
	for(i=0;i<=number;i++) {
		time = 200+(i*400);
	//$('#subpage').fadeIn(1500);
	$('#img'+i).delay(time).fadeIn('slow');
	}
}
function showColorImage(id) {
	$('#'+id).fadeIn('slow');
}
function hideColorImage(id) {
	$('#'+id).fadeOut('slow');
}


function pageScroll() {
	/*if(type == 'top')
		value = 10;
	else
		value = -10;*/
window.frame.scrollBy(0,5);
scrolldelay = setTimeout('pageScroll()', 25);
/* Increase this # to slow down, decrease to speed up scrolling */
} 
function downScroll() {
	/*if(type == 'top')
		value = 10;
	else
		value = -10;*/
window.frame.scrollBy(0,-5);
scrolldelay = setTimeout('downScroll()', 25);
/* Increase this # to slow down, decrease to speed up scrolling */
}
function stopScroll() {
	clearTimeout(scrolldelay);
}
function productCallPage(page) {
window.top.$('#page_content').animate({opacity:0},800);
xmlhttp.open("GET", page);
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			window.top.document.getElementById('page_content').innerHTML = xmlhttp.responseText;
			window.top.$('#page_content').animate({opacity:1},800);
					$(document).ready(function(){
			//Examples of how to assign the ColorBox event to elements
			$("a[rel='gallery']").colorbox();
			$("a[rel='gallery']").colorbox({transition:"fade"});
			$("a[rel='gallery']").colorbox({transition:"none", width:"75%", height:"75%"});
			$("a[rel='gallery']").colorbox({slideshow:true});
			$(".gallery").colorbox();
			$(".gallery").colorbox({iframe:true, innerWidth:425, innerHeight:344});
			$(".gallery").colorbox({width:"80%", height:"80%", iframe:true});
			$(".gallery").colorbox({width:"50%", inline:true, href:"#inline_example1"});
			$(".gallery").colorbox({
				onOpen:function(){ alert('onOpen: colorbox is about to open'); },
				onLoad:function(){ alert('onLoad: colorbox has started to load the targeted content'); },
				onComplete:function(){ alert('onComplete: colorbox has displayed the loaded content'); },
				onCleanup:function(){ alert('onCleanup: colorbox has begun the close process'); },
				onClosed:function(){ alert('onClosed: colorbox has completely closed'); }
			});
			
			//Example of preserving a JavaScript event for inline calls.
			$("#click").click(function(){ 
				$('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
				return false;
			});
		});
		}
	}
	xmlhttp.send(null);
}
function changeClass(id,class_name) {
	document.getElementById(id).className = class_name;
}
function callAjax(ajax_type,page_id) {
	if(ajax_type != '')
		return productCallPage('ajax/product.ajax.php?page_id='+page_id);
	else
		return false;
}
function newsAjax(page) {
	/*
window.top.$('#article_text').animate({opacity:0},800);
xmlhttp.open("GET", page);
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			window.top.document.getElementById('article_text').innerHTML = xmlhttp.responseText;
			window.top.$('#article_text').animate({opacity:1},800);
		}
	}
	xmlhttp.send(null);
	*/
	window.location = page;
}
