////////////////////////////////////////////////////////////////
//
// wScript.js 5.0.1
// erstellt durch Scholl Communications AG, 77694 Kehl, www.scholl.de
// erstellt mit Weblication Content Management Server, www.weblication.de
//
////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////
//
// Anzupassende Variablen:
//
////////////////////////////////////////////////////////////////

 /***************************************************
* @info  : Oeffnet eine URL in einem popUp *
* @param : url   : Zu oeffnende URL                *
*               width  : Breite des Fensters            *
*               height : Hoehe des Fensters             *
* @return: -                                       *
***************************************************/

function wOpenPopupURL(url, width, height){
 var name = '';

 if(width == '' || width == ' '){
  width = 786;
 }
 if(height == '' || height == ' '){
  height = 677;
 }
 url = url.replace(/&amp;/g, '&');
 options = ',location=no, menubar=yes,toolbar=no,resizable=yes,scrollbars=yes,status=no';
  width  = parseInt(width);
  height  = parseInt(height);
  //Position zentriert festlegen
  var posLeft = (screen.width / 2)  - (width  / 2);
  var posTop  = (screen.height / 2) - (height / 2);
  window.open(url, name, 'top='+posTop+',left='+posLeft+',width='+width+',height='+height+',' + options);
}


////////////////////////////////////////////////////////////////
//
// Beschreibung: Oeffnet ein Popup-Fenster
//
////////////////////////////////////////////////////////////////

function openPopup(url){

 if(debugMode == 1){
  alert(url);
 }

 window.open(url, "popup", optionsPopup);
}

////////////////////////////////////////////////////////////////
//
// Beschreibung: Oeffnet ein Popup-Fenster vom Typ 1
//
////////////////////////////////////////////////////////////////

function openPopup1(url){

 if(debugMode == 1){
  alert(url);
 }

 window.open(url, "popup1", optionsPopup1);
}

////////////////////////////////////////////////////////////////
//
// Beschreibung: Oeffnet ein Popup-Fenster vom Typ 2
//
////////////////////////////////////////////////////////////////

function openPopup2(url){

 if(debugMode == 1){
  alert(url);
 }

 window.open(url, "popup2", optionsPopup2);
}


////////////////////////////////////////////////////////////////
//
// Beschreibung: Zeigt die Druckansicht an
//
////////////////////////////////////////////////////////////////

function wShowPrintpreview(){  

  var url = location.href;

  if(url.indexOf('?') >= 0){
    url += '&viewmode=print';
  }
  else{
    url += '?viewmode=print';    
  }
  
  openWindow(url, 'wPrintpreview', 'width=768,height=520,scrollbars=yes');
}

/*********************************************************************************/
//
// Öffnet ein Fenster
//
// @param string Url
//
// @param string Name des Fensters
//
// @param string Optionen
//
// @return window			
//
/*********************************************************************************/

function openWindow(url, name, options){

  var regWidth = /width=(\d+)/;
  regWidth.exec(options);
  width = RegExp.$1; 
  if(width == ''){   
    width = 640; 
  }

  var regHeight = /height=(\d+)/;
  regHeight.exec(options);
  height = RegExp.$1;       
  if(height == ''){   
    height = 480; 
  }    


  if(!name && !width && !height && !options){
    return window.open(url, name);
    return;
  }
  //Zusaetzliche Optionen angeben
  if(!options){
    options = ',resizable=no,scrollbars=no,status=no';
  }
  //Position zentriert festlegen
  
  var posLeft = (screen.width / 2)  - (width  / 2);
  var posTop  = (screen.height / 2) - (height / 2);
  //alert('top='+posTop+',left='+posLeft+',width='+width+',height='+height+',' + options);<<<
  return window.open(url, name, 'top='+posTop+',left='+posLeft+',width='+width+',height='+height+',' + options);
}

////////////////////////////////////////////////////////////////
//
// Beschreibung: Druckt das aktuelle Dokument
//
////////////////////////////////////////////////////////////////

function printDocument(){  

  if(document.all && navigator.appVersion.substring(22,23)==4) {
    self.focus();
    var OLECMDID_PRINT = 6;
    var OLECMDEXECOPT_DONTPROMPTUSER = 2;
    var OLECMDEXECOPT_PROMPTUSER = 1;
    var WebBrowser = '<object id="WebBrowser1" width="0" height="0" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>';
    document.body.insertAdjacentHTML('beforeEnd',WebBrowser);
    WebBrowser1.ExecWB(OLECMDID_PRINT,OLECMDEXECOPT_DONTPROMPTUSER);
    WebBrowser1.outerHTML = '';
  }
  else{
    window.print();  
  }
}


function getInpValue(field) {
	if(document.getElementById(field)) {
		return document.getElementById(field).value; 
	} else {
		return "";
	}
}

