/* CONTENTS

1. Browserweiche

2.1 Fenster oeffnen(width*height)
 openAlertWindow(url, name) (300*250)
 openXSWindow(url, name) (300*150)
 openSWindow(url, name)(530*180)
 openSMWindow(url, name)(530*240)
 openBigInfoWindow(600*600)
 openMWindow(url, name)(530*300)
 openLWindow(url, name)(530*400)
 openBWindow(url, name) (650*400)
 openBigInfoWindow(url, name) (600*600)
 openSpecialWindow(url, name)(824*600)
 openSpecialWindowVC(url,name)(800*600)
 openBigResizableWindow(url, name) (850*600)
 openSelectWindow(url, name)(530*600) (Auswahlfenster)
 openCalendarSpecialWindow(url, name, scrolling) (um den Kalender ohne scrollen oeffnen zu koennen)
 CenterWindow  (zentriert ein Fenster,Beispiel in openLoginWindow)

2.2 Fenster oeffnen mit bestimmter url

mediaPlayer(fileName, width, height) (/util/mediaplayer.jsp)
openRating(id,opener) (servlet/de.imc.clix.control.Clix?clixEvent=rating&opener)
openRatingStatistic(id) (servlet/de.imc.clix.control.Clix?clixEvent=rating-statistic)
openUpload() (upload/uploadform.jsp)
viewComponent(id,mode) (/servlet/de.imc.clix.control.Clix?clixEvent=view-ecomponent)
openComponent() (/servlet/de.imc.clix.control.Clix?clixEvent=open-ecomponent)
mailto(to, subject, body, func) (/util/mailto.jsp?)
openProfile(id) (/servlet/de.imc.clix.control.Clix?clixEvent=profileViewEvent)
setRefInUpperwork(Fensterreferenz) (schreibt Referenz des Fensters in upperwork.jsp -> Fenster werden geschlossen, wenn Navigation wechselt)
openChooseSkill(container,context,levelType,schedulingDisabled,comment,partner,name) (/servlet/de.imc.clix.control.Clix?clixEvent=chooseSkill)
openEditSkill(skillId,container,context,levelType,schedulingDisabled,comment,partner,name) (/servlet/de.imc.clix.control.Clix?clixEvent=chooseSkillLevel&edit=true)
3. Layer Funktionalitaeten

 openCloseAlert() (blendetLayer ein und aus)
 showHideLayers() (wird fuer openCloseAlert() gebraucht)
 findObj(n, d) (wird fuer showHideLayersde() gebraucht)
 setLayerToCenter(layerName)
 closeAlerts(alertLayerArray) (schliesst alle offenen Layer)
 hidealllayers() (laesst alle Layer im frame verschwinden)
 moveLayer(layerName,toppos,leftpos)


4. Formulare
 submitFormular(action,target,method,formname) (Formular verschicken)
 getFirstCheckedBoxof(formID) (Findet die erste gecheckte Box und gibt das Checkboxobjekt zur?ck)
 checkAllBoxesof(formID)
 uncheckAllBoxesof(formID)
 checkie() setzt den Zustand einer Liste (?bergabe der Namen) von Checkboxen um
 getParameterListOfAllCheckedBoxesOf(formID)
 getValueOfSelectedOptionOfBox(selectBoxName)(gibt den Wert der Selektbox zurueck, der selektiert ist)
 nolinebreak(formname,elemname) (Zeilenumbrueche entfernen)


Diverse
setTimestamp(url) (schraubt dummy an url)
setCursorClass(link,flag)  (Cursor aendern)
closeMenuItem() (Navi schliessen)
*/
var Loadcontrol=false;
var IE = false;
var N4 = false;
var N6 = false;

if ((navigator.appName=="Netscape") && (parseFloat(navigator.appVersion.substring(0,4))<5.0))
{N4=true;};
if ((navigator.appName=="Netscape") && (parseFloat(navigator.appVersion.substring(0,4))>=5.0))
{N6=true;};
if (navigator.appName =="Microsoft Internet Explorer")
{IE=true;};


// ALAN 20.06.06 -> offene Fenster werden beim Wechsel der Navigation geschlossen
    function setRefInUpperwork(clixWindow)
    {
        if (typeof(top.upperframe)!="undefined") top.upperframe.setReference(clixWindow);
        else
        {
            if (typeof(top.opener.top.upperframe)!="undefined") top.opener.top.upperframe.setReference(clixWindow) ;
            else
            {
                if (typeof(top.opener.top.opener.top.upperframe)!="undefined")  top.opener.top.opener.top.upperframe.setReference(clixWindow);
                else  top.opener.top.opener.top.opener.top.upperframe.setReference(clixWindow);
            }
        }
    }

