// basic js-file
// sun26 vsd
///////////////////////////////////////////////////////////////////////
// data & array handling
function array_key_exists(key,arr){
	for(keys in arr) if(keys==key) return true;
	return false;
	}
	

function array_keys(arr){
	var keys = new Array();
	var i=0;
	for(key in arr){keys[i]=key;i++}
	return keys;
	}


function in_array(value,arr){
	for(key in arr) if(arr[key]==value) return true;
	return false;
	}
	
function count(arr){
	var i=0;
	for(keys in arr) i++;
	return i;
	}

// some functions
function getOBJ(item) {
	if (document.all) return(document.all[item]);
	if (document.getElementById) return(document.getElementById(item));
	return(false);
	}

function center(w){
	if(window.innerWidth) screenWidth = window.innerWidth;
	if(document.body.offsetHeight) screenWidth = document.body.offsetWidth;
	var rv = (screenWidth-w)/2-10;
	if(rv<0) rv=0;
	return rv;
	}

function getRef(id){
	if (document.getElementById) return document.getElementById(id);
	else if (document.all) return document.all[id];
	else return false;
	}
function getImg(id){
	if(typeof(document.images[id])!="undefined") return document.images[id]; else return false;
	}
	
function fadeswap(imgid,bgobjid,isrc){
	imgob = getImg(imgid);
	bgob = getOBJ(bgobjid);
	// set current image obj url to background image
	if(browser.isIE){
		bgob.style.backgroundImage = 'url('+imgob.src+')';
		// set image to monitor
		imgob.style.filter="alpha(opacity=0)";
		imgob.src = isrc;
		// set opacity object
		opacity_object = imgob;
		if(fader) reset_fader();
		fader = window.setInterval("faseit(opacity_object)",5); 
		} else {
			imgob.src = isrc;
			}
	}
	
var fader;
var opacity_object;
var opacity=0;
function faseit(this_obj){
  if(typeof(this_obj)=='object'){
	opacity+=4;
	this_obj.style.filter="alpha(opacity="+opacity+")";
	if(opacity>=100) reset_fader();
	}
  }
function reset_fader(){
	window.clearInterval(fader);
	fader=null;
	opacity=0;
	}
///////////////////////////////////////////////////////////////////////
// some functions loading modules

function search(){
	document.location.href = action_url+"search.php";
	}

function index(){
	document.location.href = action_url+"index.php";
	}

function sitemap(){
	document.location.href = action_url+"sitemap.php";
	}

function info(){
	document.location.href = action_url+"info.php";
	}

function mail(d,n,f){
	if(typeof(d)=="undefined"){var d=''; var n=''; var f='any.com';}
	document.location.href=action_url+"mail.php?n="+n+"&d="+d+"&f="+f;
	}

function mailorder(address,id){
	if(typeof(address)=="undefined") var address='';
	document.location.href = action_url+"order.php?address="+address+"&product="+id;
	}

function shop(address,id,prize){
	if(typeof(address)=="undefined") var address='';
	document.location.href = action_url+"shop.php?address="+address+"&product="+id+"&prize="+prize;
	}
function checkMailImput(id){
	var checked=true;
	var ok=/^([_a-zA-Z0-9-]+)(\.[_a-zA-Z0-9-]+)*@([a-zA-Z0-9-]+\.)+([a-zA-Z]{2,3})$/;  //checkmail
	if(!ok.test(getOBJ(id).value)) {
		  alert('Bitte geben Sie eine vollständige Email Adresse an!');
		  checked=false;
		  }
	return checked;
	}
	
function iPop(src,w,h){
	// under construction
	window.status="ipop: "+src+" "+w+" "+h;
	}
	
