var showdebug = true;
function kdebug(msg)
{
 if(showdebug)alert("DEBUG : "+msg);
}
function klog(msg)
{ 
 alert(msg);
}
/*
var detect = navigator.userAgent.toLowerCase();
var brOp=false,brIe6=false,brFox=false,brKnow=false;
if (checkIt('opera')){brOp=true;brKnow=true}
if (!brKnow && checkIt('msie 6.0')){brIe6=true;brKnow=true;}
if (!brKnow && checkIt('firefox')){brFox=true;brKnow=true}
function checkIt(string)
{
	place = detect.indexOf(string) + 1;	
	return place;
}
function returnObjById( id ) 
{ 
    if (document.getElementById) 
        var returnVar = document.getElementById(id); 
    else if (document.all) 
        var returnVar = document.all[id]; 
    else if (document.layers) 
        var returnVar = document.layers[id]; 
    return returnVar; 
} 
function contentminheight(id)
{ 
  obj = returnObjById(id);
  if(obj.offsetHeight!= null) alt=obj.offsetHeight;  
  else if (obj.style.height != null)alt=obj.style.height;  
  else alt=0;  
  if(brKnow)
  {   
   //kdebug(alt+""+screen.height);
   if(brIe6 && alt < 463) alt=463;   
   if(brOp && alt <= 466) alt+=34;   
   if(brFox && alt <= 466) alt=alt+1   
   obj.style.height=alt;
  } 
}
window.onload = function(){ 
 contentminheight("contentContainer");
}
*/
function openWin(url)
{
 child = window.open(url,"child","menubar=no,location=no,resizable=no,scrollbars=yes,status=yes,width=600,height=500");
 child.focus();
 child.opener= self;
}
function loginCheck()
{
 frm = document.forms[0];
 if(frm.action.value=="chpwd")
 {
  inputElements = frm.elements;
  for (var i=0;i<inputElements.length;i++)
  {
   inputElement = inputElements[i];
   if(inputElement.type == "password" && inputElement.value.length < 6)
   {
    klog("ATTENTION : all fields are required (min password length 6) !!!");
    inputElement.focus();
    return false;
   }
  }
 }
 else if(frm.action.value=="login")
 {
  if(frm.username.value.length == 0)
  {
   klog("ATTENTION : username cannot be empty !!!");
   return false;
  }
  if(frm.pwd.value.length == 0)
  {
   klog("ATTENTION : password cannot be empty !!!");
   return false;
  }
 }
 return true; 
}
function loginFocus()
{
 frm = document.forms[0];
 if(frm.action.value=="chpwd")
 {
  inputElements = frm.elements;
  for (var i=0;i<inputElements.length;i++)
  {
   inputElement = inputElements[i];
   if(inputElement.type == "password" && i==1)
   {
    inputElement.focus();
    return false;
   }
  }
 }
 else if(frm.action.value=="login")
  frm.username.focus();
 return false;
}
function doSearch(frm)
{
 frm.submit();
}
function confirmDelete(username)
{
 vgo = confirm("Are you sure to delete this user ?");
 if(vgo) return true;
 else return false;
}


function reDirComp(oInput)
{
	switch (oInput)
	{
		case 0 :
			break;
		case 1 : // Fund Admin
			window.location = "navigation.jsp?_section=4&_page=43";
			break;
		case 2 : // Asset Manager
			window.location = "navigation.jsp?_section=4&_page=42";
			break;
		case 3 : // Hedge Funds
			window.location = "navigation.jsp?_section=4&_page=42";
			break;
		case 4 : // Brokers
			window.location = "navigation.jsp?_section=4&_page=42";
			break;
		case 5 : // Services Providers
			window.location = "navigation.jsp?_section=4&_page=45";
			break;
		case 6 : // --------------- nothing
			break;
		case 7 : // Trading
			window.location = "navigation.jsp?_section=4&_page=42";
			break;
		case 8 : // Post-Trading
			window.location = "navigation.jsp?_section=4&_page=43";
			break;
		case 9 : // Reconciliation
			window.location = "navigation.jsp?_section=4&_page=44";
			break;
		case 10 : // FIX Implementation
			window.location = "navigation.jsp?_section=5&_page=52";
			break;
		case 11 : // MiFID
			window.location = "navigation.jsp?_section=5&_page=53";
			break;
		case 12 : // STP
			window.location = "navigation.jsp?_section=5&_page=53";
			break;			
		case 13 : // WEB
			window.location = "navigation.jsp?_section=4&_page=45";
			break;			
	}
}
function reDirAct(oInput)
{
	switch (oInput)
	{
		case 0 :
			break;
		case 1 : // Trading
			window.location = "navigation.jsp?_section=4&_page=42";
			break;
		case 2 : // Post-Trading
			window.location = "navigation.jsp?_section=4&_page=43";
			break;
		case 3 : //Reconciliation
			window.location = "navigation.jsp?_section=4&_page=44";
			break;
		case 4 : //FIX Implementation
			window.location = "navigation.jsp?_section=5&_page=52";
			break;
		case 5 : // STP
			window.location = "navigation.jsp?_section=5&_page=53";
			break;
		case 6 : // WEB
			window.location = "navigation.jsp?_section=4&_page=45";
			break;
		case 7 : // MiFID
			window.location = "navigation.jsp?_section=5&_page=55";
			break;


	}
}