// ENDET



 function generalOpenWindow(url, name, strParams, returnWindow){
    if(name == null)
        name = "clixWindow";
    clixWindow = window.open(url,name,strParams);
    clixWindow.focus();
    setRefInUpperwork(clixWindow);
    if(returnWindow)
        return clixWindow;
 }


 function openSWindow(url, name) {
      return generalOpenWindow(url,name,'width=530,height=180,top=100,left=100,resizable=no,dependent=no,scrollbars=no',true);
}

function openSMWindow(url, name) {
  return generalOpenWindow(url,name,'width=530,height=240,top=100,left=100,resizable=no,dependent=no,scrollbars=no',true);
}

function openMWindow(url, name) {
      return generalOpenWindow(url,name,'left=100,top=100,width=530,height=300,resizable=no,dependent=no,scrollbars=no',true);
}


function openLWindow(url, name) {
 return generalOpenWindow(url,name,'left=100,top=100,width=530,height=400,resizable=no,dependent=no,scrollbars=1',true);
}

function openSpecialWindow(url, name, scrolling) {

    if (arguments.length < 3)
         return generalOpenWindow(url,name,'width=824,height=600,top=50,left=100,resizable=yes,dependent=no,scrollbars=no',true);
    else {
          p = 'width=824,height=600,top=50,left=100,resizable=yes,dependent=no,scrollbars='+scrolling;
          return generalOpenWindow(url,name,p,true);
    }

}


function openCalendarSpecialWindow(url, name, scrolling) {
    if (arguments.length < 3)
        return generalOpenWindow(url,name,'width=860,height=600,top=50,left=100,resizable=yes,dependent=no,scrollbars=no',true);
    else {
       p = 'width=860,height=600,top=50,left=100,resizable=yes,dependent=no,scrollbars='+scrolling;
       return generalOpenWindow(url,name,p,true);
    }

}


//A.O. 10.4.2004: Fktn. notwendig, da die vorher verwendete Funktion openSpecialWindow keine Vergr??erung des Fensters zulie?. Weiterhin ist f?r die korrekte
//Funktionalit?t der F11-Taste unter dem IE ein directories=yes notwendig. Ansosnten wird der obere Teil, z.B. eine
//Titelzeile in einem "nackten" PopUp abgeschnitten.

function openSpecialWindowVC(url,name){
     generalOpenWindow(url,name,'width=800,height=600,top=50,left=100,resizable=yes,dependent=no,scrollbars=1,directories=yes',false);
}

function openBigResizableWindow(url, name, noReturn ) {
     clixWindow = generalOpenWindow(url,name,'left=50,top=50,width=850,height=600,resizable=yes,dependent=no,scrollbars=1', true);

    if (!noReturn) {
        return clixWindow;
    }
}

function openAlertWindow(url, name) {
     return generalOpenWindow(url,name,'top=200,left=400,width=300,height=250,resizable=no,dependent=no,scrollbars=no', true);
}


function openXSWindow(url, name) {
     return generalOpenWindow(url,name,'top=200,left=400,width=300,height=150,resizable=no,dependent=no,scrollbars=no', true);
}

function openBWindow(url, name) {
   return generalOpenWindow(url,name,'width=650,height=400,resizable=no,dependent=no,scrollbars=1', true);
}


function openBigInfoWindow(url, name) {
   return generalOpenWindow(url,name,'width=600,height=600,top=50,left=100,resizable=no,dependent=no,scrollbars=1', true);
  }

function openLoginWindow(url) {
     var paramstring=CenterWindow(350,400)+"resizable=no,dependent=no,scrollbars=no";
     return generalOpenWindow(url,'login',paramstring, true);
}


function CenterWindow(_width, _height) {
	var ow = screen.availWidth;
	var oh = screen.availHeight;
    var str = "width="+_width+",height="+_height+",left=" + (ow-_width)/2 + ",top=" + (oh-_height)/2 + ",";
	return str
}

function mediaPlayer(fileName, width, height) {
   openWindow(contextPath+"/testtool/mediaplayer.jsp?timestamp=" + (new Date()).getTime() + "&file=" + fileName + "&width=" + width + "&height=" + height, "clixMediaPlayer", width, height);
}

function starter(url) {
   openWindow(url + "&timestamp=" + (new Date()).getTime(), "contentStarter", 800, 600);
}

function openRating(id,opener) {
     rating = generalOpenWindow(contextPath+"/servlet/de.imc.clix.control.Clix?clixEvent=rating&opener="+opener+"&id="+id+'&dmy='+(new Date()).getTime(), "rating","top=100,left=200,width=300,height=300",true);
     rating.focus();
  }

function openRatingStatistic(id) {
       ratingStatistic = generalOpenWindow(contextPath +"/servlet/de.imc.clix.control.Clix?clixEvent=rating-statistic&id="+id+'&dmy='+(new Date()).getTime(), "rating_statistic","top=100,left=200,width=400,height=400",true);
       ratingStatistic.focus();
}


