/*
+---- Programming: ------------------------ Developer: ------------------------+
|                                                                              |
|   PixelProductions GmbH                   Sven Henneböle                     |
|   Hansastr. 2                             Fachinformatiker AE                |
|   D-59557 Lippstadt                                                          |
|                                                                              |
|   E-Mail: Info@PixelProductions.de                                           |
|                                                                              |
|   Fon: +49 (0)2941 22 333                  Version: 1.0                      |
|   Fax: +49 (0)2941 22 414                  Release Date: 01.08.2007          |
|                                                                              |
+------------------------------------------------------------------------------+
*/

var http_request = null;

function createXMLHTTPRequest() {
	
	if(window.XMLHttpRequest) {
		
		return new XMLHttpRequest();
	}
	else if(window.ActiveXObject) {
		
		try {
			
			return new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e) {
			
			try {
				
				return new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e) {
				
				return null;
			}
		}
	}
}

function doAjaxRequest(city) {
	
	http_request = createXMLHTTPRequest();
	http_request.onreadystatechange = setOutput;
	http_request.open('GET', '/Includes/address.changer.php?city='+city, true);
	http_request.send(null);

}

function setOutput() {

	var obj = document.getElementById("address");

	if (http_request.readyState == 4) {

		//Put your content here
		obj.innerHTML = http_request.responseText;
	}

}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function GP_AdvOpenWindow(theURL,winName,features,popWidth,popHeight,winAlign,ignorelink,alwaysOnTop,autoCloseTime,borderless) { //v2.0
  var leftPos=0,topPos=0,autoCloseTimeoutHandle, ontopIntervalHandle, w = 480, h = 340;  
  if (popWidth > 0) features += (features.length > 0 ? ',' : '') + 'width=' + popWidth;
  if (popHeight > 0) features += (features.length > 0 ? ',' : '') + 'height=' + popHeight;
  if (winAlign && winAlign != "" && popWidth > 0 && popHeight > 0) {
    if (document.all || document.layers || document.getElementById) {w = screen.availWidth; h = screen.availHeight;}
		if (winAlign.indexOf("center") != -1) {topPos = (h-popHeight)/2;leftPos = (w-popWidth)/2;}
		if (winAlign.indexOf("bottom") != -1) topPos = h-popHeight; if (winAlign.indexOf("right") != -1) leftPos = w-popWidth; 
		if (winAlign.indexOf("left") != -1) leftPos = 0; if (winAlign.indexOf("top") != -1) topPos = 0; 						
    features += (features.length > 0 ? ',' : '') + 'top=' + topPos+',left='+leftPos;}
  if (document.all && borderless && borderless != "" && features.indexOf("fullscreen") != -1) features+=",fullscreen=1";
  if (window["popupWindow"] == null) window["popupWindow"] = new Array();
  var wp = popupWindow.length;
  popupWindow[wp] = window.open(theURL,winName,features);
  if (popupWindow[wp].opener == null) popupWindow[wp].opener = self;  
  if (document.all || document.layers || document.getElementById) {
    if (borderless && borderless != "") {popupWindow[wp].resizeTo(popWidth,popHeight); popupWindow[wp].moveTo(leftPos, topPos);}
    if (alwaysOnTop && alwaysOnTop != "") {
    	ontopIntervalHandle = popupWindow[wp].setInterval("window.focus();", 50);
    	popupWindow[wp].document.body.onload = function() {window.setInterval("window.focus();", 50);}; }
    if (autoCloseTime && autoCloseTime > 0) {
    	popupWindow[wp].document.body.onbeforeunload = function() {
  			if (autoCloseTimeoutHandle) window.clearInterval(autoCloseTimeoutHandle);
    		window.onbeforeunload = null;	}  
   		autoCloseTimeoutHandle = window.setTimeout("popupWindow["+wp+"].close()", autoCloseTime * 1000); }
  	window.onbeforeunload = function() {for (var i=0;i<popupWindow.length;i++) popupWindow[i].close();}; }   
  document.MM_returnValue = (ignorelink && ignorelink != "") ? false : true;
}

var start_var = 0;

function doAlphabetRequest(value, lang) {

	if (document.getElementById('flash_video')) {
		document.getElementById('flash_video').style.display = 'none';
	}


	if (document.getElementById('ShortBasket')) {
		document.getElementById('ShortBasket').style.display = 'none';
	}

	var farbe = "";
	if (document.getElementById('select_passpart_1').checked == true) {
		farbe = "Creme";
	} else if (document.getElementById('select_passpart_2').checked == true) {
		farbe = "Antrazit";
	}
	
	if (value != "" && start_var == 0) {
		start_var = 1;
		http_request = createXMLHTTPRequest();
		http_request.onreadystatechange = setAlphabetRequestOutput;
		http_request.open('GET', '/Includes/konfi_ajax/alphabet_ajax.php?word=' + value +'&select_passpart=' + farbe +'&lang=' +lang, true);
		http_request.send(null);
	}

}

