// es muss immer als erster Parameter die Sid und als zweiter der referer übergeben werden (bzw. sowerden sie beim Aufruf immer übergeben -> also muss die Funktion dementsprechend so aufgebaut sein)


// öffnet in xml-schnittstelle die layout-vorschau

function openDlinksVS(promurl, sess, extraparams)
{
		F1 = window.open('contentpage.php?SESS=' + sess + '&promurl=' + escape(promurl) + '&mod=vidclips@@list_links.php' + extraparams, 'DirektLinks', 'toolbar=no,scrollbars=yes,resizable=yes,width=500,height=700,screenX=100,screenY=100,left=100,top=100');
  		F1.focus();
}


function open_layoutpreview(sid, referer, wsid, show_pastandard_layouts, show_eigene_layouts, xml_schnittstelle)
{  
  layoutref = document.form1.link_referer.value;
  
  F1 = window.open('promotion_xmllayoutpreview.php?sid=' + sid + '&referer=' + referer + '&wsid=' + wsid + '&layout_ref=' + layoutref + '&show_pastandard_layouts=' + show_pastandard_layouts + '&show_eigene_layouts=' + show_eigene_layouts + '&xml_schnittstelle=' + xml_schnittstelle, 'WEBMASTER_PROMOTION', 'toolbar=yes,scrollbars=yes,resizable=yes,width=1024,height=850,screenX=100,screenY=100,left=100,top=100');
  F1.focus();
}

function open_layout_vorschau(url) 
{
	F1 = window.open(url, "vorschau",'toolbar=yes,scrollbars=yes,resizable=yes,width=1024,height=850,screenX=100,screenY=100,left=100,top=100' );
	F1.focus();
}
	
// selectiert anhand des übergebenen referers das zugehörige layout in der referer-dropdown liste (welches der wm anklickt)

/* ALT WENN MIT LAYOUT DROPDOWN LISTE
function layout_select(referer)
{		
	var all_options = document.form1.link_referer.options;
	
	i=0;
	while(elem = all_options[i])  // alle optionen durchlaufen
	{
		if(referer == elem.value)
		{
			document.form1.link_referer.selectedIndex = i;			
			break;
		}		
		i++;		
	}	
}
*/
function layout_select(referer)
{		
		document.form_parameter.link_referer.value = referer;
}



// scrollt herunter wenn link in standard-layouts, standard-layouts-baukasten etc. geklickt wurde
function scroll_down(pix)
{		
		window.scrollTo(0, pix);  // bei richtigem frameset (z.B. referer 20013)
		
		window.parent.parent.scrollTo(0, pix);  // bei iframe framset muss im parent.parent gescrollt werden (z.B. referer 100)
}

// scrollt herunter wenn link in standard-layouts, standard-layouts-baukasten etc. geklickt wurde
function scroll_down_by(pix)
{		
		window.scrollBy(0, pix);  // bei richtigem frameset (z.B. referer 20013)	
		
		window.parent.parent.scrollBy(0, pix);  // bei iframe framset muss im parent.parent gescrollt werden (z.B. referer 100)
}

// banner anzeigen in popup
function openBanner(promurl, sess, lang_pre, extraparams)
{
		F1 = window.open('contentpage.php?SESS=' + sess + '&promurl=' + escape(promurl) + '&mod=banner&lang_pre=' + lang_pre + '&' + extraparams, 'Banner', 'toolbar=no,scrollbars=yes,resizable=yes,width=500,height=700,screenX=100,screenY=100,left=100,top=100');
  		F1.focus();
}

// dlinks anzeigen in popup
function openDlinks(promurl, sess, extraparams)
{
		F1 = window.open('contentpage.php?SESS=' + sess + '&promurl=' + escape(promurl) + '&mod=promo@@list_dlinks.php' + extraparams, 'DirektLinks', 'toolbar=no,scrollbars=yes,resizable=yes,width=500,height=700,screenX=100,screenY=100,left=100,top=100');
  		F1.focus();
}

