// This  js pluginn is made, because I got tierd of working whit non-working javascript frameworks like nyromodal and tickbox... This is how it is done whitout  bugs!
function priInitSet(){
	////$("#masker").css("display", "none");
	var heigth_of_doc =($(window).height()-1);
	var width_of_doc =($(window).width()-1);
	//////alert($("#masker").width());
	$("#masker").css("width", width_of_doc);
	$("#masker").css("height", heigth_of_doc);
	//////alert($("#masker").width());
	$("#maskica").css("width", width_of_doc);
	$("#maskica").css("height", heigth_of_doc);
	//$("#maskica").css("display" "none");
	$("#masker").css("display","none");
	
	$("#Ftitle").css("display", "none");
	$("#Ftitle").css("width", "auto");
	$("#Ftitle").css("height", "auto");
	$("#Ftitle").css("z-index", "802");
	
	$("#Ftitle").css("position", "fixed");
	$("#mainloader").css("background-color", "#000");
	$("#dispRight").html("<img src='img/flashbox/right.gif' />");
	$("#dispLeft").html("<img src='img/flashbox/left.gif' />");
	$("#dispRight").css('display', 'none');
	$("#dispLeft").css('display', 'none');
	$("#dispLeft").css('z-index', '703');
	$("#dispRight").css('z-index', '702');
	$("#dispLeft").css('position', 'fixed');
	$("#dispRight").css('position', 'fixed');
	$("#hotSpotLeft").css('display','none');
	$("#hotSpotLeft").css('width','auto');
	$("#hotSpotLeft").css('height','auto');
	$("#hotSpotLeft").css('z-index','800');
	$("#hotSpotLeft").css('position','fixed');
	$("#hotSpotLeft").css('border','none');
	$("#hotSpotLeft").html("<img src='img/flashbox/hotspot.gif' id='leftspot' onClick='goLeft()'/>");
	
	$("#hotSpotRight").css('display','none');
	$("#hotSpotRight").css('width','auto');
	$("#hotSpotRight").css('height','auto');
	$("#hotSpotRight").css('z-index','801');
	$("#hotSpotRight").css('position','fixed');
	$("#hotSpotRight").css('border','none');
	$("#hotSpotRight").html("<img src='img/flashbox/hotspot.gif' id='rightspot' onClick='goRight()'/>")

	$("#mainloader").css('position', 'fixed');
	$("#closeButton").css('position', 'fixed');
	$("#loadgif").css('position', 'fixed');
	$("#closeButton").css("display","none");
	$("#closeButton").html("<a href='javascript:initSet()'><img src='img/flashbox/close.gif'/></a>");
	$("#loadgif").css("display",'none');
	$("#loadgif").html("<img src = 'img/flashbox/ajaxLoader.gif' />");
	$("#mainloader").css( 'z-index', '700');
	$("#closeButton").css('z-index', '500')
	$("#loadgif").css("z-index",'501');
	initSet();
	
}
function initSet(){
	//alert("initSet");
	$("#masker").css("display", "none");
  	$('#mainloader').css("display", "none");
	$("#hotSpotLeft").css('display','none');
	$("#hotSpotRight").css('display','none');
	$("#dispLeft").css('display', 'none');
	$("#dispRight").css("display", "none");
	$("#hotSpotLeft").html("<img src='img/flashbox/hotspot.gif' id='leftspot' onClick='goLeft()'/>");
	$("#hotSpotRight").html("<img src='img/flashbox/hotspot.gif' id='rightspot' onClick='goRight()'/>")
	$("#closeButton").css("display","none"); 
	$("#loadgif").css("display",'none');
	$("#Ftitle").css("display", "none");
		
}