function setAlphabetRequestOutput() {

	if (http_request.readyState == 4) {
		if (document.getElementById('bild_gen_cont')) {
			//alert(http_request.responseText);
			document.getElementById('bild_gen_cont').innerHTML = http_request.responseText;
		}
		start_var = 0;
	}

}

var aktive_id = "";
var aktiv_lang = "";

function change_letter(aktiv_id, lang) {
	aktive_id = aktiv_id;
	aktiv_lang = lang;
	divlayer();
}

function start_pics(aktiv_id) {
	var value = document.getElementById(aktive_id + '_char').value;
	var pic = document.getElementById(aktive_id + '_input').value;
	var groesse = document.getElementById(aktive_id + '_groesse').value;
	
	if (document.getElementById(aktive_id + '_char').value != "" && start_var == 0) {
		start_var = 1;
		http_request = createXMLHTTPRequest();
		http_request.onreadystatechange = start_picsOutput;
		http_request.open('GET', '/Includes/konfi_ajax/alphabet_latter_change_ajax.php?char=' + value + '&pic=' + pic + '&groesse=' + groesse + '&lang=' + aktiv_lang + '&id=' + aktive_id, true);
		http_request.send(null);
	}

}

function start_picsOutput() {

	if (http_request.readyState == 4) {
		if (document.getElementById('inlay1')) {
			//alert(http_request.responseText);
			document.getElementById('inlay1').innerHTML = http_request.responseText;
		}
		start_var = 0;
	}

}


function change_letter_now(id, text, style, pic_id) {
	
	text = text.replace('alphabetbilder', 'alphabetbilder/Gross');
	text = text.replace('border', 'style="' + style + '" border');
	//alert(text);
	document.getElementById(id).innerHTML = text; 
	var id2 = id.replace('Bild_','');
	document.getElementById('Bild_id_'+id2).innerHTML = pic_id; 
	
	Ende(100);	
}



var id_array = new Array("overlay","Bild_copy","inlay1","Bild","overlay2","overlay3","titel1","exit1","mehr1","next1","pref1","Loading","Bild_load")

var loading = '../Includes/PicBox/loading.gif';
var more = '../Includes/PicBox/play.jpg';
var more2 = '../Includes/PicBox/pause.jpg';
var next = '../Includes/PicBox/next.jpg';
var pref = '../Includes/PicBox/pref.jpg';
var exit = '../Includes/PicBox/beenden.jpg';
var border = 5;

var galeriename = "";
var aktives_bild = "";
var aktive_id = 0;
var aktive_id_anzahl = 0;
var preloadImage = new Image();
var imageArray = new Array;
var imageArray2 = new Array;
var speed = 8;
var blend_speed = 8;
var merker_groesse = 600;

var timer_auto_fade = -1;
var timeout_fade_top = -1;
var autofading = 0;

var Bilder_liste = "";

