
function MaxLengthOnKeyPress(control)
{
    maxLength = control.attributes["maxLength"].value;
    return (control.value.length <= maxLength);
}

// Cancel default behavior
function MaxLengthOnBeforePaste(control){
    maxLength = control.attributes["maxLength"].value;
     if(maxLength)
     {
          event.returnValue = false;
     }
}
// Cancel default behavior and create a new paste routine
function MaxLengthOnPaste(control){
    maxLength = control.attributes["maxLength"].value;
    value = control.value;
     if(maxLength){
          event.returnValue = false;
          maxLength = parseInt(maxLength);
          var oTR = control.document.selection.createRange();
          var iInsertLength = maxLength - value.length + oTR.text.length;
          var sData = window.clipboardData.getData("Text").substr(0,iInsertLength);
          oTR.text = sData;
     }
}

function redirect_to_page(targetUrl)
{ 
    location.href = targetUrl;
}

function PageFlick(iid){  

  if(iid != null && iid != "")
  {
    
  for(i=1;i<=20;i++){
    e = document.getElementById('Page'+i);
    t = document.getElementById('tab'+i);
    if(e && i != iid){
      e.style.display='none';
    }

    if(t){
      t.className='';
      if(i == iid)
      {
        t.className='selectedTab';
        
        var faq = "#faq=faq0";
        var tab = "#tab=tab" + iid;
        
        if(window.location.hash)
        {            
            faq = window.location.hash.substring(window.location.hash.indexOf("#faq="),window.location.hash.indexOf("#tab="));
        }
        
        window.location.hash = faq + tab;
      }
    }
    }
  }

  if(document.getElementById('Page'+iid)){
//    Effect.Appear('Page'+iid,{ duration: 0.7});
    e = document.getElementById('Page'+iid);
	e.style.display='block';
  }
}

<!--// Show or hide layers in locator map //-->
 function changePage(pageNumber){
   for(i=1;i<=40;i++){
     e = document.getElementById('staff'+i);
	 if(e){
	   e.style.display='none';
	   if(i == pageNumber){
	     e.style.display = 'block';
	   }
	 }
   }
 }
 
 <!--// Show or hide layers in locator map //-->
 function toggleNews(pageNumber){
   for(i=0;i<=30;i++){
     e = document.getElementById('latest_news'+i);
	 if(e){
	   e.style.display='none';
	   if(i == pageNumber){
	     e.style.display = 'block';
	   }
	 }
   }
 }


<!--// Activates DropDown navigation for IE //-->
sfHover = function() {
	var sfEls = document.getElementById("navigation").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);





function addbookmark(bookmarkurl, bookmarktitle)
{	
	if(bookmarkurl == null)
	    bookmarkurl="http://www.medacs.com";
	   
	if(bookmarktitle == null || bookmarktitle=='')
	    bookmarktitle="Medacs Healthcare";
	    
	//YG - Fix bookmarking for all browsers..    
    //	if (document.all)
    //	    window.external.AddFavorite(bookmarkurl,bookmarktitle);

    if (window.sidebar) { // Mozilla Firefox Bookmark 
        window.sidebar.addPanel(bookmarktitle, bookmarkurl,""); 
    } else if( window.external ) { // IE Favorite 
        window.external.AddFavorite( bookmarkurl, bookmarktitle); } 
    else if(window.opera && window.print) { // Opera Hotlist 
        return true; }

}


function PopupPic(sPicURL) { 
     window.open( "popup.php?"+sPicURL, "",  
     "resizable=0,HEIGHT=200,WIDTH=200"); 
} 

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}


//Style Sheet Switcher version 1.0 Nov 9th, 2005
//Author: Dynamic Drive: http://www.dynamicdrive.com
//Usage terms: http://www.dynamicdrive.com/notice.php

function getCookie(Name) { 
var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
if (document.cookie.match(re)) //if cookie found
return document.cookie.match(re)[0].split("=")[1] //return its value
return null
}

function setCookie(name, value, days) {
var expireDate = new Date()
//set "expstring" to either future or past date, to set or delete cookie, respectively
var expstring=(typeof days!="undefined")? expireDate.setDate(expireDate.getDate()+parseInt(days)) : expireDate.setDate(expireDate.getDate()-5)
document.cookie = name+"="+value+"; expires="+expireDate.toGMTString()+"; path=/";
}

