var win = null;

var browserHeight = 0;
var browserWidth  = 0;

var TobitFMwin;

function donothing()
{
   var adsas=1;
}


function TobitFM() 
{
	if (TobitFMwin && !TobitFMwin.closed) 
	{
		document.getElementById("TobitFMIcon").src = "/graphic/Tobit.FM_Icon_off.gif";
		//TobitFMwin.vis_radio.sendToActionScript();
	} 
	else 
	{
		//document.getElementById("TobitFMIcon").src = "/graphic/Tobit.FM_Icon_on.gif";
		TobitFMwin = window.open('/TobitFM.asp','TobitFM','location=no,menubar=no,status=no,toolbar=no,scrollbars=no,resizeable=no,width=480,height=320,top=50,left=50');
		TobitFMwin.focus();
	}
}

function TobitFMOff() 
{
	document.getElementById("TobitFMIcon").src = "/graphic/Tobit.FM_Icon_off.gif";
}

function TobitFMOn() 
{
	document.getElementById("TobitFMIcon").src = "/graphic/Tobit.FM_Icon_on.gif";
}				

function getClientData ()
{
   if (document.body.clientWidth)
      browserWidth = document.body.clientWidth;

   if (document.body.clientHeight)
      browserHeight = document.body.clientHeight;
}

function NewWindow(mypage, myname, w, h, scroll) 
{
   var winl = (screen.width-w) / 2;
   var wint = (screen.height-h) / 2;
   var settings = 'height=' + h + ',';
   settings += 'width=' + w + ',';
   settings += 'top=' + wint + ',';
   settings += 'left=' + winl + ',';
   settings += 'scrollbars=' + scroll + ',';
   settings += 'resizable=no';

   win = window.open (mypage, myname, settings); 
   return win;
}

function MrdArticle_OpenPicture( ID, picID )
{
   var _wnd = window.open( "http://club.tobit.com/imageview.asp?documentid=" + ID + "&pictureid=" + picID, "pictureCollection", 
                " dependent=yes, height=545, width=470, center=1, status=no, scrollbars=no, reziseable=no, location=no ");
   if ( _wnd != null && _wnd != "undefined" && _wnd != "null" && _wnd != undefined)
		_wnd.focus();
}

defaultStatus = "Tobit.Software";

function placeSubMenu ()
{
   if (document.getElementById("dsubmenu") && document.getElementById ("activemenupoint"))
      document.getElementById("dsubmenu").style.left = (document.getElementById ("activemenupoint").offsetLeft + 20) + "px";
}

var startPos = 10;
function fadeSubMenu(fadeIn)
{
   return;
   if (!document.getElementById ("ssubmenu") || document.getElementById ("dsubmenunofade"))
      return;
   startPos += 1;
   document.getElementById("dsubmenu").style.top = startPos + "px";
   if (startPos < 46)
      window.setTimeout ("fadeSubMenu(1)", 10);
}

function openLiveChannel () 
{
   var olc_url = '/login/livechannel/livechannel.asp';
   var olc_winName = 'LiveChannelWindow';
   var olc_w = 880;
   var olc_h = 670;
   LeftPosition = (screen.width) ? (screen.width - olc_w) / 2 : 0;
   TopPosition = (screen.height) ? (screen.height - olc_h) / 2 : 0;
   settings ='height=' + olc_h + ',width=' + olc_w + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=no, location=no, menubar=no';
   LiveChannelWin = window.open(olc_url, olc_winName, settings);
   LiveChannelWin.focus();
}


var ScrolloutTimer = null;
function StartScrollMRDInfo()
{
   if (ScrolloutTimer)
      window.clearTimeout (ScrolloutTimer);
   scrollMenu.Start();
}

function StartScrollOutMRDInfo()
{
   ScrolloutTimer = window.setTimeout ("scrollMenu.Start(true);", 40);
}

function initScroll()
{
   scrollMenu.ScrollElementID = "docnote-content";
   scrollMenu.AddEventElement (document.getElementById("docnote-content"), "onmouseover", StartScrollMRDInfo);
   scrollMenu.AddEventElement (document.getElementById("docnote-content"), "onmouseout", StartScrollOutMRDInfo);
   scrollMenu.ScrollMode = "x";
   scrollMenu.MaxScrollOffset = -10;
   scrollMenu.DisableScrollOut = true;
   scrollMenu.Duration = 300;
   //scrollMenu.ScrollCallback = function (scrollPos) {document.getElementById ("docnote-content").style.left = scrollPos + "px";}
   scrollMenu.Init();
}         

/*=======================================
Quicksearch
=========================================*/

function Search()
{
   if (CheckSearch())
      document.forms.SearchForm.submit()
}

function CheckSearch()
{
   SearchValue = document.forms.SearchForm.SearchValue.value;
   SearchValue = SearchValue.replace(/(^\s*)|(\s*$)/g, "");
   document.forms.SearchForm.SearchValue.value = SearchValue

   if ( SearchValue.length < 2)
      return false;
   else
      return true;
}

function checkInput (evt)
{
   var evtObj = null;
   var keyCode = null;
   
   if (window.event)
   {
      evtObj = window.event.srcElement;
      keyCode = window.event.keyCode;
   }
   else 
   {
      evtObj = evt.target;
      keyCode = evt.keyCode;
   }
   if (keyCode != 13)
      return;

   if (evtObj.id == "searchExpression" && CheckSearch(evtObj))
   {
      window.location.href = "CLUBFulltextSearch.asp?SearchValue=" + escape (evtObj.value);
   }
   else if (evtObj.id == "webcode")
   {
      window.location.href = "ShowTopicPerson.asp?webCode=" + escape (evtObj.value);
   }
   
}

