// Kontrolle von Eingaben in Eingabetextfeldern auf max. Länge
// Aufruf mit z.B. <textarea onkeyup="kontrolle(1,2)">
function kontrolle( a, b ){
var x = document.forms[a].elements[b].value;
if( x.length > 255 ) x = x.substring( 0, 255 );
document.forms[a].elements[b].value = x;
}

// Social Bookmarking
function socialOver(text) {
	if (text == '') {
		text = '...';
	} else {
		text='&nbsp;<strong>'+text+'</strong>';
	}
	document.getElementById('socialText').innerHTML=text;
}
function socialDo(was) {
	socialurl=encodeURIComponent(location.href);
	socialtitle=encodeURIComponent(document.title);
	switch(was) {		
		case 'delicious':
			window.open('http://del.icio.us/post?url='+socialurl+'&title='+socialtitle);
			break;
		case 'wong':
			window.open('http://www.mister-wong.de/index.php?action=addurl&bm_url='+socialurl+'&bm_description='+socialtitle);
			break;
		case 'blinkList':
			window.open('http://www.blinklist.com/index.php?Action=Blink/addblink.php&Description=&Url='+socialurl+'&Title='+socialtitle);
			break;
		case 'yahoo':
			window.open('http://myweb2.search.yahoo.com/myresults/bookmarklet?u='+socialurl+'&t='+socialtitle);
			break;
		case 'yigg':
			window.open('http://yigg.de/neu?exturl='+socialurl+'&exttitle='+socialtitle);
			break;	
		case 'furl':
			window.open('http://www.furl.net/storeIt.jsp?u='+socialurl+'&t='+socialtitle);
			break;
		case 'oneview':
			window.open('http://beta.oneview.de:80/quickadd/neu/addBookmark.jsf?URL='+socialurl+'&title='+socialtitle);			
			break;
		case 'folkd':
			window.open('http://www.folkd.com/submit/page/'+socialurl);
			break;
		case 'linkarena':	
			window.open('http://linkarena.com/bookmarks/addlink/?url='+socialurl+'&title='+socialtitle+'&desc=&tags=');
			break;
		case 'google': 		
			window.open('http://www.google.com/bookmarks/mark?op=add&hl=de&bkmk='+socialurl+'&title='+socialtitle);
			break;
		case 'webnews': 		
			window.open('http://www.webnews.de/einstellen?url='+socialurl+'&title='+socialtitle);
			break;

		case 'edelight': 		
			form.edelight.submit();
			break;
	}
}


// Title: Tigra Calendar
// URL: http://www.softcomplex.com/products/tigra_calendar/
// Version: 3.3 (European date format)
// Date: 09/01/2005 (mm/dd/yyyy)
// Note: Permission given to use this script in ANY kind of applications if
//    header lines are left unchanged.
// Note: Script consists of two files: calendar?.js and calendar.html

// if two digit year input dates after this year considered 20 century.
var NUM_CENTYEAR = 30;
// is time input control required by default
var BUL_TIMECOMPONENT = false;
// are year scrolling buttons required by default
var BUL_YEARSCROLL = true;

var calendars = [];
var RE_NUM = /^\-?\d+$/;

function calendar1(obj_target) {

	// assigning methods
	this.gen_date = cal_gen_date1;
	this.gen_time = cal_gen_time1;
	this.gen_tsmp = cal_gen_tsmp1;
	this.prs_date = cal_prs_date1;
	this.prs_time = cal_prs_time1;
	this.prs_tsmp = cal_prs_tsmp1;
	this.popup    = cal_popup1;

	// validate input parameters
	if (!obj_target)
		return cal_error("Error calling the calendar: no target control specified");
	if (obj_target.value == null)
		return cal_error("Error calling the calendar: parameter specified is not valid target control");
	this.target = obj_target;
	this.time_comp = BUL_TIMECOMPONENT;
	this.year_scroll = BUL_YEARSCROLL;
	
	// register in global collections
	this.id = calendars.length;
	calendars[this.id] = this;
}

