var debug=true;
function isset(A){
	if(document.getElementById(A)){	
		return true;
	}else{
		return false;
	}	
}
function get(A){
	if(isset(A)){
		return document.getElementById(A);
	}else if(true){
		throw new Error("\nfunction: get\nparam: "+A);
	}	
}



function getInnerSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
	return new Array(myWidth, myHeight);
}

function bind(id, w){
		if(get(w+'ou_'+id).style.display=="block"){
			get(w+'ou_'+id).style.display="none";
			get(w+'ov_'+id).style.display="block";
		}else{
			get(w+'ou_'+id).style.display="block";
			get(w+'ov_'+id).style.display="none";			
		}
}

function init(nb, w){
	for(var i=0;i<nb;i++){
		if(isset(w+'ov_'+i)){
			get(w+'ov_'+i).style.display="none";
			get(w+'ou_'+i).style.display="block";
		}
	}
}



var inter;
var speed=20;
var width=501;
var pos;



function initv(id,nb, w, s){
	pos=id;
	width=w;
	speed=s
	get("band").style.left=pos+"px";
	get("band").style.width=width*nb+"px";
}
function next(p){
	clearInterval(inter);
	pos=p*width*-1;
	inter=setInterval("move()", 1);
}
function move(){
	if(isset("biographie")){
		if(get("biographie").style.display=="block"){
			bio('click');
		}
	}
	var x=parseInt(get("band").style.left);
	if(x>pos){
		x-=speed;		
		if(x<=pos+speed){
			x=pos;
			clearInterval(inter);
		}
	}else{
		x+=speed;		
		if(x>=pos-speed){
			x=pos;
			clearInterval(inter);
		}
	}
	//get("debug").innerHTML=x+"px";
	get("band").style.left=x+"px";	
}
function v(id){
	if(get('v_'+id).style.display=="block"){
			get('v_'+id).style.display="none";
		}else{
			get('v_'+id).style.display="block";		
	}
}

