/**
 * @author hk
 */

/*
 * Automatische Silbentrennung
 */
/*
Hyphenator.config({
	displaytogglebox : false,
	minwordlength : 3
});
Hyphenator.run();
*/

function Open_Popup(mylink,width,height,scroll)
{
	if (! window.focus)return true;
	var href;
	if (typeof(mylink) == 'string')
	   href=mylink;
	else
	   href=mylink.href;
	window.open(href,'Popup', 'width='+width+',height='+height+',scrollbars='+scroll);
	return false;
}

function openFileBrowser(field_name, url, type, win) 
{ 
            browserField = field_name; 
            browserWin = win; 
            window.open('../images/popup_index', 'browserWindow', 'modal,width=600,height=400,scrollbars=yes'); 
}


function OpenMenu()
{
	document.getElementById('preise_anfragen_s1').style.visibility = 'visible';
	document.getElementById('preise_anfragen_s2').style.visibility = 'visible';
}

function CloseMenu()
{
	document.getElementById('preise_anfragen_s1').style.visibility = 'hidden';
	document.getElementById('preise_anfragen_s2').style.visibility = 'hidden';
}

/*
 * Slideshow
 */
var UpdateObjects = new Array();

function Slideshow(delay,start,bilder,bildelement)
{
	//this.Bilder = new Array();
	this.Bilder = bilder
	this.bildelement = bildelement;
	this.BildAnzahl = this.Bilder.length;
	this.number = 0;
	this.Delay = delay;
	this.Start = start;
	
	this.LastChange = 0;
	
	//if(this.Bilder.length > 1)
	//	this.number = 1;
	this.BildFolge = new Image(); this.BildFolge.src = this.Bilder[this.number];

}

Slideshow.prototype.change = function() 
{
	//this.bildelement = bildelement;
	this.number++;
	if (this.number == this.BildAnzahl) this.number = 0;
	
	this.BildFolge.src = this.Bilder[this.number];
	this.bildelement.src = this.BildFolge.src;
}

Slideshow.prototype.next = function() 
{
    this.number++;
    if (this.number == this.BildAnzahl) this.number = 0;
    
    this.BildFolge.src = this.Bilder[this.number];
    this.bildelement.src = this.BildFolge.src;
}

Slideshow.prototype.prev = function() 
{
    this.number--;
    if (this.number < 0) this.number = this.BildAnzahl-1;
    
    this.BildFolge.src = this.Bilder[this.number];
    this.bildelement.src = this.BildFolge.src;
}

Slideshow.prototype.start = function(object,delay,bildelement)
{
		this.Delay = delay;
		setTimeout(this.change(bildelement), delay);
		
}

// Öffnet ein Popup mit dem Bild
Slideshow.prototype.openPopup = function() 
{
    //this.BildFolge.src = this.Bilder[this.number];
}

function UpdateSlideshow()
{
	  var currentDate = new Date()
	  
	  for(var i=0;i<UpdateObjects.length;i++)
	  {
		if(currentDate.valueOf() >= UpdateObjects[i].Start && currentDate.valueOf() >= UpdateObjects[i].LastChange + UpdateObjects[i].Delay)
		{
			UpdateObjects[i].change();
			UpdateObjects[i].LastChange = currentDate.valueOf();
		}
	  }
}

setInterval("UpdateSlideshow()", 100);

// Home Video

function toggleHomeVideo()
{
	$('#homeVideo').toggle();
	$('.homeBigImage').toggle();
	if( $('#homeVideo').css('display') == 'none')
	{
		$('#homeShowVideoText').text(">> Intro anzeigen");
	}
	else
	{
		$('#homeShowVideoText').text(">> Intro schließen");
	}
}
	
