
//*****************************************************************************
// Global Javascript Functions
//*****************************************************************************

//-----------------------------------------------------------------------------
//--- Set Global Variables like Navigator
//-----------------------------------------------------------------------------

var InfoWin;
infowinopen=false;
PromoWinopen=false;

if (navigator.appName == "Netscape" && parseInt(navigator.appVersion) >= 3  ) netsc = true;
else
  if (navigator.appName.substring(0,9)=="Microsoft"&&parseInt(navigator.appVersion)>=4)
    netsc=true
  else netsc = false;
	
//-----------------------------------------------------------------------------
//--- Open Remote Window --- Window Name is 'InfoWin'
//-----------------------------------------------------------------------------

function InfoWinOpen(strWindowName,strLocation){
	var intWidth, intHeigth
	intWidth=985;
	intHeight=600;
	InfoWin = window.open(strLocation,strWindowName,"dependent=yes,locationbar=no,menubar=no,resizeable=yes,status=yes,scrollbars=yes,width=" + intWidth + ",height=" + intHeight);
	InfoWin.moveTo((screen.width/2)-492,(screen.height/2)-300);
	InfoWin.focus()
	}

//-----------------------------------------------------------------------------
//--- Window Name is 'ImageWin'
//-----------------------------------------------------------------------------

function ImageWinOpen(link,winWidth,winHeight){
	if (winWidth > 800)
		winWidth = 800;
	if (winHeight > 600)
		winHeight = 600;
	if (winWidth <= 80)
		winWidth = 400;
	if (winHeight <= 220)
		winHeight = 400;
	ImageWin = window.open(link,"ImageWin","WIDTH=" + winWidth + ",HEIGHT=" + winHeight + ",resizeable=yes,status=yes,scrollbars=yes");
	ImageWin.focus()
	}
//-----------------------------------------------------------------------------
//--- Window Name is 'SearchWin'
//-----------------------------------------------------------------------------

function SearchWinOpen(link,winWidth,winHeight){
	window.open(link,"SearchWin","WIDTH=" + winWidth + ",HEIGHT=" + winHeight + ",resizeable=yes,status=yes,scrollbars=yes");
	}
	
//-----------------------------------------------------------------------------
//--- Window Name is 'HelpWin'
//-----------------------------------------------------------------------------

function HelpWinOpen(link,winWidth,winHeight){
	InfoWin = window.open(link,"InfoWin","WIDTH=" + winWidth + ",HEIGHT=" + winHeight + ",scrollbars=yes,resizable=no");
	InfoWin.moveTo((screen.width/2)-(winWidth/2),(screen.height/2)-(winHeight/2));
	InfoWin.focus()
	}

//-----------------------------------------------------------------------------
//--- Open Remote Window --- Window Name is 'ExportAlertWin'
//-----------------------------------------------------------------------------

function ExportAlertWinOpen(varparam,link){
	winname="ExportAlertWin";
	parent.ExportAlertWin=window.open("",winname,"width=650,height=450,resizable=0,scrollbars=yes");
	parent.ExportAlertWin.location=link + varparam
}
//-----------------------------------------------------------------------------
//--- Open Remote Window --- Window Name is 'DownloadWin'
//-----------------------------------------------------------------------------

function DownloadWinOpen(varparam,link){
	DownloadWin = window.open(link + varparam,"DownloadWin","WIDTH=800,HEIGHT=600,resizable=yes,scrollbars=yes,status=yes,menubar=yes");
	}

//-----------------------------------------------------------------------------
//--- Open Remote Window --- Window Name is 'InfoWin'
//-----------------------------------------------------------------------------

function mailopen(varparam,link,Width,Height){
 InfoWin=window.open("","InfoWin","WIDTH=" + Width + ",HEIGHT=" + Height + ",resizable=yes,scrollbars=yes,status=yes");
InfoWin.location=link + varparam;
 infowinopen=true;
if (netsc)
	InfoWin.focus()
}

