// JavaScript Document
function panoVideo(src, w, h)
{
	var top = (jQuery('window').scrollTop() + jQuery(window).height()/2)- h/2 // y pos
	// holder div
	var overlay  = '<div id="overlay" style="width:100%;height:100%;z-index:100;position:absolute;display:none;top:0;left:0;" >'
		overlay += 	'<div id="panorama_holder" style="width:100px;height:300px;margin:auto;margin-top:'+top+'px;" >'
		overlay += '<div id="panoramaSWF"></div>'
		overlay += '<div id="panoramaFooter" style="display:none;" ><a href="javascript:closeOverlay()"><img src="img/lightbox/closelabel.gif" alt="close"/></a>'
		overlay += '</div></div>'

	// ubaci div
	jQuery('body').prepend(overlay)
	
	// ubaci crni bg
	var bh = jQuery('body').height();
	jQuery('body').prepend('<div class="modalOverLay"></div>');
    jQuery('.modalOverLay').css({ opacity: 0.8, width: '100%', height: bh+'px' });
    
	jQuery('.modalOverLay').fadeIn('slow' , function (){
												 
		// animiraj holder
		jQuery('#overlay').fadeIn(500);
		jQuery('#panorama_holder').animate({width:w+"px"} , 500 ,  function(){
			jQuery('#panorama_holder').animate({height:h+"px"} , 500 , embed)
		})
		jQuery('#panoramaSWF').animate({height:h+"px"} , 500 )
	});
	
	setCookie("vid" , src)
	// ubaci flash
	function embed(){
		var swf = createswf("krpano/video_krpano.swf", "krpanoSWFObject", w , h);
		swf.addParam("wmode", "direct");
		swf.addVariable("xml", "krpano/krpano_video.asp");
		swf.addVariable("license","krpano/krpano_lic.xml");
		swf.embed("panoramaSWF");
		
		jQuery('#panorama_holder').animate({height:(h+25)+"px"} , 200 , function(){ jQuery('#panoramaFooter').fadeIn(200) })
	}
}
function showPanorama(src, w, h)
{	
	var top = (jQuery('window').scrollTop() + jQuery(window).height()/2)- h/2 // y pos
	// holder div
	var overlay  = '<div id="overlay" style="width:100%;height:100%;z-index:100;position:absolute;display:none;top:0;left:0;" >'
		overlay += 	'<div id="panorama_holder" style="width:100px;height:300px;margin:auto;margin-top:'+top+'px;" >'
		overlay += 	'<div id="panoramaSWF"></div>'
		overlay += 	'<div id="panoramaFooter" style="display:none;" ><a href="javascript:closeOverlay()"><img src="img/lightbox/closelabel.gif" alt="close"/></a></div>'
		overlay += '</div></div>'

	// ubaci div
	jQuery('body').prepend(overlay)
	
	// ubaci crni bg
	var bh = jQuery(document).height();
	jQuery('body').prepend('<div class="modalOverLay"></div>');
    jQuery('.modalOverLay').css({ opacity: 0.8, width: '100%', height: bh+'px' , "z-index":100 , position:'absolute' , backgroundColor:'#000' });
    
	// fade in crna pozadina
	jQuery('.modalOverLay').fadeIn('slow' , function (){
		
		// animiraj holder
		jQuery('#overlay').fadeIn(500);
		jQuery('#panorama_holder').animate({width:w+"px"} , 500 ,  function(){
			jQuery('#panorama_holder').animate({height:h+"px"} , 500 , embed)
		})
		jQuery('#panoramaSWF').animate({height:h+"px"} , 500 )
	});
	
	// ubaci flash
	function embed(){
		/*var flashvars = {};
		jQuery('#panoramaSWF').flash(
			{ src:src, width: w, height:h, flashvars:flashvars  , AllowScriptAccess:"always" , allowfullscreen:"true"},
			{ version: 9, expressInstall: true}*/
		var swf = createswf("krpano/krpano.swf", "krpanoSWFObject", w , h);
		swf.addParam("wmode", "direct");
		swf.addVariable("xml", "krpano/krpano.asp?img="+src);
		swf.addVariable("license","krpano/krpano_lic.xml");
		swf.embed("panoramaSWF");
		
		jQuery('#panorama_holder').animate({height:(h+25)+"px"} , 200 , function(){ jQuery('#panoramaFooter').fadeIn(200) })
		// fade in swf
		/*jQuery('#panoramaSWF').fadeIn(200 ,  function(){
			jQuery('#panorama_holder').animate({height:(h+20)+"px"} , 200 , function(){ jQuery('#panoramaFooter').fadeIn(50) }) // pokazi footer
		});*/
	}
}
function krpanoMap(w , h , src)
{
	// src
	if(src==null){src="karta.xml"}
	if(w=="w"){w = (jQuery(window).width()-40)}
	if(h=="h"){h = (jQuery(window).height()-100)}
	
	//jQuery(window).scrollTop(0)
	var top = (jQuery(window).scrollTop() + jQuery(window).height()/2)- h/2 -20// y pos
	// holder div
	var overlay  = '<div id="overlay" style="width:100%;height:100%;z-index:100;position:absolute;display:none;top:0;left:0;" >'
		overlay += 	'<div id="panorama_holder" style="width:100px;height:300px;margin:auto;margin-top:'+top+'px;" >'
		overlay += 	'<div id="panoramaSWF"></div>'
		overlay += 	'<div id="panoramaFooter" style="display:none;" ><a href="javascript:closeOverlay()"><img src="img/lightbox/closelabel.gif" alt="close"/></a></div>'
		overlay += '</div></div>'

	// ubaci div
	jQuery('body').prepend(overlay)
	
	// ubaci crni bg
	var bh = jQuery(document).height();
	jQuery('body').prepend('<div class="modalOverLay"></div>');
    jQuery('.modalOverLay').css({ opacity: 0.8, width: '100%', height: bh+'px' , "z-index":100 , position:'absolute' , backgroundColor:'#000' });
    
	// fade in crna pozadina
	jQuery('.modalOverLay').fadeIn('slow' , function (){
		
		// animiraj holder
		jQuery('#overlay').fadeIn(500);
		jQuery('#panorama_holder').animate({width:w+"px"} , 500 ,  function(){
			jQuery('#panorama_holder').animate({height:h+"px"} , 500 , embed)
		})
		jQuery('#panoramaSWF').animate({height:h+"px"} , 500 )
	});
	
	// ubaci flash
	function embed(){
		/*var flashvars = {};
		jQuery('#panoramaSWF').flash(
			{ src:src, width: w, height:h, flashvars:flashvars  , AllowScriptAccess:"always" , allowfullscreen:"true"},
			{ version: 9, expressInstall: true}*/
		var swf = createswf("krpano/krpano.swf", "krpanoSWFObject", w , h);
		swf.addParam("wmode", "direct");
		swf.addVariable("xml", "krpano/"+src);
		swf.addVariable("license","krpano/krpano_lic.xml");
		swf.embed("panoramaSWF");
		
		jQuery('#panorama_holder').animate({height:(h+25)+"px"} , 200 , function(){ jQuery('#panoramaFooter').fadeIn(200) })
		// fade in swf
		/*jQuery('#panoramaSWF').fadeIn(200 ,  function(){
			jQuery('#panorama_holder').animate({height:(h+20)+"px"} , 200 , function(){ jQuery('#panoramaFooter').fadeIn(50) }) // pokazi footer
		});*/
	}	
	jQuery("body").css("overflow", "hidden");

}

function closeOverlay()
{
	// fade out i remove
	jQuery('#overlay').fadeOut(100);	
	jQuery('.modalOverLay').fadeOut('slow' , function(){  jQuery(this).remove() ;jQuery('#overlay').remove()}) 
	jQuery("body").css("overflow", "auto");
	//window.removeEventListener('DOMMouseScroll',krpmw_we, false)
	//document.removeEventListener('DOMMouseScroll',krpmw_we, false)
}
function setCookie(name, value) {
	var expires = new Date();
	expires.setDate(expires.getDate()+1);
	document.cookie = name + "=" + escape(value) + "; path=/" + ((expires == null) ? "" : "; expires=" + expires.toGMTString());
} 