// extra verkleinertes popup für die Spezial-OnlineCams
function openSpezialOnlineCams(promurl, sess, extraparams)
{
		F1 = window.open('contentpage.php?SESS=' + sess + '&promurl=' + escape(promurl) + '&mod=promo@@list_dlinks.php' + extraparams, 'DirektLinks', 'toolbar=no,scrollbars=yes,resizable=yes,width=500,height=200,screenX=100,screenY=100,left=100,top=100');
  		F1.focus();
}

// Hotgirl anzeigen in popup
function openHG(promurl, sess, extraparams)
{
		F1 = window.open('contentpage.php?SESS=' + sess + '&promurl=' + escape(promurl) + '&mod=promo@@list_hotgirl.php' + extraparams, 'Banner', 'toolbar=no,scrollbars=yes,resizable=yes,width=500,height=550,screenX=100,screenY=100,left=100,top=100');
  		F1.focus();
}

// Sender-Direkt-Bewerbung anzeigen in popup
function openSenderMember(promurl, sess, extraparams)
{
		F1 = window.open('contentpage.php?SESS=' + sess + '&promurl=' + escape(promurl) + '&mod=promo@@list_senderbewerben.php' + extraparams, 'SenderMember', 'toolbar=no,scrollbars=yes,resizable=yes,width=500,height=550,screenX=100,screenY=100,left=100,top=100');
  		F1.focus();
}

// Sender-Keywordsuche anzeigen in popup
function openKeywordsuche(wmvars, sess, extraparams)
{
		F1 = window.open('contentpage.php?SESS=' + sess + '&wmvars=' + escape(wmvars) + '&mod=promo@@list_keywordsuche.php' + extraparams, 'KeywordSendersuche', 'toolbar=no,scrollbars=yes,resizable=yes,width=500,height=650,screenX=100,screenY=100,left=100,top=100');
  		F1.focus();
}

// Hilfe-Fenster bei Projekt bearbeiten als popup
function openHelpEditProject(sess)
{
		F1 = window.open('contentpage.php?SESS=' + sess + '&mod=projekte@@help.php', 'Help', 'toolbar=no,scrollbars=yes,resizable=yes,width=250,height=400,screenX=100,screenY=100,left=100,top=100');
  		F1.focus();
}

// Hilfe-Fenster bei Standard/Eigene als popup
function openHelpLayouts(sess)
{
		F1 = window.open('contentpage.php?SESS=' + sess + '&mod=promo@@help_layouts.php', 'Help', 'toolbar=no,scrollbars=yes,resizable=yes,width=250,height=550,screenX=100,screenY=100,left=100,top=100');
  		F1.focus();
}


// Hilfe-Fenster bei Standard/Eigene als popup
function openVisitDetails(sess, startper)
{
		F1 = window.open('contentpage.php?mod=stats@@visits.php&SESS=' + sess + '&startper=' + startper + '&DONTSHOW_PAGEHEAD=true', 'Help', 'toolbar=no,scrollbars=yes,resizable=yes,width=600,height=600,screenX=100,screenY=100,left=100,top=100');
  		F1.focus();
}


// Hilfe-Fenster bei Standard/Eigene als popup
function openHelpNewLayout(sess, typ, breite, hoehe)
{
		F1 = window.open('contentpage.php?SESS=' + sess + '&mod=promo@@help_eigene.php&typ=' + typ + '&breite=' + breite + '&hoehe=' + hoehe, 'Help', 'toolbar=no,scrollbars=yes,resizable=yes,width=450,height=600,screenX=100,screenY=100,left=100,top=100');
  		F1.focus();
}

// öffnet Popup mit Beispiel-Bildern
function openShowpic(sess, pic, breite, hoehe)
{
		F1 = window.open('contentpage.php?SESS=' + sess + '&mod=promo@@showpic.php&pic=' + pic, 'Help', 'toolbar=no,scrollbars=no,resizable=yes,width=' + breite + ',height=' + hoehe + ',screenX=0,screenY=0,left=0,top=0');
  		F1.focus();
}