function initSetTwo (){
	$("#hotSpotLeft").css('display','none');
	$("#hotSpotRight").css('display','none');
	$("#dispLeft").css('display', 'none');
	$("#dispRight").css("display", "none");
	$("#hotSpotLeft").html("<img src='img/flashbox/hotspot.gif' id='leftspot' onClick='goLeft()'/>");
	$("#hotSpotRight").html("<img src='img/flashbox/hotspot.gif' id='rightspot' onClick='goRight()'/>")
	$("#closeButton").css("display","none"); 
	$("#mainloader").css( "display",'none');
	$("#loadgif").css("display",'none');
	$("#Ftitle").css("display", "none");
}
	
$(document).ready(function() {
	priInitSet();
});
function openImageEvent(imageUrl){
	////alert("imageUrl" + imageUrl);
	$("#hotSpotLeft").html("<img src='img/flashbox/hotspot.gif' id='leftspot' onClick = 'goLeftEvent()'/>");
	$("#hotSpotRight").html("<img src='img/flashbox/hotspot.gif' id='rightspot' onClick = 'goRightEvent()'/>");
	var heigth_of_doc =($(window).height()-1);
	var width_of_doc =($(window).width()-1);

	$("#closeButton").css("display","none");
	$("#mainloader").css("display",'none');
	var prviy = ($("#loadgif").height()/2);
	var kalkulacijay = ((($(window).height()-1))/2) - prviy;
	var prvix = ($("#loadgif").width()/2);
	var kalkulacijax = ((($(window).width()-1))/2) - prvix;
	$("#loadgif").css("top", kalkulacijay);
	$("#loadgif").css("left", kalkulacijax);
	$("#loadgif").css('display','block');
	
	var loaderWidth = $("#mainloader").height();
	var FrameWidth = $("#mainloader").width();
	
	$("#mainloader").css( "width",'auto');
	$("#mainloader").css( "height",'auto');
	setTimeout(openMask, 100);
	
	////alert("main load");
	$('#mainloader').html("<img src='"+ imageUrl + "' id='mainerr' /> ");
   	setTimeout ( tempload, 1000 );

	function openMask(){
		$("#masker").css("display", "block");
	}
	function tempload (){
		////alert("temp load");
		////alert(imageUrl);
   			//temp load is safe load!
			setTimeout (safeLoad, 1000 );
			//$("#masker").css("display", "block");
	}
    function safeLoad(){
		
		$("#loadgif").css("display", "none")
		
		$("#mainloader").css( "z-index", '501');
		
		var heigth_of_doc =($(window).height()-1);
		var width_of_doc =($(window).width()-1);
    	
		
		var Frameheight = $("#mainloader").height();
		var FrameWidth = $("#mainloader").width();
		
		if(Frameheight>heigth_of_doc){
			 
			 var eksHeight = Frameheight;
			 var eksWidth = FrameWidth;
			 var newProportion = Frameheight / (heigth_of_doc-50);
			 var Frameheight = eksHeight/newProportion;
			 var FrameWidth = eksWidth/newProportion;
			
		
			$("#hotSpotLeft").css("width", FrameWidth/2);
			$("#hotSpotLeft").css("height", Frameheight);
		
			$("#mainloader").css("left", (width_of_doc - FrameWidth)/2 + "px");
			$("#mainloader").css("top", (heigth_of_doc -Frameheight )/2 + "px");
			$("#mainloader").css( "display",'none');
			////////alert("the case" + Frameheight)
			
			 ////////alert("rekonfigured" +Frameheight )
			 
			$("#mainloader").css("width","auto");
			$("#mainloader").css("height","auto");
			$("#mainLoadedImage").css("height", Frameheight-1+"px");
			$("#mainLoadedImage").css("width", FrameWidth-1 + "px");
			$("#mainloader").css("height",Frameheight+ "px");
			$("#mainloader").css("width",FrameWidth+ "px");
			$("#mainerr").css("width", FrameWidth + "px");
			$("#mainerr").css("height",Frameheight+ "px");
			$("#mainloader").css( "display",'block');
			
			
			$("#mainloader").css("left", (width_of_doc - FrameWidth)/2 + "px");
			$("#mainloader").css("top", (heigth_of_doc -Frameheight )/2 + "px");
			
			
			 
			$("#leftspot").css("width", FrameWidth/2+ "px");
			$("#leftspot").css("height", Frameheight + "px");
			
			
		
			$("#rightspot").css("width", FrameWidth/2 + "px");
			$("#rightspot").css("height", Frameheight + "px");
		
		
		
			$("#hotSpotLeft").css("left", (width_of_doc - FrameWidth)/2 + "px");
			$("#hotSpotLeft").css("top", (heigth_of_doc -Frameheight )/2 + "px");
			$("#hotSpotLeft").css('display','block');
			
			var constantW = ((width_of_doc - FrameWidth)/2);
			var constantH = (heigth_of_doc - Frameheight )/2;
		
			$("#hotSpotRight").css("left", constantW + $("#hotSpotLeft").width() + "px");
			$("#hotSpotRight").css("top", constantH + "px");
			$("#dispRight").css("left",  constantW + ($("#hotSpotLeft").width()+ $("#hotSpotRight").width())-$("#dispRight").width() - 2 + "px");
			$("#dispRight").css("top",  constantH + ($("#hotSpotRight").height()/2)) +"px";
			//$("#dispRight").css("display", "block");
			
			$("#dispLeft").css('left', constantW + "px");
			$("#dispLeft").css('top', constantH + (Frameheight/2) + "px");
			//$("#dispLeft").css('display', 'block');
			
			$("#hotSpotRight").css("display", "block");
		
		
			$("#closeButton").css("width","auto");
			$("#closeButton").css("height", "auto");
			$("#closeButton").css("left",((width_of_doc - FrameWidth)/2)+ FrameWidth + "px");
			$("#closeButton").css("top", ((heigth_of_doc -Frameheight )/2)-$("#closeButton").height() +"px");
			$("#closeButton").css('z-index', '502');
			$("#closeButton").css("display", "block");
			
		}else{
		
	
		$("#hotSpotLeft").css("width", FrameWidth/2);
			$("#hotSpotLeft").css("height", Frameheight);
		
			$("#mainloader").css("left", (width_of_doc - FrameWidth)/2 + "px");
			$("#mainloader").css("top", (heigth_of_doc -Frameheight )/2 + "px");
			$("#mainloader").css( "display",'none');
			////////alert("the case" + Frameheight)
			
			 ////////alert("rekonfigured" +Frameheight )
			 
			$("#mainloader").css("width","auto");
			$("#mainloader").css("height","auto");
			$("#mainLoadedImage").css("height", Frameheight-1+"px");
			$("#mainLoadedImage").css("width", FrameWidth-1 + "px");
			$("#mainloader").css("height",Frameheight+ "px");
			$("#mainloader").css("width",FrameWidth+ "px");
			$("#mainloader").css( "display",'block');
			
			
			$("#mainloader").css("left", (width_of_doc - FrameWidth)/2 + "px");
			$("#mainloader").css("top", (heigth_of_doc -Frameheight )/2 + "px");
			
			
			 
			$("#leftspot").css("width", FrameWidth/2+ "px");
			$("#leftspot").css("height", Frameheight + "px");
			
			
		
			$("#rightspot").css("width", FrameWidth/2 + "px");
			$("#rightspot").css("height", Frameheight + "px");
		
		
		
			$("#hotSpotLeft").css("left", (width_of_doc - FrameWidth)/2 + "px");
			$("#hotSpotLeft").css("top", (heigth_of_doc -Frameheight )/2 + "px");
			$("#hotSpotLeft").css('display','block');
			
			var constantW = ((width_of_doc - FrameWidth)/2);
			var constantH = (heigth_of_doc - Frameheight )/2;
		
			$("#hotSpotRight").css("left", constantW + $("#hotSpotLeft").width() + "px");
			$("#hotSpotRight").css("top", constantH + "px");
			$("#dispRight").css("left",  constantW + ($("#hotSpotLeft").width()+ $("#hotSpotRight").width())-$("#dispRight").width()  + "px");
			$("#dispRight").css("top",  constantH + ($("#hotSpotRight").height()/2)) +"px";
			//$("#dispRight").css("display", "block");
			
												
			
			$("#dispLeft").css('left', constantW + "px");
			$("#dispLeft").css('top', constantH + (Frameheight/2) + "px");
			//$("#dispLeft").css('display', 'block');
			
			$("#hotSpotRight").css("display", "block");
		
		
			$("#closeButton").css("width","auto");
			$("#closeButton").css("height", "auto");
			$("#closeButton").css("left",((width_of_doc - FrameWidth)/2)+ FrameWidth + "px");
			$("#closeButton").css("top", ((heigth_of_doc -Frameheight )/2)-$("#closeButton").height() +"px");
			$("#closeButton").css('z-index', '502');
			$("#closeButton").css("display", "block");
		}

	}
}