function cal_popup1 (str_datetime) {
	if (str_datetime) {
		this.dt_current = this.prs_tsmp(str_datetime);
	}
	else {
		this.dt_current = this.prs_tsmp(this.target.value);
		this.dt_selected = this.dt_current;
	}
	if (!this.dt_current) return;

	var obj_calwindow = window.open(
		'calendar.html?datetime=' + this.dt_current.valueOf()+ '&id=' + this.id,
		'Calendar', 'width=200,height='+(this.time_comp ? 215 : 190)+
		',status=no,resizable=no,top=200,left=200,dependent=yes,alwaysRaised=yes'
	);
	obj_calwindow.opener = window;
	obj_calwindow.focus();
}

// timestamp generating function
function cal_gen_tsmp1 (dt_datetime) {
	return(this.gen_date(dt_datetime) + ' ' + this.gen_time(dt_datetime));
}

// date generating function
function cal_gen_date1 (dt_datetime) {
	return (
		(dt_datetime.getDate() < 10 ? '0' : '') + dt_datetime.getDate() + "."
		+ (dt_datetime.getMonth() < 9 ? '0' : '') + (dt_datetime.getMonth() + 1) + "."
		+ dt_datetime.getFullYear()
	);
}
// time generating function
function cal_gen_time1 (dt_datetime) {
	return (
		(dt_datetime.getHours() < 10 ? '0' : '') + dt_datetime.getHours() + ":"
		+ (dt_datetime.getMinutes() < 10 ? '0' : '') + (dt_datetime.getMinutes()) + ":"
		+ (dt_datetime.getSeconds() < 10 ? '0' : '') + (dt_datetime.getSeconds())
	);
}

// timestamp parsing function
function cal_prs_tsmp1 (str_datetime) {
	// if no parameter specified return current timestamp
	if (!str_datetime)
		return (new Date());

	// if positive integer treat as milliseconds from epoch
	if (RE_NUM.exec(str_datetime))
		return new Date(str_datetime);
		
	// else treat as date in string format
	var arr_datetime = str_datetime.split(' ');
	return this.prs_time(arr_datetime[1], this.prs_date(arr_datetime[0]));
}

// date parsing function
function cal_prs_date1 (str_date) {

	var arr_date = str_date.split('.');

	if (arr_date.length != 3) return cal_error ("Invalid date format: '" + str_date + "'.\nFormat accepted is dd-mm-yyyy.");
	if (!arr_date[0]) return cal_error ("Invalid date format: '" + str_date + "'.\nNo day of month value can be found.");
	if (!RE_NUM.exec(arr_date[0])) return cal_error ("Invalid day of month value: '" + arr_date[0] + "'.\nAllowed values are unsigned integers.");
	if (!arr_date[1]) return cal_error ("Invalid date format: '" + str_date + "'.\nNo month value can be found.");
	if (!RE_NUM.exec(arr_date[1])) return cal_error ("Invalid month value: '" + arr_date[1] + "'.\nAllowed values are unsigned integers.");
	if (!arr_date[2]) return cal_error ("Invalid date format: '" + str_date + "'.\nNo year value can be found.");
	if (!RE_NUM.exec(arr_date[2])) return cal_error ("Invalid year value: '" + arr_date[2] + "'.\nAllowed values are unsigned integers.");

	var dt_date = new Date();
	dt_date.setDate(1);

	if (arr_date[1] < 1 || arr_date[1] > 12) return cal_error ("Invalid month value: '" + arr_date[1] + "'.\nAllowed range is 01-12.");
	dt_date.setMonth(arr_date[1]-1);
	 
	if (arr_date[2] < 100) arr_date[2] = Number(arr_date[2]) + (arr_date[2] < NUM_CENTYEAR ? 2000 : 1900);
	dt_date.setFullYear(arr_date[2]);

	var dt_numdays = new Date(arr_date[2], arr_date[1], 0);
	dt_date.setDate(arr_date[0]);
	if (dt_date.getMonth() != (arr_date[1]-1)) return cal_error ("Invalid day of month value: '" + arr_date[0] + "'.\nAllowed range is 01-"+dt_numdays.getDate()+".");

	return (dt_date)
}