//function mailopen(varparam,link){
// InfoWin=window.open("","InfoWin","Width=600, Height=350");
//InfoWin.location=link + varparam;
//  infowinopen=true;
// if (netsc)
//	InfoWin.focus()
//}

function remclose(){
  if (netsc){
   if (infowinopen)
    if (!InfoWin.closed)
     InfoWin.close()
  }
  else{
    InfoWin=window.open('','InfoWin','width=0,height=0,resizable=yes,scrollbars=yes,status=yes');
    InfoWin.close()
  }
}

function OpenWindow(page) {window.open(page,"Winner","dependent=yes,height=600,locationbar=no,menubar=no,resizeable=no,status=no,width=400,left=100,top=50");}

//-----------------------------------------------------------------------------
//--- Open Remote Window for Meta data editing
//-----------------------------------------------------------------------------

function MetaWinOpen(strLocation,strWindowName){
	MetaWin = window.open(strLocation,strWindowName,"dependent=yes,locationbar=no,menubar=no,resizeable=yes,status=yes,scrollbars=yes,width=776,height=690");
	MetaWin.moveTo((screen.width/2)-388,0);
	MetaWin.focus()
	}

//-----------------------------------------------------------------------------
//--- Open Remote Window for Content data editing
//-----------------------------------------------------------------------------

function ContentWinOpen(strLocation){
	ContentWin = window.open(strLocation,'ContentWin','resizable=yes,scrollbars=yes,status=yes');
	ContentWin.focus()
}

//-----------------------------------------------------------------------------
//--- Open Remote Window for Attachment
//-----------------------------------------------------------------------------

function AttachmentWinOpen(strLocation,strAttachmentNumber){
	var intWidth, intHeigth
	AttachmentWin = window.open(strLocation,strAttachmentNumber,"dependent=yes,locationbar=no,menubar=no,resizable=yes,status=yes,scrollbars=yes,width=810,height=690");
	//AttachmentWin.moveTo((screen.width/2)-388,0);
	intWidth=736;
	intHeight=380;
	if (screen.availHeight < intHeight) intHeight = screen.availHeight;
	if (screen.availWidth < intWidth) intWidth = screen.availWidth;
	AttachmentWin.resizeTo(intWidth, intHeight);
	AttachmentWin.focus()
	}
//	AttachmentWin = window.open(strLocation,strAttachmentNumber,"dependent=yes,width=810,height=' + window.screen.availHeight + ',locationbar=no,menubar=no,resizable=yes,status=yes,scrollbars=yes"); //


//-----------------------------------------------------------------------------
//--- ocImgButton Functions
//-----------------------------------------------------------------------------

function hov(button,on){
    if (verok){
		if (hovButtonInit.length>0&&hovButtonInit==button) return true;
		if (hovButton.length > 0) {
			//-- Restore old button --//
			if (hovButtonInit.length > 0 && hovButtonInit==hovButton) {
				document.images["btn"+hovButtonInit].src=eval("btn"+hovButtonInit+hovStatusInit+".src");
				hovButton=hovButtonInit;
				hovStatus = hovStatusInit;
				if (on=="-1") on=hovStatusInit;
				}
			else {
				document.images["btn"+hovButton].src=eval("btn"+hovButton+"0.src");
				hovStatus="0";
				}
			}
		if (on=="-1") on="0";
		if (hovButton!=button||hovStatus!=on) {
			document.images["btn"+button].src=eval("btn"+button+on+".src");
			hovButton=button;
			hovStatus=on;
			}
		if (on=="3"){
			if (hovButtonInit.length>0&&hovButtonInit!=button){
				document.images["btn"+hovButtonInit].src=eval("btn"+hovButtonInit+"0.src");
				}
			hovButtonInit=button
			hovStatusInit=3
			}
    }
    return true;
}