function divlayer(galerie, pfad, groesse) {

	window.scroll(0,0);

	if (!groesse || groesse == "") { groesse = 600; }
	merker_groesse = groesse;
	
	/*for (i = 0 ; i <= 100 ; i++) {
		if (timeout_opacity_1[i]) { clearTimeout(timeout_opacity_1[i]); }
		if (timeout_opacity_2[i]) { clearTimeout(timeout_opacity_2[i]); }
	}*/

	//window.scroll(0,0);


//alert((aktive_id+1));
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	var objBody = document.getElementsByTagName("body").item(0);
		
	var objOverlay = document.createElement("div");
	objOverlay.setAttribute('id','overlay');
	objOverlay.onclick = function() { Ende(100); return false; };
	objOverlay.style.position = 'absolute';
	objOverlay.style.left = '0px';
	objOverlay.style.top = '0px';
	objOverlay.style.zIndex = '1111';
	objOverlay.style.opacity = (60 / 100);
	objOverlay.style.MozOpacity = (60 / 100);
	objOverlay.style.KhtmlOpacity = (60 / 100);
	objOverlay.style.filter = "alpha(opacity=" + 60 + ")";
	objOverlay.style.backgroundColor = '#000000';
	objBody.appendChild(objOverlay);
	objOverlay.style.width=arrayPageSize[0]-21;
	objOverlay.style.height=arrayPageSize[1];

	var objBild_copy = document.createElement("img");
	objBild_copy.setAttribute('src','../Includes/PicBox/pixelproductions.gif');
	objBild_copy.setAttribute('id','Bild_copy');
	objBild_copy.style.position = 'absolute';
	objBild_copy.style.width = 50;
	objBild_copy.style.height = 25;
	objBild_copy.style.right = border;
	objBild_copy.style.top = border;
	objBild_copy.style.opacity = (20 / 100);
	objBild_copy.style.MozOpacity = (20 / 100);
	objBild_copy.style.KhtmlOpacity = (20 / 100);
	objBild_copy.style.filter = "alpha(opacity=" + 20 + ")";
	objOverlay.appendChild(objBild_copy);


	var objInlay1 = document.createElement("div");
	objInlay1.setAttribute('id','inlay1');
	objInlay1.style.position = 'absolute';
	objInlay1.style.zIndex = '1112';
	objInlay1.style.width = (merker_groesse+(border*2)) + 'px';
	objInlay1.style.height = (merker_groesse+(border*2)+35) + 'px';
	objInlay1.style.backgroundColor = '#FFFFFF';
	objInlay1.style.left = ((arrayPageSize[0]/2)-(600/2)) + 'px';
	objInlay1.style.top = (20) + 'px'; //arrayPageScroll[1]+
	objInlay1.style.border = '1px solid #b0232b';
	objBody.appendChild(objInlay1);
	objOverlay.style.height=arrayPageSize[1];

	var objBild_load = document.createElement("img");
	objBild_load.setAttribute('src','../Includes/PicBox/loading.gif');
	objBild_load.setAttribute('id','Bild_load');
	objBild_load.style.position = 'absolute';
	objBild_load.style.width = 205 + 'px';
	objBild_load.style.height = 22 + 'px';
	objBild_load.style.right = border;
	objBild_load.style.top = border;
	objInlay1.appendChild(objBild_load);


	var objOverlay2 = document.createElement("div");
	objOverlay2.setAttribute('id','overlay2');
	objOverlay2.style.position = 'absolute';
	objOverlay2.style.left = '0px';
	objOverlay2.style.top = '0px';
	objOverlay2.style.opacity = (0 / 100);
	objOverlay2.style.MozOpacity = (0 / 100);
	objOverlay2.style.KhtmlOpacity = (0 / 100);
	objOverlay2.style.filter = "alpha(opacity=" + 0 + ")";
	objOverlay2.style.backgroundColor = '#ffffff';
	objOverlay2.style.display = 'none';
	objInlay1.appendChild(objOverlay2);

	var objOverlay3 = document.createElement("div");
	objOverlay3.setAttribute('id','overlay3');
	objOverlay3.style.position = 'absolute';
	objOverlay3.style.left = '0px';
	objOverlay3.style.top = '0px';
	objInlay1.appendChild(objOverlay3);
	objOverlay3.style.display = 'none';
	objOverlay3.innerHTML= '<table align="center" width="100%" height="100%"><tr><td align="center">&nbsp;</td></tr></table>'

	if ((preloadImage.height+200)>document.getElementById("overlay").offsetHeight) {
		document.getElementById("overlay").style.height=(preloadImage.height+200) + 'px';
	}


	var objTitel = document.createElement("div");
	objTitel.style.zIndex = '1112';
	objTitel.setAttribute('id','titel1');
	objTitel.style.position = 'absolute';
	objTitel.style.left = '2px';
	objTitel.style.top = '2px';
	objTitel.style.textAlign = 'left';
	objTitel.style.overflow = 'auto';
	objTitel.style.backgroundColor = '#ffffff';
	objBody.appendChild(objTitel);
	objTitel.style.display = 'none';
	objTitel.innerHTML= '<div>'+Bilder_liste+'</div><table border="0" cellpadding="0" cellspacing="0" align="left" width="100%"><tr><td align="left"><font style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; "><strong>Titel</strong></font></td></tr></table>'

	var objExit = document.createElement("div");
	objExit.setAttribute('id','exit1');
	objExit.onclick = function() { Ende(0); return false; };
	objExit.style.position = 'absolute';
	objExit.style.right = '2px';
	objExit.style.top = '2px';
	objExit.style.backgroundImage = 'url('+exit+')';
	objExit.style.cursor = 'pointer';
	objInlay1.appendChild(objExit);
	objExit.style.display = 'none';
	objExit.style.width="30px";
	objExit.style.height="30px";		


	var objMore = document.createElement("div");
	objMore.setAttribute('id','mehr1');
	objMore.onclick = function() { auto_fade(); return false; };
	objMore.style.position = 'absolute';
	objMore.style.left = '2px';
	objMore.style.top = '2px';
	objMore.style.backgroundImage = 'url('+more+')';
	objMore.style.cursor = 'pointer';
	objInlay1.appendChild(objMore);
	objMore.style.width="30px";
	objMore.style.height="30px";		
	objMore.style.display = 'none';

	var objNext = document.createElement("div");
	objNext.setAttribute('id','next1');
	objNext.onclick = function() { aktive_id++; manuel_next_img(); return false; };
	objNext.style.position = 'absolute';
	objNext.style.right = '62px';
	objNext.style.top = '2px';
	objNext.style.backgroundImage = 'url('+next+')';
	objNext.style.cursor = 'pointer';
	objInlay1.appendChild(objNext);
	objNext.style.width="30px";
	objNext.style.height="30px";		
	objNext.style.display = 'none';

	var objPref = document.createElement("div");
	objPref.setAttribute('id','pref1');
	objPref.onclick = function() { aktive_id--; manuel_next_img(); return false; };
	objPref.style.position = 'absolute';
	objPref.style.right = '92px';
	objPref.style.top = '2px';
	objPref.style.backgroundImage = 'url('+pref+')';
	objPref.style.cursor = 'pointer';
	objInlay1.appendChild(objPref);
	objPref.style.width="30px";
	objPref.style.height="30px";		
	objPref.style.display = 'none';

	setTimeout("start_pics();",500);
	//setTimeout("document.getElementById('Bild_load').style.display = 'none'; resize();",500);
}

