/* PopUp Menu Script */

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function setLyr(obj, lyr, corX, corY)
{
	var coors = findPos(obj);
	coors[0] -= corX;
	coors[1] += corY;
	var x = document.getElementById(lyr);
	x.style.top = coors[1] + 'px';
	x.style.left = coors[0] + 'px';
}

function showP(obj, idPop, corX, corY)
{
	var x = document.getElementById('id_popup_menu' + idPop);
	x.style.visibility = 'visible';
	setLyr(obj, 'id_popup_menu' + idPop, corX, corY);
}

function hideP(obj)
{
	var x = document.getElementById('id_popup_menu1');
	x.style.visibility = 'hidden';
	setLyr(obj,'id_popup_menu1', 3, 14);
	x = document.getElementById('id_popup_menu2');
	x.style.visibility = 'hidden';
	setLyr(obj,'id_popup_menu2', 3, 14);
}

function showP1(obj)
{
  showP(obj, 1, 3, 14);
}

function showP2(obj)
{
  showP(obj, 2, 3, 14);
}

/* Button Disabling Script */

function DisableButtons(){
  //get all the input elements in the document
  var x=document.getElementsByTagName("input");
  //loop throught all the input form elements and display them by the input type then identify them by input name.
  for (i=0; i<x.length;i++) {
    /*
    if (x[i].getAttribute("type")=="checkbox") {
      if(x[i].className="myCheck"){then do something here.}
    }
    if (x[i].getAttribute("type")=="radio") {
      if( x[i].className="myRadio"){do something here}
    }
    if (x[i].getAttribute("type")=="text") {
      x[i].className="myText";
    }
    */
    if (x[i].getAttribute("type")=="submit") {
      //x[i].className="mySubmit";
      if(x[i].getAttribute("id")!="fs_main_login_button") {
        x[i].disabled = true;
      }
    }
    if (x[i].getAttribute("type")=="button") {
      //x[i].className="myButton";
      x[i].disabled = true;
    }
  }
  
  return true;
}

function EnableButtons(){
  //get all the input elements in the document
  var x=document.getElementsByTagName("input");
  //loop throught all the input form elements and display them by the input type then identify them by input name.
  for (i=0; i<x.length;i++) {
    if (x[i].getAttribute("type")=="submit") {
      //x[i].className="mySubmit";
      x[i].disabled = false;
    }
    if (x[i].getAttribute("type")=="button") {
      //x[i].className="myButton";
      x[i].disabled = false;
    }
  }
  
  return true;
}

function insertSmiley(){
  EnableButtons();
  void(0);
}

window.onbeforeunload=function (){
	DisableButtons();
}