function hovSelect(button) {
	hovButtonInit=button;
	hovStatusInit="3";
	document.images["btn"+hovButtonInit].src=eval("btn"+hovButtonInit+hovStatusInit+".src");
}

        
function hov2(button,on){
    if (verok){
        if ((status!="0")&&(status!=button)&&(on=="2"))
        document.images["button"+status].src = eval("btn"+status+".src");
        if (on=="1") text="h"; else text="";
        if ((on!="2")&&( status!=button  )) document.images["button"+button].src = eval("btn"+button+text+".src");
        if ((on=="2")&&(status!=button))  document.images["button"+button].src = eval("btn"+button+"o"+".src");
        if (on=="2")   status=button
    }
}
        
//-------------------------------------------------------------------------------------------------
//--- Save Records without question
//-------------------------------------------------------------------------------------------------
function saveNow(ns){
	if (document.readyState == "complete"){
		blnIsLoaded = true
	}
	
	strAlert = strLoadingText;
	
	if (blnIsSaving==true){
		strAlert = strSavingText;
	}
	if (blnIsLoaded==true){
		if (blnIsSaving==false){
			blnIsSaving = true;
			strAlert = strSavingText;
			window.defaultStatus=strAlert;
			scriptForm.action = scriptForm.action + '&ns=' + ns;
			document.scriptForm.submit();
		}else{
			info(strAlert)
		}
	}else{
		info(strAlert)
	}
	return false;
}

//-------------------------------------------------------------------------------------------------
//--- Save Records without question
//-------------------------------------------------------------------------------------------------
function info(strAlert){
	alert(strAlert);
	}
        
//-------------------------------------------------------------------------------------------------
//--- Delete Records with question Yes or no 
//-------------------------------------------------------------------------------------------------
function deleteQuestion(){
if (IE4){
	if(confirm("geänderten Datensatz\n\nWirklich Löschen?\n\n JA? --> OK\nNEIN? --> Abbrechen")){
		document.scriptForm.submit()
		return false
		}
	else{
		}
	}
else{
	if(confirm("geänderten Datensatz\n\nWirklich Löschen?\n\n JA? --> OK\nNEIN? --> Abbrechen")){
		document.Main.document.scriptForm.submit()
		return false
		}
	else{
		}
	}	
	return true	
}
//-------------------------------------------------------------------------------------------------
//--- Delete Records without question
//-------------------------------------------------------------------------------------------------
function deleteNow(){
if (IE4){
	document.scriptForm.submit()
	return false
	}
else{
	document.Main.document.scriptForm.submit()
	return false
	}	
}


//-------------------------------------------------------------------------------------------------
//--- Calculate metering or inch
//-------------------------------------------------------------------------------------------------
function metertoinch(strSourceField,strOutputField,strTypeField,strType){
var SourceValue = 0
var outputValue = 0
var intVar		= 2.54
if (IE4){
	if (strType == 'cm'){
		if (document.scriptForm[strTypeField][0].checked){
			SourceValue = document.scriptForm[strSourceField].value
			outputValue = SourceValue / intVar
			outputValue = Math.round(outputValue * 100)/100
			document.scriptForm[strOutputField].value = outputValue
			}
		else{
			metertoinch(strOutputField,strSourceField,strTypeField,'inch')
			return false
			}
		}
	else{
		if (document.scriptForm[strTypeField][1].checked){
			SourceValue = document.scriptForm[strSourceField].value
			outputValue = SourceValue * intVar
			outputValue = Math.round(outputValue * 100)/100
			document.scriptForm[strOutputField].value = outputValue
			}
		else{
			metertoinch(strOutputField,strSourceField,strTypeField,'cm')
			return false
			}
		}

	}
else{
	if (strType == 'cm'){
		if (document.Main.document.scriptForm[strTypeField][0].checked){
			SourceValue = document.Main.document.scriptForm[strSourceField].value
			outputValue = SourceValue / intVar
			outputValue = Math.round(outputValue * 100)/100
			if (outputValue < 1){
				outputValue = '0' + outputValue
				}
			document.Main.document.scriptForm[strOutputField].value = outputValue
			}
		else{
			metertoinch(strOutputField,strSourceField,strTypeField,'inch')
			return false
			}
		}
	else{
		if (document.Main.document.scriptForm[strTypeField][1].checked){
			SourceValue = document.Main.document.scriptForm[strSourceField].value
			outputValue = SourceValue * intVar
			outputValue = Math.round(outputValue * 100)/100
			if (outputValue < 1){
				outputValue = '0' + outputValue
				}
			document.Main.document.scriptForm[strOutputField].value = outputValue
			}
		else{
			metertoinch(strOutputField,strSourceField,strTypeField,'cm')
			return false
			
			}
		}

	}
}


