﻿// JScript File
function foo(px,py,pw,ph,baseElement,fid)
{
var win = document.getElementById(this.fid);
}


function dropdown_expand_menu(el, sWidth, bPopup, sPage)
{
if(el == null || !el.runtimeStyle || el.runtimeStyle.behavior.toLowerCase()=="none"){return;}
 var sPopUpHeight = 0;
 sPopUpHeight = el.options.length;
el.runtimeStyle.behavior="none";

var ie5 = (document.namespaces==null);
el.ondblclick = function(e)
{
window.event.returnValue=false;
return false;
}

if(window.createPopup==null)
{

var fid = "dropdown_expand_menu_" + Date.parse(new Date());

window.createPopup = function()
{
if(window.createPopup.frameWindow==null)
{
el.insertAdjacentHTML("AfterEnd","<iframe id='"+fid+"' name='"+fid+"' src='about:blank' frameborder='1' scrolling='no'></></iframe>");
var f = document.frames[fid];
f.document.open();
f.document.write("<html><body></body></html>");
f.document.close();
f.fid = fid; 


var fwin = document.getElementById(fid);
fwin.style.cssText="position:absolute;top:0;left:0;display:none;z-index:99999;";


f.show = function(px,py,pw,ph,baseElement)
{ 
py = py + baseElement.getBoundingClientRect().top + Math.max( document.body.scrollTop, document.documentElement.scrollTop) ;
//px = px + baseElement.getBoundingClientRect().left + Math.max( document.body.scrollLeft, document.documentElement.scrollLeft) ;
fwin.style.width = pw + "px";
fwin.style.height = ph + "px"; 
fwin.style.posLeft =px ;
fwin.style.posTop = py ; 
fwin.style.display="block"; 
}


f_hide = function(e)
{ 
if(window.event && window.event.srcElement && window.event.srcElement.tagName && window.event.srcElement.tagName.toLowerCase()=="select"){return true;}
fwin.style.display="none";
} 
f.hide = f_hide;
document.attachEvent("onclick",f_hide); 
document.attachEvent("onkeydown",f_hide); 

}
return f;
}
}

function showMenu()
{
document.onkeydown = KeyCheck;
function KeyCheck()
{
  if(event.keyCode == 38 || event.keyCode == 40)
  {
      event.cancelBubble = true;
      event.returnValue = false;
  }
}
function selectMenu(obj)
{ 
var o = document.createElement("option");
o.value = obj.value;
o.innerHTML = obj.innerHTML; 
while(el.options.length>0){el.options[0].removeNode(true);}
el.appendChild(o);
el.title = o.innerHTML; 
el.contentIndex = obj.selectedIndex ;
el.menu.hide(); 
} 


el.menu.show(0 , el.offsetHeight , 1, 1, el); 
var mb = el.menu.document.body;
if(sPage == "contact-us")
{
  mb.style.cssText = "background-color: #ffffff; border: 1px solid #4C5A74; font-weight: normal; text-decoration: none; color: #000000; font-family: Arial; font-size: 11px; height: auto; letter-spacing: 1px; width: 165px; padding:0; overflow-y: auto; overflow-x: auto; margin:0;";
}
else
{
  mb.style.cssText = "background-color: #BDBCBC; border: 1px solid #4C5A74; font-weight: normal; text-decoration: none; color: #000000; font-family: Arial; font-size: 11px; height: auto; letter-spacing: 1px; width: 165px; padding:0; overflow-y: auto; overflow-x: auto; margin:0;";
}
mb.style.cssText ="border:solid 1px black;margin:0;padding:0;overflow-y:auto;overflow-x:auto;background:white;text-aligbn:center;font-family:Verdana;font-size:12px;";
var t = el.contentHTML;
t = t.replace(/<select/gi,'<ul');
t = t.replace(/<option/gi,'<li');
t = t.replace(/<\/option/gi,'</li');
t = t.replace(/<\/select/gi,'</ul');
mb.innerHTML = t; 

el.select = mb.all.tags("ul")[0];
if(sPage == "contact-us")
{
  el.select.style.cssText= "background-color: #ffffff; font-weight: normal; text-decoration: none; color: #000000; font-family: Arial; font-size: 11px; list-style:none;margin:0;padding:0;";
}
else
{
  el.select.style.cssText= "background-color: #BDBCBC; font-weight: normal; text-decoration: none; color: #000000; font-family: Arial; font-size: 11px; list-style:none;margin:0;padding:0;";
}
mb.options = el.select.getElementsByTagName("li");

for(var i=0;i<mb.options.length;i++)
{
mb.options[i].selectedIndex = i;
if(sPage == "contact-us")
{
  mb.options[i].style.cssText = "background-color: #ffffff; font-weight: normal; text-decoration: none; color: #000000; font-family: Arial; font-size: 11px;list-style:none;margin:0;width:100%;cursor:hand;cursor:pointer;white-space:nowrap;"
}
else
{
  mb.options[i].style.cssText = "background-color: #BDBCBC; font-weight: normal; text-decoration: none; color: #000000; font-family: Arial; font-size: 11px;list-style:none;margin:0;width:100%;cursor:hand;cursor:pointer;white-space:nowrap;"
}
mb.options[i].title =mb.options[i].innerHTML;
mb.options[i].innerHTML ="<nobr>" + "&nbsp;" + mb.options[i].innerHTML + "</nobr>";
mb.options[i].onmouseover = function()
{

if( mb.options.selected )
{
  if(sPage == "contact-us")
  {
    mb.options.selected.style.background="#ffffff";mb.options.selected.style.color="#000000";
  }
  else
  {
    mb.options.selected.style.background="#BDBCBC";mb.options.selected.style.color="#000000";
  }
}
mb.options.selected = this;
this.style.background="#2763C2";this.style.color="#FFFFFF";
}

mb.options[i].onmouseout = function()
  {
    if(sPage == "contact-us")
    {
      this.style.background="#ffffff";this.style.color="#000000";
    }
    else
    {
      this.style.background="#BDBCBC";this.style.color="#000000";
    }
  }
mb.options[i].onmousedown = function(){selectMenu(this); }
mb.options[i].onkeydown = function(){selectMenu(this); }


if(i == el.contentIndex)
{
mb.options[i].style.background="#2763C2";
mb.options[i].style.color="#FFFFFF"; 
mb.options.selected = mb.options[i];
}
}


var mw = Math.max( ( el.select.offsetWidth ), el.offsetWidth );
mw = Math.max( mw, ( mb.scrollWidth) );
var mh = mb.options.length * 15 + 8 ; 
mw = mw + sWidth;

var mx = (ie5)?-3:0;
var my = el.offsetHeight -2;
var docH = document.documentElement.offsetHeight ;
var bottomH = docH - el.getBoundingClientRect().bottom ; 

mh = Math.min(mh, Math.max(( docH - el.getBoundingClientRect().top - 50),100) );

if(( bottomH < mh) )
{

mh = Math.max( (bottomH - 12),10);
if( mh <100 ) 
{
my = -100 ;

}
mh = Math.max(mh,100); 
}


self.focus(); 
if(bPopup == true)
{ 
  mh = sPopUpHeight * 3;
}
el.menu.show( mx , my , mw, mh , el); 
sync=null;
if(mb.options.selected)
{
mb.scrollTop = mb.options.selected.offsetTop;
}




window.onresize = function(){el.menu.hide()}; 
}

function switchMenu()
{
if(event.keyCode)
{
if(event.keyCode==40){ el.contentIndex++ ;}
else if(event.keyCode==38){ el.contentIndex--; }
}
else if(event.wheelDelta )
{
if (event.wheelDelta >= 120)
el.contentIndex++ ;
else if (event.wheelDelta <= -120)
el.contentIndex-- ;
}else{return true;}




if( el.contentIndex > (el.contentOptions.length-1) ){ el.contentIndex =0;}
else if (el.contentIndex<0){el.contentIndex = el.contentOptions.length-1 ;}

var o = document.createElement("option");
o.value = el.contentOptions[el.contentIndex].value;
o.innerHTML = el.contentOptions[el.contentIndex].text;
while(el.options.length>0){el.options[0].removeNode(true);}
el.appendChild(o);
el.title = o.innerHTML; 
}

if(dropdown_expand_menu.menu ==null)
{
dropdown_expand_menu.menu = window.createPopup();
document.attachEvent("onkeydown",dropdown_expand_menu.menu.hide);
}
el.menu = dropdown_expand_menu.menu ;
el.contentOptions = new Array();
el.contentIndex = el.selectedIndex;
el.contentHTML = el.outerHTML;
if(bPopup == true)
{
  var mh = (el.options.length * 3) - 3; 
  el.contentHTML = "<div style=\"overflow:auto;height:" + mh+ "px;\">" + el.contentHTML + "</div>";
}
for(var i=0;i<el.options.length;i++)
{ 
el.contentOptions [el.contentOptions.length] = 
{
"value": el.options[i].value,
"text": el.options[i].innerHTML
}

if(!el.options[i].selected){el.options[i].removeNode(true);i--;};
}


el.onkeydown = switchMenu;
el.onclick = showMenu;
el.onmousewheel= switchMenu;

}
