/*youtube tags*/
function displaymovie(the_hub){
	if(document.getElementById(the_hub).style.display==""){
		document.getElementById(the_hub).style.display = "none";
		return
	}
	document.getElementById(the_hub).style.display = "";
}
function displaybigger(the_hub){
	if(document.getElementById(the_hub).width=="425"){
		document.getElementById(the_hub).width ="640";
		document.getElementById(the_hub).height ="505";
		return
	}
	document.getElementById(the_hub).width = "425";
	document.getElementById(the_hub).height = "350";
}
/*form maxlenght*/
function ismaxlength(obj){
			var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
			if (obj.getAttribute && obj.value.length>mlength)
	obj.value=obj.value.substring(0,mlength)
}
/*reload image*/
function flip(name,src){
    if (document.images)
        document.images[name].src = src+'?rand='+Math.random();
}
/*Panorama*/
var x=0,y=0;
var imageheight=0,embedheight=0;
var mousedown=0;
var prefmcord_x=0,prefmcord_y=0;
var imagecord_x=0,imagecord_y=0;
var temp;
var id;

function displaypanorama(the_hub){
    if(document.getElementById("panorama"+the_hub).style.display == 'none'){
		divs=document.getElementsByTagName('div');
		for(var i = 0; i < divs.length; i++){
			divname=divs[i].id.slice(0,8);
			if(divname == "panorama" && divs[i].name != the_hub){
				divs[i].style.display = 'none';
			}
		}
		document.getElementById("panorama"+the_hub).style.display = 'block';
	}else{
      document.getElementById("panorama"+the_hub).style.display = 'none';
    }
}
function show_coords(event,id2,up_or_down,imageheight){
	id=id2;//make id global so the arrowkey's will work.
	x=event.clientX;
	y=event.clientY;
	//document.getElementById('debug').innerHTML=" x:"+x+"-"+prefmcord_x+" y:"+y+" imagecord_y: "+embedheight+" imagecord_x:"+imagecord_x;
	if(up_or_down==1){//mouse down
		embedheight=document.getElementById('panorama'+id).offsetHeight;//height of embed
		document.getElementById('panorama'+id).style.cursor="move";
		mousedown=1;
		prefmcord_x=x;
		prefmcord_y=y;
	}else if(up_or_down==2){//mouse up
		document.getElementById('panorama'+id).style.cursor="pointer";
		mousedown=0;
	}else if(up_or_down==3){//mouse move
		if(mousedown==1){
			imagecord_x=imagecord_x-((prefmcord_x-x)*3);//horizontaal
			if(prefmcord_y>y){//naar beneden
				temp=imagecord_y-((prefmcord_y-y)*3);
				if(-(imageheight-embedheight)<temp){
					imagecord_y=temp;
				}
			}else if(prefmcord_y<y){//naar boven
				temp=imagecord_y-((prefmcord_y-y)*3);
				if(1>temp){
					imagecord_y=temp;
				}
			}
			prefmcord_x=x;
			prefmcord_y=y;
			//document.getElementById("panorama").style.height="149";
			document.getElementById("panorama"+id).style.backgroundPosition=imagecord_x+" "+imagecord_y;
		}
	}
}
document.onkeydown=function(e){
	var e=window.event || e
	//alert("CharCode value: "+e.keyCode)
		//39 ->
		//37 <-
	if(e.keyCode==39){//move right
		imagecord_x-=30;
		document.getElementById("panorama"+id).style.backgroundPosition=imagecord_x;
	}else if(e.keyCode==37){//move left
		imagecord_x+=30;
		document.getElementById("panorama"+id).style.backgroundPosition=imagecord_x;
	}
}
/*Panorama end*/