﻿var kmMpWorkspaceH = 0;
var kmMpHeaderAdSpace = 0;
var kmMpMenuBar = 0;
var kmUa = navigator.userAgent.toLowerCase();
var kmState = 'none';

if (!document.all){
    HTMLElement.prototype.click = function() {
    var evt = this.ownerDocument.createEvent('MouseEvents');
    evt.initMouseEvent('click', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
    this.dispatchEvent(evt);
    };
}
function kmGetElementLeft(e){
   var nLeftPos = e.offsetLeft;
   var eParElement = e.offsetParent;
   while (eParElement !== null){
      nLeftPos += eParElement.offsetLeft;
      eParElement = eParElement.offsetParent;
   }
   return nLeftPos;
}
function kmGetElementTop(e){
   var nTopPos = e.offsetTop;
   var eParElement = e.offsetParent; 
   while (eParElement !== null){
      nTopPos += eParElement.offsetTop;
      eParElement = eParElement.offsetParent;
   }
   return nTopPos;
}
function kmGPS(obj){
   kmCache.cId = obj.id;
   kmCache.cName = obj.name;
   try{
      kmCache.cValue = obj.value;
   }
   catch(e){
      kmCache.cValue = obj.innerHTML;;
   }
   kmCache.cTabIndex = obj.tabIndex;
   kmCache.cClass = document.getElementById(""+obj.id+"").className;
   kmCache.cX = kmGetElementLeft(obj);
   kmCache.cY = kmGetElementTop(obj);
   return;
}
function kmGetW(){
   var w;
   if(document.innerWidth){
      w=document.innerWidth;
   } 
   else if(document.documentElement.clientWidth){
      w=document.documentElement.clientWidth;
   }
   else if(document.body){
      w=document.body.clientWidth;
      }
   return w;
}
function kmGetH(){
   var h;
   if(document.innerHeight){
      h=document.innerHeight;
   }
   else if(document.documentElement.clientHeight){
      h=document.documentElement.clientHeight;
   }
   else if(document.body){
      h=document.body.clientHeight;
   }
   return h;
}
function kmObject(a,b,c,d,e,f,g,h,i,j,k,l){
   this.cClass = a || "";
   this.cId = b || "";
   this.cName = c || "";
   this.cRecCount = d || 0;
   this.cState = e || -1;
   this.cTabIndex = f || "0";
   this.cValue = g || "";
   this.cX = g || 0;
   this.cxXml = h || "";
   this.cY = i || 0;
   this.XmlData = k;
   //this.trace = kmTrace(l)
   return this;
}
function kmPopPic(picURL, picWidth, picHeight, capt, msg) {
   var newWindow;
   newWindow = window.open(picURL, 'newWin', 'toolbar=no,width=' + picWidth + ',height=' + picHeight + ',scrollbars=yes,resizable=yes')
   newWindow.document.write('<head><title>'+capt+'<\/title><\/head>');
   newWindow.document.write('<body style="overflow:auto;margin:0px;" bgcolor="#000000">');
   newWindow.document.write('<center><img src="' + picURL + '" border="0" alt="' + capt + '"><\/center>');
   newWindow.document.write('<p align="center"><font color="#E7BA83" face="Verdana" size="3"><b>' + capt + '<\/b><\/font><\/p>');
   newWindow.document.write('<center><font face="Verdana" size="2"><a href="javascript:window.close();"><font color="#C0C0C0">' + msg + '<\/font><\/a><\/font><p>&nbsp;<\/p><\/center>');
   newWindow.document.write('<\/body><\/html>');
   newWindow.resizeBy(picWidth-newWindow.document.body.clientWidth,picHeight-newWindow.document.body.clientHeight)
   newWindow.focus()
}
function kmQuickEditPosition(obj){
   document.getElementById("kmFckX").value = kmGetElementLeft(document.getElementById("kmCText"));
   document.getElementById("kmFckY").value = kmGetElementTop(document.getElementById("kmCText")) - 14;
   return;
}
function kmShowHide(src, layer_ref) {
    if (kmState == 'block') {
        kmState = 'none';
        document.getElementById("" + src.id + "").src = "_assets/images/icon_plus.gif";
    } else {
       kmState = 'block';
       document.getElementById("" + src.id + "").src = "_assets/images/icon_minus.gif";
    }
    if (document.all) { //IS IE 4 or 5 (or 6 beta) 
        eval("document.all." + layer_ref + ".style.display = kmState");
    }
    if (document.layers) { //IS NETSCAPE 4 or below 
        document.layers[layer_ref].display = kmState;
    }
    if (document.getElementById && !document.all) {
        hza = document.getElementById(layer_ref);
        hza.style.display = kmState;
    }
} 
function kmStripUnicode(s) {
   o = "";
   for(m=0;s.charAt(m);++m){
      if ( (c=s.charCodeAt(m))<128&&c!=38){
	    o+=s.charAt(m);
      }
      else if (c==38){
	     o+="&";
      }
      else{
	     o+="&#"+c+";";
      }     
    }
    return o;
}

   //var generator=window.open('','name','height=400,width=500');
//generator.document.write(KiimAjaxMessage(obj,obj.options[kmSelectKey].value));
//generator.document.close();

/* CMS Layout */
function kmResetCTextMargin(){
   try{
      //document.getElementById("kmCText").style.marginRight = "380px";
   }
   catch(e){}

   return;
}
function kmResetMainMargin(){
   try{
      document.getElementById("kmSidebar").style.width = "0px";
 	  document.getElementById("kmSecondary").style.width = "0px";
      document.getElementById("kmMain").style.marginLeft = "0px";
	  document.getElementById("kmMain").style.marginRight = "0px";
	}
	catch(e){}
return;
}
function kmResetSidebarMargin(){
   try{
      document.getElementById("kmSidebar").style.width = "0px";
      document.getElementById("kmMain").style.marginLeft = "0px";
	}
	catch(e){}
return;
}
function kmResetSecondaryMargin(){
   try{
      document.getElementById("kmSecondary").style.width = "0px";
      document.getElementById("kmMain").style.marginRight = "0px";
	}
	catch(e){}
return;
}