/* javascript - Kavoo v5 */

/*********************************/
// 00 - Popup
// 05 - Write Flash
// 10 - rescueFrame
// 15 - Home switcher
// 99 - onLoad
/*********************************/

/***** 00 - Popup *****/
function popThis(url,nom,c,w,h,o){
	if(c){
		var popHPos = (screen.availWidth/2)-(w/2);
		var popVPos = (screen.availHeight/2)-(h/2);
		pop = window.open(url,nom,'width='+w+',height='+h+',top='+popVPos+',left='+popHPos+','+o);
	} else {
		pop = window.open(url,nom,'width='+w+',height='+h+','+o);
	}
	pop.focus();
}

/***** 05 - Write Flash *****/
function writeFlash(url,id,w,h,o){
	document.write('\n<object id="'+id+'" type="application/x-shockwave-flash" data="'+url+'" width="'+w+'" height="'+h+'">\n');
	document.write('\t<param name="movie" value="'+url+'" />\n');
	if(o != ''){
		var flashOptionsTab = new Array();
		flashOptionsTab = o.split('|');
		for(i=0; i<flashOptionsTab.length; i++){
			var tempParam = flashOptionsTab[i].split('#')[0];
			var tempValue = flashOptionsTab[i].split('#')[1];
			document.write('\t<param name="'+tempParam+'" value="'+tempValue+'" />\n');
		}
	}
	document.write('</object>\n');
}

/***** 10 - rescueFrame *****/
function rescueFrame(){
	if(isIE && !isIE7){		
		if(!$('rescueFrame')){
			var rescueObj = document.createElement('iframe');
			var rescueElement = document.body.appendChild(rescueObj);
			rescueElement.id = 'rescueFrame';
			rescueElement.style.position = 'absolute';
			rescueElement.style.visibility = 'hidden';
			rescueElement.style.border = '0';
		}
		$('rescueFrame').style.zIndex = (typeof arguments[1] == 'number')? arguments[1] : $Z(arguments[1])+1;
		$('rescueFrame').style.top = $C('y',arguments[0])+'px'; 
		$('rescueFrame').style.left = $C('x',arguments[0])+'px'; 
		$('rescueFrame').style.width = arguments[0].offsetWidth+'px'; 
		$('rescueFrame').style.height = arguments[0].offsetHeight+'px'; 
		$('rescueFrame').style.visibility = 'visible';
	}
}
function endRescueFrame(){
	if(isIE && !isIE7){
		$('rescueFrame').style.visibility = 'hidden';
	}
}

/***** 15 - Home switcher *****/
var lastSwitched = '';
var switchTimer;
var currentSwitch = 0;
function switchTo(id){
	clearInterval(fadeTimer);
	if(lastSwitched != ''){
		$S('del',$(lastSwitched),'on');
		$(lastSwitched).onmouseover = function(){ switchTo(this.id); };
	}
	$S('add',$(id),'on');
	$(id).onmouseover = null;
	fadeTimer = setInterval('fadeOff(\''+id+'\');', 25);
	lastSwitched = id;
	currentSwitch = id.substr(8);
}

var opacityLVL = 0;
var fadeTimer;
function fadeOff(id){
	if(opacityLVL > 0){
		opacityLVL = opacityLVL-10;
		$('switcherView').style.opacity  = opacityLVL/100;
		$('switcherView').style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity='+opacityLVL+')';
	} else {
		clearInterval(fadeTimer);
		$('switcherView').innerHTML = $(id+'Content').innerHTML;
		fadeTimer = setInterval('fadeOn()', 25);
	}
}
function fadeOn(){
	if(opacityLVL < 100){
		opacityLVL = opacityLVL+10;
		$('switcherView').style.opacity  = opacityLVL/100;
		$('switcherView').style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity='+opacityLVL+')';
	} else {
		clearInterval(fadeTimer);
	}
}

function autoSwitcher(){
	if(currentSwitch < 4){
		currentSwitch++;
	} else {
		currentSwitch = 0;
	}
	switchTo('switcher'+currentSwitch);
}

/***** 99 - onLoad *****/
window.onload = function(){
	
	// 15 - Home switcher
	var switcherTab = $$('div','switcher');
	if(switcherTab.length > 0){
		switcherTab[0].id = 'switcher';
		var switcherElement = $('switcher','li',-1);
		for(i=0; i<switcherElement.length; i++){
			switcherElement[i].id = 'switcher'+i;
			switcherElement[i].onmouseover = function(){ clearInterval(switchTimer); switchTo(this.id); }
		}
		var switcherContent = $('switcher','p',-1);
		for(i=0; i<switcherContent.length; i++){
			switcherContent[i].id = 'switcher'+i+'Content';
		}
		$('switcher','div',0).id = 'switcherView';
		switchTo('switcher0');
		switchTimer = setInterval('autoSwitcher();', 5000);
		$('switcher').onmouseover = function(){ clearInterval(switchTimer); }
		$('switcher').onmouseout = function(){ clearInterval(switchTimer); switchTimer = setInterval('autoSwitcher();', 5000); }
	}
	
}

function show_language()
{

    if(document.getElementById("list_flag").style.display == "block")
    {
        document.getElementById("list_flag").style.display = "none";
    } else {
        document.getElementById("list_flag").style.display = "block";
    }    
}