function CheckSearch(_evtObj)
{
   SearchValue = _evtObj.value;
   SearchValue = SearchValue.replace(/(^\s*)|(\s*$)/g, "");
   _evtObj.value = SearchValue

   if ( SearchValue.length < 2)
      return false;
   else
      return true;
}

var WebcodeOld = "";
var SearchOld = "";
function checkFocus (evtObj, blur)
{
   if (blur)
   {
      evtObj.value = evtObj.id == "webcode" ? WebcodeOld : SearchOld;
   }
   else
   {
      //if (document.getElementById("webcode"))
      //   WebcodeOld = document.getElementById("webcode").value;
      SearchOld = document.getElementById("searchExpression").value;
      evtObj.value = "";
   }
}

/*=======================================
Menu
=========================================*/

var subMenuTimer = null;
function hideSubmenu(_id) 
{
   if (_id == 20005)
      HideLoginDialog();
   else
   {
      subMenuTimer = window.setTimeout("displaySubmenu(" + _id + ", false);", 70);
   }
}

function clearSubMenuTimeout()
{
   if (subMenuTimer)
      window.clearTimeout(subMenuTimer);
}

var activeSubMenuID = -1;
var cookiesOK = false;
var supressHideSubmenu = -1;
function displaySubmenu(_id, _display) 
{
   var menElement = document.getElementById("MenuPoint" + _id);
   if (_id == 20005)
   {
      ShowLoginDialog();
      return;
   }

   if (_id == supressHideSubmenu && _display == false)
   {
      menElement.className = "";
      return;
   }
   
   clearSubMenuTimeout();
   subMenuTimer = null;

   if (activeSubMenuID != -1 && activeSubMenuID != _id && _display && document.getElementById("SubMenuPoint" + activeSubMenuID)) 
   {
      document.getElementById("MenuPoint" + activeSubMenuID).className = "";
      document.getElementById("SubMenuPoint" + activeSubMenuID).style.display = "none";
      activeSubMenuID = -1;
   }
   
   var smObj = document.getElementById("SubMenuPoint" + _id);
   if (!smObj)
   {
      return;
   }

   smObj.style.left = "0px";
   smObj.style.display = _display ? "block" : "none";
   
   var OffsetLeft = 0;
   menElement.className = _display ? "mainmenuhover" : "";
   
   if (menElement.parentNode.id == "rightMenu" && (navigator.userAgent.indexOf("MSIE 6") != -1 || navigator.userAgent.indexOf("MSIE 7") != -1) )
      OffsetLeft = (menElement.offsetParent.offsetLeft - 0);   
   else
      OffsetLeft = (menElement.offsetLeft - 0);   
   
   if (OffsetLeft + smObj.offsetWidth > document.body.offsetWidth)
   {
      OffsetLeft = document.body.offsetWidth - (smObj.offsetWidth + 20);
      var scrollPosLeft = 0;
      if (document.documentElement)
         scrollPosLeft = document.documentElement.scrollLeft;
      else 
         scrollPosLeft = document.body.scrollLeft;
      OffsetLeft += scrollPosLeft;
   }

   smObj.style.left = (OffsetLeft) + "px";
   smObj.onmouseover = function() { displaySubmenu(_id, true); };
   smObj.onmouseout = function() { hideSubmenu(_id); };
   activeSubMenuID = _display ? _id : -1;

   if (_id == 10007 && _display)
   {
      if (!cookiesOK)
      {
         cookiesOK = true;  
         readLoginCookies();
      }
      if (document.Loginform && document.Loginform.LoginID)
      {
         //document.Loginform.LoginID.focus();
         document.Loginform.LoginPwd.onkeypress = checkLoginEnterSubmit;
      }
   }
}

function checkLoginEnterSubmit(evt)
{
   if (!evt)
      evt = window.event;
   if (evt.keyCode == 13)
      document.Loginform.submit();
}

function ChangeLanguage(lang)
{
   location.href="/login/start.asp?SetLanguage=" + lang
}

/*=======================================
Login
=========================================*/

function readLoginCookies()
{
   if (!document.Loginform || document.Loginform.LoginID)
      return;
      
	if (navigator.cookieEnabled == true)
	{
	   var userID = getCookieStr ("AccDataClub");
	   var PassWD = getCookieStr ("PassWDClub");
	   var pwState = getCookieStr ("storePwdClub") == 1;

      document.Loginform.LoginID.value = userID;
      document.Loginform.LoginPwd.value = PassWD;
      document.Loginform.RememberPassword.checked = pwState;
	}
}

function setLoginCookie(src)
{
   if (src.checked) 
      updateCookie();
   else
      deleteCookie();
}

function updateCookie()
{
	if (navigator.cookieEnabled)
	{
	   var userID  = document.Loginform.LoginID.value;
	   var PassWD  = document.Loginform.LoginPwd.value;
	   var pwState = document.Loginform.RememberPassword.checked;

      setCookie ("AccDataClub", userID, null, null, "/");
      setCookie ("PassWDClub", PassWD, null, null, "/");
      setCookie ("storePwdClub", 1, null, null, "/");
	}
}

function deleteCookie()
{
	if(navigator.cookieEnabled == true)
	{
      setCookie ("AccDataClub", "");
      setCookie ("PassWDClub", "");
      setCookie ("storePwdClub", 0);
	}
}

 