document.write('<script type="text/javascript" src="/js/jquery/jquery.lightbox-0.5.pack.js"></script>');

var w3cDOMsupport		= (document.getElementById && document.createElement) ? true : false;
var isIE			= (document.all && !document.addEventListener) ? true : false;
var isIE50			= (isIE && !document.createEventObject) ? true : false;
var isIE55			= (isIE && document.createEventObject && !document.compatMode) ? true : false;
var isIE60			= (isIE && document.defaultCharset && document.compatMode) ? true : false;
var isFirefox			= (window.XML) ? true : false;
var isOpera			= (document.detachEvent && document.addEventListener) ? true : false;
var msgBoxEnlarged		= false;
var msgBoxWidth			= null;
var msgBoxHeight		= null;
var subnavDisplayed		= true;
var contentSubnavPaddingLeft	= null;
var categoryName 		= null;
var sntHeight 			= null;

function insertCode(str)
{
	if (w3cDOMsupport) {
		document.getElementById('msg').value += ' '+str;
	}
}
 
function addTag(obj, targetField)
{
	tag = obj.innerHTML;
	if (document.getElementById(targetField)) {
		document.getElementById(targetField).value += tag +', ';
	}
	return false;
};

function checkFieldValue(obj)
{
	if (obj.value.substr(0,1) == '<') obj.value='';
};

/**
 *
 */

function validateForm(f)
{
	f.submitButton.value= '... Ihr Beitrag wird geschrieben - bitte etwas Geduld ...';
	f.submitButton.disabled = true;
};

/**
 *
 */

function resizeTextarea(obj)
{
	if (w3cDOMsupport) {
		var msgBox = document.getElementById(obj);
		if (msgBoxEnlarged == false) {
			msgBoxWidth = msgBox.style.width;
			msgBoxHeight = msgBox.rows;
			msgBox.style.width ="99%";
			msgBox.rows = msgBoxHeight*2;
			msgBoxEnlarged = true;
			document.getElementById("resizeButton").value = "Eingabefeld verkleinern";
			if (document.getElementById("msgHelp")) {
				document.getElementById("msgHelp").style.visibility = "hidden";
				document.getElementById("msgHelp").style.position= "absolute";
			}
		} else {
			document.getElementById("resizeButton").value = "Eingabefeld vergrößern";
			msgBox.style.width=msgBoxWidth;
			msgBox.rows=msgBoxHeight;
			msgBoxEnlarged = false;
			if (document.getElementById("msgHelp")) {
				document.getElementById("msgHelp").style.visibility = "visible";
				document.getElementById("msgHelp").style.position= "relative";
			}
		}
	}
};

/**
 *
 */

function pasteQuotation(id)
{
	if (w3cDOMsupport) {
		var thisMsgHTML = document.getElementById("msg-"+id);
		var thisMsg = thisMsgHTML.innerHTML;
		var msgBody = thisMsg.split("<p");
		msgBody[0] = msgBody[0].replace(/^\s+/, "");
		msgBody[0] = msgBody[0].replace(/\s+$/, "");
		msgBody[0] = msgBody[0].replace(/<(\/)?strong>/ig,"[$1fett]"); 
		msgBody[0] = msgBody[0].replace(/<(\/)?em>/ig,"[$1kursiv]");
		//msgBody[0] = msgBody[0].replace(/<(\/)?blockquote>/ig,"[$1zitat]");
		msgBody[0] = msgBody[0].replace(/layout/ig,"$1.gif"); 
		msgBody[0] = msgBody[0].replace(/(<([^>]+)>)/ig,""); 
		document.getElementById("msg").value = "[zitat]"+msgBody[0]+"[/zitat]";
		document.getElementById("reply2Msg").value = id;
		document.getElementById("msg").focus();
	}
};

/**
 *
 */

function pop(obj, width, height, scrolling)
{ 
	var x=(screen.width-width)/2; 
	var y=(screen.height-height)/2;
	if (scrolling) {
		scrollbars = "yes";
	} else {
		scrollbars = "no";
	}
	popUpWindow = window.open(obj.href, "", "width="+width+",height="+height+",resizable=no,scrollbars="+scrollbars+",screenX="+x+",screenY="+y+",left="+x+",top="+y);
	popUpWindow.focus();
	return false;
};

function getCookie(key) 
{
	var s, e;
	if (document.cookie) {
		s = document.cookie.indexOf(key+"=");
		if (s < 0) return null;
		s = document.cookie.indexOf("=", s) + 1;
		e = document.cookie.indexOf(";", s);
		if (e < 0) {
			e = document.cookie.length;
		}
		return unescape(document.cookie.substring(s, e));
 	} else {
 		return null;
 	}
};

function setCookie(key, value, lifetime)
{
	var now = new Date();
	var expiry = new Date(now.getTime() + lifetime*24*60*60*1000);
	if ((key != null) && (value != null)) {
		document.cookie = key + "=" + escape(value) + "; expires=" + expiry.toGMTString() + "; path=/; domain=.phantastik-couch.de";
	}
};

function dropCookie(key) 
{
	document.cookie = key+ "=; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=.phantastik-couch.de";
};

function savePreferredDisplay(obj)
{
	if (obj.value && obj.checked) {
		setCookie('BookshelfPreferredDisplay', obj.value, 30);
	}
};

function openMailDialogue(obj)
{
	if (w3cDOMsupport) {
		var m = obj.innerHTML;
		m = m.replace(/\s+at\s+/, '@');
		document.location = 'mailto:'+m;
	}
};

function confirmSubmit(question)
{
	var agree = confirm(question);
	return agree ? true : false;
};

function trim(s) {
	return s.replace(/^\s+(.*)\s+$/,"$1")
};

function printJSDependendFunctions() {
	var liClass, newStyleName, newStyle;
	
	document.write('</li><li><a id="print" href="javascript:window.print()">Seite ausdrucken</a>');
};

$(document).ready(function() { 	
	
	if (isIE && parseInt($.browser.version.substr(0,1)) == 6) {
		$('#couch-hopper').mouseover(function(){
			$(this).addClass('hover');
		}).mouseout(function(){
			$(this).removeClass('hover');
		});
	}
	
	$('#couch-hopper').append('<span>Couch wechseln</span><ul><li><a href="http://www.histo-couch.de/">Histo-Couch.de</a></li><li><a href="http://www.jugendbuch-couch.de/">Jugendbuch-Couch.de</a></li><li><a href="http://www.kinderbuch-couch.de/">Kinderbuch-Couch.de</a></li><li><a href="http://www.kochbuch-couch.de/">Kochbuch-Couch.de</a></li><li class="l"><a href="http://www.krimi-couch.de/">Krimi-Couch.de</a></li></ul>');
	
	$('a[rel=lightbox]').lightBox({
		overlayOpacity: 0.5,
		containerResizeSpeed: 350,
		imageLoading: '/images/layout/ajax-loader-img.gif',
		txtImage: '',
		txtOf: ''
	});		
});

//if (parent.frames.length) window.top.location.replace(document.location.href);