<!--


//////////////////////
// Start ad section //

errorCount      = 0;
contentad       = 0;
contentad_small = 0;
promo           = 0;
skyscraper      = 0;
LeaderBoard     = 0;
errorString     = "";

var panoramaBox	= "adpanoramabox";
var standardBox	= "adstandardbox";
var halfpageBox	= "adhalfpagebox";

var halfpage = 0;
var contentad = 0;
var promo = 0;

$(document).ready(function(){
	if ($(".standardbox .content") != null){
	
		$(".standardbox .content").mouseover(function(){switchOnHighlight(this, '#FE0000');});
		$(".standardbox .content").mouseout(function(){switchOffHighlight(this, '#999999');});
		$(".panoramabox .content").mouseover(function(){switchOnHighlight(this, '#FE0000');});
		$(".panoramabox .content").mouseout(function(){switchOffHighlight(this, '#999999');});
		$(".halfpagebox .content").mouseover(function(){switchOnHighlight(this, '#FE0000');});
		$(".halfpagebox .content").mouseout(function(){switchOffHighlight(this, '#999999');});
		
		$(".newsitem").mouseover(function(){switchOnHighlight(this, '#fe0000');});
		$(".newsitem").mouseout(function(){switchOffHighlight(this, '#999999');});
		
		$(".rubrikbox .content").mouseover(function(){switchOnHighlight(this, '#FE0000');});
		$(".rubrikbox .content").mouseout(function(){switchOffHighlight(this, '#000000');});
		
		$(".ergebnisbox .content").mouseover(function(){switchOnHighlight(this, '#FE0000');});
		$(".ergebnisbox .content").mouseout(function(){switchOffHighlight(this, '#000000');});
	 }	
	});
	
//onMouseOver='switchOnHighlight(this);' onMouseOut='switchOffHighlight(this);'

function genRand( min, max)
{
    var number = Math.floor( (min + (max - min + 1)) * Math.random() );
	return number;
}

function isAdBoxUsed( id ) {
	if(!id) return false;

	// Box mit der Ÿbergebenen id suchen 
	var e = document.getElementById( id );
	if (!e || !e.childNodes) return false;
	// Elemente bestimmen (einmal fŸr IE und fŸr den Rest)
	if ( e.firstChild ) {
		elem = false;
		if (navigator.userAgent.indexOf('MSIE') > -1) {
			if( e.firstChild && e.firstChild.firstChild && e.firstChild.firstChild.nextSibling && e.firstChild.firstChild.nextSibling.nextSibling && e.firstChild.firstChild.nextSibling.nextSibling.firstChild )
				elem = e.firstChild.firstChild.nextSibling.nextSibling.firstChild
		} else {
			if ( e.firstChild.nextSibling && e.firstChild.nextSibling.firstChild && e.firstChild.nextSibling.firstChild.nextSibling && e.firstChild.nextSibling.firstChild.nextSibling.nextSibling && e.firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling && e.firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.firstChild ) {
				elem = e.firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.firstChild;
			}
		}

		if (elem && elem.nodeName == 'IMG' && elem.alt == '.' && elem.width < 2 && elem.height < 2) {
			return false;
		}
	}
	return true;
}

function showBox( id ) {
	if(!id) return false;

	// Box mit der Ÿbergebenen id suchen 
	var node = document.getElementById( id );
	if (!node) return false;

	// Box wird sichtbar gemacht (display:inline wird aufgrund eine IE Bugs verwendet)
	node.style.display = "inline";
}

function showBox2( id, classes ) {
	if(!id) return false;

	// Box mit der Ÿbergebenen id suchen 
	var node = document.getElementById( id );
	if (!node) return false;

	// Box wird sichtbar gemacht (display:inline wird aufgrund eine IE Bugs verwendet)
	node.style.display = "inline";
	node.className = classes;
}

function handleAd() {
	var left = 0;
	var right = 0;

	// linke Seite behandeln
	if (contentad == 1) {
		// auf der linken Seite wurde Werbung für eine PanoramaBox ausgeliefert
		showBox2("ad01", panoramaBox);
		left++;
	} else if( contentad_small == 1 ) {
		// auf der linken Seite wurde Werbung für die StandardBox ausgeliefert
		showBox2("ad01", standardBox);
		showBox("pseudo01");
		left++;
	}
	
	// Promofläche und HalfPageAd dürfen angezeigt werden
	if ( contentad != 1 && halfpage == 1 ) {
		showBox2("ad02", halfpageBox);
		right = right + 2;
	} else if ( promo == 1 ) {
		showBox2("ad02", standardBox);
		showBox("pseudo02");
		right++;
	}
	
/*	// Ad auf der Linken Seite überprüfen
	if ( isAdBoxUsed( "ad01") ) {
		showBox( "ad01" );
		left++;
	}

	if ( isAdBoxUsed( "ad02" ) ) { 
		showBox("ad02");
		showBox("pseudo02");
		left++;
	}

	// Ad auf der Rechten Seite überprüfen
	if ( isAdBoxUsed( "ad03") ) {
		showBox( "ad03" );
		showBox( "pseudo03" );
		right++;
	}

	if ( isAdBoxUsed( "ad04") ) {
		showBox( "ad04" );
		right = right + 2;			// Ad04 ist eine HalfPageAd (doppelte Höhe)
	}*/

	diff = right - left;
	if (diff == -1) { // Links ist eins größer
		showBox( "addt04" );
		showBox( "addt05" );
	} else if (diff == 1) {	// Rechts ist eins größer
		showBox( "addt01" );
	} else if (diff == 2) {  // Rechts ist zwei größer
		showBox( "addt01");
		showBox( "addt02");
		showBox( "addt03");	
	} 
}

