
function chattjek(){
	var xmlHttp;
	try{
		xmlHttp=new XMLHttpRequest();
	}
	catch (e){
		try{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e){
			try{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e){
				return false;
			}
		}
	}
	xmlHttp.onreadystatechange=function(){
		if(xmlHttp.readyState==4){
			resultat=xmlHttp.responseText;
			if (resultat.indexOf("Y teambenns : ONLINE")>3){
				document.getElementById("chatimg").src="/gfx/vm_skiferie/btn_chat_online.jpg";
			}else{
				document.getElementById("chatimg").src="/gfx/vm_skiferie/btn_chat_offline.jpg";
			}
		}
	}
	xmlHttp.open("GET","/ajax/vmski_proxy_chat.php?cache="+new Date().getTime(),true);
	xmlHttp.send(null);
}


/** jTabs **/

$jq(function () {
	var tabContainers = $jq('div#tabContainer > div');
	tabContainers.hide().filter(':first').show();
	
	$jq('div#tabContainer ul.tabNavigation a').click(function () {
		tabContainers.hide();
		tabContainers.filter(this.hash).show();
		$jq('div#tabContainer ul.tabNavigation a').removeClass('selected');
		$jq(this).addClass('selected');
		return false;
	}).filter('.selected').click();
});

	
	/* 
Simple JQuery menu.
HTML structure to use:

Notes: 

Each menu MUST have a class 'menu' set. If the menu doesn't have this, the JS won't make it dynamic
If you want a panel to be expanded at page load, give the containing LI element the classname 'expand'.
Use this to set the right state in your page (generation) code.

Optional extra classnames for the UL element that holds an accordion:

noaccordion : no accordion functionality
collapsible : menu works like an accordion but can be fully collapsed

<ul class="menu [optional class] [optional class]">
<li><a href="#">Sub menu heading</a>
<ul>
<li><a href="http://site.com/">Link</a></li>
<li><a href="http://site.com/">Link</a></li>
<li><a href="http://site.com/">Link</a></li>
...
...
</ul>
// This item is open at page load time
<li class="expand"><a href="#">Sub menu heading</a>
<ul>
<li><a href="http://site.com/">Link</a></li>
<li><a href="http://site.com/">Link</a></li>
<li><a href="http://site.com/">Link</a></li>
...
...
</ul>
...
...
</ul>

Copyright 2007-2010 by Marco van Hylckama Vlieg

web: http://www.i-marco.nl/weblog/
email: marco@i-marco.nl

Free to use any way you like.
*/

jQuery.fn.initMenu = function() {  
    return this.each(function(){
        var theMenu = $jq(this).get(0);
        $jq('.acitem', this).hide();
        $jq('li.expand > .acitem', this).show();
        $jq('li.expand > .acitem', this).prev().addClass('active');
        $jq('li a', this).click(
            function(e) {
                e.stopImmediatePropagation();
                var theElement = $jq(this).next();
                var parent = this.parentNode.parentNode;
                if($jq(parent).hasClass('noaccordion')) {
                    if(theElement[0] === undefined) {
                        window.location.href = this.href;
                    }
                    $jq(theElement).slideToggle('normal', function() {
                        if ($jq(this).is(':visible')) {
                            $jq(this).prev().addClass('active');
                        }
                        else {
                            $jq(this).prev().removeClass('active');
                        }    
                    });
                    return false;
                }
                else {
                    if(theElement.hasClass('acitem') && theElement.is(':visible')) {
                        if($jq(parent).hasClass('collapsible')) {
                            $jq('.acitem:visible', parent).first().slideUp('normal', 
                            function() {
                                $jq(this).prev().removeClass('active');
                            }
                        );
                        return false;  
                    }
                    return false;
                }
                if(theElement.hasClass('acitem') && !theElement.is(':visible')) {         
                    $jq('.acitem:visible', parent).first().slideUp('normal', function() {
                        $jq(this).prev().removeClass('active');
                    });
                    theElement.slideDown('normal', function() {
                        $jq(this).prev().addClass('active');
                    });
                    return false;
                }
            }
        }
    );
});
};

$jq(document).ready(function() {$jq('.userActions').initMenu();});


