function set_bgblack(divName){
	var bodyhight=document.getElementsByTagName('body')[0].scrollHeight;
	var bodywidth=document.getElementsByTagName('body')[0].scrollWidth;
	document.getElementById(divName).style.width=bodywidth+'px';
	document.getElementById(divName).style.height=bodyhight+'px';
	//document.getElementById('yachtblock').style.zIndex="49";
}
function closeZoom(){
	var activeBlock=document.getElementById('checkBlock').value;
	document.getElementById(activeBlock).style.display='none';
	document.getElementById('zoomBlock_background').style.display='none';
}
function zoomBlockGo(block){
	document.getElementById('checkBlock').value=block;
	document.getElementById('zoomBlock_background').style.display='block';
	set_bgblack('zoomBlock_background');
	center(block);
}
function showVideoNow(url){
	alert('12');
	//myVideoFrame.src=url;
	blockWithBlackBg('videoBlock',true);
}
function showVideo(url){
	parent.parent.showVideoZipp(url);
}
function blockWithBlackBg(block,aktion){
	if(aktion==true){
		document.getElementById('checkBlock').value=block;
		document.getElementById('zoomBlock_background').style.display='block';
		set_bgblack('zoomBlock_background');
		document.getElementById(block).style.display='block';


	}else if(aktion==false){
		document.getElementById('zoomBlock_background').style.display='none';
		document.getElementById(block).style.display='none';
	}
}
function center(element){

	try{
		element = $(element);
	}catch(e){
		return;
	}

	var my_width  = 0;
	var my_height = 0;

	if ( typeof( window.innerWidth ) == 'number' ){
		my_width  = window.innerWidth;
		my_height = window.innerHeight;
	}else if ( document.documentElement &&
			 ( document.documentElement.clientWidth ||
			   document.documentElement.clientHeight ) ){
		my_width  = document.documentElement.clientWidth;
		my_height = document.documentElement.clientHeight;
	}
	else if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) ){
		my_width  = document.body.clientWidth;
		my_height = document.body.clientHeight;
	}

	//element.style.position = 'absolute';
	element.style.zIndex   = 9999;

	var scrollY = 0;

	if ( document.documentElement && document.documentElement.scrollTop ){
		scrollY = document.documentElement.scrollTop;
	}else if ( document.body && document.body.scrollTop ){
		scrollY = document.body.scrollTop;
	}else if ( window.pageYOffset ){
		scrollY = window.pageYOffset;
	}else if ( window.scrollY ){
		scrollY = window.scrollY;
	}

	var elementDimensions = Element.getDimensions(element);

	var setX = ( my_width  - elementDimensions.width  ) / 2;
	var setY = ( my_height - elementDimensions.height ) / 2 + scrollY;

	setX = ( setX < 0 ) ? 0 : setX;
	setY = ( setY < 0 ) ? 0 : setY;

	element.style.left = 110 + "px";
	element.style.top  = 50 + "px";
	element.style.display="block";
}

function startZoomPic(){
	var x=document.getElementById('start_zoom_url').value;
	zoomDaPic(x);
}

