//OLICMS Tag-area window (DHTML window)
var dragapproved=false
var minrestore=0
var initialwidth,initialheight
var ie5=document.all&&document.getElementById
var ns6=document.getElementById&&!document.all

function iecompattest(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function drag_drop(e){
if (ie5&&dragapproved&&event.button==1){
document.getElementById("dwindow").style.left=tempx+event.clientX-offsetx+"px"
document.getElementById("dwindow").style.top=tempy+event.clientY-offsety+"px"
}
else if (ns6&&dragapproved){
document.getElementById("dwindow").style.left=tempx+e.clientX-offsetx+"px"
document.getElementById("dwindow").style.top=tempy+e.clientY-offsety+"px"
}
}

function initializedrag(e){
offsetx=ie5? event.clientX : e.clientX
offsety=ie5? event.clientY : e.clientY
document.getElementById("dwindowcontent").style.display="none" //extra
tempx=parseInt(document.getElementById("dwindow").style.left)
tempy=parseInt(document.getElementById("dwindow").style.top)

dragapproved=true
document.getElementById("dwindow").onmousemove=drag_drop
}

function loadwindow(url,width,height){
if (!ie5&&!ns6)
window.open(url,"","width=width,height=height,scrollbars=1")
else{
document.getElementById("dwindow").style.display=''
document.getElementById("dwindow").style.width=initialwidth=width+"px"
document.getElementById("dwindow").style.height=initialheight=height+"px"
document.getElementById("dwindow").style.left="30px"
document.getElementById("dwindow").style.top=ns6? window.pageYOffset*1+30+"px" : iecompattest().scrollTop*1+30+"px"
document.getElementById("cframe").src=url
}
}

function maximize(){
if (minrestore==0){
minrestore=1 //maximize window
document.getElementById("maxname").setAttribute("src","../img/olicms/resize.gif")
document.getElementById("dwindow").style.width=initialwidth
document.getElementById("dwindow").style.height=10 + "px";
}
else{
minrestore=0 //restore window
document.getElementById("maxname").setAttribute("src","../img/olicms/resize.gif")
document.getElementById("dwindow").style.width=initialwidth
document.getElementById("dwindow").style.height=initialheight
}
document.getElementById("dwindow").style.left=ns6? window.pageXOffset+"px" : iecompattest().scrollLeft+"px"
document.getElementById("dwindow").style.top=ns6? window.pageYOffset+"px" : iecompattest().scrollTop+"px"
}

function closeit(){
document.getElementById("dwindow").style.display="none"
}

function stopdrag(){
dragapproved=false;
document.getElementById("dwindow").onmousemove=null;
document.getElementById("dwindowcontent").style.display="" //extra
}

// Over-Effect on table <td> element (having 'ove' class) =====================
var oldFg = '#6C000A'; 
var oldBg = '#FFF99D';
function ove_check(flag, source4){
if (flag == 1){
	oldFg=source4.style.color;
	oldBg=source4.style.backgroundColor;
	source4.style.color='#6C000A';
	source4.style.backgroundColor ='#FFF99D';
}
else{
	source4.style.color=oldFg;
	source4.style.backgroundColor =oldBg;
}
}
function ove(e, flag){
if (document.all)
	source4=event.srcElement;
else if (document.getElementById)
	source4=e.target;
	
if (source4.className=="ove"){
	ove_check(flag, source4); 
}
else{
while(source4.tagName!="TABLE"){
	source4=document.getElementById? source4.parentNode : source4.parentElement
	if (source4.className=="ove"){
	  ove_check(flag, source4); 
	}
}
}
}

// Highlight form element =====================================================
var highlightcolor="#E6E6E6"
var foregroundcolor="#121C46"
var ns6=document.getElementById&&!document.all
var previous=''
var eventobj;
//Regular expression to highlight only form elements
var intended=/INPUT|SELECT|OPTION|TEXTAREA/
//Function to check whether element clicked is form element
function checkel(which){
if (which.style&&intended.test(which.tagName) && which.id != 'cmsarea'){
if (ns6&&eventobj.nodeType==3)
eventobj=eventobj.parentNode.parentNode
return true
}
else
return false
}
//Function to highlight form element
function highlight(e){
eventobj=ns6? e.target : event.srcElement
if (previous!=''){
if (checkel(previous))
previous.style.backgroundColor=''
previous=eventobj
if (checkel(eventobj))
eventobj.style.backgroundColor=highlightcolor
eventobj.style.color=foregroundcolor
}
else{
if (checkel(eventobj))
eventobj.style.backgroundColor=highlightcolor
eventobj.style.color=foregroundcolor
previous=eventobj
}
}
// ============================================================================
var Z_Protect=0; // Protect right click
function z_reloadPage(init) {
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.z_pgW=innerWidth; document.z_pgH=innerHeight; onresize=z_reloadPage; }}
  else if (innerWidth!=document.z_pgW || innerHeight!=document.z_pgH) location.reload();
}
z_reloadPage(true);

function z_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=z_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function z_swapImgRestore() {
  var i,x,a=document.z_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function z_preloadImages() {
	if (Z_Protect)
		z_trap();
  var d=document; if(d.images){ if(!d.z_p) d.z_p=new Array();
    var i,j=d.z_p.length,a=z_preloadImages.arguments; for(i=0; i<a.length; i++) 
    if (a[i].indexOf("#")!=0){ d.z_p[j]=new Image; d.z_p[j++].src=a[i];}}
}

function z_swapImage() {
  var i,j=0,x,a=z_swapImage.arguments; document.z_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=z_findObj(a[i]))!=null){document.z_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
// [*]
function z_protect(e) {
alert("Sorry, you don't have permission to right-click.");
return false;
}

function z_trap() {
if(document.images)
for(i=0;i<document.images.length;i++)
document.images[i].onmousedown = z_protect;
}
