/*
* JavaScript default.js
*/

function UtsiOnLoad() {
    FadePreStart();
}

function bwechsel(bpfad){
	document.MoiBild.src = bpfad;
}
 
function popup(bpfad2){
	F = window.open(bpfad2, "_blank");
}

function noSpam(user){
	
	domain = "pong.li";
	defaultmail="ping@pong.li";

	if (user != undefined){
		defaultemail = user+"@"+domain;
	}

	window.location.href = 'mailto:'+defaultmail;

}

function OnMouseOverHandler(inUtsi) {
   
  if (inUtsi[0] == "0"){
   inUtsi = inUtsi.slice(1); 
  }
  
  document.getElementById('dynamicContent').firstChild.nodeValue = GetDynamicText(inUtsi);
  
}


function ChangeSelect(dropDown, dropDownSub, dropDownDoc, inRootList, inSubList, inDocList){


	
	foundSelect = false;
	idx = 0;
	
	for (i=0; i<inRootList.length; i++) {
		if (dropDown.options[dropDown.selectedIndex].value == inRootList[i]) { // kategorie selektiert?
			dropDownSub.options.length = 0;
			for (k=0; k<inSubList[i].length; k++){
				dropDownSub.options[k] = new Option(inSubList[i][k]);
			}
			foundSelect = true;
		}
	}
	
	
	if (foundSelect) {

		for (i=0; i<inRootList.length; i++) {
			for (k=0; k<inSubList[i].length; k++){
				if (dropDownSub.options[dropDownSub.selectedIndex].value == inSubList[i][k]) { // subkategorie selektiert?
					for (l=0; l<inDocList[i][k].length; l++){
						dropDownDoc.options[l] = new Option(inDocList[i][k][l]);
					}
				} else {
					dropDownDoc.options.length = 0;
					dropDownDoc.options[0]= new Option("*nix*");
				}
			}
		}
	
	} else {
		dropDownSub.options.length = 0;
		dropDownSub.options[0] = new Option("*nix*");
	
/*	
		idx = 1;
		dropDownSub.options.length = 0;
		dropDownSub.options[0] = new Option("");
		for (i=0; i<inRootList.length; i++) {
			for (k=0; k<inSubList[i].length; k++){
				dropDownSub.options[idx] = new Option(inSubList[i][k]);
				idx++;
			}
		}			
*/
	}


} // End ChangeSelect


function ChangeSelectSub(dropDown, dropDownSub, dropDownDoc, inRootList, inSubList, inDocList){


	for (i=0; i<inRootList.length; i++) {
		for (k=0; k<inSubList[i].length; k++){
			if (dropDownSub.options[dropDownSub.selectedIndex].value == inSubList[i][k]) { // subkategorie selektiert?
				dropDownDoc.options.length = 0;
				if (inDocList[i][k].length>0) {
					for (l=0; l<inDocList[i][k].length; l++){
						dropDownDoc.options[l] = new Option(inDocList[i][k][l]);
					} 
				} else {
					dropDownDoc.options[0] = new Option("*nix*");
				}
			} 
		}
	}
	

}



function windowed(bnr){
	
    var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		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
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			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 = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
	
	var containerWidth = 640;
	
	document.getElementById("imgContainer").style.left = pageWidth/2 - containerWidth/2+"px";
	document.getElementById("galleryBG").style.width = pageWidth+"px";
	document.getElementById("galleryBG").style.height = pageHeight+"px";
	document.getElementById("galleryBG").style.visibility = "visible";
	_imageNr = bnr;
	ChangeImage(bnr);
		
}

function windowedclose() {
	
	document.getElementById("galleryBG").style.visibility = "hidden";
	_imageNr = 0;
	

}

function Gback() {
	
	if (_imageNr<=0){
		_imageNr = _maxNr;
	} else {
		_imageNr--;
	}
	
	ChangeImage(_imageNr);

}


function Gnext() {
	
	if(_imageNr>=_maxNr){
		_imageNr = 0;
	} else {
		_imageNr++;
	}
	
	ChangeImage(_imageNr);
	
}

function ChangeImage(bnr){
	
	document.__UTSIgallery.src = _imageSrc[bnr];
	
}


//
//  getPageSize()
//
function getPageSize() {
 
	return [pageWidth,pageHeight];
}









