/* ################################################################### */
/*   © 2011 MyArtSide 			                                       */
/*   all rights reserved                                               */
/* ################################################################### */

function checkBrowserName(name){   
   var agent = navigator.userAgent.toLowerCase();   
   if (agent.indexOf(name.toLowerCase())>-1) {   
     return true;   
   }   
   return false;   
}


/* Popup */
var request = false;
function setRequest(content) {
	if (window.XMLHttpRequest) {
		request = new XMLHttpRequest(); // Mozilla, Safari, Opera
	} else if (window.ActiveXObject) {
		try {
			request = new ActiveXObject('Msxml2.XMLHTTP'); // IE 5
		} catch (e) {
			try {
				request = new ActiveXObject('Microsoft.XMLHTTP'); // IE 6
			} catch (e) {}
		}
	}

	if (!request) {
		alert("Kann keine XMLHTTP-Instanz erzeugen");
		return false;
	} else {
		var url = "incl/ajax.php";
		var value = content;
		request.open('post', url, true);
		request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		request.send('var='+value);
		request.onreadystatechange = interpretRequest;
	}
}


function interpretRequest() {
	switch (request.readyState) {
	
		case 4:
			if (request.status != 200) {
				alert("Fehler:"+request.status);
			} else {
				var xmlDoc	= request.responseXML;
        var content	= xmlDoc.getElementsByTagName('html')[0].firstChild.nodeValue;
        document.getElementById('ajax_content').style.display = 'block';
				document.getElementById('ajax_content').innerHTML	= content;
        //document.body.style.overflow = 'hidden';
        
        if(checkBrowserName('MSIE')){
          document.getElementById('GUIsysPopup').style.top = document.body.scrollTop+'px';
          document.body.style.overflow = 'hidden';
        }
      }
			break;
		default:
		break;
	}
}

function popupClose(){
  document.getElementById('ajax_content').innerHTML = '';
  if(checkBrowserName('MSIE')){
    document.body.style.overflow = 'auto';
  }
  document.getElementById('ajax_content').style.display = 'none';
}


/* player */

function getPlayer(movieName){
	if (navigator.appName.indexOf("Microsoft") != -1) 	{
		return window[movieName];
  } 	else {
		return document[movieName];
	}
}

function play1(){
	getPlayer('player1').playMusic();
}
	
function stop1(){
  getPlayer('player1').stopMusic();
}

/* Slidebox  /
var pos = 0;
if(checkBrowserName('MSIE')){
  var speed = 140
}else{
  var speed = 200
}
 
function scrollLeft(space)
{
  
	var obj = document.getElementById('slider');
	var apos = pos;
	var width = parseInt(document.getElementById("slide_"+pos).width) + parseInt(space);
	pos += 1;
	pos %= obj.children.length;
	// 148px Breite und 50 Schritte
	slide(obj, 'style.marginLeft', (-apos*width), (-pos*width), speed);     
}

function scrollRight(space)
{
	var obj = document.getElementById('slider');
	var apos = pos;
  pos -= 1;
	if(pos<0) pos += obj.children.length;
	alert(apos);
	alert(document.getElementById("slide_"+apos).style.width);
	var width = parseInt(document.getElementById("slide_"+apos).style.width) + parseInt(space);
	
	
	// 148px Breite und 50 Schritte
	slide(obj, 'style.marginLeft', (-apos*width), (-pos*width), speed);  
}

function slide(obj, attribute, start, ende, duration, func)
{
	var step = (ende-start)/duration;
	//px-angabe nötig ?
	var px = ((attribute.indexOf("style.height")>-1) ? 'px' : '');
	px = ((px || attribute.indexOf("style.width")>-1) ? 'px' : '');
	px = ((px || attribute.indexOf("style.top")>-1) ? 'px' : '');
	px = ((px || attribute.indexOf("style.left")>-1) ? 'px' : '');
	px = ((px || attribute.indexOf("style.marginTop")>-1) ? 'px' : '');
	px = ((px || attribute.indexOf("style.marginLeft")>-1) ? 'px' : '');
	setTimeout(function doit() {slideStep(obj, attribute, start, step, ende, px, func);}, 1);
}

function slideStep(obj, attribute, start, step, ende, px, func)
{
	eval('obj.'+attribute+'="'+start.toString()+px+'"');
	if(((ende<start) && step<0) || ((ende>start) && step>0)) setTimeout(function() {slideStep(obj, attribute, (start+step), step, ende, px, func);}, 1);
	else
	{
		eval('obj.'+attribute+'="'+ende.toString()+px+'"');
		if(typeof(func)=="function") func();
	}
}
*/

/* Slidebox */
var pos = 0;
if(checkBrowserName('MSIE')){
  var speed = 140
}else{
  var speed = 200
}


function scrollLeft(width)
{
	var obj = document.getElementById('slider');
	var apos = pos;
	pos += 1;
	pos %= obj.children.length;
	// 148px Breite und 50 Schritte
	slide(obj, 'style.marginLeft', (-apos*width), (-pos*width), speed);
}

function scrollRight(width)
{
	var obj = document.getElementById('slider');
	var apos = pos;
	pos -= 1;
	if(pos<0) pos += obj.children.length;
	// 148px Breite und 50 Schritte
	slide(obj, 'style.marginLeft', (-apos*width), (-pos*width), speed);
}

function slide(obj, attribute, start, ende, duration, func)
{
	var step = (ende-start)/duration;
	//px-angabe nötig ?
	var px = ((attribute.indexOf("style.height")>-1) ? 'px' : '');
	px = ((px || attribute.indexOf("style.width")>-1) ? 'px' : '');
	px = ((px || attribute.indexOf("style.top")>-1) ? 'px' : '');
	px = ((px || attribute.indexOf("style.left")>-1) ? 'px' : '');
	px = ((px || attribute.indexOf("style.marginTop")>-1) ? 'px' : '');
	px = ((px || attribute.indexOf("style.marginLeft")>-1) ? 'px' : '');
	setTimeout(function doit() {slideStep(obj, attribute, start, step, ende, px, func);}, 1);
}

function slideStep(obj, attribute, start, step, ende, px, func)
{
	eval('obj.'+attribute+'="'+start.toString()+px+'"');
	if(((ende<start) && step<0) || ((ende>start) && step>0)) setTimeout(function() {slideStep(obj, attribute, (start+step), step, ende, px, func);}, 1);
	else
	{
		eval('obj.'+attribute+'="'+ende.toString()+px+'"');
		if(typeof(func)=="function") func();
	}
}