function deleteCookie(name){
setCookie(name, "moot")
}

function setStylesheet(title) {
var i, cacheobj
for(i=0; (cacheobj=document.getElementsByTagName("link")[i]); i++) {
if(cacheobj.getAttribute("rel").indexOf("style") != -1 && cacheobj.getAttribute("title")) {
cacheobj.disabled = true
if(cacheobj.getAttribute("title") == title)
cacheobj.disabled = false //enable chosen style sheet
}
}
}

function chooseStyle(styletitle, days){
if (document.getElementById){
setStylesheet(styletitle)
setCookie("mysheet", styletitle, days)
}
}

function indicateSelected(element){ //Optional function that shows which style sheet is currently selected within group of radio buttons or select menu 
var i
if (selectedtitle!=null && (element.type==undefined || element.type=="select-one")){ //if element is a radio button or select menu
var element=(element.type=="select-one") ? element.options : element
for (i=0; i<element.length; i++){
if (element[i].value==selectedtitle){ //if match found between form element value and cookie value
if (element[i].tagName=="OPTION") //if this is a select menu
element[i].selected=true
else //else if it's a radio button
element[i].checked=true
break
}
}
}
}

var selectedtitle=getCookie("mysheet")
if (document.getElementById && selectedtitle!=null) //load user chosen style sheet if there is one stored
setStylesheet(selectedtitle)



function toggleLayer(whichLayer)
{       
    if (document.getElementById)
    {   
        var style2;      
        // this is the way the standards work  
        if(document.getElementById(whichLayer))
            style2 = document.getElementById(whichLayer).style;
    }
    else if (document.all)
    {
        var style2;
        // this is the way old msie versions work      
        if(document.getElementById(whichLayer))            
            style2 = document.all[whichLayer].style;
    }
    else if (document.layers)
    {
        var style2;
        // this is the way nn4 works      
        if(document.getElementById(whichLayer))            
            style2 = document.layers[whichLayer].style;
    }
    
    
    if(style2 != null)
    {  
        if(style2.display)
        {    
            style2.display = "";
            
            //Reset the faq
            var faq = "#faq=faq0";
            var tab = "#tab=tab0";
            if(window.location.hash)
            {
                tab = window.location.hash.substring(window.location.hash.indexOf("#tab="),window.location.hash.length);
                faq = "#faq=faq0";
            }
            
            window.location.hash = faq + tab;
            
        }                
        else
        {   
            style2.display = "block";
            
            //Add hash to querystring to bookmark position on the search indexes
            var faq = "#faq=" + whichLayer;
            var tab = "#tab=tab0";
            if(window.location.hash)
            {        
                tab = window.location.hash.substring(window.location.hash.indexOf("#tab="),window.location.hash.length);            
            }
            window.location.hash = faq + tab;        
        }   
    }
    else
    {           
        //Add hash to querystring to bookmark position on the search indexes
        var faq = "#faq=" + whichLayer;
        var tab = "#tab=tab0";
        if(window.location.hash)
        {        
            tab = window.location.hash.substring(window.location.hash.indexOf("#tab="),window.location.hash.length);            
        }
        window.location.hash = faq + tab;        
    } 
}

//function KeyDownHandler(btn)
//{
//    if (event.keyCode == 13 || event.which == 13)
//    {        
//        event.returnValue=false;
//        event.cancel = true;
//        //document.getElementById(btn).click(); 
//        alert(btn);      
//         __doPostBack(btn,'');
//        return false;
//    }
//}

function FireDefaultButton(event, target) 
{
    // srcElement is for IE
    var element = event.target || event.srcElement;

    if (13 == event.keyCode && !(element && "textarea" == element.tagName.toLowerCase())) 
    {
    	var defaultButton;
    	defaultButton = document.getElementById(target);

    	if (defaultButton && "undefined" != typeof defaultButton.click) 
    	{
    		defaultButton.click();
    		event.cancelBubble = true;
    		if (event.stopPropagation) 
    			event.stopPropagation();
    		return false;
    	}
    }
    return true;
}

