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);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}


function MM_showHideLayers() {
 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')?'block':(v=='hide')?'none':v;
     }
     obj.display=v;
   }
}
/*
function MM_showHideLayers() {
  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')?'block':(v=='hide')?'none':v; }
    obj.display=v; }
}
*/
function change_kulbutton_status()
{ 
  var i, p, v,obj,args=change_kulbutton_status.arguments;
  for (i=0; i<(args.length-1); i+=2)
   if ((obj=MM_findObj(args[i]))!=null)
   {
     v=args[i+1];
     if(v=='on')
     {
       p =  "/custom/karten/images/map_change__" + args[i] + "_1.gif";
     }
     else
     {
       p =  "/custom/karten/images/map_change__" + args[i] + "_2.gif";
     }
     obj.setAttribute("src", p);
   }
}
function change_map_pic(map_id, set_pic)
{
  if((obj=MM_findObj(map_id))!=null && set_pic != null)
  {
    set_pic = "/custom/karten/images/" + set_pic;
    obj.setAttribute("src", set_pic);
  }
}

function openWindow(theURL,winName,features) {
  mywindow=window.open(theURL,"popupwindow",features);
  //window.open("/abc/","title","");
}
function addfavorite() 
{
	if (window.external) 
	{
         external.AddFavorite(document.location.href,document.title);
    } 
    return;
}
function IFRAME_size_to_content(iframe_id) 
{
		 var the_height=document.getElementById(iframe_id).contentWindow.document.body.scrollHeight;//find the height of the internal page
		 document.getElementById(iframe_id).style.height=the_height + "px";		
     //container div in layout must also be resized 
     document.getElementById(iframe_id + '_container').style.height = the_height + 'px';
}   

function createcontent (folderid,secdescid)
{
	return window.open ("/admin/worklist/contextedit/itemcreatein.asp?secdescid=" + secdescid + "&awfolderid=" + folderid,"CONTEXTEDIT","toolbar=no,width=780,height=650,directions=no,status=yes,scrollbars=yes,menubar=no");
}

function show_main_menu(position, set_active, count_children)
{
  try 
  {
    if(position != "")
    {
      var dom_node_main = document.getElementById(position + "_main");
      if(count_children > 0)
      {
        var dom_node_subbox = document.getElementById(position + "_subbox");    
        if(dom_node_subbox.style.display == 'block')
          dom_node_subbox.style.display = 'none';
        else
          dom_node_subbox.style.display = 'block';
      }
    }
    if(set_active!=1)
    {
      //dom_node_main.style.backgroundImage = 'url(/custom/kws/images/navigation/kws_saat_ag__navi_aktiv.jpg)';
        //dom_node_main.style.color = '#FFF';
        
        // alto: setAttribte-class funktioniert leider nicht im MSIE
        
        var isIe/*@cc_on = true@*/;
        if(isIe)
          dom_node_main.setAttribute("className", "main_menu_link_act");
        else
          dom_node_main.setAttribute("class","main_menu_link_act");
    }
  } 
  catch (e) {};
}
      
function hide_main_menu(position, set_active)
{
  try
  {
    var dom_node_subbox = document.getElementById(position + "_subbox");
    var dom_node_main = document.getElementById(position + "_main");
        
    if(position != "")
    {
      dom_node_subbox.style.display = 'none';
      if(set_active!=1)
      {
        //dom_node_main.style.backgroundImage = 'url(/custom/kws/images/navigation/kws_saat_ag__navi_inaktiv.jpg)';
        //dom_node_main.style.color = '#000';
        
        // alto: setAttribte-class funktioniert leider nicht im MSIE
        var isIe/*@cc_on = true@*/;
        if(isIe)
          dom_node_main.setAttribute("className", "main_menu_link");
        else
          dom_node_main.setAttribute("class","main_menu_link");

      }
    }
  }
  catch (e) {};
}

function getmaincontent(strlink) {
    $.ajax({
        type: "GET",
        dataType: "html",
        url: strlink,
        success: function(htmlcontent) {
            var blockhtml = $(htmlcontent).find("#block_1_large > div");
            if (blockhtml.length == 0) {
                blockhtml = $(htmlcontent).find("#block_1 > div");
            }
            if (blockhtml.length > 0) {
                var block = $("#block_1");
                if (block.length == 0) {
                    block = $("#block_1_large");
                }
                if (block.length > 0) {
                    var linklistmiddle = $("#linklistmiddle");
                    if (linklistmiddle.length > 0) {
                        linklistmiddle.prev().remove();
                        linklistmiddle.before(blockhtml);
                    }
                    else {
                        block.html(blockhtml);
                    }
                }
                //blockhtml.insertAfter("#block_1 > div");
                //$("<h2>test</h2>").insertAfter("#block_1");



                /*$(this).prev('input')

                if (block.length > 0) {
                
                }*/
            }
        }
    });
}

