// JS Document

var myWidth = 0, myHeight = 0, myScroll = 0; myScrollWidth = 0, myScrollHeight = 0;
  
function getSize() {
	
	// Window Size

    if (self.innerHeight) { // Everyone but IE
    	myWidth = window.innerWidth;
    	myHeight = window.innerHeight;
    	myScroll = window.pageYOffset;
    } else if (document.documentElement && document.documentElement.clientHeight) { // IE6 Strict
    	myWidth = document.documentElement.clientWidth;
    	myHeight = document.documentElement.clientHeight;
    	myScroll = document.documentElement.scrollTop;
    } else if (document.body) { // Other IE, such as IE7
    	myWidth = document.body.clientWidth;
    	myHeight = document.body.clientHeight;
    	myScroll = document.body.scrollTop;
    }

    // Page size w/offscreen areas

    if (window.innerHeight && window.scrollMaxY) {	
    	myScrollWidth = document.body.scrollWidth;
    	myScrollHeight = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight) { // All but Explorer Mac
    	myScrollWidth = document.body.scrollWidth;
    	myScrollHeight = document.body.scrollHeight;
    } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
    	myScrollWidth = document.body.offsetWidth;
    	myScrollHeight = document.body.offsetHeight;
    }
}
	
function findPosX(obj) {
  var curleft = 0;
  if(obj.offsetParent)
      while(1) {
        curleft += obj.offsetLeft;
        if(!obj.offsetParent)
          break;
        obj = obj.offsetParent;
      }
  else if(obj.x)
      curleft += obj.x;
  return curleft;
}

function findPosY(obj) {
  var curtop = 0;
  if(obj.offsetParent)
      while(1) {
        curtop += obj.offsetTop;
        if(!obj.offsetParent)
          break;
        obj = obj.offsetParent;
      }
  else if(obj.y)
      curtop += obj.y;
  return curtop;
}

function jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function usFocus(id,val) {
	if ($(id).value == val) {
		$(id).value = '';
	}
}

function usBlur(id,val) {
	if ($(id).value == '') {
		$(id).value = val;
	}
}

function pwFocus() {
	$('passT').style.display = 'none';
	$('pass').style.display = 'inline';
	$('pass').focus();
}

function pwBlur() {
	if ($('pass').value == '') {
		$('passT').style.display = 'inline';
		$('pass').style.display = 'none';
	}
}

function modalBox(width,title,content) {

	getSize();
	
	var inBody = document.getElementsByTagName('body').item(0);
	
	var whiteBg = document.createElement("div");
	whiteBg.setAttribute('id', 'whiteBg');
	whiteBg.style.position = 'absolute';
	whiteBg.style.zIndex = '999';
	whiteBg.style.left = '0';
	whiteBg.style.top = '0';
	whiteBg.className = 'blackBg';
	whiteBg.style.width = (myWidth-15)+'px';
	//whiteBg.style.height = (myScroll+myHeight)+'px';
	whiteBg.style.height = (myScrollHeight)+'px';
	whiteBg.onclick = closeModalBox;
	
	var maskBg = document.createElement("div");
	maskBg.setAttribute('id', 'modalBox');
	maskBg.style.width = width+'px';
	maskBg.style.position = 'absolute';
	maskBg.style.zIndex = '1000';
	maskBg.style.left = ((myWidth/2)-(width/2))+'px';
	maskBg.style.top = (myScroll+15)+'px';
	maskBg.className = 'modalBox';
	
	maskBg.innerHTML = '<div class="mb_title"><div class="left tit">'+title+'</div><div class="right"><div class="mb_close" onclick="closeModalBox()"></div></div><div class="clear"></div></div><div id="mb_content">'+content+'</div>';
		
	inBody.appendChild(whiteBg);
	inBody.appendChild(maskBg);
	
	myInterval = setInterval("checkModalBoxPos()", 1);
	
}

function checkModalBoxPos() {
	getSize();
	$('modalBox').style.top = (myScroll+15)+'px';
}
	
function closeModalBox() {
   	var inBody = document.getElementsByTagName('body').item(0);
    inBody.removeChild($('whiteBg'));
    inBody.removeChild($('modalBox'));
    clearInterval(myInterval);
}

function getLocation(loc) {
	location = loc;
}