function showInfo(aID, isHOK)
{
	var aInfo;
	var aX = new String(screen.availWidth/2-200);
	var aY = new String(screen.availHeight/2-200);

	aParam = "width=400,height=350,left="+aX+",top="+aY+"dependent=yes,menubar=no,status=no,toolbar=no,scrollbars=yes";
	
	if (isHOK==true)
	{
		aInfo = window.open("/onlinekatalog/info.asp?aID="+aID,"aInfo",aParam);
	}
	else
	{
		aInfo = window.open("/info.asp?aID="+aID,"aInfo",aParam);
	}
	aInfo.focus();
}

// rwh 060817 function showImage(imgPath)
function showImage(imgPath, wm)
{
	var aImage;
/*	var aX = new String(screen.availWidth/2-200);
	var aY = new String(screen.availHeight/2-200); */

	var aX = "50"
	var aY = "50"

//	aParam = "width=200,height=350,left="+aX+",top="+aY+"dependent=yes,menubar=no,status=no,toolbar=no";
	aParam = "width=1,height=1,left="+aX+",top="+aY+"dependent=yes,menubar=no,status=no,toolbar=no";

	imgPath = imgPath.replace("+","__plus__");
	imgPath = imgPath.replace("&","__und__");
// rwh 050905	aImage = window.open("showImage.asp?img="+imgPath,"aImage",aParam);
// rwh 060817 	aImage = window.open("/showImage.asp?img="+imgPath,"aImage",aParam);
	aImage = window.open("/showImage.asp?img="+imgPath+"&nowm="+wm,"aImage",aParam);

	aImage.focus();
}

/*****************************************************************************************************
	die folgenden 4 funktionen betreffen die preiseinschränkung bei der suche sowohl nach 
	einkaufspreis als auch nach verkaufspreis, aufschlag und frachtkosten;
******************************************************************************************************/
function myRound(aNumber, aDigits)
{
	return Math.round(aNumber * Math.pow(10,aDigits)) / Math.pow(10,aDigits)
}
	
function berechneEKPreise(aForm)
{
	if (aForm.radioPreis[0].checked)
	{
		fracht = Number(aForm.fracht.value.replace(",","."));
		aufschlag = Number(aForm.aufschlag.value.replace(",","."));
		//frachtundaufschlag = fracht + aufschlag;
		min_vk_preis = Number(aForm.min_vk_preis.value.replace(",","."));
		max_vk_preis = Number(aForm.max_vk_preis.value.replace(",","."));
		if (aForm.min_vk_preis.value != '')
		{
			min_preisohneaufschlag = min_vk_preis*100/(100+aufschlag);
			min_preisohnefracht = min_preisohneaufschlag*100/(100+fracht);
			aForm.min_ek_preis.value=String(myRound(min_preisohnefracht,3)).replace(".",",");
		}
		else
			aForm.min_ek_preis.value='';
		if (aForm.max_vk_preis.value != '')
		{
			max_preisohneaufschlag = max_vk_preis*100/(100+aufschlag);
			max_preisohnefracht = max_preisohneaufschlag*100/(100+fracht);
			aForm.max_ek_preis.value=String(myRound(max_preisohnefracht,3)).replace(".",",");
		}
		else
			aForm.max_ek_preis.value='';
	}
}

function radioPreisChange(aForm)
{
	with (aForm)
	{
		if (radioPreis[0].checked)
		{
			min_ek_preis.disabled = true;
			max_ek_preis.disabled = true;
			
			min_vk_preis.disabled = false;
			max_vk_preis.disabled = false;
			aufschlag.disabled = false;
			fracht.disabled = false;
			
			berechneEKPreise(aForm);
// rwh 050722 
			if (document.searchform.authenticated.value.toLowerCase()=="authorized")
			{
				min_vk_preis.focus();
			}
// rwh 050722 ende
		}
		else
		{
			min_vk_preis.disabled = true;
			max_vk_preis.disabled = true;
			aufschlag.disabled = true;
			fracht.disabled = true;

			min_ek_preis.disabled = false;
			max_ek_preis.disabled = false;
// rwh 050722 
			if (document.searchform.authenticated.value.toLowerCase()=="authorized")
			{
				min_ek_preis.focus();
			}
// rwh 050722 ende
		}
	}
}

function enablePreise(aForm)
{
	aForm.min_ek_preis.disabled = false;
	aForm.max_ek_preis.disabled = false;
}

// Datumsvalidierung

var dtCh= ".";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strDay=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("Bitte geben Sie ein gültiges Datum in der Form tt.mm.jjjj ein")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Bitte geben Sie ein gültiges Monat ein.")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Bitte geben Sie einen gültigen Tag ein.")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Bitte geben Sie eine gültige Jahreszahl zwischen "+minYear+" und "+maxYear+" ein.")
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Bitte geben Sie ein gültiges Datum in der Form tt.mm.jjjj ein")
		return false
	}
return true
}
// Datumsvalidierung ende