function openImage(imageUrl){
	////////alert('open image');

	var heigth_of_doc =($(window).height()-1);
	var width_of_doc =($(window).width()-1);

	$("#closeButton").css("display","none");
	$("#mainloader").css("display",'none');
	var prviy = ($("#loadgif").height()/2);
	var kalkulacijay = ((($(window).height()-1))/2) - prviy;
	var prvix = ($("#loadgif").width()/2);
	var kalkulacijax = ((($(window).width()-1))/2) - prvix;
	$("#loadgif").css("top", kalkulacijay);
	$("#loadgif").css("left", kalkulacijax);
	$("#loadgif").css('display','block');
	
	var loaderWidth = $("#mainloader").height();
	var FrameWidth = $("#mainloader").width();
	
	$("#mainloader").css( "width",'auto');
	$("#mainloader").css( "height",'auto');
	setTimeout(openMask, 100);
	
	////alert(imageUrl);
	$('#mainloader').html("<img src='"+ unescape(imageUrl) + "' id ='mainer'/> ");
   		setTimeout ( tempload, 1000 );


	function openMask(){
		$("#masker").css("display", "block");
	}
	function tempload (){
	
	
   			//temp load is safe load!
			setTimeout (safeLoad, 50 );
			//$("#masker").css("display", "block");


	}
    function safeLoad(){
		
		$("#loadgif").css("display", "none")
		
		$("#mainloader").css( "z-index", '501');
		
		var heigth_of_doc =($(window).height()-1);
		var width_of_doc =($(window).width()-1);
    	
		
		var Frameheight = $("#mainloader").height();
		var FrameWidth = $("#mainloader").width();
		
		if(Frameheight>heigth_of_doc){
			 
			 var eksHeight = Frameheight;
			 var eksWidth = FrameWidth;
			 var newProportion = Frameheight / (heigth_of_doc-50);
			 var Frameheight = eksHeight/newProportion;
			 var FrameWidth = eksWidth/newProportion;
			
		
			$("#hotSpotLeft").css("width", FrameWidth/2);
			$("#hotSpotLeft").css("height", Frameheight);
		
			$("#mainloader").css("left", (width_of_doc - FrameWidth)/2 + "px");
			$("#mainloader").css("top", (heigth_of_doc -Frameheight )/2 + "px");
			$("#mainloader").css( "display",'none');
			////////alert("the case" + Frameheight)
			
			 ////////alert("rekonfigured" +Frameheight )
			 
			$("#mainloader").css("width","auto");
			$("#mainloader").css("height","auto");
			$("#mainLoadedImage").css("height", Frameheight-1+"px");
			$("#mainLoadedImage").css("width", FrameWidth-1 + "px");
			$("#mainloader").css("height",Frameheight+ "px");
			$("#mainloader").css("width",FrameWidth+ "px");
			$("#mainer").css("width", FrameWidth + "px");
			$("#mainer").css("height",Frameheight+ "px");
			$("#mainloader").css( "display",'block');
			
			
			$("#mainloader").css("left", (width_of_doc - FrameWidth)/2 + "px");
			$("#mainloader").css("top", (heigth_of_doc -Frameheight )/2 + "px");
			
			
			 
			$("#leftspot").css("width", FrameWidth/2+ "px");
			$("#leftspot").css("height", Frameheight + "px");
			
			
		
			$("#rightspot").css("width", FrameWidth/2 + "px");
			$("#rightspot").css("height", Frameheight + "px");
		
		
		
			$("#hotSpotLeft").css("left", (width_of_doc - FrameWidth)/2 + "px");
			$("#hotSpotLeft").css("top", (heigth_of_doc -Frameheight )/2 + "px");
			$("#hotSpotLeft").css('display','block');
			
			var constantW = ((width_of_doc - FrameWidth)/2);
			var constantH = (heigth_of_doc - Frameheight )/2;
		
			$("#hotSpotRight").css("left", constantW + $("#hotSpotLeft").width() + "px");
			$("#hotSpotRight").css("top", constantH + "px");
			$("#dispRight").css("left",  constantW + ($("#hotSpotLeft").width()+ $("#hotSpotRight").width())-$("#dispRight").width() - 2 + "px");
			$("#dispRight").css("top",  constantH + ($("#hotSpotRight").height()/2)) +"px";
			//$("#dispRight").css("display", "block");
			
			$("#dispLeft").css('left', constantW + "px");
			$("#dispLeft").css('top', constantH + (Frameheight/2) + "px");
			//$("#dispLeft").css('display', 'block');
			
			$("#hotSpotRight").css("display", "block");
		
		
			$("#closeButton").css("width","auto");
			$("#closeButton").css("height", "auto");
			$("#closeButton").css("left",((width_of_doc - FrameWidth)/2)+ FrameWidth + "px");
			$("#closeButton").css("top", ((heigth_of_doc -Frameheight )/2)-$("#closeButton").height() +"px");
			$("#closeButton").css('z-index', '502');
			$("#closeButton").css("display", "block");
			
		}else{
		
	
		$("#hotSpotLeft").css("width", FrameWidth/2);
			$("#hotSpotLeft").css("height", Frameheight);
		
			$("#mainloader").css("left", (width_of_doc - FrameWidth)/2 + "px");
			$("#mainloader").css("top", (heigth_of_doc -Frameheight )/2 + "px");
			$("#mainloader").css( "display",'none');
			////////alert("the case" + Frameheight)
			
			 ////////alert("rekonfigured" +Frameheight )
			 
			$("#mainloader").css("width","auto");
			$("#mainloader").css("height","auto");
			$("#mainLoadedImage").css("height", Frameheight-1+"px");
			$("#mainLoadedImage").css("width", FrameWidth-1 + "px");
			$("#mainloader").css("height",Frameheight+ "px");
			$("#mainloader").css("width",FrameWidth+ "px");
			$("#mainloader").css( "display",'block');
			
			
			$("#mainloader").css("left", (width_of_doc - FrameWidth)/2 + "px");
			$("#mainloader").css("top", (heigth_of_doc -Frameheight )/2 + "px");
			
			
			 
			$("#leftspot").css("width", FrameWidth/2+ "px");
			$("#leftspot").css("height", Frameheight + "px");
			
			
		
			$("#rightspot").css("width", FrameWidth/2 + "px");
			$("#rightspot").css("height", Frameheight + "px");
		
		
		
			$("#hotSpotLeft").css("left", (width_of_doc - FrameWidth)/2 + "px");
			$("#hotSpotLeft").css("top", (heigth_of_doc -Frameheight )/2 + "px");
			$("#hotSpotLeft").css('display','block');
			
			var constantW = ((width_of_doc - FrameWidth)/2);
			var constantH = (heigth_of_doc - Frameheight )/2;
		
			$("#hotSpotRight").css("left", constantW + $("#hotSpotLeft").width() + "px");
			$("#hotSpotRight").css("top", constantH + "px");
			$("#dispRight").css("left",  constantW + ($("#hotSpotLeft").width()+ $("#hotSpotRight").width())-$("#dispRight").width()  + "px");
			$("#dispRight").css("top",  constantH + ($("#hotSpotRight").height()/2)) +"px";
			//$("#dispRight").css("display", "block");
			
												
			
			$("#dispLeft").css('left', constantW + "px");
			$("#dispLeft").css('top', constantH + (Frameheight/2) + "px");
			//$("#dispLeft").css('display', 'block');
			
			$("#hotSpotRight").css("display", "block");
		
		
			$("#closeButton").css("width","auto");
			$("#closeButton").css("height", "auto");
			$("#closeButton").css("left",((width_of_doc - FrameWidth)/2)+ FrameWidth + "px");
			$("#closeButton").css("top", ((heigth_of_doc -Frameheight )/2)-$("#closeButton").height() +"px");
			$("#closeButton").css('z-index', '502');
			$("#closeButton").css("display", "block");
		}

	}
}
$(document).ready(function(){

$("#hotSpotRight").hover( 
	function () {												
		$("#dispRight").css("display", "block");
	},
	function (){
		$("#dispRight").css("display", "none");
	}
	
	);
});

