// for admin panel
function changeDatasetPublishmentBehaviour(cookieName, value) {
	document.cookie = cookieName + "=" + value;
	document.location.reload();
}

/* PopUp fuer Modul Link */
function openLinkWindow(link, breite, hoehe, left, top, scrollbars, resizable, status) {
	var linkPopUp = window.open(link, 'LinkPopUp', 'toolbar=no,scrollbars='+scrollbars+',status='+status+',menubar=no,location=no,resizable='+resizable+',width='+breite+',height='+hoehe+',left='+left+',top='+top);

	if (linkPopUp.opener == null)
		linkPopUp.opener = self;
	linkPopUp.focus();
}

function ContentPrint(link){
	var ContentPrintPopUp = window.open(link, 'NSZContentPrint', 'toolbar=no,scrollbars=yes,status=no,menubar=no,location=no,resizable=no,width=520,height=600,left=50,top=50');

	if (ContentPrintPopUp.opener == null)
		ContentPrintPopUp.opener = self;
	ContentPrintPopUp.focus();
}

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

// Notwendige Funktion zur Umsetzung der Paging-Klasse im Frontend mit POST-Werten
function NFYPagingSubmit(FormName,costart_val) {
	window.document.forms[FormName].elements['costart'].value=costart_val;
	window.document.forms[FormName].submit();
}

// Werbebanner ein / ausblenden
function showHideAdLayer() {
  var i,p,v,obj,args=showHideAdLayer.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='block')?'block':(v=='none')?'none':v; }
    obj.display=v; }
}

// Funktionen zur Darstellung der Werbelayer
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_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function PopUpS_NoScroll(seite,breite,hoehe,wb_id)
{
	window.open (seite,'new','scrollbars=no,status=no,width='+breite+',height='+hoehe+',menubar=no,left=50,top=50,location=no,resizable=no,directories=no')
}

function PopUpS_Scroll(seite,breite,hoehe,wb_id)
{
	window.open (seite,'new','scrollbars=yes,status=no,width='+breite+',height='+hoehe+',menubar=no,left=50,top=50,location=no,resizable=no,directories=no')
}

function openAdminPanel() {
	document.getElementById('adminpanel').style.left = 0;
	document.getElementById('adminpanelopener').style.display = 'none';

}

function closeAdminPanel() {
	document.getElementById('adminpanel').style.left = -200+'px';
	document.getElementById('adminpanelopener').style.display = 'inline';
}

// Setzen eines Cookies ueber JavaScript
// Verwendung in epaper
function SetCookie (name, value) {
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	document.cookie = name + "=" + escape (value) +
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
	((path == null) ? "" : ("; path=" + path)) +
	((domain == null) ? "" : ("; domain=" + domain)) +
	((secure == true) ? "; secure" : "");
}

// Auslesen des Cookie-Wertes
function get_cookie(Name) {
	var search = Name + "="
	var returnvalue = "";
	if (document.cookie.length > 0) {
	offset = document.cookie.indexOf(search)
	if (offset != -1) { // if cookie exists
		offset += search.length
		// set index of beginning of value
		end = document.cookie.indexOf(";", offset);
		// set index of end of cookie value
		if (end == -1)
			end = document.cookie.length;
			returnvalue=unescape(document.cookie.substring(offset, end))
		}
	}
	return returnvalue;
}

// Moegliche Tracking-Funktion beim Abspielen eines Videos und Audios
function tracking(nfy_content_type, nfy_content_id) {
	//Default-Werte
	if(!nfy_content_type) var nfy_content_type = '';	
	if(!nfy_content_id) var nfy_content_id = '';

	//alert(nfy_content_id);
	//var ivw = new Image();
	//ivw.src = "http://_____.ivwbox.de/cgi-bin/ivw/CP/multimedia?d="+(Math.random()*100000);
	
	//if(nfy_content_type != '' && nfy_content_id != '')
	//{
	//	var playCount = new Image();
	//	playCount.src = "/pu_all/scripts/player_count.php?id="+nfy_content_id+"&type="+nfy_content_type+"&rand="+(Math.random()*100000);
	//}
}

// inElement muss ein Formularfeld sein
function copyToClipboard (inElement) {
	if (inElement.createTextRange) { 
    	var range = inElement.createTextRange();
    	if (range) // IE
      		range.execCommand('Copy');
  		} else {
    		var flashcopier = 'flashcopier';
		    if(!document.getElementById(flashcopier)) {
		     var divholder = document.createElement('div');
		     divholder.id = flashcopier;
		     document.body.appendChild(divholder);
    	}
	    document.getElementById(flashcopier).innerHTML = '';
	    var divinfo = '<embed src="/redFACT/kernel/flash/clipboard.swf" FlashVars="clipboard='+encodeURIComponent(inElement.value)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
	    document.getElementById(flashcopier).innerHTML = divinfo;
  	}
}
