// JavaScript Document


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function getAllImages(actPic) {
	var tmpText = '';
	var active = '';
	if (document.getElementById("prodImage")) {
		if (actPic == 0) { document.imageList[0]["file"] = document.getElementById("prodImage").src.substr(document.getElementById("prodImage").src.lastIndexOf("/")+1); }
		for (var i=0; i < document.imageList.length; i++) {
			tmpText += '<a href="#" onClick="MM_swapImage(\'prodImage\',\'\',\'../../img/prod/' + document.imageList[i]["file"] + '\',1);getAllImages(' + i + ');MM_findObj(\'prodImage\').title=\'' + document.imageList[i]["copy"] + '\';return true;"><img src="../../img/icon_image' + (i == actPic ? '_a' : '') + '.gif" width="10" height="8" alt="Bild ' + i + '" name="bild' + i + '"></a> ';
		}
		/*Zurückblättern*/
		if (actPic != 0) { tmpText = '<a href="#" onClick="MM_swapImage(\'prodImage\',\'\',\'../../img/prod/' + document.imageList[actPic-1]["file"] + '\',1);getAllImages(' + (actPic-1) + ');MM_findObj(\'prodImage\').title=\'' + document.imageList[actPic-1]["copy"] + '\';return true;"><img src="../../img/icon_lastimage.gif" width="10" height="10" alt="Bild' + (actPic-1) + ' &lt;"></a> ' + tmpText; }
		/*Vorblättern*/
		if (actPic != (document.imageList.length-1)) { 
			tmpText += '<a href="#" onClick="MM_swapImage(\'prodImage\',\'\',\'../../img/prod/' + document.imageList[actPic+1]["file"] + '\',1);getAllImages(' + (actPic+1) + ');MM_findObj(\'prodImage\').title=\'' + document.imageList[(actPic+1)]["copy"] + '\';return true;"><img src="../../img/icon_nextimage.gif" width="10" height="10" alt="&gt; Bild' + (actPic+1) + '"></a> ';
		} else {
			tmpText += '<img src="../../img/trans.gif" width="10" height="10" alt="">';
		}
	} else if (document.getElementById("refImage")) {
		if (actPic == 0) { document.imageList[0]["file"] = document.getElementById("refImage").src.substr(document.getElementById("refImage").src.lastIndexOf("/")+1); }
		for (var i=0; i < document.imageList.length; i++) {
			tmpText += '<a href="#" onClick="MM_swapImage(\'refImage\',\'\',\'../../img/ref/' + document.imageList[i]["file"] + '\',1);getAllImages(' + i + ');MM_findObj(\'refImage\').title=\'' + document.imageList[i]["copy"] + '\';return true;"><img src="../../img/icon_image' + (i == actPic ? '_a' : '') + '.gif" width="10" height="8" alt="Bild ' + i + '" name="bild' + i + '"></a> ';
		}
		/*Zurückblättern*/
		if (actPic != 0) { tmpText = '<a href="#" onClick="MM_swapImage(\'refImage\',\'\',\'../../img/ref/' + document.imageList[actPic-1]["file"] + '\',1);getAllImages(' + (actPic-1) + ');MM_findObj(\'refImage\').title=\'' + document.imageList[actPic-1]["copy"] + '\';return true;"><img src="../../img/icon_lastimage.gif" width="10" height="10" alt="Bild' + (actPic-1) + ' &lt;"></a> ' + tmpText; }
		/*Vorblättern*/
		if (actPic != (document.imageList.length-1)) { 
			tmpText += '<a href="#" onClick="MM_swapImage(\'refImage\',\'\',\'../../img/ref/' + document.imageList[actPic+1]["file"] + '\',1);getAllImages(' + (actPic+1) + ');MM_findObj(\'refImage\').title=\'' + document.imageList[(actPic+1)]["copy"] + '\';return true;"><img src="../../img/icon_nextimage.gif" width="10" height="10" alt="&gt; Bild' + (actPic+1) + '"></a> ';
		} else {
			tmpText += '<img src="../../img/trans.gif" width="10" height="10" alt="">';
		}
	}
	document.getElementById("navImages").innerHTML = tmpText;
	
}

function validateKontaktde() {
	var returnString = '';
	if (document.forms['jobFormular'].surname.value == '')	{ 
		returnString += '- Surname\n'; 
		document.forms['jobFormular'].surname.style.border = '2px solid #FF0000';
	} else {
		document.forms['jobFormular'].surname.style.border = '1px solid #BABABA';
	}
	if (document.forms['jobFormular'].mail.value == '')	{
		returnString += ('- E-mail');
		document.forms['jobFormular'].mail.style.border = '2px solid #FF0000';
	} else {
		document.forms['jobFormular'].mail.style.border = '1px solid #BABABA';
	}
	if (returnString != '') { 
		returnString = ('Please fill in the following fields:\n') + returnString;
		alert(returnString);
		return false; 
	}
	else { return true; }
}

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_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 MM_CheckFlashVersion(reqVerStr,msg){
  with(navigator){
    var isIE  = (appVersion.indexOf("MSIE") != -1 && userAgent.indexOf("Opera") == -1);
    var isWin = (appVersion.toLowerCase().indexOf("win") != -1);
    if (!isIE || !isWin){  
      var flashVer = -1;
      if (plugins && plugins.length > 0){
        var desc = plugins["Shockwave Flash"] ? plugins["Shockwave Flash"].description : "";
        desc = plugins["Shockwave Flash 2.0"] ? plugins["Shockwave Flash 2.0"].description : desc;
        if (desc == "") flashVer = -1;
        else{
          var descArr = desc.split(" ");
          var tempArrMajor = descArr[2].split(".");
          var verMajor = tempArrMajor[0];
          var tempArrMinor = (descArr[3] != "") ? descArr[3].split("r") : descArr[4].split("r");
          var verMinor = (tempArrMinor[1] > 0) ? tempArrMinor[1] : 0;
          flashVer =  parseFloat(verMajor + "." + verMinor);
        }
      }
      // WebTV has Flash Player 4 or lower -- too low for video
      else if (userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 4.0;

      var verArr = reqVerStr.split(",");
      var reqVer = parseFloat(verArr[0] + "." + verArr[2]);
  
      if (flashVer < reqVer){
        if (confirm(msg))
          window.location = "http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash";
      }
    }
  } 
}