function switchOnHighlight(obj, colorCode) {
	var objName = obj.getAttribute('name');

	if (objName) {
		var h1ID = "h1_" + objName;
		var h2ID = "h2_" + objName;

		if(document.getElementById(h1ID)) {
			document.getElementById(h1ID).style.color = colorCode;
		}
		if(document.getElementById(h2ID)) {
			document.getElementById(h2ID).style.color = colorCode;
		}
	}
}

function switchOffHighlight(obj, colorCode) {
	var objName = obj.getAttribute('name');

	if (objName) {
		var h1ID = "h1_" + objName;
		var h2ID = "h2_" + objName;

		if(document.getElementById(h1ID)) {
			document.getElementById(h1ID).style.color = colorCode;
		}
		if(document.getElementById(h2ID)) {
			document.getElementById(h2ID).style.color = colorCode;
		}
	}
}

function activateLink(obj) {
	obj.style.cursor = 'pointer';
//	cursor:pointer;
}

function deactivateLink(obj) {
	obj.style.cursor = 'auto';
//	cursor:auto;
}


/*
	If I am not mistaken, these functions are not being used anymore, due to the settings in the ad bookings.
*/

function test_contentad(randomNumber, adTextPrefix, pgType) {

	if (adTextPrefix == '/test-wf') {
		additionalParameter = "";
	} else {
		additionalParameter = "/" + pgType;
	}

	if (contentad != 1) {
		/* Links wurde kein grosses Contentad ausgeliefert, also muss fuer die rechte Spalte zuerst ein Halfpagead angefragt werden. 
			Wenn das auch nicht kommt, dann noch nach ner Promofläche anfragen. */
			document.write('<script type="text/javascript" src="http://ad.de.doubleclick.net/adj' + adTextPrefix + '/art-halfpage' + additionalParameter + ';pg=' + pgType + ';!category=stop;sz=1x1;tile=2;ord=' + randomNumber + '?"><\/script>');

			document.write('<script type="text/javascript">test_halfpagead(' + randomNumber + ', "' + adTextPrefix + '", "' + pgType + '"); </script>');
//			test_halfpagead(randomNumber, adTextPrefix, pgType);

	} else {
		/* Links wurde ein großes Contentad ausgeliefert, also muss fuer die rechte Spalte eine Promofläche angefragt werden. */
		document.write('<script type="text/javascript" src="http://ad.de.doubleclick.net/adj' + adTextPrefix + '/art-promo' + additionalParameter + ';pg=' + pgType + ';!category=stop;sz=1x1;tile=4;ord=' + randomNumber + '?"><\/script>');
	}
}

function test_halfpagead(randomNumber, adTextPrefix, pgType) {

	if (adTextPrefix == '/test-wf') {
		additionalParameter = "";
	} else {
		additionalParameter = "/" + pgType;
	}

	if (halfpage != 1) {
		document.write('<script type="text/javascript" src="http://ad.de.doubleclick.net/adj' + adTextPrefix + '/art-promo' + additionalParameter + ';pg=' + pgType + ';!category=stop;sz=1x1;tile=3;ord=' + randomNumber + '?"><\/script>');
	}
}

function test_contentad_sidebar(randomNumber, adTextPrefix, pgType) {
	
	if (adTextPrefix == '/test-wf') {
		additionalParameter = "";
	} else {
		additionalParameter = "/" + pgType;
	}
	
	/* Zuerst ein ContentAd anfragen */
	document.write('<script type="text/javascript" src="http://ad.de.doubleclick.net/adj' + adTextPrefix + '/art-contentad' + additionalParameter + ';pg=' + pgType + ';!category=stop;sz=1x1;tile=2;ord=' + randomNumber + '?"><\/script>');

	/* Wenn kein ContentAd ausgeliefert wurde, muss fuer die rechte Spalte ein Halfpagead angefragt werden. */
/*
	if (contentad != 1) {
		document.write('<script type="text/javascript" src="http://ad.de.doubleclick.net/adj' + adTextPrefix + '/art-halfpage;pg=' + pgType + ';!category=stop;sz=1x1;tile=3;ord=' + randomNumber + '?"><\/script>');
	}
*/
	return true;
}


// End Ad section //
////////////////////



///////////////////////////
// Start comment section //

/*
	The following section contains functions that are essential for the comment functionality.
*/

// First define a global variable that is being used in several places.
var errorMessage = "Bitte füllen Sie dieses Feld aus.";