function movieShow(director, id, width, height, desc, hd, hdCapacity){
	// les BOLEAN EN STRING !!
	var quality;
	get("full").style.height="100%";
	if(hd=="true"){
		get("movie").style.top='20px';
		get("movie").style.marginTop="0px";
		if(getInnerSize()[1]<576){
			get("full").style.height=576+70+'px';// taille+description+marge
		}
		get("movie").style.marginLeft=(720/-2)+"px";
		get("movie").style.widrh=720+'px'
	}else{
		get("movie").style.top='50%';
		get("movie").style.marginTop=(height/-2-18)+"px";
		get("movie").style.marginLeft=(width/-2)+"px";
	}
	if(hd=="true"){
		quality="hd"
	}else{
		quality="movies"
	}
	var flashvars = {width:width, height:height, id:id, path:director, quality:quality, desc:desc, hd:hd, hdCapacity:hdCapacity};
	var params = {wmode:"transparent",bgcolor:"#000000"};
	var attributes = {name:"myCom", id:"myCom"};
	if(hd=="true"){
		width=720;
		height=576;
	}
	if(id!=416){ // hack barnaby ropper
		swfobject.embedSWF("./rsc/swf/Player.swf", "myContent", width+1, height+18, "9.0.0", "./rsc/swf/expressInstall.swf", flashvars, params, attributes);
	}else{
		
		swfobject.embedSWF("/misc/barnabyroper/eniko.swf", "myContent", 770, 433, "9.0.0", "./rsc/swf/expressInstall.swf", flashvars, params, attributes);
		get("movie").style.marginTop=-216+"px";
		get("movie").style.marginLeft=-385+"px"
	}
//+18 pour la barre de description
   get("full").style.display="block";
   get("movie").style.display="block";
}
function movieHide(){
   //get("myCom").innerHTML=""; //sauf ie
    get("myCom").style.display="none";
	get("myCom").id="myContent";
   get("movie").style.display="none";
   get("full").style.display="none";
}
function bio(e){
	if(!get("bio").color){
		get("bio").color="blanc";
	}
	if(e=="click"){
		if(get("biographie").style.display=="block"){
				get("biographie").style.display="none";
				get("bio").style.backgroundPosition="0 -26px";	
				get("bio").color="blanc";
			}else{
				get("biographie").style.display="block";	
				get("bio").style.backgroundPosition="-24px -26px";
				get("bio").color="bleu";
		}
	}else if(e=="over"){
		if(get("bio").color=="bleu"){
			get("bio").style.backgroundPosition="0 -26px";	
		}else{
			get("bio").style.backgroundPosition="-24px -26px";
		}
	}else if(e=="out"){
		if(get("bio").color=="bleu"){
			get("bio").style.backgroundPosition="-24px -26px";	
		}else{
			get("bio").style.backgroundPosition="0 -26px";
		}
	}
}
function getScrollBarWidth () {  
    var inner = document.createElement('p');  
    inner.style.width = "100%";  
    inner.style.height = "200px";  
  
    var outer = document.createElement('div');  
    outer.style.position = "absolute";  
    outer.style.top = "0px";  
    outer.style.left = "0px";  
    outer.style.visibility = "hidden";  
    outer.style.width = "200px";  
    outer.style.height = "150px";  
    outer.style.overflow = "hidden";  
    outer.appendChild (inner);  
  
    document.body.appendChild (outer);  
    var w1 = inner.offsetWidth;  
    outer.style.overflow = 'scroll';  
    var w2 = inner.offsetWidth;  
    if (w1 == w2) w2 = outer.clientWidth;  
  
    document.body.removeChild (outer);  
  
    return (w1 - w2);  
};
function boucle(id, a){
	if(a==null){
		for(i=0;i<6;i++){
			get('pou_'+i).style.display="block";
			get('pov_'+i).style.display="none";
		}
	}else{		
		for(i=0;i<6;i++){
			if(id==i){
				get('pou_'+i).style.display="none";
				get('pov_'+i).style.display="block";
			}else{
				get('pou_'+i).style.display="block";
				get('pov_'+i).style.display="none";
			}
		}
		
		for(i=0;i<a.length;i++){
			get('pou_'+a[i]).style.display="none";
			get('pov_'+a[i]).style.display="block";	
		}
	}
}
function oct2dec(lOctalNum) {
    try {
        var vError = null;
        var iNumArguments = arguments.length;
        if (iNumArguments != 1) {
            throw vError = new IllegalArgumentException('Math.oct2dec', 1, iNumArguments);
        }
        if((typeof lOctalNum != 'number') || (lOctalNum.toString().indexOf('.') != -1)) {
            throw vError = new TypeMismatchException('Math.oct2dec', 'long', typeof lOctalNum);
        }
        var iDecimalNum = parseInt(lOctalNum.toString(), 8);
    }catch (vError){
        if (vError instanceof Error) {
            vError.handleError();
        }
    }
    finally {
        return vError ? null : iDecimalNum;
    }
}
function dec2oct(lDecimalNum) {

    try {
        var vError = null;
        var iNumArguments = arguments.length;

        if (iNumArguments != 1) {
            throw vError = new IllegalArgumentException('Math.dec2oct', 1, iNumArguments);
        }
        if ((typeof lDecimalNum != 'number') || (lDecimalNum.toString().indexOf('.') != -1)) {
            throw vError = new TypeMismatchException('Math.dec2oct', 'long', typeof lDecimalNum);
        }
        var sOctalNum = lDecimalNum.toString(8);
    }catch (vError) {
        if (vError instanceof Error) {
            vError.handleError();
        }
    }finally {
        return vError ? null : sOctalNum;
    }
}
function findPos(o) {
	var l=t=0;
	if (o.offsetParent) {
		do {
			l+= o.offsetLeft;
			t+= o.offsetTop;
		} while (o = o.offsetParent);
	}
	return [l,t];
}


	
var anim ={
	inter:null, a:null,	a1:null, a2:null,	walking:false,
    init:function(){
		this.a1=document.getElementById('a1');
		this.a2=document.getElementById('a2');
		this.a1.style.left=this.a2.style.left='230px';
		this.a1.style.display=this.a2.style.display='block';
		this.startStop();
	},
	walk:function(){
		if(parseInt(this.a1.style.left)<=-this.a1.offsetWidth){
			this.a=this.a2;
			this.a2=this.a1;
			this.a1=this.a;
		}
		this.a1.style.left=parseInt(this.a1.style.left)-2+'px';
		this.a2.style.left=parseInt(this.a1.style.left)+this.a1.offsetWidth+2+'px';
	},
	startStop:function(){
		if(this.walking){
			clearInterval(this.inter);
			this.walking=false;
		}else{
			this.inter=setInterval("anim.walk()", 60);
			this.walking=true;
		}
	}
}

function isIphone(){
	if(navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i)|| navigator.userAgent.match(/iPod/i)) {
	   if (document.cookie.indexOf("iphone_redirect=false") == -1) return true;
	}
	return false;
}