function openUpload(){
    if(isArabic == "true")
        param = 'width=520,height=205,screenX=300,screenY=350,top=300,left=350,dependant=yes';
   else
        param = 'width=520,height=198,screenX=300,screenY=350,top=300,left=350,dependant=yes'

  newFile=generalOpenWindow(contextPath+'/upload/uploadform.jsp?&dummy='+(new Date()).getTime(),'upload',param,true);
  newFile.focus();
}

function viewComponent(id,mode) {
       if(window.component) component.close;
       var url = contextPath+'/servlet/de.imc.clix.control.Clix?clixEvent=view-ecomponent&id='+id+'&mode='+mode+'&popup=true&dmy='+(new Date()).getTime();
       openBigInfoWindow(url,'component')
    }

function openComponent(id, source, mode) {	
	if(typeof source == 'undefined'){
		source = 0;
	}
	if(typeof mode == 'undefined'){
		mode = 'start';
	}
    loadScript(contextPath + '/script/ajax/ajax.js', ['ajax']);
	new ajax.AjaxRequest(contextPath+'/servlet/de.imc.clix.control.Clix', {
            onload: doOpenComponent,
            responseType: ajax.RESPONSE_JSON,
            method: ajax.METHOD_POST,
            parameters: {
                clixEvent: 'ecomponent-link',
            	id: id,
            	source: source,
            	mode: mode,
            	dmy: (new Date()).getTime()
            }                        
    });    
}

function doOpenComponent(reply) {
	var link = new String(reply.eComponentLink);
	if(link.search(/clixEvent=load-media*/) < 0){
		if(window.component) component.close;
    	var url = contextPath+'/servlet/de.imc.clix.control.Clix?clixEvent=open-ecomponent&id='+reply.id+'&source='+reply.source+'&mode='+reply.mode+'&popup=true&dmy='+(new Date()).getTime();
    	if (navigator.appName == "Microsoft Internet Explorer"){
    		component = generalOpenWindow(url,'component','top=50,left=50,width=850,height=600,resizable=yes,scrollbars=auto',true);
            component.focus();
        } else {
    	    component = generalOpenWindow(url,'component','top=50,left=50,width=850,height=600,resizable=yes,scrollbars=yes',true);
            component.focus();
         }
    } else {
    	var parameters = {
    		id: reply.id,
    		source: reply.source,
    		mode: reply.mode,
    		dmy: (new Date()).getTime()
    	};
    	loadScript(contextPath + '/script/edu/loadmedia.js', ['getMedia','loadMedia']);
    	getMedia(contextPath + link, 'component', null, parameters);
    }	
}

function mailto(to, subject, body, func) {	   
	if(func && typeof func == 'function'){		 
		func.call(this);
	}
    var width = 560;
    var height = 375;
    if (navigator.appName == "Netscape")
        height = 419;

    if (arguments.length < 3) body = "";

    if (arguments.length < 2) subject = "";

    if (arguments.length < 1){
	 to = "";
    }else{
	// Bug8731
        to = escape(to);
    }

    openWindow(contextPath + "/internalmailing/mailto.jsp?timestamp=" + (new Date()).getTime() + "&to=" + to + "&subject=" + subject + "&body=" + body, 'mailto', width, height);
}

function mailtoCancelRequest(to, subject, body) {
    var width = 560;
    var height = 375;
    if (navigator.appName == "Netscape")
        height = 419;

    if (arguments.length < 3) body = "";

    if (arguments.length < 2) subject = "";

    if (arguments.length < 1){
	 to = "";
    }else{
	// Bug8731
        to = escape(to);
    }

    openWindow(contextPath + "/internalmailing/mailto.jsp?timestamp=" + (new Date()).getTime() + "&mode=cancelRequest&to=" + to + "&subject=" + subject + "&body=" + body, 'mailto', width, height);
}
/* wird wohl nich mehr verwendet
function MM_findObj(n, d) {
 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); return x;
}
*/








function findObj(n, d) {

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=findObj(n,d.layers[i].document);

if(!x && document.getElementById) x=document.getElementById(n); return x;

}

