/**
 * the old soloution, replaced by zhe following two functions (Change Background bevore)
 */
 
function changeBg(id,src,actNumber) {
//	document.getElementById(id).style.background = "url("+src+")";
//	document.getElementById(id).style.backgroundRepeat = "no-repeat";
//	document.getElementById('movieContent').style.display = "none";
//	alert("function changeBg(id,src)");
showGalleryImg(id, src,actNumber);
}

/**
 * Changes the image foreward or backward
 */

function changeGalleryImg(step, currImgSrc, actNumber) {
/*
var arrOfImg = ['http://admin.florianklein.com/docroot/tmp/694x354ar0:0/gallery/imageContent/018/cig_thumb.jpg','http://admin.florianklein.com/docroot/tmp/694x354ar0:0/gallery/imageContent/019/fire_1_thumb.jpg','http://admin.florianklein.com/docroot/tmp/694x354ar0:0/gallery/imageContent/017/paper_1_thumb.jpg' ];

*/
        var lastSlash = currImgSrc.lastIndexOf('/');
        var imgName;
	actNumber = actNumber+parseInt(step);
	
	//if he actual number is less than the first, or higher than the last jump to the end or beginn (Loop it)
	if(actNumber < 0 ){
		actNumber=arrOfImg.length-1;
	}else if( actNumber >= arrOfImg.length){
		actNumber=0;
	}
	//alert(actNumber);

	imgName = currImgSrc.substr(lastSlash+1,currImgSrc.length);
		var imgHtml='';
		
		newImg = arrOfImg[actNumber][0].toString();
		newImgTitle = arrOfImg[actNumber][1].toString();
						
		
		imgHtml ='<div style=\'index:99;position:relative;\'>'+
                		'<img src='+newImg+' alt=\''+ newImgTitle +'\' title=\''+ newImgTitle +'\' />'+
                                	'<span style=\'position:absolute; bottom:22px; right: 31px;\' >'+   
					  '<a id=\'backButton\' href=\'JavaScript: changeGalleryImg(-1,&quot;'+newImg+'&quot;,'+actNumber+' );\' style=\'border:none;\'  alt=\'test\'>'+
                                          '<img src=\'/docroot/florianklein.com/imgs/navigation/pic_left.png\'  style=\'border:none;\' alt=\'back\' title=\'back\' />'+                                              '</a>&nbsp;'+
					   '<a href=\'' + window.location.pathname + '\' alt=\'test\' style=\'border:none;\'>'+
                                           '<img src=\'/docroot/florianklein.com/imgs/navigation/pic_close.gif\'  style=\'border:none;\'  alt=\'back\' title=\'close\' />'+
                                           '</a>&nbsp;'+
                                           '<a id=\'continueButton\' href=\'JavaScript: changeGalleryImg(1,&quot;'+newImg+'&quot;,'+actNumber+');\' alt=\'zwei\' style=\'border:none;\' >'+
                                           '<img src=\'/docroot/florianklein.com/imgs/navigation/pic_right.png\'  style=\'border:none;\' alt=\'back\' title=\'continue\' />'+
                                           '</a>'+
                                        '<span>'+
                           '</div>';

		//alert(imgHtml);
		document.getElementById('mainContent').innerHTML = imgHtml;
                document.getElementById('mainContent').style.backgroundImage = "none";
                document.getElementById('mainContent').style.display = "block";
		//document.getElementById('bottomLogoLeftSide').style.visibility = "hidden";
		document.getElementById('bottomLogoRightSide').style.visibility = "hidden";
		document.getElementById('bottomLogoRightSide').style.bottom ="0px";
		document.getElementById('bottomLogoRightSide').style.right ="-1px";
		document.getElementById('bottomLogoRightSide').src = "/docroot/florianklein.com/imgs/border/corner-bottom-right.gif";
		document.getElementById('bottomLogoRightSide').style.visibility = "visible";
}



