function showPopup (page,width,height,resizeable,scrollbars) {
  day = new Date();
  id = day.getTime();
  eval("page" + id + " = window.open('"+page+"', '" + id + "', 'toolbar=0,scrollbars='+scrollbars+',location=0,statusbar=0,menubar=0,resizable='+resizeable+',width="+width+",height="+height+"');");
};


function setSIFRFonts () {
	if(typeof sIFR == "function") {
		sIFR.replaceElement(named({sSelector:"h1.page_headline", sFlashSrc:"/images/daniel.swf", sColor:"#000000", sWmode : "transparent", sFlashVars: "textalign=right"}));
		sIFR.replaceElement(named({sSelector:"h1.page_headline2", sFlashSrc:"/images/daniel.swf", sColor:"#000000", sWmode : "transparent", sFlashVars: "textalign=right"}));

	};
}

function checkIE6 () {
	var Browser = {
	  Version: function() {
	    var version = 999; // we assume a sane browser
	    if (navigator.appVersion.indexOf("MSIE") != -1)
	      // bah, IE again, lets downgrade version number
	      version = parseFloat(navigator.appVersion.split("MSIE")[1]);
	    return version;
	  }
	}
	if (Browser.Version() < 7) {
	  document.getElementById('warning_ie6').style.display='block';
	}
}

/* Carousel logic */
carouselItemsPerPage = 3;
carouselLockClick = false;

function mycarousel_scrollTo (carousel, idx) {
	var scrollIdx = idx;
	if (!carousel.has (scrollIdx))
		return;
	jQuery ('.menu3 a').removeClass ('marked');
	if (carousel.options.size>carouselItemsPerPage) {
		if ((idx+carouselItemsPerPage)>carousel.options.size) {
			scrollIdx = (carousel.options.size-carouselItemsPerPage)+1;
    	jQuery ('#scroller_arrow_right').hide ();
    }
    else    
    	jQuery ('#scroller_arrow_right').show ();
    	
    if (scrollIdx==1)
    	jQuery ('#scroller_arrow_left').hide ();				
		else
			jQuery ('#scroller_arrow_left').show ();
	}   

  
  jQuery ('.menu3 a:eq('+(idx-1)+')').addClass ('marked');
	carousel.scroll(scrollIdx);
}

function mycarousel_initCallback(carousel) {


  jQuery('.menu3 a').bind('click', function() {      
		if (carouselLockClick)
			return false;
			
    var idx = jQuery.jcarousel.intval(jQuery(this).text());
		mycarousel_scrollTo (carousel, idx);      

    return false;
  });

  jQuery('#scroller_arrow_right').bind('click', function() {
		if (carouselLockClick)
			return false;
		jQuery ('.menu3 a').removeClass ('marked');
		jQuery ('.menu3 a:eq('+(carousel.first)+')').addClass ('marked');
		if ((carousel.first+carouselItemsPerPage)>=carousel.options.size)
    	jQuery ('#scroller_arrow_right').hide ();
   	jQuery ('#scroller_arrow_left').show (); 	 			
    carousel.next();				
	  return false;
  });

  jQuery('#scroller_arrow_left').bind('click', function() {
		if (carouselLockClick)
			return false;
		jQuery ('.menu3 a').removeClass ('marked');
		if ((carousel.first-2)<1)
    	jQuery ('#scroller_arrow_left').hide ();
    jQuery ('#scroller_arrow_right').show ();
								
    carousel.prev();
		jQuery ('.menu3 a:eq('+(carousel.first-1)+')').addClass ('marked');
    return false;
  });



};

function mycarousel_onBeforeAnimation (carousel, state) {
	carouselLockClick=true;
}

function mycarousel_onAfterAnimation (carousel, state) {
	if (state=='init') {
		// Show init state of controls
		jQuery ('.menu3 a').removeClass ('marked');
		jQuery ('.menu3 a:eq(0)').addClass ('marked');
		if (carousel.options.size>carouselItemsPerPage)
	    jQuery ('#scroller_arrow_right').show ();		
		jQuery ('#scroller_arrow_left').hide ();
		jQuery ('#scroller_loading').hide ();
	}
	carouselLockClick=false;
}

function initPage (fWithCarousel) {
	// Ride the carousel...
	jQuery(document).ready(function() {
		if (fWithCarousel) {
			carouselLockClick=true;
			jQuery ('#scroller_loading').show ();
		  jQuery("#scroller_frame").jcarousel({
		      scroll: 1,
		      initCallback: mycarousel_initCallback,        
		      itemLoadCallback: {
					  onBeforeAnimation: mycarousel_onBeforeAnimation,
					  onAfterAnimation: mycarousel_onAfterAnimation
					},
		      // This tells jCarousel NOT to autobuild prev/next buttons
		      buttonNextHTML: null,
		      buttonPrevHTML: null
		  });
			carouselLockClick=false;
	  }	
	});
}