var fokussedSize={height:0, width:0};
function zoomDaPic(picUrl){
	if(picUrl!=""){
		document.getElementById('actUrlHidden').value=picUrl;
		var imgHtml="";
		var puffer=0, puffer2=0, erg=0, erg2=0;
		var blockHoehe=486;
		var blockBreite=476;
		imageObject = new Image();
		imageObject.src = picUrl;

		if(imageObject.complete==true){
			var imgWidth=imageObject.width;
			var imgHeight=imageObject.height;
			if(imgWidth ==imgHeight && imgHeight>430){
				fokussedSize.height=430;
				fokussedSize.width=430;
				imgHtml="<img src='"+picUrl+"' alt='' style='width:430px;height:430px;display:block;margin-top:27px;margin-left:23px;' id='zP' />"
				document.getElementById("zoomPicBox").innerHTML =imgHtml;
			}else if(imgWidth >imgHeight && imgWidth > 430){
				erg=imgWidth/430;
				erg2=imgHeight/erg;
				puffer=(blockHoehe-erg2)/2;
				imgHtml="<img src='"+picUrl+"' alt='' style='width:430px;height:"+erg2+"px;display:block;margin-left:23px;margin-top:"+puffer+"px;' id='zP' />"
				document.getElementById("zoomPicBox").innerHTML =imgHtml;
				fokussedSize.height=erg2;
				fokussedSize.width=430;
				puffer=0;
			}else if(imgWidth < imgHeight && imgHeight > 430 ){
				erg=imgHeight/430;
				erg2=imgWidth/erg;
				puffer=(blockBreite-erg2)/2;
				imgHtml="<img src='"+picUrl+"' alt='' style='height:430px;width:"+erg2+"px;display:block;margin-top:23px;margin-left:"+puffer+"px;' id='zP' />"
				document.getElementById("zoomPicBox").innerHTML =imgHtml;
				fokussedSize.height=430;
				fokussedSize.width=erg2;
				puffer=0;
				erg=0;erg2=0;
			}else{
				puffer=(blockBreite-imgWidth)/2;
				puffer2=(blockHoehe-imgHeight)/2;
				imgHtml="<img src='"+picUrl+"' alt='' style='display:block;margin-left:"+puffer+"px;margin-top:"+puffer2+"px;' id='zP' />"
				document.getElementById("zoomPicBox").innerHTML =imgHtml;
				fokussedSize.height=imgHeight;
				fokussedSize.width=imgWidth;
				puffer=0;
				puffer2=0;
			}
		}else{

				window.setTimeout("zoomDaPic('"+picUrl+"')",100);
		}
		new Draggable('zP',{handle:'handle2', onEnd:function(){getActPos()}});
	}
}



var actPos={left:0, top:0};
var vcache=1;
function fokusZoom(v,imgUrl){
	imageObject = new Image();
	imageObject.src = imgUrl;

	var imgHeight=fokussedSize.height;
	var imgWidth=fokussedSize.width;
	var ergW,endW,ergH,endH;
	if(imageObject.height>=530 && imageObject.width>=530){
		ergH=imageObject.height-430;
		endH=(ergH/100)*v;
		endH=endH+imgHeight;

		ergW=imageObject.width-430;
		endW=(ergW/100)*v;
		endW=endW+imgWidth;
	}else{
		ergW=(imgWidth/100)*v;
		endW=ergW+imgWidth;

		ergH=(imgHeight/100)*v;
		endH=ergH+imgHeight;
	}

	if(vcache!=v){
		document.getElementById('zP').style.height=endH+'px';
		document.getElementById('zP').style.width=endW+'px';
	}
	vcache=v;
}

function zoomChange(v){
	var actUrl=	document.getElementById('actUrlHidden').value;
	fokusZoom(v,actUrl);
}

function getActPos(){
	var obj = document.getElementById('zP');
	var pos = {left:0, top:0};
	if(typeof obj.offsetLeft != 'undefined'){
		while (obj)	{
			pos.left += obj.offsetLeft;
			pos.top += obj.offsetTop;
			obj = obj.offsetParent;
		}
	}else{
		pos.left = obj.left ;
		pos.top = obj.top ;
	}
	actPos.left=pos.left;
	actPos.top=pos.top;
	//document.getElementById('debug5').innerHTML=actPos.left+" -- "+actPos.top;
}

function resetZoomPic(){
	actPos={left:0, top:0};
	vcache=0;
	fokussedSize.height=0;
	fokussedSize.width=0;
	startZoomPic();
	document.getElementById('zP').style.left=-7+'px';
	document.getElementById('zP').style.top=-7+'px';
	document.getElementById('handle3').style.left=0+'px';
	document.getElementById('debug3').innerHTML="0";
}