// popUp Javascript //

function popUp(URL) {
   day = new Date();
   id = day.getTime();
   eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1,width=600,height=440');");
}

function popUpMain(URL) {
   day = new Date();
   id = day.getTime();
   eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=340,height=340,left = 470,top = 342');");
}

// PopUp Javascript //

function PopUp_focus(url, x, y) {
    var options = "toolbar=no,menubar=no,scrollbars=yes,resizable=yes,width=" + x + ",height=" + y;
    msgWindow=window.open(url,"WinOpen",options);
    msgWindow.focus();
}

function checkMaxLength(field, maxlimit) {
    if (field.value.length > maxlimit)
        field.value = field.value.substring(0, maxlimit);
}

function clearText() {
    if( document.editForm.companyDetails.value  == document.editForm.defaultText.value ) {
        document.editForm.companyDetails.value = "" ;
    }
}

function DisplayImage(url, x, y) {
   var ht = y-10;
   var wd = x-10;
   var options = "status=no,toolbar=no,menubar=no,scrollbars=no,resizable=yes,width=" + wd + ",height=" + ht;
   imgWindow=window.open(url,"",options);
   imgWindow.focus();
}

function toggleLayer(whichLayer){  
    var elem, vis;
    if( document.getElementById ){ // this is the way the standards work
        elem = document.getElementById( whichLayer );
    }else if( document.all ) // this is the way old msie versions work
        elem = document.all[whichLayer];
    else if( document.layers ) // this is the way nn4 works
        elem = document.layers[whichLayer];
        vis = elem.style;  // if the style.display value is blank we try to figure it out here
    if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
        vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
        vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}

// tab switching //

var tmp;

first = "item1";

function miuAccordion(clicked) {

  if(clicked.className  == 'collapsed') {
    if (typeof tmp != 'undefined') {
      document.getElementById(tmp.id).className = 'collapsed';
      document.getElementById(tmp.id+"_content").className = 'collapsed';
    } else {
      document.getElementById(first).className = 'collapsed';
      document.getElementById(first+"_content").className = 'collapsed';
    }

    status = (clicked.className  == 'collapsed') ? 'expanded' : 'collapsed';
    clicked.className = status;
    document.getElementById(clicked.id+"_content").className = status;

    tmp = clicked;
  }

}