/**
 * shows the Gallery first Time an prepares the javascript-navigation
 */

function showGalleryImg(id,src,actNumber) {
	//alert("function showGalleryImg()\n ID="+id+"src="+src+"\nbildNR="+actNumber);
	var lastSlash = src.lastIndexOf('/');
	var newImgTitle = src.substr(src.lastIndexOf('/')+1,src.length).replace('_thumb', '').replace('.jpg','');
	imgHtml =   '<div style=\'index:99;position:relative;\'>'+
                      '<img src='+src+' alt=\''+ newImgTitle +'\' title=\''+ newImgTitle +'\' />'+
                          '<span style=\'position:absolute; bottom:22px; right: 31px;\' >'+
                              '<a id=\'backButton\' href=\'JavaScript: changeGalleryImg(-1,&quot;'+src+'&quot;,'+actNumber+');\' style=\'border:none;\'  alt=\'test\'>'+
                                  '<img src=\'/docroot/florianklein.com/imgs/navigation/pic_left.png\'  style=\'border:none;\' alt=\'back\' title=\'back\' />'+
                              '</a>&nbsp;'+
                              '<a href=\'' + window.location.pathname + '\' alt=\'test\' style=\'border:none;\'>'+
                                  '<img src=\'/docroot/florianklein.com/imgs/navigation/pic_close.gif\'  style=\'border:none;\'  alt=\'back\' title=\'close\' />'+
                              '</a>&nbsp;'+
                              '<a id=\'continueButton\' href=\'JavaScript: changeGalleryImg(1,&quot;'+src+'&quot;,'+actNumber+');\' alt=\'zwei\' style=\'border:none;\' >'+
                                  '<img src=\'/docroot/florianklein.com/imgs/navigation/pic_right.png\'  style=\'border:none;\' alt=\'back\' title=\'continue\' />'+
                              '</a>'+
                          '<span>'+
                   '</div>';

	document.getElementById('mainContent').style.backgroundImage = "none";
	document.getElementById('mainContent').innerHTML = imgHtml;
	document.getElementById('mainContent').style.display = "block";
	//document.getElementById('bottomLogoLeftSide').style.visibility = "hidden";
        document.getElementById('bottomLogoRightSide').style.visibility = "hidden";
        document.getElementById('bottomLogoRightSide').style.bottom ="0px";
        document.getElementById('bottomLogoRightSide').style.right ="-1px";
        document.getElementById('bottomLogoRightSide').src = "/docroot/florianklein.com/imgs/border/corner-bottom-right.gif";
        document.getElementById('bottomLogoRightSide').style.visibility = "visible";



}


/**
 * Start Movie
 */

function startMovie(id, src) {
	var len = src.length;
	var position = eval(len - 4);
	var fileType = src.substring(position, len);
	
	var el = document.getElementById(id);
	var width = "320px";
    var height = "240px";
    var autoplay = "true";
    var controller = "false";
    var loop = "false";
	
	if (fileType == ".mov") {
    	var movieHtml = "<object classid='clsid:02bf25d5-8c17-4b23-bc80-d3488abddc6b' codebase='http://www.apple.com/qtactivex/qtplugin.cab' height='" + height + "' width='" + width+ "' id=''><param name='src' value='" + src + "'><param name='autoplay' value='" + autoplay+ "'><param name='controller' value='" + controller + "'><param name='loop' value='" + loop+ "'><embed src='" + src + "' height='" + height + "' width='" + width+ "' type='video/quicktime' pluginspage='http://www.apple.com/quicktime/download/' autoplay='" + autoplay+ "' controller='" + controller + "' loop='" + loop+ "'/></object>";
    }
    else if (fileType == ".swf") {
    	var movieHtml = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0' width='"+width+"' height='"+height+"' id='myMovie'><param name='movie' value='"+src+"'><param name='quality' value='high'><embed src='"+src+"' quality='high' width='"+width+"' height='"+height+"' name='movie' align='' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'></embed></object>"
    }
    else if (fileType == ".flv" || fileType == ".FLV"){
    	var movieHtml = "<object type='application/x-shockwave-flash' data='/docroot/florianklein.com/flowplayer/FlowPlayer.swf'	height='" + height + "' width='" + width+ "' id='FlowPlayer'><param name='allowScriptAccess' value='sameDomain' /><param name='movie' value='/docroot/florianklein.com/flowplayer/FlowPlayer.swf' /><param name='quality' value='high' /><param name='scale' value='noScale' />	<param name='wmode' value='transparent' />	<param name=\"flashvars\" value=\"config={videoFile: '"+src+"'}\" /></object>"
    }
    else {
    	var movieHtml = "<object width='"+width+"' height='"+height+"'><param name='movie' value='"+src+"'><embed src='"+src+"' width='"+width+"' height='"+height+"'></embed></object>"
    }
    document.getElementById('mainContent').style.backgroundImage = "none";
    el.innerHTML = movieHtml;
    el.style.display = "block";
}