function showHideLayers() {

var i,p,v,obj,args=showHideLayers.arguments;

for (i=0; i<(args.length-2); i+=3) if ((obj=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; }
}

/*
Parameter  (Layername,'','show' oder 'hide',framename)    ('newlayer','','show','content')
*/
function openCloseAlert() {
    if (IE) {
        if (arguments.length <= 3) {
            eval ('document.all.'+arguments[0]+'.style.left=(parseInt(document.body.clientWidth)-(parseInt(document.all.'+arguments[0]+'.offsetWidth)))/2');
            eval('document.all.'+arguments[0]+'.style.top=(parseInt(document.body.clientHeight)-(parseInt(document.all.'+arguments[0]+'.offsetHeight)))/2');
            if (document.all["content"]) {
                eval('document.all.'+arguments[0]+'.style.top=parseInt(document.all["content"].style.top)+30');
            }
        } else if (arguments.length == 4) {
            eval('parent.'+arguments[3]+'.document.all.'+arguments[0]+'.style.left=parseInt((document.body.clientWidth-parseInt(parent.'+arguments[3]+'.document.all.'+arguments[0]+'.offsetWidth))/2)');
            if (eval('parent.'+arguments[3]+'.document.all.content')) {
                eval('parent.'+arguments[3]+'.document.all.'+arguments[0]+'.style.top=parseInt(parent.'+arguments[3]+'.document.all.content.style.top)+30');
            }
        }
    }
    if (arguments.length == 5) { // top, left position as parameters
       moveLayer(arguments[0], arguments[3], arguments[4]);
    }
    if (arguments[2]=="show") {
        setTimeout("window.scrollTo(0,0)",10);
    }
    showHideLayers(arguments[0],'',arguments[2]);
}

// add 2004.02.17 by Yi, hide all Layers of alertLayerArray
// also alle Layer die auf der Seite in einem array angegeben wurden:
//var taskAlertLayers = ["noresults", "dateinvalid", "tooManyValuesLayer"];

function closeAlerts(alertLayerArray) {
    if (alertLayerArray != null) {
        for (i = 0; i < alertLayerArray.length; i++) {
            var alertLayer = findObj(alertLayerArray[i]);
            if (alertLayer != null) {
                openCloseAlert(alertLayerArray[i], "", "hide");
            }
        } // end next
    }
}

function hidealllayers()
{
var allLayers=document.getElementsByTagName('div');
var NumberOfLayers=allLayers.length
for (i=0;i<NumberOfLayers;i++)
 {
 if (allLayers[i].style.visibility!="hidden") allLayers[i].style.visibility="hidden";
 }
}

/* zentriert Layer horizontal  */
  function setLayerToCenter(layerName){
    var layer;
    var width;
    if (IE || N6) {
      layer = document.getElementById(layerName);
      width = parseInt(document.body.clientWidth);
      var alertWidth = parseInt(layer.style.width);
      var newWidth = (width-alertWidth)/2;
      layer.style.left = newWidth;
    }
  }

function moveLayer(layerName,toppos,leftpos)
{
if (IE || N6)
{
eval("document.getElementById('"+layerName+"').style.top="+toppos);
eval("document.getElementById('"+layerName+"').style.left="+leftpos);
eval("document.getElementById('"+layerName+"').style.visibility='visible'");
}
if (N4)
{
eval("document.layers['"+layerName+"'].top="+toppos);
eval("document.layers['"+layerName+"'].left="+leftpos);
eval("document.layers['"+layerName+"'].visibility='show'");
}
}

/* wird nicht mehr verwendet

function showInfoWithoutScrolling(url) {
   	  url = setDummy(url);
        window.open(url,'Info','width=640,height=480,scrollbars=no');
}
*/


/* verschickt ein Formular
 gibt es nur 1 Formular auf der Seite und die action ist bereits im formular gesetzt,
sind keine Parameter notwendig:submitFormular()
soll die action gesetzt werden dann ein Aufruf der Art:submitFormular('/home/formular3.jsp')
*/
function submitFormular(action,target,method,formname)
 {
 if (document.forms.length==0) {alert("There is no form to be sent on this page!");return}
 var theform = document.forms[0];
 if (document.forms.length>1)
   {
   if (arguments.length==4) { var theform = findObj(formname)}
   else {alert("Please specify a formname");return}
   }
 if (arguments.length==0){
    if (document.forms[0].action=="") { alert("Please specify an action page");}
    else {document.forms[0].submit();return}
 }
 theform.action=top.upperframe.contextPath+arguments[0];

 if (arguments.length>1)
    {
	if (arguments[1]=="") theform.target="_self"; else theform.target=arguments[1];
    }
 else theform.target=theform.target="_self";

 if (arguments.length>2)
    {
	if (arguments[2]=="") theform.method="get"; else theform.method=arguments[2];
    }
    else theform.method="get";

 theform.submit();
}

 /* (Findet die erste gecheckte Box und gibt das Checkboxobjekt zur?ck)
 man erh?lt also den Wert der ersten checkbox:getFirstCheckedBoxof().value
  */
function getFirstCheckedBoxof(formID)
{
if (document.forms.length==1)
 {
 var numberOfFormelements=document.forms[0].elements.length;
 for (i=0;i<numberOfFormelements;i++)
  {
  if (document.forms[0].elements[i].checked) return document.forms[0].elements[i];
  }
 }
else
 {
 var numberOfFormelements=document.getElementById(formID).elements.length;
 for (i=0;i<numberOfFormelements;i++)
  {
  if (document.getElementById(formID).elements[i].checked) return document.getElementById(formID).elements[i];
  }
 }
}

// checked alle Boxen - gibt es mehr als ein Formular so muss die ID des Formulars
// angegeben werden dessen Boxen gecheckt werden sollen.
function checkAllBoxesof(formID)
{
if (document.forms.length==1)
 {
 var numberOfFormelements=document.forms[0].elements.length;
 var theform=document.forms[0];
 for (i=0;i<numberOfFormelements;i++)
  theform.elements[i].checked=true;
  }
else
 {
 var numberOfFormelements=document.getElementById(formID).elements.length;
 var theform=document.getElementById(formID);
 for (i=0;i<numberOfFormelements;i++)
 theform.elements[i].checked=true;
 }
}

// unchecked alle Boxen - gibt es mehr als ein Formular so muss die ID des Formulars
// angegeben werden dessen Boxen gecheckt werden sollen.
function uncheckAllBoxesof(formID)
{
if (document.forms.length==1)
 {
 var numberOfFormelements=document.forms[0].elements.length;
 var theform=document.forms[0];
 for (i=0;i<numberOfFormelements;i++)
  theform.elements[i].checked=false;
  }
else
 {
 var numberOfFormelements=document.getElementById(formID).elements.length;
 var theform=document.getElementById(formID);
 for (i=0;i<numberOfFormelements;i++)
 theform.elements[i].checked=false;
 }
}

// checkie() setzt den Zustand einer Liste (?bergabe der Namen) von Checkboxen um
//moegliche Checkboxzust?nde sind checkandenable,checkandisable,uncheckandenable,uncheckandisable
//Beispieaufruf: checkie('uncheckandisable','checkbox2','checkbox3')
function checkie() {
var checking=true;
var disabling=false;
var abbruch=true;
if (arguments[0]=="checkandenable") abbruch=false;
if (arguments[0]=="checkandisable") {abbruch=false;disabling=true;}
if (arguments[0]=="uncheckandenable") {abbruch=false;checking=false;}
if (arguments[0]=="uncheckandisable") {abbruch=false;disabling=true;checking=false;}
if (!abbruch)
{
for (j=1;j<arguments.length;j++)
{
for (i=0;i<document.forms[0].length;i++)
 {
 if ((document.forms[0].elements[i].name==arguments[j])&& (document.forms[0].elements[i].type == 'checkbox'))
  {

  document.forms[0].elements[i].checked=checking ;
  document.forms[0].elements[i].disabled=disabling ;
  }
 }
}
}
}

function getParameterListOfAllCheckedBoxesOf(formID)
{
var list="";
if (document.forms.length==1)
 {
 var numberOfFormelements=document.forms[0].elements.length;
 var theForm=document.forms[0]
 for (i=0;i<numberOfFormelements;i++)
  {
  if (theForm.elements[i].checked)
   {
   list = list + "&" + theForm.elements[i].name + "=" +theForm.elements[i].value;

   }
  }
 }
else
 {
 var numberOfFormelements=document.getElementById(formID).elements.length;
 var theForm=document.getElementById(formID)
 for (i=0;i<numberOfFormelements;i++)
  {
  if (theForm.elements[i].checked)
     {
	 list = list + "&" + theForm.elements[i].name + "=" +theForm.elements[i].value;

	 }
  }
 }
 return(list);
}


// gibt den Wert der Selektbox zurueck, der selektiert ist
function getValueOfSelectedOptionOfBox(selectBoxName)
{
var selectObject=document.getElementsByName(selectBoxName);
if (selectObject.length==1)
 {
 return(selectObject[0].options[selectObject[0].selectedIndex].value);
 }
else
 {
 alert("Please assign a unique name to the selectbox!");
 }
}


/* entfernt Zeilenumbrueche */
function nolinebreak(formname,elemname)
{
numberoflinebreaks=0;
for (i=0;i<eval("document."+formname+"."+elemname+".value.length");i++)
 {
 if (eval("document."+formname+"."+elemname+".value.charAt(i)")=="\n") numberoflinebreaks++;
 }
eval("document."+formname+"."+elemname+".value=escape(document."+formname+"."+elemname+".value)");
for (j=0;j<numberoflinebreaks;j++)
 {
 eval("document."+formname+"."+elemname+".value=document."+formname+"."+elemname+".value.replace('%0D%0A','%20')");
 }
eval("document."+formname+"."+elemname+".value=unescape(document."+formname+"."+elemname+".value)");
}

/* schraubt dummy an url*/
function setTimeStamp(url) {
    if (url.indexOf('?') < 0) {
      url += '?';
    } else {
      url += '&';
    }
    url += 'jsdmy=' + (new Date()).getTime();
  return url;
}

/* verhindert, dass sich der Cursor ueber einem inaktiven Link aendert
fuer die  Buttons in der Buttonrow die inaktiv werden gibt es ein Tag ->designvorlagen/baukasten.jsp
*/
function setCursorClass(link,flag){
  if(IE){
    if(flag) link.style.cursor = "default";
    else link.style.cursor = "hand";
  }
  if(N6){
    if(flag) link.style.cursor = "default";
    else link.style.cursor = "pointer";
  }
}



/* ruft den Navipunkt  'my_home' auf -> Navi schliessen und myHome in den Contentframe*/
  function closeMenuItem(){
    top.upperframe.toMenuItem('my_home');
  }


/* -- Deprecated -- jetzt kommen die deprecated functions
   -- Deprecated -- jetzt kommen die deprecated functions
   -- Deprecated -- jetzt kommen die deprecated functions
   -- Deprecated -- jetzt kommen die deprecated functions
   -- Deprecated -- jetzt kommen die deprecated functions
   -- Deprecated -- jetzt kommen die deprecated functions
*/


function openWBT(url){
    var wbtWindow = generalOpenWindow(url,'WBT','width=800,height=600,top=100,left=200,resizable=yes,scrollbars=yes,toolbar=yes,status=yes',true);
    wbtWindow.focus();
}

function newwindow(urlie,named)
{

if (navigator.appName == "Microsoft Internet Explorer")
{

Fenster=generalOpenWindow(urlie,named,'top=200,left=150,toolbar=no,location=no,status=no,menubar=no,resizable=yes,scrollbars=auto,directories=no,width=650,height=400',true);
};
if (navigator.appName == "Netscape")
{

Fenster=generalOpenWindow(urlie,named,'toolbar=no,location=no,status=no,menubar=no,resizable=yes,scrollbars=auto,directories=no,width=650,height=400',true);
Fenster.moveTo(150,200);

}
}


function preview(url) {
   // SSC 13.05.03  Umstellung der PopUps
        url = setDummy2(url);
        openSpecialWindow(url,'Preview');
   // ende
}

function showInfo(url) {
        url = setDummy2(url);
        // SSC 13.05.03  Umstellung der PopUps
            openLWindow(url,'Info');
        // ende
}

function setDummy2(url) {
    if (url.indexOf('?') < 0) {
      url += '?';
    } else {
      url += '&';
    }
    url += 'jsdmy=' + (new Date()).getTime();
  return url;
}

function windowOpen(url) {
   // SSC 14.05.03  Umstellung der PopUps
        var clixWindow = openSpecialWindow(url,'clixWindow');
   // ende

    return clixWindow;
}

function openExternal(url) {
     externWindow = generalOpenWindow(url,'clixWindow','width=700,height=460,left=150,top=110,scrollbars=1,location=yes,menubar=yes,status=yes,toolbar=yes,resizable=yes',true) ;
     externWindow.focus();
}

// Bitte diese Funktion nicht mehr verwenden (C.L. 08.07.2003)
// stattdessen: Fensterinhalt in Frameset packen, wo der Inhaltsframe scrollt
function openWindow(url, name, _width, _height,resizability) {
	var ow = screen.availWidth;
	var oh = screen.availHeight;
   var scrollBar = "0";
   if ((_width > screen.availWidth) || (_height > screen.availHeight))
      scrollBar = "1";
    if  (arguments.length<5)
	{
	var str = "left=" + (ow-_width)/2 + ",top=" + (oh-_height)/2 + ",width=" + _width + ",height=" + _height + ",scrollbars=" + scrollBar;
    }
	else
	{
	if (resizability=='yes')
	 {
	 var str = "left=" + (ow-_width)/2 + ",top=" + (oh-_height)/2 + ",width=" + _width + ",height=" + _height + ",scrollbars=" + scrollBar+",resizable=yes";
	 }
	}

	var newWindowObject = generalOpenWindow(url, name, str,true);
    newWindowObject.focus();


}
// Bitte diese Funktion nicht mehr verwenden (C.L. 08.07.2003)
// stattdessen: Fensterinhalt in Frameset packen, wo der Inhaltsframe scrollt

function getOpenWindow(url, name, _width, _height) {
        var ow = screen.availWidth;
        var oh = screen.availHeight;
   var scrollBar = "0";
   if ((_width > screen.availWidth) || (_height > screen.availHeight))
      scrollBar = "1";

        var str = "left=" + (ow-_width)/2 + ",top=" + (oh-_height)/2 + ",width=" + _width + ",height=" + _height + ",scrollbars=" + scrollBar;

        return generalOpenWindow(url, name, str,true);
}

/*A.O. 29.8.2003, da Scrollbarfunktionalit?t bei openWindow fehlerhaft*/
// erweitert CL 22.03.2007
function openWindowCommon(url, name, _width, _height,scrollbars,resizeable, noReturn) {
    if(typeof noReturn == 'undefined'){
	   noReturn =false;
   }
   var ow = screen.availWidth;
   var oh = screen.availHeight;
   var str = "left=" + (ow-_width)/2 + ",top=" + (oh-_height)/2 + ",width=" + _width + ",height=" + _height + ",scrollbars="+scrollbars+",resizable="+resizeable;
   var fileWindow = generalOpenWindow(url, name, str,true);
   fileWindow.focus();
    if(!noReturn)
   return fileWindow;
}

function openWindowCommonFull(url, name, _width, _height, toolbar, menubar, location, scrollbars, status, resizeable) {
   var ow = screen.availWidth;
   var oh = screen.availHeight;
   var str = "left=" + (ow-_width)/2 + ",top=" + (oh-_height)/2 + ",width=" + _width + ",height=" + _height + ",toolbar="+toolbar + ",menubar="+menubar + ",location="+location + ",scrollbars="+scrollbars + ",status="+status+",resizable="+resizeable;
   fileWindow = generalOpenWindow(url, name, str,true);
   fileWindow.focus();
}

function openInfo(url) {
       if(window.info)
           info.close;

       info = generalOpenWindow(url,'Info','width=400,height=600,resizable=yes, dependent=yes,scrollbars=yes',true);
       info.focus();
}

function openInfoType(url) {
 // SSC 13.05.03  Umstellung der PopUps
    openMWindow(url,'Info');
}


function newwindowComponent(urlie,named){
 // SSC 13.05.03  Umstellung der PopUps
      openSpecialWindow(setTimeStamp(urlie),named,'yes');    // Sonderfall bis Frageb?gen-Frontend umgebaut ist, dann brauch man keine Scrollbalken mehr
   // ende
}


function openInfoStatus(url) {
       // SSC 13.05.03  Umstellung der PopUps
        openLWindow(url,'Info');
      // ende
}

 function setLayerToCenter(layerName, layerWidth){
    var layer;
    var width;
    if (IE || N6) {
      layer = document.getElementById(layerName);
      if ((arguments.length==1)&&(IE)) layerWidth=parseInt(layer.clientWidth);
      width = parseInt(document.body.clientWidth);
      var alertWidth = parseInt(layerWidth);
      var newWidth = (width-alertWidth)/2;
      layer.style.left = newWidth;
    }
  }

function MM_showHideLayers() {
var da,weg;
if (arguments[2]=='show') {
  da="visible";
  if(arguments.length==5 && arguments[4]) setTimeout("window.scrollTo(0,0)",10);
}
if (arguments[2]=='hide')
 {
 if (navigator.appName == "Netscape") {da="hide";}
 if (navigator.appName == "Microsoft Internet Explorer") {da="hidden";}
 }

 if (arguments[2]=='show')
 {
 if (navigator.appName == "Netscape") {da="show";}
 if (navigator.appName == "Microsoft Internet Explorer") {da="visible";}
 }
 if (arguments.length==4 || arguments.length==5){
  if(arguments[3] == ''){
    if (navigator.appName == "Microsoft Internet Explorer"){
      eval('document.all.'+arguments[0]+'.style.visibility="'+da+'"');
    }else{
      var argumente = arguments[0];
      document.layers[argumente].visibility="'+da+'";
    }
  }else{
    if (navigator.appName == "Microsoft Internet Explorer"){
      eval('parent.'+arguments[3]+'.document.all.'+arguments[0]+'.style.visibility="'+da+'"');
    }else{
      var argumente = arguments[0];
      if (N4) {document.layers[argumente].visibility="'+da+'";}
	  if (N6) {document.getElementById(argumente).style.visibility="'+da+'";}
    }
  }
}
if (arguments.length==3)
  if (navigator.appName == "Microsoft Internet Explorer"){
    eval('document.all.'+arguments[0]+'.style.visibility="'+da+'"');
  }else{
    var argumente = arguments[0];
    document.layers[argumente].visibility="'+da+'";
  }

if (navigator.appName == "Microsoft Internet Explorer")
{
if (arguments.length<=3)
{
eval('document.all.'+arguments[0]+'.style.pixelLeft=parseInt((document.body.clientWidth-parseInt(document.all.'+arguments[0]+'.style.width))/2)');
if (document.all["content"])
{
eval('document.all.'+arguments[0]+'.style.top=parseInt(document.all["content"].style.top)+30');
}
}

if (arguments.length==4)
{
eval('parent.'+arguments[3]+'.document.all.'+arguments[0]+'.style.pixelLeft=parseInt((document.body.clientWidth-parseInt(parent.'+arguments[3]+'.document.all.'+arguments[0]+'.style.width))/2)');

if (eval('parent.'+arguments[3]+'.document.all.content'))
{
eval('parent.'+arguments[3]+'.document.all.'+arguments[0]+'.style.top=parseInt(parent.'+arguments[3]+'.document.all.content.style.top)+30');

}
}

}

}

/* laed die myHome in den Contentframe*/
 function closePage(){
   top.upperframe.closeNavi();
   top.contentframe.location = contextPath+"/home/myhome.jsp";
  }

  /* schaltet scrollen aus */
function s()
{
if (navigator.appName=="Microsoft Internet Explorer")
 {document.body.scroll="no";
 }
}

/* ueberprueft Laenge eines Eintrags->dies geschieht eigentlich im Tag Java*/
function check_length(area,length,text){
    if (area.value.length > length){
      area.value = area.value.substr(0,length);
      alert(text);
    }
  }

  /* verschickt Formular*/
function toggleGroup(groupName){
 if(window.newFile)
        window.newFile.close();
 document.clixform.clixFormEvent.value="toggleGroup$"+groupName;
 document.clixform.submit();
}
function submitClixForm(clixEventName){
 document.clixform.clixFormEvent.value=clixEventName;
 document.clixform.submit();
}

// R.S. wie openSpecialWindow aber mit Scrolling nur f?r HTML-Upload-Seiten
function openHTMLUploadWindow(url, name){
    clixWindow = generalOpenWindow(url,name,'width=800,height=600,top=50,left=100,resizable=yes,dependent=no,scrollbars=yes',true);  // eingentlich no wird ge?ndert, wenn alle gr?sseren Fenster zum Frameset umgebaut werden
    clixWindow.focus();
}

function openProfile(id){
    openSpecialWindow(contextPath +'/servlet/de.imc.clix.control.Clix?clixEvent=profileViewEvent&newWindow=true&userId='+id+'&dummy='+(new Date()).getTime(),'userProfile');
}

function openUserInfo(id){
    openBWindow(contextPath+'/servlet/de.imc.clix.control.Clix?clixEvent=user-info&dmy='+(new Date()).getTime()+'&id='+id,'userInfo');
}

function addToAddressBook(id,searchMapKey){
    parent.location.href = contextPath + '/servlet/de.imc.clix.control.Clix?clixEvent=addusertoaddressbook&addressId='+id+'&searchMapKey='+searchMapKey+'&dmy='+(new Date()).getTime();
}

function toGuestBook(id){
    if(top.contentframe){
        top.contentframe.location.href = contextPath + '/servlet/de.imc.clix.control.Clix?clixEvent=my-messageboard-list&owner_id='+id+'&dmy='+(new Date()).getTime();
    }
}
function openSelectWindow(url, name) {
    if(window.clixWindow)
       clixWindow.close;

    clixWindow = generalOpenWindow(url,name,'left=100,top=100,width=530,height=600,resizable=yes,dependent=no,scrollbars=1',true);
    clixWindow.focus();

  return clixWindow;
}
function getClixTop(){
	var currentFrame = window;
	try {
		while(currentFrame.parent && currentFrame.parent != currentFrame){
			if(currentFrame.location.hostname == currentFrame.parent.location.hostname
				&& String(currentFrame.parent.location.pathname).indexOf(contextPath) == 0){
				currentFrame = currentFrame.parent;			
			} else {
				break;
			}
		}
	} catch (e){}
	return currentFrame;
}
function getAjaxRequest(){
	var request;
    if (window.XMLHttpRequest){
    	request = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
    	try {
        	request = new ActiveXObject('Msxml2.XMLHTTP');
        } catch(err) {
        	request = new ActiveXObject('Microsoft.XMLHTTP');
        }
    }
    return request;	
}
function loadScript(scriptpath, functions){
	var request = getAjaxRequest();
    request.open('GET', scriptpath, false);
    request.send(null);
    eval(request.responseText);
	for(var i=0; i<functions.length; i++){
		window[functions[i]] = eval(functions[i]);
	}
}

// Start: Vorschlag von A.O. (Bug16623)
var originaloption;
function setOriginaloption(ac){
   originaloption=ac;
}

function resetToOriginaloption(dc){
   dc.selectedIndex=originaloption;
   dc.blur();
}
// Ende: Vorschlag von A.O. (Bug16623)

// RS Start: Bug 16918
function openChooseSkill(container,context,levelType,schedulingDisabled,comment,partner,name){
   return generalOpenWindow(contextPath+'/servlet/de.imc.clix.control.Clix?clixEvent=chooseSkill&container='+container+'&context='+context+'&levelType='+levelType+'&schedulingDisabled='+schedulingDisabled+'&comment='+comment+'&partner='+partner+'&dmy='+(new Date()).getTime(),name,'width=600,height=600,top=50,left=100,resizable=auto,dependent=no,scrollbars=1', true);
}
function openEditSkill(skillId,container,context,levelType,schedulingDisabled,comment,partner,name){
   return generalOpenWindow(contextPath+'/servlet/de.imc.clix.control.Clix?clixEvent=chooseSkillLevel&edit=true&skillId='+skillId+'&container='+container+'&context='+context+'&levelType='+levelType+'&schedulingDisabled='+schedulingDisabled+'&comment='+comment+'&partner='+partner+'&dmy='+(new Date()).getTime(),name,'width=600,height=600,top=50,left=100,resizable=auto,dependent=no,scrollbars=1', true);
}
// RS End
