jQuery(document).ready(function() {
	jQuery('#menu h5').click(function () {
		if ( jQuery('#menu ul').css('display') != 'block' ) jQuery('#menu ul').fadeIn();
		else jQuery('#menu ul').fadeOut();
		jQuery('#menu-right ul').fadeOut();
		return false;
	});
	jQuery('#menu-right h5').click(function () {
		if ( jQuery('#menu-right ul').css('display') != 'block' ) jQuery('#menu-right ul').fadeIn(); 
		else jQuery('#menu-right ul').fadeOut();
		jQuery('#menu ul').fadeOut();
		return false;
	});
	jQuery(document).click(function () {
		jQuery('.menu ul').fadeOut();
		//return false;
	});
	/*jQuery('a[rel=facebox]').facebox();*/
	if (typeof(cufonize) != "undefined" && cufonize == false) {
	} else {
		Cufon.replace('.content-bottom h3');
		Cufon.replace('.content-map h2');
	}
	/*jQuery(document).pngFix();*/
});

function mycarousel_initCallback(carousel) {
	jQuery('.jcarousel-control a').bind('click', function() {
		carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
		return false;
	});
};
function mycarousel_itemVisibleInCallbackAfterAnimation(carousel, item, idx, state) {
	activo = idx-1;
	jQuery('.jcarousel-control a.activo').removeClass('activo');
	jQuery('.jcarousel-control a:eq('+activo+')').addClass('activo');
}


function mycarousel_itemLoadCallback(carousel, state)
{
    // Since we get all URLs in one file, we simply add all items
    // at once and set the size accordingly.
    if (state != 'init')
        return;
    jQuery.get('dynamic_ajax.txt', function(data) {
        mycarousel_itemAddCallback(carousel, carousel.first, carousel.last, data);
    });
};
function mycarousel_itemAddCallback(carousel, first, last, data)
{
    // Simply add all items at once and set the size accordingly.
    var items = data.split('|');
	var pag = 0; var i = 0;
	while (i < items.length ) {
		var fotos ='';
	    for (f = 0; f < 6; f++) {
			if ( i < items.length ) fotos = fotos + mycarousel_getItemHTML(items[i]);
			i++;
		}
		carousel.add(pag+1, fotos)
		pag++;
    }
    carousel.size(pag);
	jQuery('#myFlick a[rel=facebox]').facebox();
};
/**
 * Item html creation helper.
 */
function mycarousel_getItemHTML(url)
{
    return '<a href="' + url + '" rel="facebox"><img src="' + url + '" width="50" height="50" alt="" /></a>';
};

function toggleEditLinks() {
	jQuery(".edit-link").toggle();
	jQuery(".edit_link").toggle();
	
	};

	jQuery(window).load(function(){
	var Cokelocale = window.location.href.split("/");
	var CokeURL = "";
	
	if(Cokelocale[4]=="id_ID" || Cokelocale[2]=="id_ID" || Cokelocale[3]=="id" || Cokelocale[1]=="id") {
		
		CokeURL = jQuery("#menu ul li:nth-child(2) a").attr("href");
		jQuery("#menu ul li:nth-child(2) a").attr("href", CokeURL+"?WT.cs=1&WT.mm=topleftmenu1-cokeredindonesia");
		
		CokeURL = jQuery("#menu ul li:nth-child(3) a").attr("href");
		jQuery("#menu ul li:nth-child(3) a").attr("href", CokeURL+"?WT.cs=1&WT.mm=topleftmenu2-aboutcompany");
		
		CokeURL = jQuery("#menu-right ul li:nth-child(2) a").attr("href").split("?");
		jQuery("#menu-right ul li:nth-child(2) a").attr("href", CokeURL[0]+"?WT.cl=1&WT.mm=toprightmenu1-changecountry&WT.pi=Change%20Market");
	}
});