/*
 * Calculate price
 */
 
function calculatePrice(el, id, price, amount) {
	if (isNaN (amount)) {
		el.value = "";
	}
	else {
		document.getElementById(id).value = Math.abs(price * amount);
	}
}

/**
 * Check if Products are selected
 */

function checkProducts() {
	if (document.getElementById("product0").value != '' && document.getElementById("product0").value != 0)
		return true;
	else if (document.getElementById("product1").value != '' && document.getElementById("product1").value != 0)
		return true;
	else {
		document.getElementById("product0").style.borderColor = "#ff0000";
		document.getElementById("product1").style.borderColor = "#ff0000";
		document.getElementById("message").style.display = "block";
		return false;
	}
	return false;
}

/**
 * Check date
 */

function checkDate() {
	if (document.getElementById("date").value == ''){
		document.getElementById("message").style.display = "block";
		return false;
	}
	return true;
}

/** 
 * NewsBar 
 */
// Id des parent-Elementes
var parentNodeId = "newsBar";	
// Pause in Millisekunden								
var timeOutInMs = 10000;										
// Position im Array (Global)
var pos = -1;
// Anzahl der Childnodes (Global)													
var length = 0;	
// Parent-Element (Global)												
var parentNode;
// Aktuelles Element (Global)												    
var childNode;													

/**
 * Onload Funktion
 */

window.onload=function() {
	// Pruefen ob Dieses Element vorhanden ist
	if (document.getElementById(parentNodeId)) {					
		parentNode = document.getElementById(parentNodeId);
		// Anzahl der ChildNodes angefangen bei 0 (Arraykonform)
		length = parentNode.childNodes.length - 1;				
		if (length > -1) {
			// Aufruf der Funktion										
			changeNews(0);										
		}
	}
	if (document.getElementById('pageWithHovers')) {
		setHoverSize();
	}

		
}

function changeNews(pos) {
	// 	Wenn dies das erste Element ist	
	if (pos == 0) {	
		//  Erstes Element holen											
		childNode = parentNode.firstChild;
		//  das letzte Element ausblenden						
		parentNode.lastChild.style.display = "none";
		//  dieses Element einblenden			
		parentNode.firstChild.style.display = "block";			
	}
	else {
		//  letztes Element ausblenden	
		childNode.style.display = "none";
		//  naechstes Element auf der gleichen Ebene holen				
		childNode = childNode.nextSibling;
		//  und einblenden						
		childNode.style.display = "block";						
	}
	//   Position im Array bestimmen
	if (pos == length) {
		nextPos = 0;											
	}
	else {
		nextPos = pos + 1;
	}
	// 	 Die selbe Funktion nochmal aufrufen mit der Position im Array und der Wartezeit bis zum Funktionsaufruf (hier kann man keine Objekte mitgeben)
	window.setTimeout("changeNews("+nextPos+")", timeOutInMs);  
}
