// JavaScript Document

$(function() {
		   
	// scroller
	// Custom scrolbar must be first!!
	update();
	 $('#overlay_pack').css('display','none');
});

function openreg(reg) {
	opencontent(reg);
}

function openfile(file) {
	if (file) $.getJSON(
        	file,
                function(data){
			$('#overlay_pack').css('display','block');
			$('.content_frame').html(data.content);
			update();
		});
}

function openini(file) {
	if (file) {
		file = file.indexOf('?') > -1 ?  file + '&json=1' : file + '?json=1',
		$.getJSON(
        	file,
                function(data){
			$('#overlay_pack').css('display','block');
			$('.content_frame').html(data.content);
			update();
		});
	}
}

function opencontent(arg) {
	switch(arg) {
		case "menu0" : file="the_company.php?json=1"; break;
		case "menu1" : file="about_the_water.php?json=1"; break;
		case "menu2" : file="news.php?json=1"; break;
		case "menu3" : file="products.php?json=1"; break;
		case "menu4" : file="for_the_office.php?json=1"; break;
		case "menu5" : file="distributors.php?json=1"; break;
		case "mcEgg_Products.swf" : file="products.php?json=1"; break;
		case "mcEgg_About.swf" : file="about_the_water.php?json=1"; break;
		case "mcEgg_Instalations.swf" : file="for_the_office.php?json=1"; break;
		case "mcEgg_Map.swf" : file="distributors.php?json=1"; break;
		case "mcEgg_News.swf" : file="news.php?json=1"; break;
		case "mcEgg_TheCompany2.swf" : file="the_company.php?json=1"; break;
		case "mcEgg_en_Products.swf" : file="products.php?json=1"; break;
		case "mcEgg_en_About.swf" : file="about_the_water.php?json=1"; break;
		case "mcEgg_en_Instalations.swf" : file="for_the_office.php?json=1"; break;
		case "mcEgg_en_Map.swf" : file="distributors.php?json=1"; break;
		case "mcEgg_en_News.swf" : file="news.php?json=1"; break;
		case "mcEgg_en_TheCompany2.swf" : file="the_company.php?json=1"; break;
		default : file="distributors.php?json=1&dna=" + arg;

	}
	if (file) $.getJSON(
        	file,
                function(data){
			$('#overlay_pack').css('display','block');
			$('.content_frame').html(data.content);
			update();
		});
}


function hidehtml() {
	$('#overlay_pack').css('display','none');
}

function update() {
	$("a[rel^='gb']").click( function() {
                $.getJSON(
                    ($(this).attr('href').indexOf('?') > -1) ?  $(this).attr('href') + '&json=1' : $(this).attr('href') + '?json=1',
                    function(data){
                        $('#overlay_pack').css('display','block');
                        $('.content_frame').html(data.content);
                        update();
                    }
                );
                return false;
        });
	$('.content_txt, .news_txt, .distributors_info').jScrollPane({verticalDragMaxHeight: 78, verticalDragMinHeight :78, hijackInternalLinks: true});
	
	$('.distributors_txt select').change( function() {
		openfile('distributors.php?json=1&did=' + $(this).val());
	});
	
	$("a[rel^='prettyPhoto']").prettyPhoto({social_tools: '', deeplinking: false });
}