// time parsing function
function cal_prs_time1 (str_time, dt_date) {

	if (!dt_date) return null;
	var arr_time = String(str_time ? str_time : '').split(':');

	if (!arr_time[0]) dt_date.setHours(0);
	else if (RE_NUM.exec(arr_time[0]))
		if (arr_time[0] < 24) dt_date.setHours(arr_time[0]);
		else return cal_error ("Invalid hours value: '" + arr_time[0] + "'.\nAllowed range is 00-23.");
	else return cal_error ("Invalid hours value: '" + arr_time[0] + "'.\nAllowed values are unsigned integers.");
	
	if (!arr_time[1]) dt_date.setMinutes(0);
	else if (RE_NUM.exec(arr_time[1]))
		if (arr_time[1] < 60) dt_date.setMinutes(arr_time[1]);
		else return cal_error ("Invalid minutes value: '" + arr_time[1] + "'.\nAllowed range is 00-59.");
	else return cal_error ("Invalid minutes value: '" + arr_time[1] + "'.\nAllowed values are unsigned integers.");

	if (!arr_time[2]) dt_date.setSeconds(0);
	else if (RE_NUM.exec(arr_time[2]))
		if (arr_time[2] < 60) dt_date.setSeconds(arr_time[2]);
		else return cal_error ("Invalid seconds value: '" + arr_time[2] + "'.\nAllowed range is 00-59.");
	else return cal_error ("Invalid seconds value: '" + arr_time[2] + "'.\nAllowed values are unsigned integers.");

	dt_date.setMilliseconds(0);
	return dt_date;
}

function cal_error (str_message) {
	alert (str_message);
	return null;
}

function renameField(wrd_nr,f_code)
{
	var datei = "admin.php?mode=lang_rename_field&f_code="+f_code+"&wrd_nr="+wrd_nr+"&l_code=de";
	window.open(datei,"Rename","width=300,height=120,status=no,menubar=no,scrollbars=yes");
}




function focuswechseldich(feld, next, anzahl)
		{
			nextid = document.getElementById(next);
			if(feld.value.length >= anzahl)
			{
				nextid.focus();
			}
		}
function top_window()
    {
    self.focus();
    // window.setTimeout("top()",1000);		//Zeitwert zum erneuten öffnen
    }

function OpenNewWindow(Picture, Hoch, Breit)
    {
    xsize = Breit + 35; // Zusatz für Rand rechts und links
    ysize = Hoch + 130; //Zusatz für Rand oben und unten - damit Button angezeigt werden kann 

    ScreenWidth = screen.width;
    ScreenHeight = screen.height;

    xpos = (ScreenWidth / 2) - (xsize / 2);
    ypos = (ScreenHeight / 2) - (ysize / 2);

    NewWindow = window.open("", "Picture", "height=" + ysize + ",width=" + xsize + ",scrollbars=no,resizable=no,top="
                                + ypos + ",left=" + xpos + "");
    NewWindow.document.write("<html><head><title>DETAIL LIMAGE");
    NewWindow.document.write("</title><link rel='stylesheet' type='text/css' href='tpl/css1.css'></head>");
    NewWindow.document.write("<body onload='focus()'>");
    NewWindow.document.write("<table align='center'><tr>");
    NewWindow.document.write("<td align='center' valign='top'>");
    NewWindow.document.write("<table border='0' cellpadding='0' cellspacing='1'><tr><td align='center'>");
    NewWindow.document.write("<img src=");
    NewWindow.document.write(Picture);
    NewWindow.document.write(">");
    NewWindow.document.write("</tr></table>");
    NewWindow.document.write("</td></tr><tr>");
    NewWindow.document.write("<td align='center' valign='top'>");
    NewWindow.document.write("<center><form><input type='button' value='FENSTER SCHLIESSEN' style='font-family: Verdana; font-size: 10px' onClick='self.close()'>");
    NewWindow.document.write("</td></tr></table>");
    NewWindow.document.write("</form></body></html>");
    NewWindow.document.close();
    NewWindow.resizeTo(xsize, ysize);
    }

function setPointer(theRow)
    {
    if (typeof (theRow.style) == 'undefined')
        {
        return false;
        }

    if (typeof (document.getElementsByTagName) != 'undefined')
        {
        var theCells = theRow.getElementsByTagName('td');
        }

    else if (typeof (theRow.cells) != 'undefined')
        {
        var theCells = theRow.cells;
        }

    else
        {
        return false;
        }

    var rowCellsCnt = theCells.length;

    for (var c = 0; c < rowCellsCnt; c++)
        {
        if (theCells[c].parentNode == theRow)
            {
            theCells[c].style.backgroundColor = '#E7EBEB';
            }
        }

    return true;
    }