/*
	This function handles the submitted comment form.
	It uses the checkFields() function to check the field contents' validity. Only if no input or validity errors are being found
	is the addComment.php script being called (using ajax) to actually submit the comment.
	In case of a field being invalid or empty, javascript and CSS are being used to highlight the field and inform the user about
	the problem.
*/
function sendForm() {
	var userName     = document.getElementById('userName').value;
	var commentTitle = document.getElementById('commentTitle').value;
	var commentText  = document.getElementById('commentText').value;
	var article_id   = document.getElementById('art').value;
	var action       = document.getElementById('action').value;
	var formAction   = document.getElementById('formAction').value;
	
	// This array contains information about the field names, their valid content (regular expression) and their original CSS classes
	var checkFields = Array('userName@@@\\S+@@@inputtext', 'commentTitle@@@\\S+@@@inputtext', 'commentText@@@\\S+@@@inputtextarea');

	// Iterate over all form fields and check their contents for validity
	for (fieldCounter = 0; fieldCounter < checkFields.length; fieldCounter++) {
		checkFieldContent(checkFields[fieldCounter]);
	}

	// Now make sure no one uses any of the "restricted" comment sender names
	var lowerUserName = userName.toLowerCase();
	if (lowerUserName.match("^art-magazin.de$") || lowerUserName.match("^art redaktion$") || lowerUserName.match("^redaktion$") || lowerUserName.match("^art$") || lowerUserName.match("^hannes ludwig$") || lowerUserName.match("^tim sommer$") || lowerUserName.match("^ralf schl[Ã¼|ü]ter$") || lowerUserName.match(errorMessage.toLowerCase())) {
		document.getElementById('userName').className = "inputtext inputerror";
		errorCount++;
	}

	// If any of the "restricted" sender names is being used in its "correct" syntax (starting and ending with "@@@") cut off these "@" characters
	if (lowerUserName == '@@@art-magazin.de@@@' || lowerUserName == '@@@art redaktion@@@' || lowerUserName == '@@@redaktion@@@' || lowerUserName == '@@@art@@@' || lowerUserName == '@@@hannes ludwig@@@' || lowerUserName == '@@@tim sommer@@@' || lowerUserName.match("^@@@ralf schl[Ã¼|ü]ter@@@$")) {
		userName = lowerUserName.replace(/^@@@(.+)@@@$/, "$1");
	}

	if (errorCount > 0) {
		errorCount = 0;
		return false;
	} else {
		if (formAction.search(/htdocs/)) {
			// This is on the TeamSite server
			formAction = formAction.replace(/(\S*\/htdocs)\/(\S*)/, "$1/_components/comment/addComment.php");
		} else {
			// This is on the "real" webserver/website
			formAction = formAction.replace(/(\S*art-magazin\.de)\/(\S*)/, "$1/_components/comment/addComment.php");
		}

		// Call the correct addComment.php script via ajax
		$.post(formAction, { 'userName': userName, 'commentTitle': commentTitle, 'commentText': commentText, 'art': article_id, 'action': action }, function(data) {fillCommentDiv(data);});
	}
}

/*
	This function appends the handed over string (data) to the <div> element with the ID "reloadableComments" 
	and empties the <input> fields of the element with the ID "commentForm".
*/
function fillCommentDiv(data) {
	$("#reloadableComments").empty().prepend(data);
	$("#commentForm input").val("");
	document.getElementById('commentText').value = "";
}

/*
	This function checks the field content for its validity. It uses regular expressions defined in the calling function sendForm().
	The handed over string (checkField) contains the field name, the regular expression and the field's CSS class, concatenated with
	the glue string "@@@".
	If the field's content starts and ends with "@@@" it is considered to be a "special" user who has entered the comment.
	In case the regular expression does not match the field's submitted value, the CSS class "inputerror" is appended to the field's
	original class name. Via the CSS the field background image is changed to visually display the input error.
*/
function checkFieldContent (checkField) {
	var fieldElements = checkField.split("@@@");
	var fieldID       = fieldElements[0];
	var fieldRegex    = fieldElements[1];
	var fieldClass    = fieldElements[2];

	var fieldContent = document.getElementById(fieldID).value;
	
	if (!fieldContent.match("@@@\\S+@@@")) {
		if (!fieldContent.match(fieldRegex) || fieldContent.match(errorMessage)) {
			document.getElementById(fieldID).className = fieldClass + " inputerror";
			document.getElementById(fieldID).value = errorMessage;
			errorCount++;
		} else {
			document.getElementById(fieldID).className = fieldClass;
		}
	} else {
		document.getElementById(fieldID).className = fieldClass;
	}
	
}

// End comment section //
/////////////////////////



/////////////////////////////
// Start bookmarks section //

/*
	This function switches on and off the display of the bookmarks <div> via CSS
*/
function toggleBookmarks(element) {
	var linkid = element.id;
	var listid = linkid + "list";
	var list = document.getElementById(listid);
	var listVisibility = list.style.display;

	var nextStatus = (listVisibility == "block") ? "none" : "block";

	list.style.display = nextStatus;

}

// End bookmarks section //
/////////////////////////////

-->