$(document).ready(function(){
	$("#hotSpotLeft").hover( 
		function () {
			$("#dispLeft").css("display", "block");
		},
		function (){
		$("#dispLeft").css("display", "none");
		}
		);
})

function openIframe(url,fborder,fheight,fweight,fname,fscroll,Ftitle){
	
	$("#cms_indicator").load("cms/ifLoged.php");
	var heigth_of_doc =($(window).height()-1);
	var width_of_doc =($(window).width()-1);
	
	
	var Frameheight = fheight;
	var FrameWidth = fweight;
	
	var prviy = ($("#loadgif").height()/2);
	var kalkulacijay = ((($(window).height()-1))/2) - prviy;
	var prvix = ($("#loadgif").width()/2);
	var kalkulacijax = ((($(window).width()-1))/2) - prvix;
	$("#loadgif").css("top", kalkulacijay);
	$("#loadgif").css("left", kalkulacijax);
	$("#loadgif").css('display','block');
	
	$("#mainloader").html("");
	$("#mainloader").css("background-color","#FFFFFF");
	$("#mainloader").html("<iframe src='"+unescape(url)+"' height='"+fheight+"px' width='"+fweight+"px' name = '"+fname+"' scrolling = '"+fscroll+"' frameborder='1' style='background-color:#333;' ></iframe>");
	$("#mainloader").css("left", (width_of_doc - FrameWidth)/2 + "px");
	$("#mainloader").css("top", (heigth_of_doc -Frameheight )/2 + "px");

	
	
	$("#masker").css("width", width_of_doc);
	$("#masker").css("height", heigth_of_doc);
	
	$("#flashmask").css("display", "block");
	$("#closeButton").css("left",((width_of_doc - FrameWidth)/2)+ FrameWidth + "px");
	$("#closeButton").css("top", ((heigth_of_doc -Frameheight )/2)+"px");
	$("#Ftitle").html("");
	$("#Ftitle").css("top", ((heigth_of_doc -Frameheight )/2)-$("#closeButton").height() +"px");
	$("#Ftitle").css("left", (width_of_doc - FrameWidth)/2 + "px");
	$("#closeButton").css('z-index', '502');
	setTimeout(safeloadOfFrame, 1000);
	
}
function openMask(){
		$("#masker").css("display", "block");
}
function safeloadOfFrame(){
	$("#masker").css("display", "block");
	$("#loadgif").css('display','none');
	$("#mainloader").css("display", "block");
	$("#mainloader").focus();
	$("#mainloader").focus();
	$("#mainloader").focus();
	$("#mainloader").focus();
	$("#mainloader").focus();
	$("#mainloader").focus();
	$("#mainloader").focus();
	$("#mainloader").focus();
	$("#mainloader").focus();
	$("#mainloader").focus();
	$("#mainloader").focus();
	$("#closeButton").css("display", "block");
	$("#Ftitle").css("display","block");
	
}