function unsetPointer(theRow)
    {
    if (typeof (document.getElementsByTagName) != 'undefined')
        {
        var theCells = theRow.getElementsByTagName('td');
        }

    else if (typeof (theRow.cells) != 'undefined')
        {
        var theCells = theRow.cells;
        }

    else
        {
        return false;
        }

    var rowCellsCnt = theCells.length;

    for (var c = 0; c < rowCellsCnt; c++)
        {
        if (theCells[c].parentNode == theRow)
            {
            theCells[c].style.backgroundColor = '';
            }
        }

    return true;
    }

function openWin()
    {
    window.open('order.php?mode=password&sid=<?php echo $sid ?>', 'Passwort',
                'toolbar=no,statusbar=no,scrollbars=no,menu=no,height=300,width=450');
    }

function radio_input(url)
    {
    // Re-direct the browser to the url value
    window.location.href = url
    }

function disable()
    {
    document.getElementById("Submit").value = "submit";
    var result = gbSubmit;

    if (gbSubmit)
        {
        gbSubmit = false;
        }

    document.basketForm.CheckOut.value = "purchase";
    document.getElementById("Submit").disabled = result;
    document.basketForm.submit();
    }

function change_article_picture(URL)
    {
    document.js_article_picture.src = URL;
    return;
    }

function jumpto(form)
    {
    var myindex = form.sortbar.selectedIndex

    if (form.sortbar.options[myindex].value != "0")
        {
        location = form.sortbar.options[myindex].value;
        }
    }

if (self != top)
    {
    top.location.href = location.href;
    }

// Function to "activate" images
function imgOver(imgName, StatusMsg)
    {
    document[imgName].src = eval(imgName + "h.src");
    window.status = StatusMsg;
    }

// Function to "deactivate" images.
function imgOut(imgName)
    {
    document[imgName].src = eval(imgName + "n.src");
    window.status = "";
    }

var mstat = new Array();

function klapp(mid, mdepht)
    {
    if (mstat[mdepht] == undefined)
        {
        mstat[mdepht] = "";
        }

    if (mstat[mdepht] != "" && mstat[mdepht] != mid)
        {
        window.document.getElementById(mstat[mdepht]).style.display = "none";
        }

    if (mstat[mdepht] != mid)
        {
        window.document.getElementById(mid).style.display = "block";
        window.document.getElementById(mid).style.paddingLeft = mdepht * 3;
        mstat[mdepht] = mid;
        }

    else
        {
        window.document.getElementById(mid).style.display = "none";
        mstat[mdepht] = "";
        }
    }

function popup(picture, x, y)
    {
    target = picture;
    x += 20;
    y += 20;
    window.open(target, "popup", "toolbar=no,statusbar=no,scrolling=no,menubar=no,width=" + y + ",height=" + x);
    }

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_validateForm()
    { //v4.0
    var i, p, q, nm, test, num, min, max, errors = '', args = MM_validateForm.arguments;

    for (i = 0; i < (args.length - 2); i += 3)
        {
        test = args[i + 2];
        val = MM_findObj(args[i]);

        if (val)
            {
            nm = val.name;

            if ((val = val.value) != "")
                {
                if (test.indexOf('isEmail') != -1)
                    {
                    p = val.indexOf('@');

                    if (p < 1 || p == (val.length - 1))
                        errors += '- ' + nm + ' must contain an e-mail address.\n';
                    }

                else if (test != 'R')
                    {
                    num = parseFloat(val);

                    if (isNaN(val))
                        errors += '- ' + nm + ' must contain a number.\n';

                    if (test.indexOf('inRange') != -1)
                        {
                        p = test.indexOf(':');
                        min = test.substring(8, p);
                        max = test.substring(p + 1);

                        if (num < min || max < num)
                            errors += '- ' + nm + ' must contain a number between ' + min + ' and ' + max + '.\n';
                        }
                    }
                }

            else if (test.charAt(0) == 'R')
                errors += '- ' + nm + ' is required.\n';
            }
        }

    if (errors)
        alert('The following error(s) occurred:\n' + errors);

    document.MM_returnValue = (errors == '');
    }

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

function MM_jumpMenu2(targ, selObj, restore)
    { //v3.0
    eval(targ + ".location='" + selObj.options[selObj.selectedIndex].value + "'");

    if (restore)
        selObj.selectedIndex = 0;
    }

function MM_jumpMenuGo(selName, targ, restore)
    { //v3.0
    var selObj = MM_findObj(selName);

    if (selObj)
        MM_jumpMenu(targ, selObj, restore);
    }