// Werbetool Externer Memberlogin anzeigen in popup
function openExtML(wmvars, sess)
{
		F1 = window.open('contentpage.php?SESS=' + sess + '&wmvars=' + escape(wmvars) + '&mod=promo@@list_extmemberlogin.php', 'Externer_MemberLogin', 'toolbar=no,scrollbars=yes,resizable=yes,width=500,height=760,screenX=100,screenY=100,left=100,top=100');
  		F1.focus();
}

// rss-feeds anzeigen in popup
function openRSS(promurl, sess, extraparams)
{				
		F1 = window.open('contentpage.php?SESS=' + sess + '&promurl=' + escape(promurl) + '&mod=rss&' + extraparams, 'RSS', 'toolbar=no,scrollbars=yes,resizable=yes,width=800,height=400,screenX=100,screenY=100,left=100,top=100');
  		F1.focus();
}

// dyn. banner anzeigen in popup  TODO -> raus wenn auch VideoDYNBANNER über webmaster.webmaster_promotionsettings laufen
function openDynBanner(bannerid, promurl, sess, extraparams)
{				
		F1 = window.open('contentpage.php?SESS=' + sess + '&promurl=' + escape(promurl) + '&mod=dynbanner&bannerid=' + bannerid + '&' + extraparams, 'DYN_BANNER', 'toolbar=no,scrollbars=yes,resizable=yes,width=500,height=700,screenX=100,screenY=100,left=100,top=100');
  		F1.focus();
}


// dyn. banner anzeigen in popup
function openDynBannerNew(bannerid, sess, bannerType, extraparams)
{				
		F1 = window.open('contentpage.php?SESS=' + sess + '&mod=dynbanner&bannerid=' + bannerid + '&bannerType=' + bannerType + '&' + extraparams, 'DYN_BANNER', 'toolbar=no,scrollbars=yes,resizable=yes,width=500,height=700,screenX=100,screenY=100,left=100,top=100');
  	    F1.focus();
}

// dyn. banner anzeigen in popup
function openSuchbox(promurl, sess, extraparams)
{				
		F1 = window.open('contentpage.php?SESS=' + sess + '&promurl=' + escape(promurl) + '&mod=suchbox&' + extraparams, 'RSS', 'toolbar=no,scrollbars=yes,resizable=yes,width=500,height=550,screenX=100,screenY=100,left=100,top=100');
  		F1.focus();
}

// flash-Preview-Videos anzeigen in popup
function openVideosFlashPreview(graphictype, promurl, sess, extraparams)
{				
		F1 = window.open('contentpage.php?SESS=' + sess + '&flash_graphicType=' + graphictype + '&promurl=' + escape(promurl) + '&mod=videos@@list_flashPreviewvideos.php&' + extraparams, 'FlashPreviewvideos', 'toolbar=no,scrollbars=yes,resizable=yes,width=500,height=550,screenX=100,screenY=100,left=100,top=100');
  		F1.focus();
}

/*
    json2.js
    2007-12-02

    Public Domain

    No warranty expressed or implied. Use at your own risk.

    See http://www.JSON.org/js.html

    This file creates a global JSON object containing two methods:

        JSON.stringify(value, whitelist)
            value       any JavaScript value, usually an object or array.

            whitelist   an optional array prameter that determines how object
                        values are stringified.

            This method produces a JSON text from a JavaScript value.
            There are three possible ways to stringify an object, depending
            on the optional whitelist parameter.

            If an object has a toJSON method, then the toJSON() method will be
            called. The value returned from the toJSON method will be
            stringified.

            Otherwise, if the optional whitelist parameter is an array, then
            the elements of the array will be used to select members of the
            object for stringification.

            Otherwise, if there is no whitelist parameter, then all of the
            members of the object will be stringified.

            Values that do not have JSON representaions, such as undefined or
            functions, will not be serialized. Such values in objects will be
            dropped; in arrays will be replaced with null.
            JSON.stringify(undefined) returns undefined. Dates will be
            stringified as quoted ISO dates.

            Example:

            var text = JSON.stringify(['e', {pluribus: 'unum'}]);
            // text is '["e",{"pluribus":"unum"}]'

        JSON.parse(text, filter)
            This method parses a JSON text to produce an object or
            array. It can throw a SyntaxError exception.

            The optional filter parameter is a function that can filter and
            transform the results. It receives each of the keys and values, and
            its return value is used instead of the original value. If it
            returns what it received, then structure is not modified. If it
            returns undefined then the member is deleted.

            Example:

            // Parse the text. If a key contains the string 'date' then
            // convert the value to a date.

            myData = JSON.parse(text, function (key, value) {
                return key.indexOf('date') >= 0 ? new Date(value) : value;
            });

    This is a reference implementation. You are free to copy, modify, or
    redistribute.

    Use your own copy. It is extremely unwise to load third party
    code into your pages.
*/