//--- Functions for ocMenu			
function ShowTab(objElement){
	if (IEx4||IEx5)
	{
		if (objElement == '0') {
			if (openMenu != '0' && stop == false){
				openMenu.style.visibility='hidden';
				openMenu = 0;
			}
			return true
		}else{
			whichEl = eval(objElement);
			if (openMenu != 0 && openMenu != whichEl)
			{
				openMenu.style.visibility='hidden';
			}
			whichEl.style.visibility='visible';
			openMenu = eval(whichEl);
		}
	}
	if (Net4x||Net4)
	{
		if (objElement == '0') {
			if (openMenu != '0' && stop==false){
				openMenu.visibility='hidden';
				openMenu = 0;
			}
			return true
		}else{
			whichEl = eval('document.' + objElement);
			if (openMenu != 0 && openMenu != objElement)
			{
				whichClose = eval('document.' + openMenu)
				whichClose.visibility='hidden';
			}
			whichEl.visibility='visible';
			openMenu = objElement;
		}
	}
	if (Net6)
	{
		if (objElement == '0') {
			if (openMenu != '0' && stop==false){
				document.getElementById(openMenu).style.visibility='hidden';
				openMenu = 0;
			}
			return true
		}else{
			if (openMenu != 0 && openMenu != objElement)
			{
				document.getElementById(openMenu).style.visibility='hidden';
			}
			document.getElementById(objElement).style.visibility='visible';
			openMenu = objElement;
		}
	}
}
			
function closeTab(){
	var time= new Date();
	hours= time.getHours();
	mins= time.getMinutes();
	secs= time.getSeconds();
	closeTime=hours*3600+mins*60+secs;
	closeTime+=1;
	stop = false;
	Timer();
}

function Timer(){
	var time= new Date();
	hours= time.getHours();
	mins= time.getMinutes();
	secs= time.getSeconds();
	curTime=hours*3600+mins*60+secs;
	if(curTime>=closeTime){
		ShowTab('0');
	}else{
		if (stop == false){
			timeLeft();
		}
	}
}

function timeLeft(){
	count = closeTime-curTime;
	window.setTimeout('Timer()',50);
}

function stopCloseTab(objElement){
	stop = true;
}


//-------------------------------------------------------------------------------------------------
//--- Homepage Function for the 500.100 Error Page
//-------------------------------------------------------------------------------------------------

function Homepage(){
// in real bits, urls get returned to our script like this:
// res://shdocvw.dll/http_404.htm#http://www.DocURL.com/bar.htm 

	//For testing use DocURL = "res://shdocvw.dll/http_404.htm#https://www.microsoft.com/bar.htm"
	
	DocURL=document.URL;
	
	//this is where the http or https will be, as found by searching for :// but skipping the res://
	
	protocolIndex=DocURL.indexOf("://",4);
	
	//this finds the ending slash for the domain server 
	
	serverIndex=DocURL.indexOf("/",protocolIndex + 3);

	//for the href, we need a valid URL to the domain. We search for the # symbol to find the begining 
	//of the true URL, and add 1 to skip it - this is the BeginURL value. We use serverIndex as the end marker.
	//urlresult=DocURL.substring(protocolIndex - 4,serverIndex);
	
	BeginURL=DocURL.indexOf("#",1) + 1;
	urlresult=DocURL.substring(BeginURL,serverIndex);
		
	//for display, we need to skip after http://, and go to the next slash
	
	displayresult=DocURL.substring(protocolIndex + 3 ,serverIndex);
	document.write('<A HREF="' + urlresult + '">' + displayresult + "</a>");
}
