﻿// NewsModule fÃ¼r zufÃ¤llig eingeblendete News mit Bildern
// Sonderanwendung fÃ¼r Swissvault Webauftritt
// By MHM & Partner AG 2009
// Sascha Lorenz

//**********************************************************************************************************************************************************************************************

var News = new Array();

News[0] = new Object();
News[0]["Text"] = "The current special edition of the GEO has been published with the focus topic of...";
News[0]["Image"] = "/Data/Sites/1/images/newspics/geo.gif";
News[0]["Link"] = "./news.aspx";

News[1] = new Object();
News[1]["Text"] = "The client magazine „SPIRIT“ of the Grand Hotel Les Trois Rois and the Grand Hotel Bellevue contains...";
News[1]["Image"] = "/Data/Sites/1/images/newspics/spirit.gif";
News[1]["Link"] = "./news.aspx";

News[2] = new Object();
News[2]["Text"] = "The famous publication „Le Monde Magazine“ from France features in the current issue a detailed story...";
News[2]["Image"] = "/Data/Sites/1/images/newspics/lemonde.gif";
News[2]["Link"] = "./news.aspx";

News[3] = new Object();
News[3]["Text"] = "On March 10th the annual SwissSecurityDay will take place for the 5th time. SWISSVAULT presents this event...";
News[3]["Image"] = "/Data/Sites/1/images/newspics/ssd.gif";
News[3]["Link"] = "./news.aspx";

News[4] = new Object();
News[4]["Text"] = "Just in time for the Swissbau the two magazines BauInfo and BauFlash...";
News[4]["Image"] = "/Data/Sites/1/images/newspics/swissbau.gif";
News[4]["Link"] = "./news.aspx";





//**************************************************************************************************************************************
var i=0;
var ScriptStartup = (
function ()
{
	var doml = new Array(); // dom loaded
	var winl = new Array(); // window loaded
	var doml_scripts_ready = true;
	var window_ready       = false;
			   
	var browser = {
		safari:/WebKit/i.test(navigator.userAgent),
		ff:/Firefox/i.test(navigator.userAgent),
		opera:/Opera/i.test(navigator.userAgent)
}
                                
function initLoadingUntilDomReady () {
			doml_scripts_ready = false;
			
				
				if(document.addEventListener)
					document.addEventListener('DOMContentLoaded',startUpDomLoaded,false);
			}
		
					
		function initLoadingUntilWindowReady () {
			window.onload = function () {
				window_ready = true;
				for(var i = 0 ; i < winl.length;i++) winl[i]();
			}
		}
					
		function startUpDomLoaded() {
		
			for(var i = 0 ; i < doml.length;i++) doml[i]();
			doml_scripts_ready = true;                        
			if(window_ready) startUpWindowLoaded();
			else             
			initLoadingUntilWindowReady();
		}
					
		function startUpWindowLoaded () {
			if(!doml_script_ready) return;
			for(var i = 0 ; i < winl.length;i++) winl[i]();
		}
					
		return {
			/**
			* Ladevorgang fuer script starten 
			* @access public
			* @params Object func                // function
			* @params boolean DOMLoaded          // start Script Function if DOMLoaded
			* @return void
			*/
			
			addLoad:function(func,DOMLoaded){                            
				if(DOMLoaded && (browser.ie || browser.ff || browser.opera) ) {
					doml.push(func);
				} else {
					winl.push(func);
				}
			},
			initLoad:function () {
				if(doml.length > 0) initLoadingUntilDomReady() ;
				else                initLoadingUntilWindowReady() 
			}
		}
	}
)();

			
var doSlide = false;
function slidepics()
{
	doSlide = true;
	refresh();
}

function refresh()
{
	var offset = Math.floor(Math.random()*News.length)
    document.getElementById('Newsimage').src = News[offset]["Image"];
	
	var newsText = document.createTextNode(unescape(News[offset]["Text"]));
	document.getElementById("News").innerHTML = "";
	document.getElementById("News").appendChild(newsText);
	document.getElementById("url").href=News[offset]["Link"];
	if (doSlide)
	{
		window.setTimeout("refresh()", 10000);
	}
}    

ScriptStartup.addLoad(slidepics,true);
ScriptStartup.initLoad();