// Emailvalidierung
function checkEmail(str)
{
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1)
	{
		alert("Diese EMail-Adresse ist ungültig. Geben Sie bitte eine gültige EMail-Adresse an.")
		return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
	{
		alert("Diese EMail-Adresse ist ungültig. Geben Sie bitte eine gültige EMail-Adresse an.")
		return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	    alert("Diese EMail-Adresse ist ungültig. Geben Sie bitte eine gültige EMail-Adresse an.")
	    return false
	}

	if (str.indexOf(at,(lat+1))!=-1)
	{
		alert("Diese EMail-Adresse ist ungültig. Geben Sie bitte eine gültige EMail-Adresse an.")
		return false
	}

	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
	{
		alert("Diese EMail-Adresse ist ungültig. Geben Sie bitte eine gültige EMail-Adresse an.")
		return false
	}

	if (str.indexOf(dot,(lat+2))==-1)
	{
		alert("Diese EMail-Adresse ist ungültig. Geben Sie bitte eine gültige EMail-Adresse an.")
		return false
	}

	if (str.indexOf(" ")!=-1)
	{
		alert("Diese EMail-Adresse ist ungültig. Geben Sie bitte eine gültige EMail-Adresse an.")
		return false
	}
	return true					
}

function checkEmail2(emailStr)
{
	/* The following pattern is used to check if the entered e-mail address
	fits the user@domain format.  It also is used to separate the username
	from the domain. */

	var emailPat=/^(.+)@(.+)$/;

	/* The following string represents the pattern for matching all special
	characters.  We don't want to allow special characters in the address. 
	These characters include ( ) < > @ , ; : \ " . [ ] */

	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

	/* The following string represents the range of characters allowed in a 
	username or domainname.  It really states which chars aren't allowed.*/

	var validChars="\[^\\s" + specialChars + "\]";

	/* The following pattern applies if the "user" is a quoted string (in
	which case, there are no rules about which characters are allowed
	and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
	is a legal e-mail address. */

	var quotedUser="(\"[^\"]*\")";

	/* The following pattern applies for domains that are IP addresses,
	rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
	e-mail address. NOTE: The square brackets are required. */

	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

	/* The following string represents an atom (basically a series of non-special characters.) */

	var atom=validChars + '+';

	/* The following string represents one word in the typical username.
	For example, in john.doe@somewhere.com, john and doe are words.
	Basically, a word is either an atom or quoted string. */

	var word="(" + atom + "|" + quotedUser + ")";

	// The following pattern describes the structure of the user

	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

	/* The following pattern describes the structure of a normal symbolic
	domain, as opposed to ipDomainPat, shown above. */

	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

	/* Finally, let's start trying to figure out if the supplied address is valid. */

	/* Begin with the coarse pattern to simply break up user@domain into
	different pieces that are easy to analyze. */

	var matchArray=emailStr.match(emailPat);

	if (matchArray==null)
	{
		/* Too many/few @'s or something; basically, this address doesn't
		even fit the general mould of a valid e-mail address. */

		alert("Die angegebene EMail-Adresse scheint ungültig zu sein (prüfen Sie die @ und .)");
		return false;
	}

	var user=matchArray[1];
	var domain=matchArray[2];

	// Start by checking that only basic ASCII characters are in the strings (0-127).

	for (i=0; i<user.length; i++)
	{
		if (user.charCodeAt(i)>127)
		{
			alert("Der Benutzername der angegebenen EMail-Adresse enthält ungültige Zeichen.");
			return false;
		}
	}

	for (i=0; i<domain.length; i++)
	{
		if (domain.charCodeAt(i)>127)
		{
			alert("Der Domainname der angegebenen EMail-Adresse enthält ungültige Zeichen.");
			return false;
		}
	}

	// See if "user" is valid 

	if (user.match(userPat)==null)
	{
		// user is not valid
		alert("Der Benutzername der angegebenen EMail-Adresse scheint ungültig zu sein.");
		return false;
	}

	/* if the e-mail address is at an IP address (as opposed to a symbolic
	host name) make sure the IP address is valid. */

	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null)
	{
	// this is an IP address
		for (var i=1;i<=4;i++)
		{
			if (IPArray[i]>255)
			{
				alert("Die angegebene IP-Adresse ist ungültig.");
				return false;
			}
		}
		return true;
	}

	// Domain is symbolic name.  Check if it's valid.
	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for (i=0;i<len;i++)
	{
		if (domArr[i].search(atomPat)==-1)
		{
			alert("Der Domainname der angegebenen EMail-Adresse scheint ungültig zu sein.");
			return false;
		}
	}

	// Make sure there's a host name preceding the domain.
	if (len<2)
	{
		alert("Die angegebene EMail-Adresse enthält keinen Hostnamen.");
		return false;
	}

	// If we've gotten this far, everything's valid!
	return true;
}
// Emailvalidierung ende


function checkAuth0 (sender,tx)
{
	if (document.searchform.authenticated.value.toLowerCase()!="authorized")
	{
		if (sender)
		{
			sender.value='';
			//sender.focus();
		}
		alert(tx)		
		parent.frameRight.location.href = "right.asp?refresh=0";
	}
}