/*jslint evil: true */

/*global JSON */

/*members "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
    charCodeAt, floor, getUTCDate, getUTCFullYear, getUTCHours,
    getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join, length,
    parse, propertyIsEnumerable, prototype, push, replace, stringify, test,
    toJSON, toString
*/

if (!this.JSON) {

    JSON = function () {

        function f(n) {    // Format integers to have at least two digits.
            return n < 10 ? '0' + n : n;
        }

        Date.prototype.toJSON = function () {

// Eventually, this method will be based on the date.toISOString method.

            return this.getUTCFullYear()   + '-' +
                 f(this.getUTCMonth() + 1) + '-' +
                 f(this.getUTCDate())      + 'T' +
                 f(this.getUTCHours())     + ':' +
                 f(this.getUTCMinutes())   + ':' +
                 f(this.getUTCSeconds())   + 'Z';
        };


        var m = {    // table of character substitutions
            '\b': '\\b',
            '\t': '\\t',
            '\n': '\\n',
            '\f': '\\f',
            '\r': '\\r',
            '"' : '\\"',
            '\\': '\\\\'
        };

        function stringify(value, whitelist) {
            var a,          // The array holding the partial texts.
                i,          // The loop counter.
                k,          // The member key.
                l,          // Length.
                r = /["\\\x00-\x1f\x7f-\x9f]/g,
                v;          // The member value.
            switch (typeof value) {
            case 'string':

// If the string contains no control characters, no quote characters, and no
// backslash characters, then we can safely slap some quotes around it.
// Otherwise we must also replace the offending characters with safe sequences.

                return r.test(value) ?
                    '"' + value.replace(r, function (a) {
                        var c = m[a];
                        if (c) {
                            return c;
                        }
                        c = a.charCodeAt();
                        return '\\u00' + Math.floor(c / 16).toString(16) +
                                                   (c % 16).toString(16);
                    }) + '"' :
                    '"' + value + '"';

            case 'number':

// JSON numbers must be finite. Encode non-finite numbers as null.

                return isFinite(value) ? String(value) : 'null';

            case 'boolean':
            case 'null':
                return String(value);

            case 'object':

// Due to a specification blunder in ECMAScript,
// typeof null is 'object', so watch out for that case.

                if (!value) {
                    return 'null';
                }

// If the object has a toJSON method, call it, and stringify the result.

                if (typeof value.toJSON === 'function') {
                    return stringify(value.toJSON());
                }
                a = [];
                if (typeof value.length === 'number' &&
                        !(value.propertyIsEnumerable('length'))) {

// The object is an array. Stringify every element. Use null as a placeholder
// for non-JSON values.

                    l = value.length;
                    for (i = 0; i < l; i += 1) {
                        a.push(stringify(value[i], whitelist) || 'null');
                    }

// Join all of the elements together and wrap them in brackets.

                    return '[' + a.join(',') + ']';
                }
                if (whitelist) {

// If a whitelist (array of keys) is provided, use it to select the components
// of the object.

                    l = whitelist.length;
                    for (i = 0; i < l; i += 1) {
                        k = whitelist[i];
                        if (typeof k === 'string') {
                            v = stringify(value[k], whitelist);
                            if (v) {
                                a.push(stringify(k) + ':' + v);
                            }
                        }
                    }
                } else {

// Otherwise, iterate through all of the keys in the object.

                    for (k in value) {
                        if (typeof k === 'string') {
                            v = stringify(value[k], whitelist);
                            if (v) {
                                a.push(stringify(k) + ':' + v);
                            }
                        }
                    }
                }

// Join all of the member texts together and wrap them in braces.

                return '{' + a.join(',') + '}';
            }
        }

        return {
            stringify: stringify,
            parse: function (text, filter) {
                var j;

                function walk(k, v) {
                    var i, n;
                    if (v && typeof v === 'object') {
                        for (i in v) {
                            if (Object.prototype.hasOwnProperty.apply(v, [i])) {
                                n = walk(i, v[i]);
                                if (n !== undefined) {
                                    v[i] = n;
                                }
                            }
                        }
                    }
                    return filter(k, v);
                }


// Parsing happens in three stages. In the first stage, we run the text against
// regular expressions that look for non-JSON patterns. We are especially
// concerned with '()' and 'new' because they can cause invocation, and '='
// because it can cause mutation. But just to be safe, we want to reject all
// unexpected forms.

// We split the first stage into 4 regexp operations in order to work around
// crippling inefficiencies in IE's and Safari's regexp engines. First we
// replace all backslash pairs with '@' (a non-JSON character). Second, we
// replace all simple value tokens with ']' characters. Third, we delete all
// open brackets that follow a colon or comma or that begin the text. Finally,
// we look to see that the remaining characters are only whitespace or ']' or
// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.

                if (/^[\],:{}\s]*$/.test(text.replace(/\\./g, '@').
replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(:?[eE][+\-]?\d+)?/g, ']').
replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {

// In the second stage we use the eval function to compile the text into a
// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
// in JavaScript: it can begin a block or an object literal. We wrap the text
// in parens to eliminate the ambiguity.

                    j = eval('(' + text + ')');

// In the optional third stage, we recursively walk the new structure, passing
// each name/value pair to a filter function for possible transformation.

                    return typeof filter === 'function' ? walk('', j) : j;
                }

// If the text is not JSON parseable, then a SyntaxError is thrown.

                throw new SyntaxError('parseJSON');
            }
        };
    }();
}

// öffnet Detail-Seite der News der Homepage
function openHomepageNewsDetail(sess, stamp)
{
		F1 = window.open('contentpage.php?SESS=' + sess + '&mod=news@@news_detail.php&stamp=' + stamp, 'NewsDetail', 'toolbar=no,scrollbars=yes,resizable=yes,width=580,height=780,screenX=100,screenY=100,left=100,top=100');
  		F1.focus();
}

// allg.-gült. Funktion zum Öffnen von Popup-Fenstern
function openWindow(url, hoehe, breite)
{
	F1 = window.open(url, 'F1', 'toolbar=no,scrollbars=yes,resizable=no,width='+ breite +',height='+ hoehe +',screenX=100,screenY=100,left=100,top=100');
    F1.focus();	
}

//Funkt. zum Schliessen eines Layers
function layer_hide(id)
{
	document.getElementById(id).style.visibility = 'hidden';
}


var ajaxInterpret;
// Ajax-Request senden
function setAjaxRequest(url, interpret) {
	// Request erzeugen
	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) {}
		}
	}

	// überprüfen, ob Request erzeugt wurde
	if (!request) {
		return false;
	} else {
		//var url = "meinPhpScript.php";
		// Request öffnen	
		request.open('post', url, true);
		// Request senden
		request.send(null);
		// Request auswerten
		ajaxInterpret = interpret;
		request.onreadystatechange = interpretAjaxRequest;
	}
}

// Ajax-Request auswerten
function interpretAjaxRequest() {
	
	switch (request.readyState) {
		// wenn der readyState 4 und der request.status 200 ist, dann ist alles korrekt gelaufen
		case 4:
			if (request.status != 200) {
				return false;
			} else {
				var content = request.responseText;
				
				if(ajaxInterpret == 'webmasterGetVideoNum')
				{
					if(content != undefined)
					{
						setVidenumBox(content);
					}
					
				}
				  
			}
			break;
		default:
			break;
	}
}