function checkpricesFrontpage(value) {

	if(document.getElementById('destination').value==0) {
		alert("Du mangler at vælge rejsemål.");
	}else if (document.getElementById('transport').options[document.getElementById('transport').selectedIndex].style.color=='#bbbbbb' || document.getElementById('transport').options[document.getElementById('transport').selectedIndex].style.color=='rgb(187, 187, 187)'){
		alert(document.getElementById('transport').options[document.getElementById('transport').selectedIndex].label+' er desværre ikke mulig på '+document.getElementById('destination').options[document.getElementById('destination').selectedIndex].label);
	}else{
		document.frontPageprices.action = "/skiferie/" + value;
		document.frontPageprices.submit();
	}

}

function aktiv_tjek(){

	dest = document.getElementById('destination').value;

	document.getElementById('DKB').style.color='';
	//document.getElementById('DKT').style.color='';
	document.getElementById('BLL').style.color='';
	document.getElementById('CPH').style.color='';
	//document.getElementById('AAL').style.color='';

	if (dest.indexOf("tyskland/")>-1){
		document.getElementById('DKB').style.color='#bbbbbb';
	}
	if (dest.indexOf("tyskland/")>-1 || dest.indexOf("sverige/")>-1 || dest.indexOf("norge/")>-1){
		//document.getElementById('DKT').style.color='#bbbbbb';
		document.getElementById('BLL').style.color='#bbbbbb';
		document.getElementById('CPH').style.color='#bbbbbb';
	}
	if (dest.indexOf("tyskland/")>-1 || dest.indexOf("sverige/")>-1 || dest.indexOf("norge/")>-1 || dest.indexOf("ostrig/solden")>-1 || dest.indexOf("ostrig/bad-gastein")>-1 || dest.indexOf("ostrig/zell-am-see")>-1 || dest.indexOf("ostrig/schladming")>-1 || dest.indexOf("ostrig/filzmoos")>-1 || dest.indexOf("ostrig/lofer")>-1 || dest.indexOf("ostrig/maria-alm")>-1 || dest.indexOf("italien/")>-1){
		//document.getElementById('AAL').style.color='#bbbbbb';
	}

}

$jq(function() {
		
	$jq( "#slider1" ).slider({ step:1, value: 50 });
	$jq( "#slider2" ).slider({ step:1, value: 50 });
	$jq( "#slider3" ).slider({ step:1, value: 50 });
	
	//var value = $jq( "#slider1" ).slider( "option", "value" );
	//alert(value);

});

function checkWinGift() {
	var emailtest=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;

	if(document.getElementById('fornavn_nyhedsbrev').value=="") {
		alert("Husk at skrive noget i feltet navn.");
	}else if(document.getElementById('efternavn_nyhedsbrev').value=="") {
		alert("Husk at skrive noget i feltet efternavn.");
	}else if(document.getElementById('email_nyhedsbrev').value=="") {
		alert("Husk at skrive noget i feltet email.");
	}else if(!emailtest.test(document.getElementById('email_nyhedsbrev').value)) {
		alert("Den indtastede e-mail er ikke gyldig. Gyldig e-mail kunne være info@team-benns.com");
	}else if(!document.getElementById('email_nyhedsbrev_check').checked) {
		alert("Tilmelding til nyhedsbrevet er påkrævet for at deltage i konkurrencen.");		
	}else{
		document.winGift.submit();
	}

}

function checkOrderOffer() {
	
	var telefontest=/^\d{8,9}$/;

	if(document.getElementById('navn_tilbud').value=="") {
		alert("Husk at skrive noget i feltet navn.");
	}else if(document.getElementById('telefon_tilbud').value=="") {
		alert("Husk at skrive noget i feltet telefon.");
	}else if(!telefontest.test(document.getElementById('telefon_tilbud').value)) {
		alert("Telefonnummeret er ikke korrekt. Korrekt telefonnummer kunne være 65656563");	
	}else{
		document.orderOffer.submit();
	}

}


