
/*device comp*/

jQuery.browser.mobile = navigator.userAgent.match(/mobile/i);
jQuery.browser.android = navigator.userAgent.match(/Android/i);
jQuery.browser.iphone = navigator.userAgent.match(/iPhone/i);
jQuery.browser.ipod = navigator.userAgent.match(/iPod/i);
jQuery.browser.ipad = navigator.userAgent.match(/iPad/i);
jQuery.browser.MSMobile = navigator.userAgent.match(/Windows Phone OS/i);
jQuery.browser.touch = jQuery.browser.android || jQuery.browser.iphone || jQuery.browser.ipod || jQuery.browser.ipad;
jQuery.browser.safari = ( jQuery.browser.safari && /chrome/.test(navigator.userAgent.toLowerCase()) ) ? false : true; 
jQuery.browser.chrome = /chrome/.test(navigator.userAgent.toLowerCase());


var searchDefText = 'Søg på siden';
	
jQuery.noConflict();
(function($) {
	$(document).ready(function () {
		clearSkype();
		
		if (backend == 0)			
			if ( jQuery('#skema').length>0 && !jQuery.browser.mobile )
				jQuery("#skema").fancybox({
					'transitionIn'		: 'elastic',
					'transitionOut'		: 'elastic',
					'autoScale'     	: true,
					'speedIn'		:	600, 
					'speedOut'		:	200, 
					'scrolling'		: 'no',
					'type'				: 'iframe',
					'width'				: 560,
					'height'			: 560,
					'titleShow'	  : false,
					'overlayOpacity': 0.45,
					'overlayColor': '#000000',
					'centerOnScroll': true
				});
		
	});
})(jQuery);

function closeSearch() {
	jQuery('#searchInput').css('display','none');
}

function showSearch() {
	jQuery('#searchInput').css('display','block');
	jQuery('#swords').focus();
}

//img preload
function preload(img_src) {
	img = new Image(); 
	img.src = img_src;
}
//img preload

function clearSkype() {  
   if(!jQuery('#skype_plugin_object').length) { return; }  
   jQuery('#skype_plugin_object').remove();  
   jQuery('span.skype_pnh_print_container').each(function() {  
     var originalPhone_ = $(this).text();  

     //get all the html that is not in print_container or container  

     var originalHTML_ = jQuery(this).parent().html();  

     jQuery(originalHTML_).find('span.skype_pnh_print_container').replaceWith(originalPhone_);  

     jQuery(originalHTML_).remove('span.skype_pnh_container');  

     jQuery(this).parent().html(jQuery(originalHTML_));  

	});  
} 

function openUrl(url,target) {
	window.open(url,target);
}

function fpFlashRep() {
	swfobject.embedSWF(
	            "/g/f___.swf", "frontpageFlash",
	            '272', '378',
	            "9.0.124", "", flashvars,
	            { autostart: 'true',
	            	showstartscreen: 'false',
	            	showendscreen: 'false',
	            	menu: 'false',
	            	loop: 'false',
	            	width: '272',
	            	height: '378',
							  wmode: 'transparent',
	            	autoplay: 0 }, {
	id : "frontSwf",
	name : "frontSwf"
	} );
}


var array=[];
// id,  speed, start delay
array[0]=['scroller',150,10];

initializemarquee = function()
{
 for (var z0=0;z0<array.length;z0++)
 {
  var cm=document.getElementById(array[z0][0]);
  if (cm) cm.parentNode.marquee=new marquee(cm,array[z0]);
  
  cm.onmouseover = function()
	{
	 cm.parentNode.marquee.stop();
	};
  cm.onmouseout = function()
	{
	 cm.parentNode.marquee.start();
	};
  
 }
}

function marquee(cm,ary)
{
 this.to=null;
 this.spd=ary[1]||50;
 cm.style.top='0px';
 this.max=-cm.offsetHeight;
 this.objs=[[cm,0],[cm.cloneNode(true),-this.max]];
 cm.parentNode.appendChild(this.objs[1][0]);
 for (var z0=0;z0<this.objs.length;z0++){
  this.objs[z0][0].style.top=this.objs[z0][1]+'px';
 }
 if (ary[2]) setTimeout(function(oop){return function(){oop.start();}}(this),ary[2]);
}

marquee.prototype.start=function()
{
 this.stop();
 for (var z0=0;z0<this.objs.length;z0++){
  this.objs[z0][1]--;
  this.objs[z0][0].style.top=this.objs[z0][1]+'px';
  if (this.objs[z0][1]==this.max) this.objs[z0][1]=-this.max;
 }
 this.to=setTimeout(function(oop){return function(){oop.start();}}(this),this.spd);
}

marquee.prototype.stop=function()
{
 clearTimeout(this.to);
}

if (window.addEventListener)
{
	window.addEventListener("load", initializemarquee, false);
}
else if (document.getElementById("scroller"))
{
	window.onload=initializemarquee();
}
else if (window.attachEvent)
{
	window.attachEvent("onload", initializemarquee);
}
