/********************tabs*************************/
function Browser(){
  var detect = navigator.userAgent.toLowerCase(); // get user browser
  this.dom = document.getElementById?1:0;
  this.ie = detect.indexOf("msie") + 1;
  this.ff = detect.indexOf("firefox") + 1;
  this.opera = detect.indexOf("opera") + 1;
  this.safari = detect.indexOf("safari") + 1;
  this.mozilla4 = detect.indexOf("mozilla/4") + 1;
  this.mozilla5 = detect.indexOf("mozilla/5") + 1;
  this.mozilla = (this.mozilla5 && !this.mozilla4)?1:0;
  this.ns6 = (this.dom && !document.all)?1:0;
}
var browser = new Browser();
var ie4 = document.all;
var nn6 = document.getElementById && !document.all;
var emptySc = "";
var icon_path = "";

if (navigator.appVersion.indexOf("2.") != -1){
   check = false;
}
if ((navigator.appVersion.indexOf("3.") != -1) && (navigator.appName.indexOf("Explorer") != -1)){
   check = false;
}
else {
   check = true;
}

var imageStay = "";

function imageon(name){
  if (imageStay != name){
     document[name].src = eval(name + "on.src");
  }
}
function imageoff(name){
  if (imageStay != name){
     document[name].src = eval(name + ".src");
  }
}

function on(name){
  if (check == true){
     imageon(name);
  }
}
function off(name){
  if (check == true){
     imageoff(name);
  }
}

function stay(name){
  if (check == true){
     document[name].src = eval(name + "stay.src");
     if (imageStay != name){
        if (imageStay != ""){
           document[imageStay].src = eval(imageStay + ".src");
        }
     }
     imageStay = name
  }
}
/********************tabs ends*************************/


/******** hide & show ********/
function toggleVisibility(id, NNtype, IEtype, WC3type) {
  if (document.getElementById) {
     eval("document.getElementById(id).style.visibility = \"" + WC3type + "\"");
  } else {
     if (document.layers) {
        document.layers[id].visibility = NNtype;
     } else {
        if (document.all) {
           eval("document.all." + id + ".style.visibility = \"" + IEtype + "\"");
        }
     }
  }
}
/******** hide & show ********/

/***** Exit window *****/

function hideObject00() {

   if (ie4) {
      window.Exit.document.write (emptySc);
      document.all['n00'].style.visibility = "hidden";
      document.all['n00'].style.height = "0px";
   }
   else if (nn6) {
      document.getElementById('n00').style.visibility = "hidden";
      document.getElementById('n00').style.height = "0px";
   }
}

// Show/Hide functions for pointer objects

function showObject00(loc) {
   if (ie4) {
      document.all['n00'].style.visibility = "visible";
      document.all['n00'].style.height = "152px";
   }
   else if (nn6) {
      document.getElementById('n00').style.visibility = "visible";
      document.getElementById('n00').style.height = "152px";
   }
   window.Exit.location.href = loc;
}

/******** help window ********/
function open_window_help (loc) {
    var w = window.open (loc, "Help", "scrollbars=no,menubar=no,location=no,resizable=yes,directories=no,height=470,width=330, left=485, top=115");
     w.focus();
}
/******** help window ends ********/

var parentWindowName = "metalibMainWin";
function setWindowName() {
  window.name = "metalibMainWin";
}
function winPop(event, url, isModal, width, height)
{
	var wWidth=width * 1.1; // window width
	var wHeight=height * 1.1; // window height
	var iMyWidth;
	var iMyHeight;
	
	//half the screen width minus half the new window width (plus 5 pixel borders).
	iMyWidth = (window.screen.width/2) - (wWidth/2 + 10);
	//half the screen height minus half the new window height (plus title and status bars).
	iMyHeight = (window.screen.height/2) - (wHeight/2 + 50);
	//Give the parent window a name we know (to reference it from the child)
	window.self.name = parentWindowName;
	//Open the window.
	var win2 = window.open(url,"Window2","status=no,height="+ wHeight +",width="+ wWidth +",resizable=yes,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",toolbar=no,menubar=no,scrollbars=yes,location=no,directories=no");
	win2.focus();
}  
function winClose()
{
	var win2 = window.open("","Window2","height=1,width=1");
	win2.close();
}  

function handlePopupSubmitConditional(form,retarget){
	if (retarget != "no"){
		handlePopupSubmit(form);
	}
}
function handlePopupSubmit(form){
	form.target = parentWindowName;
	//these are attempts to make this nicer:
	//(but in reality we've already done the important stuff above)
	window.opener.window.focus();
	setTimeout("self.close()",1000); //1000 miliseconds = 1 sec
}

function handlePopupLink(link){
	link.target = parentWindowName;
	window.opener.window.focus();
}

function handlePopupLinkAndClose(link){
	handlePopupLink(link);
	setTimeout("self.close()",1000); //1000 miliseconds = 1 sec
}
/*--------------- popup script ----------- */
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 loadmenu(url,width,height,direction){
if (!ie5&&!ns6)
window.open(url,"","width=width,height=height,scrollbars=1")
else{
document.getElementById("nav_menu").style.display=''
document.getElementById("nav_menu").style.width=initialwidth=width+"px"
document.getElementById("nav_menu").style.height=initialheight=height+"px"

if (direction=="left")
	document.getElementById("nav_menu").style.left="10px"
else
	document.getElementById("nav_menu").style.right="10px"
document.getElementById("nav_menu").style.top=ns6? window.pageYOffset*1+80+"px" : iecompattest().scrollTop*1+80+"px"
document.getElementById("cframe").src=url
}
}

function closemenu(){
document.getElementById("nav_menu").style.display="none"
}

function parentRedirect(loc){
	try{
		//alert(window.opener.window.location.href);
		if ((window.opener.window.location.href  = loc) != false){
			window.opener.window.focus();
			window.self.close();
		}
	}catch(e){
		window.location = loc;
	}
	
	return false;
}

// Used to get the value of form elements specifically in popup windows.
function getValue(id){
	try{
		var o = document.getElementById(id);
		if (o.value){
			return o.value;
		}else{
			return "";
		}
	}catch(e){
		return "";
	}
}

function setIconPath(path) {
icon_path = path;
}

function setlng(lng)
{
  var location = new String(window.location);

  location = location.replace(/&new_lng=([^&#]*)/g, "");
  if (location.indexOf("#") >= 0)
  {
    location = location.replace(/#/, "&new_lng=" + lng + "#");
  }
  else
  {
    if (location.indexOf("?") >= 0)
    {
      location += "&";
    }
    else
    {
      location += "?";
    }
    location += "new_lng=" + lng;
  }
  location = location.replace(/&group_number=(\d*)/, "");
  window.location = location;
}