var fensterGenerateNewHeadlineImg;
function generateNewHeadlineImg(variante) {
	var fieldId = getInpValue(variante+'TagSaver');
	var savePfad = getInpValue(variante+'DocSaver');
	var text = document.getElementsByName('webtag_text_'+fieldId)[0].value;
	derlink = '/euvend/de/wGlobal/weblicationEdit/ajaxReturn.php?savePfad='+savePfad+'&text='+text+'&variante='+variante+'';
	macheRequest(derlink, http_request, 'noInhalt', 'results');
}

////////////////////////////////////////////////////////////////
//
// Beschreibung: macht div elemente sichtbar bzw. unsichtbar
// Aufruf: onclick="showHideLayers('idLayer1','','hide','idLayer2','','show')"
//
////////////////////////////////////////////////////////////////

function findObj(theObj, theDoc)
{
  var p, i, foundObj;
  
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  
  return foundObj;

}


// this function requires the following function: findObj
function showHideLayers()
{ 
  var i, visStr, obj, args = showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3)
  {
    if ((obj = findObj(args[i])) != null)
    {
      visStr = args[i+2];
      if (obj.style)
      {
        obj = obj.style;
        if(visStr == 'show') visStr = 'block';
        else if(visStr == 'hide') visStr = 'none';
      }
      obj.display = visStr;
    }
  }
}

function messefinderActivate(lang) {
	if(document.getElementById('messefinderClose') && document.getElementById('messefinderOpen') && document.getElementById('messefinderContent')) {
		if (lang == 'de'){
      macheRequest('/global/wGlobal/content/areas/de/messefinderAjax.php', http_request, 'returnInhalt', 'messefinderContent')
	 } else if (lang == 'en'){
      macheRequest('/global/wGlobal/content/areas/en/messefinderAjax.php', http_request, 'returnInhalt', 'messefinderContent')
   }	
    document.getElementById('messefinderContent').style.display = 'block';
		document.getElementById('messefinderClose').style.display = 'none';
		document.getElementById('messefinderOpen').style.display = 'block';
		document.getElementById('messefinderClose').style.visibility = 'hidden';
		document.getElementById('messefinderOpen').style.visibility = 'visible';
	}
}

function messefinderDeactivate() {
	if(document.getElementById('messefinderClose') && document.getElementById('messefinderOpen') && document.getElementById('messefinderContent')) {
		document.getElementById('messefinderContent').style.display = 'none';
		document.getElementById('messefinderClose').style.display = 'block';
		document.getElementById('messefinderOpen').style.display = 'none';
		document.getElementById('messefinderClose').style.visibility = 'visible';
		document.getElementById('messefinderOpen').style.visibility = 'hidden';
	}
}





var http_request 	= false;

var divToRefresh 	= "";

function macheRequest(url, requestName, functionName, divName) {
    requestName = false;
    divToRefresh = divName;

    if (window.XMLHttpRequest) { // Mozilla, Safari,...
        requestName = new XMLHttpRequest();
        if (requestName.overrideMimeType) {
            requestName.overrideMimeType('text/xml');
            // zu dieser Zeile siehe weiter unten
        }
    } else if (window.ActiveXObject) { // IE
        try {
            requestName = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                requestName = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }

    if (!requestName) {
        //alert('Ende :( Kann keine XMLHTTP-Instanz erzeugen');
        return false;
    }
      
    requestName.open('GET', url, true);
    requestName.onreadystatechange = function () {
         if(functionName == "returnInhalt") {
             returnInhalt(requestName, divName);
         }
    };

	requestName.send(null);
}
function returnInhalt(requestName, divName) {
    if (requestName.readyState == 4) {
        if (requestName.status == 200) {
        	document.getElementById(divName).innerHTML = requestName.responseText;
        } else {
            //alert('Bei dem Request ist ein Problem aufgetreten.');
        }
    }
}

// kopiert den inhalt eines textfeldes in die Zwischwenablage
function Kopieren(pos)
{
	/*
	document.tab.txtSource.focus();
	document.tab.txtSource.select();
	Copied = document.tab.txtSource.createTextRange();
	Copied.execCommand("RemoveFormat");      
	Copied.execCommand("Copy");
	*/
	if(document.getElementById('txtSource_'+pos)) {
		document.getElementById('txtSource_'+pos).focus();
		document.getElementById('txtSource_'+pos).select();
		Copied = document.getElementById('txtSource_'+pos).createTextRange();
		Copied.execCommand("RemoveFormat");      
		Copied.execCommand("Copy");
	}
}  


function wShowPressefachKM(Basisurl, Messe, Template){
	
  var Postdaten = window.location.search;
  if (Postdaten == "") Postdaten = "?messe="+Messe+"&amp;format=jscript&amp;base="+escape(Basisurl)+"&amp;tp="+Template;
  //alert('<script language="JavaScript" src="http://www.press1.de/asp/messe/'+Postdaten+'"></script>');
  document.write('<script language="JavaScript" src="http://www.press1.de/asp/messe/'+Postdaten+'"></script>');
}