/*
Simple Image Trail script- By JavaScriptKit.com
Visit http://www.javascriptkit.com for this script and more
This notice must stay intact
*/

var offsetfrommouse = [25, -15]; //image x,y offsets from cursor position in pixels. Enter 0,0 for no offset
var displayduration = 0;         //duration in seconds image should remain visible. 0 for always.
var currentimageheight = 300;    // maximum image size.

if (document.getElementById || document.all)
    {
    document.write('<div id="trailimageid">');
    document.write('</div>');
    }

function gettrailobj()
    {
    if (document.getElementById)
        return document.getElementById("trailimageid").style

    else if (document.all)
        return document.all.trailimagid.style
    }

function gettrailobjnostyle()
    {
    if (document.getElementById)
        return document.getElementById("trailimageid")

    else if (document.all)
        return document.all.trailimagid
    }

function truebody()
    {
    return (!window.opera && document.compatMode && document.compatMode != "BackCompat")
        ? document.documentElement : document.body
    }

function showtrail(imagename, title, showthumb, height, width)
    {
    if (height > 0)
        {
        currentimageheight = height;
        }

    if (width > 0)
        {
        currentimagewidth = width;
        }

    document.onmousemove = followmouse;

    cameraHTML = '';

    newHTML = '<div class="mousetrail">';
    newHTML = newHTML + '<span style="background:#cccccc;padding:1px;width:450px;">' + title + '</span><div class="borderbot"></div>';

    if (showthumb > 0)
        {
        newHTML = newHTML + '<div class="mousetrail2" align="center"><img src="' + imagename
                      + '" border="0"></div>';
        }

    newHTML = newHTML + '</div>';

    gettrailobjnostyle().innerHTML = newHTML;

    gettrailobj().visibility = "visible";
    }

function hidetrail()
    {
    gettrailobj().visibility = "hidden"
    document.onmousemove = ""
    gettrailobj().left = "-200px"
    }

function followmouse(e)
    {
    var xcoord = offsetfrommouse[0]
    var ycoord = offsetfrommouse[1]

    var docwidth = document.all ? truebody().scrollLeft + truebody().clientWidth : pageXOffset + window.innerWidth - 15
    var docheight = document.all ? Math.min(truebody().scrollHeight, truebody().clientHeight)
            : Math.min(document.body.offsetHeight, window.innerHeight)

    //if (document.all){
    //	gettrailobjnostyle().innerHTML = 'A = ' + truebody().scrollHeight + '<br />B = ' + truebody().clientHeight;
    //} else {
    //	gettrailobjnostyle().innerHTML = 'C = ' + document.body.offsetHeight + '<br />D = ' + window.innerHeight;
    //}

    if (typeof e != "undefined")
        {
        if (docwidth - e.pageX < 220)
            {
            xcoord = e.pageX - xcoord - 400; // Move to the left side of the cursor
            }

        else
            {
            xcoord += e.pageX;
            }

        if (docheight - e.pageY < (currentimageheight + 10))
            {
            ycoord += e.pageY - Math.max(0, (10 + currentimageheight + e.pageY - docheight - truebody().scrollTop));
            }

        else
            {
            ycoord += e.pageY;
            }
        }

    else if (typeof window.event != "undefined")
        {
        if (docwidth - event.clientX < 220)
            {
            xcoord = event.clientX + truebody().scrollLeft - xcoord - 400; // Move to the left side of the cursor
            }

        else
            {
            xcoord += truebody().scrollLeft + event.clientX
            }

        if (docheight - event.clientY < (currentimageheight + 10))
            {
            ycoord += event.clientY + truebody().scrollTop
                          - Math.max(0, (10 + currentimageheight + event.clientY - docheight));
            }

        else
            {
            ycoord += truebody().scrollTop + event.clientY;
            }
        }

    var docwidth = document.all ? truebody().scrollLeft + truebody().clientWidth : pageXOffset + window.innerWidth - 15
    var docheight = document.all ? Math.max(truebody().scrollHeight, truebody().clientHeight)
            : Math.max(document.body.offsetHeight, window.innerHeight)

    gettrailobj().left = xcoord + "px"
    gettrailobj().top = ycoord + "px"
    }

	
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

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_jumpMenuGo(selName,targ,restore){ //v3.0
  var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}