function gotoDestGuideFrontPage(){
	var value1 = $jq( "#slider1" ).slider( "option", "value" );
	var value2 = $jq( "#slider2" ).slider( "option", "value" );
	var value3 = $jq( "#slider3" ).slider( "option", "value" );
	
	location.href = "/skiferie/destinationsguide?slider1="+value1+"&slider2="+value2+"&slider3="+value3;
}

function getSliderValues(){
	var value1 = $jq( "#slider1" ).slider( "option", "value" );
	var value2 = $jq( "#slider2" ).slider( "option", "value" );
	var value3 = $jq( "#slider3" ).slider( "option", "value" );
	
	return "&slider1="+value1+"&slider2="+value2+"&slider3="+value3;
}

function setSlidervalues(slider1,slider2,slider3){
	$jq( "#slider1" ).slider( "option", "value", slider1);
	$jq( "#slider2" ).slider( "option", "value", slider2);
	$jq( "#slider3" ).slider( "option", "value", slider3);
}

function bookpop(linket){
	bruger_bredde = window.screen.width;
	bruger_hojde = window.screen.height;
	mvenstre = 10;
	mtop = 10;

	bredde = parseInt(bruger_bredde*0.9);
	hojde = parseInt(bruger_hojde*0.9)-120;

	if (bredde > 1000){
		bredde = 1000;
		mvenstre = (bruger_bredde-1000)/2;
	}
	if (bredde < 1000) bredde = 1000;
	if (hojde < 700) hojde = 700;

	if (bruger_hojde > 1000) mtop = 40;

	var pageTracker = _gat._getTrackerByName();
	book = window.open(pageTracker._getLinkerUrl(linket),"book","width="+bredde+",height="+hojde+",left="+mvenstre+",top="+mtop+",scrollbars=1,resizable=1,toolbar=0,menubar=0,status=0");

}

function bookpop2(linket){
	var pageTracker = _gat._getTrackerByName();
	book = window.open(pageTracker._getLinkerUrl(linket),"book","width=840,height=380,left=10,top=10,scrollbars=0,resizable=0,toolbar=0,menubar=0,status=0");
}

$jq(document).ready(function() {

	$jq('#textSlide').addClass('noshow');
	$jq("#beskrSlide").click(function () {
      $jq("#textSlide").slideToggle("slow");
	});

	$jq("a[rel^='prettyPhoto2']").prettyPhoto({
		theme: 'light_square',
		default_width: 680,
		default_height: 575,
		social_tools: '',
		horizontal_padding: 0,
		markup: '<div class="pp_pic_holder"> \
			<div class="ppt">&nbsp;</div> \
			<div class="pp_content_container"> \
					<div class="pp_content" id="pp_content2"> \
						<a class="pp_close" id="pp_close2" href="#"></a> \
						<div class="pp_loaderIcon"></div> \
						<div class="pp_fade"> \
							<div id="pp_full_res"></div> \
							<div class="pp_details"> \
							</div> \
						</div> \
					</div> \
			</div> \
			<div class="pp_bottom"> \
			</div> \
		</div> \
		<div class="pp_overlay"></div>'
	});

	$jq("a[rel^='prettyPhoto3']").prettyPhoto({
		theme: 'light_square',
		default_width: 640,
		default_height: 770,
		social_tools: '',
		allow_resize: false,
		horizontal_padding: 0,
		markup: '<div class="pp_pic_holder"> \
			<div class="ppt">&nbsp;</div> \
			<div class="pp_content_container"> \
					<div class="pp_content" id="pp_content2"> \
						<a class="pp_close" id="pp_close2" href="#"></a> \
						<div class="pp_loaderIcon"></div> \
						<div class="pp_fade"> \
							<div id="pp_full_res"></div> \
							<div class="pp_details"> \
							</div> \
						</div> \
					</div> \
			</div> \
			<div class="pp_bottom"> \
			</div> \
		</div> \
		<div class="pp_overlay"></div>'
	});

});

function triggerpretty(id){
	$jq('#billede_'+id+'_1').trigger('click');
}

