var current=1;
var previous="";
var logo="";

function popBox(indx){
        current = indx;
        var content = $('#boxcontent_' + indx).html();
        var title = $('#boxlabel_' + indx).html();

        out(current);
        $('#tictactoe').css('visibility','hidden');
        $('#lightbox-logo').html("<img src='" + $('#boximg_' + indx).attr('src') + "' border='0'>");
        $('#lightbox-content').html(content);
        $('#lightbox-title').html(title);
        $('#lightbox').show();
        
        
}

function closeBox(){
        $('#lightbox').hide();
        $('#tictactoe').css('visibility','visible');
}

function highlight(imgid){
        $('#boximg_' + imgid).attr("src","/images/icones/" + $('#boximg_' + imgid).attr("name") + "_over.png");
}

function out(imgid){
        $('#boximg_' + imgid).attr("src","/images/icones/" + $('#boximg_' + imgid).attr("name") + ".png");
}

function investin(imgid){
        $('#' + imgid).attr("src","/images/icones/" + imgid+"_yellow.jpg");
		$('#' + imgid+"_lk").attr("class","icolinkover");
}
function investout(imgid){
        $('#' + imgid).attr("src","/images/icones/" + imgid+"_red.jpg");
		$('#' + imgid+"_lk").attr("class","icolink");
}

function nextTopic(){

    var max = $('#boxes li').length;
    
    if(current >= max)
        current=1;
    else
        current++;
    
    popBox(current);
}

function previousTopic(){

    var max = $('#boxes li').length;

    if(current <= 1)
        current=max;
    else
        current--;

    popBox(current);
}

function rollo(id, province){
	
		var click="Click the map to visit ";
	
        if($('#imgmap').attr('src').indexOf(id) == -1)
        {
            if(province)
                $('#rolloverimg').attr('src','/images/provinces/' + id + '_roll_over.png');
            else
                $('#rolloverimg').attr('src','/images/regions/' + id + '_roll_over.png');

            if(document.location.href.indexOf('/ch/') != -1)
				click= "點擊地圖來開啟  ";
			if(document.location.href.indexOf('/ko/') != -1)
				click= "가고자 하는 지역의 지도를 클릭하십시오  ";
			if(document.location.href.indexOf('/fr/') != -1)
				click= "Cliquez sur la carte pour visiter  ";
            
			$('#province_caption').html(click + $('#' + id).attr('title'));
            $('#rollover').show();
        }
}

function mapout()
{
    $('#rollover').hide();
    $('province_caption').html('');
}


    
function popWin()
{
    var h = parseInt($("#jauneContent").css('height')) + 117 + "px";
    
    if(navigator.appName.indexOf('Explorer') == -1)
		$("#fenetreJaune").animate( { height:h }, { queue:false, duration:1500 } )
	else
		$("#fenetreJaune").css('height',h);
}

function closeWin()
{
    var h = 47 + "px";
    if(navigator.appName.indexOf('Explorer') == -1)	{
		$("#fenetreJaune").animate( { height:"47px" }, { queue:false, duration:1500 } );
	}
	$("#fenetreJaune").css('height',h);
}


function onglet(id)
{
    $("#box_quality_of_life").hide();
    $("#onglet_quality_of_life").removeClass('onglet-selected');
    $("#box_academic_perspectives").hide();
    $("#onglet_academic_perspectives").removeClass('onglet-selected');
    $("#box_professional_opportunities").hide();
    $("#onglet_professional_opportunities").removeClass('onglet-selected');
    
    $("#onglet_" + id).addClass('onglet-selected');
    $("#box_" + id).show();
}

function switchlang(lang,newlang)
{
	var url = document.location.href;
	url = url.replace("/" + lang, "/" + newlang);
	document.location = url;
}