function Ende(opacity){
	opacity = 0;
//timeout_fade_top = setTimeout("init_fade_top();",10);
		clearTimeout(timer_auto_fade);
		autofading = 0;
		/*if (position_fade_top == anzahl_fade_top) { 
			position_fade_top = 1; 
		} else {
			position_fade_top--;
		}*/

		var object = document.getElementById("inlay1").style; 
		object.opacity = (opacity / 100);
		object.MozOpacity = (opacity / 100);
		object.KhtmlOpacity = (opacity / 100);
		object.filter = "alpha(opacity=" + opacity + ")";
		object.display = 'block';
		if (opacity > 0) {
			setTimeout("Ende("+(opacity-5)+")",10);
		} else {
			for (var i = 0 ; i < id_array.length ; i++) {
				var merker = document.getElementById(id_array[i]);
				if(merker) {
					document.getElementById(id_array[i]).style.display = "none";
					var objOverlay = document.getElementById(id_array[i]);
					objOverlay.setAttribute('id', id_array[i]+'_close');
				}
			}
		}

}


function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}


function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function Highlight(row, hcolor) {
		
		var obj = document.getElementById(row);
		
		obj.style.background = hcolor;
}

function HighlightRestore(row, rcolor) {
		
		var obj = document.getElementById(row);
		
		obj.style.background = rcolor;
}

function ImgHighlight(img) {
	
	document.images[img].className = 'ImgHighlight';
}

function ImgHighlightReset(img) {
	
	document.images[img].className = 'ImgHighlightRestore';
}

function Change(url) {
	
	document.images['ImgLarge'].src = url;
	new Effect.Opacity('ImgLarge', {duration:1.0, from:0.0, to:1.0});
}

function ImgChange(url) {
	
	new Effect.Opacity('ImgLarge', {duration:0.3, from:1.0, to:0.0});
	setTimeout(function() { Change(url); }, 300);
}

function ChangeInd(id, url) {
	
	document.images[id].src = url;
	new Effect.Opacity(id, {duration:1.0, from:0.0, to:1.0});
}

function ImgChangeInd(id, url) {
	
	new Effect.Opacity(id, {duration:0.3, from:1.0, to:0.0});
	setTimeout(function() { ChangeInd(id, url); }, 300);
}

function show1(id, gesamt)
{
	for(var i = 1;i<=gesamt;i++) {
		document.getElementById('name'+i).style.display = 'none';
	}
	
	el = document.getElementById(id);
	//alert(id+ ' - ' + gesamt);
	if (el.style.display == 'none')
	{
		el.style.display = '';
		//el = document.getElementById('more' + id);
		//el.innerHTML = 'less...';
	} else {
		el.style.display = 'none';
		//el = document.getElementById('more' + id);
		//el.innerHTML = 'more...';
	}
}