/////////////////////////////////////////////////////////////////////// browser detedtion
function BrowserDetectLite() {
   var ua = navigator.userAgent.toLowerCase(); 

   // browser name
   this.isGecko     = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1);
   this.isMozilla   = (this.isGecko && ua.indexOf('gecko/') + 14 == ua.length);
   this.isNS        = ( (this.isGecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('opera') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) );
   this.isIE        = ( (ua.indexOf('msie') != -1) && (ua.indexOf('opera') == -1) && (ua.indexOf('webtv') == -1) ); 
   this.isSafari    = (ua.indexOf('safari') != - 1);
   this.isOpera     = (ua.indexOf('opera') != -1); 
   this.isKonqueror = (ua.indexOf('konqueror') != -1 && !this.isSafari); 
   this.isIcab      = (ua.indexOf('icab') != -1); 
   this.isAol       = (ua.indexOf('aol') != -1); 
   
   // spoofing and compatible browsers
   this.isIECompatible = ( (ua.indexOf('msie') != -1) && !this.isIE);
   this.isNSCompatible = ( (ua.indexOf('mozilla') != -1) && !this.isNS && !this.isMozilla);

   // browser version
   this.versionMinor = parseFloat(navigator.appVersion); 
   
   // correct version number
   if (this.isNS && this.isGecko) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('/') + 1 ) );
   }
   else if (this.isIE && this.versionMinor >= 4) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
   }
   else if (this.isMozilla) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) );
   }
   else if (this.isSafari) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('/') + 1 ) );
   }
   else if (this.isOpera) {
      if (ua.indexOf('opera/') != -1) {
         this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera/') + 6 ) );
      }
      else {
         this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera ') + 6 ) );
      }
   }
   else if (this.isKonqueror) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('konqueror/') + 10 ) );
   }
   else if (this.isIcab) {
      if (ua.indexOf('icab/') != -1) {
         this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab/') + 6 ) );
      }
      else {
         this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab ') + 6 ) );
      }
   }
   
   this.versionMajor = parseInt(this.versionMinor); 
   this.geckoVersion = ( (this.isGecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );
   
   // dom support
   this.isDOM1 = (document.getElementById);
   this.isDOM2Event = (document.addEventListener && document.removeEventListener);
   
   // css compatibility mode
   this.mode = document.compatMode ? document.compatMode : 'BackCompat';

   // platform
   this.isWin   = (ua.indexOf('win') != -1);
   this.isWin32 = (this.isWin && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1 || ua.indexOf('xp') != -1) );
   this.isMac   = (ua.indexOf('mac') != -1);
   this.isUnix  = (ua.indexOf('unix') != -1 || ua.indexOf('sunos') != -1 || ua.indexOf('bsd') != -1 || ua.indexOf('x11') != -1)
   this.isLinux = (ua.indexOf('linux') != -1);

   // specific browser shortcuts
   this.isNS4x = (this.isNS && this.versionMajor == 4);
   this.isNS40x = (this.isNS4x && this.versionMinor < 4.5);
   this.isNS47x = (this.isNS4x && this.versionMinor >= 4.7);
   this.isNS4up = (this.isNS && this.versionMinor >= 4);
   this.isNS6x = (this.isNS && this.versionMajor == 6);
   this.isNS6up = (this.isNS && this.versionMajor >= 6);
   this.isNS7x = (this.isNS && this.versionMajor == 7);
   this.isNS7up = (this.isNS && this.versionMajor >= 7);
   
   this.isIE4x = (this.isIE && this.versionMajor == 4);
   this.isIE4up = (this.isIE && this.versionMajor >= 4);
   this.isIE5x = (this.isIE && this.versionMajor == 5);
   this.isIE55 = (this.isIE && this.versionMinor == 5.5);
   this.isIE5up = (this.isIE && this.versionMajor >= 5);
   this.isIE6x = (this.isIE && this.versionMajor == 6);
   this.isIE6up = (this.isIE && this.versionMajor >= 6);
   
   this.isIE4xMac = (this.isIE4x && this.isMac);
}

var browser = new BrowserDetectLite();


///////////////////////////////////////////////////////////////////////
// image preloading stuff

if(typeof(pld)!="undefined") for(i=0;i<pld.length;i++){ prel = new Image(); prel.src = pld[i];}

function preload(pld){
	for(i=0;i<pld.length;i++){ prel = new Image(); prel.src = pld[i];}
	}

///////////////////////////////////////////////////////////////////////
// better debugging with this

window.onerror = errorhandler;
function errorhandler(message,url,srcLine)
	{
	var s="client side scripting error occured !\n\nplease make a note of the following information:"
	s+="\n\n" + message +"\n";
	s+="located in line:"+srcLine+"\n";
	s+="located in file:"+url+"\n";
	if(SHOW_ERROR) alert(s); 
	return true;
	}


function eventOffsetX(this_event){
		return ((this_event.offsetX) ? this_event.offsetX : this_event.layerX);
	}
function eventOffsetY(this_event){
		return ((this_event.offsetY) ? this_event.offsetY : this_event.layerY);
	}