$slideshow = {
    context: false,
    tabs: false,
    timeout: 5000,      // time before next slide appears (in ms)
    slideSpeed: 1000,   // time it takes to slide in each slide (in ms)
    tabSpeed: 500,      // time it takes to slide in each slide (in ms) when clicking through tabs
    fx: 'fade',   // the slide effect to use
    
    init: function() {
        // set the context to help speed up selectors/improve performance
        this.context = $jq('#slideshow');
        
        // set tabs to current hard coded navigation items
        this.tabs = $jq('ul.slides-nav li', this.context);
        
        // remove hard coded navigation items from DOM 
        // because they aren't hooked up to jQuery cycle
        this.tabs.remove();
        
        // prepare slideshow and jQuery cycle tabs
        this.prepareSlideshow();
    },
    
    prepareSlideshow: function() {
        // initialise the jquery cycle plugin -
        // for information on the options set below go to: 
        // http://malsup.com/jquery/cycle/options.html
        $jq('div.slides > ul', $slideshow.context).cycle({
            fx: $slideshow.fx,
			next:   	'#cycle_next',
            timeout: $slideshow.timeout,
            speed: $slideshow.slideSpeed,
            fastOnEvent: $slideshow.tabSpeed,
            pager: $jq('ul.slides-nav', $slideshow.context),
            pagerAnchorBuilder: $slideshow.prepareTabs,
            before: $slideshow.activateTab,
            pauseOnPagerHover: true,
            pause: true
        });            
    },
    
    prepareTabs: function(i, slide) {
        // return markup from hardcoded tabs for use as jQuery cycle tabs
        // (attaches necessary jQuery cycle events to tabs)
        return $slideshow.tabs.eq(i);
    },

    activateTab: function(currentSlide, nextSlide) {
        // get the active tab
        var activeTab = $jq('a[href="#' + nextSlide.id + '"]', $slideshow.context);
        
        // if there is an active tab
        if(activeTab.length) {
            // remove active styling from all other tabs
            $slideshow.tabs.removeClass('on');
            
            // add active styling to active button
            activeTab.parent().addClass('on');
        }            
    }            
};

$slideshow2 = {
    context: false,
    tabs: false,
    timeout: 5000,      // time before next slide appears (in ms)
    slideSpeed: 1000,   // time it takes to slide in each slide (in ms)
    tabSpeed: 500,      // time it takes to slide in each slide (in ms) when clicking through tabs
    fx: 'fade',   // the slide effect to use
    
    init: function() {
        // set the context to help speed up selectors/improve performance
        this.context = $jq('#slideshow2');
        
        // set tabs to current hard coded navigation items
        this.tabs = $jq('ul.slides-nav li', this.context);
        
        // remove hard coded navigation items from DOM 
        // because they aren't hooked up to jQuery cycle
        this.tabs.remove();
        
        // prepare slideshow and jQuery cycle tabs
        this.prepareSlideshow();
    },
    
    prepareSlideshow: function() {
        // initialise the jquery cycle plugin -
        // for information on the options set below go to: 
        // http://malsup.com/jquery/cycle/options.html
        $jq('div.slides > ul', $slideshow2.context).cycle({
            fx: $slideshow2.fx,
			next:   	'#cycle_next',
            timeout: $slideshow2.timeout,
            speed: $slideshow2.slideSpeed,
            fastOnEvent: $slideshow2.tabSpeed,
            pager: $jq('ul.slides-nav', $slideshow2.context),
            pagerAnchorBuilder: $slideshow2.prepareTabs,
            before: $slideshow2.activateTab,
            pauseOnPagerHover: true,
            pause: true
        });            
    },
    
    prepareTabs: function(i, slide) {
        // return markup from hardcoded tabs for use as jQuery cycle tabs
        // (attaches necessary jQuery cycle events to tabs)
        return $slideshow2.tabs.eq(i);
    },

    activateTab: function(currentSlide, nextSlide) {
        // get the active tab
        var activeTab = $jq('a[href="#' + nextSlide.id + '"]', $slideshow2.context);
        
        // if there is an active tab
        if(activeTab.length) {
            // remove active styling from all other tabs
            $slideshow2.tabs.removeClass('on');
            
            // add active styling to active button
            activeTab.parent().addClass('on');
        }            
    }            
};

$jq(function() {

    $jq('body').addClass('js');

    $slideshow.init();

    $slideshow2.init();
	
});

