
isIE4 = (document.all)? true:false;
isNav4 = (document.layers)? true:false;
isNav6 = (document.getElementById)? true:false;
isMac = (navigator.platform.indexOf("Mac") == -1)? false : true;
if (isIE4) isNav6 = false;

function preloadImages()
{
var d=document;
    if(d.images)
    {
        if(!d.p)
        {
            d.p=new Array();
        }

        var i,j=d.p.length,a=preloadImages.arguments;
        for(i=0; i<a.length; i++)
        {
            if (a[i].indexOf("#")!=0)
            {
                d.p[j]=new Image;
                d.p[j++].src=a[i];
            }
        }
    }
}

function findObj(n, d)
{
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=findObj(n,d.layers[i].document);
            return x;
        }
    }
}

function swapImage()
{

var i,j=0,x,a=swapImage.arguments;
document.sr=new Array;

    for(i=0;i<(a.length-2);i+=3)
    {
        if ((x=findObj(a[i]))!=null)
        {
            document.sr[j++]=x;
            if(!x.oSrc)
            {
                x.oSrc=x.src;
                x.src=a[i+1];
            }
        }
    }
}

function swap(img, to_state)
{
    eval("document." + img + ".src = " + img + to_state + ".src");
}

function swap_lyr(img, to_state, lyr)
{
    if (isNav4)
    {
        eval("document." + lyr + ".document." + img + ".src = " + img + to_state + ".src");
    } else {
        swap(img, to_state);
    }
}


function openwin(winame,file,height,width)
{
    window.open(file,winame,"status=no,scrollbars=no,toolbar=no,location=no,menu=no,resizable=no,width="+width+",height="+height);
}

function openwinscroll(winame,file,height,width)
{
    window.open(file,winame,"status=no,scrollbars=yes,toolbar=no,location=no,menu=no,resizable=yes,width="+width+",height="+height);
}



function showHideLayers()
{ //v3.0

var i,p,v,obj,args=showHideLayers.arguments;

    for (i=0; i<(args.length-2); i+=3)
    {
        if ((obj=findObj(args[i]))!=null)
        {
            v=args[i+2];
            if (obj.style)
            {
                obj=obj.style;
                v=(v=='show')?'visible':(v='hide')?'hidden':v;
            }
            obj.visibility=v;
        }
    }
}



function writeFlashEmbed(flashURL, flashWidth, flashHeight, flashBG, flashVersion)
{
   flashVersion = '5,0,0,0';
	document.write('<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"   codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" WIDTH="'+ flashWidth +'" HEIGHT="'+ flashHeight +'" id=ShockwaveFlash1><PARAM NAME="movie" VALUE="'+ flashURL +'"><PARAM NAME="quality" VALUE="high"><PARAM NAME="bgcolor" VALUE="#'+ flashBG +'"><PARAM NAME="version" VALUE="'+ flashVersion +'"><EMBED SRC="'+ flashURL +'" QUALITY="high" BGCOLOR="#'+ flashBG +'" WIDTH="'+ flashWidth +'" HEIGHT="'+ flashHeight +'" VERSION="'+ flashVersion +'" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED></OBJECT>');
}  
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) { //v3.0
  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); 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 Pop(url) {
OpenWin = this.open(url, "a_window", "height=425,width=500");
}

function Pop2(url) {
OpenWin = this.open(url, "a_window", "height=425,width=600, scrollbars=yes");
}

// select list script
function go_to() 
{
tIndex = document.jumpList.place.selectedIndex;
location = document.jumpList.place.options[tIndex].value;
}

// main validation function
function Validate() 
{
 var phone, i, msg, errfound;
   msg="";
   errfound = false;
   
	// make sure phone is entered
	phone = (document.info_exchange.phone1.value + document.info_exchange.phone2.value +   document.info_exchange.phone3.value);
	if (phone.length != 10 )
	{
		errfound = true;
		msg = "Please enter a Valid Phone number.";
	}

   
	// make sure username is entered
	if (document.info_exchange.username.value == "")
	{
    	 errfound = true;
	     msg = "Please enter a Valid UserName.";
	}

	if (errfound ) alert(msg);
	return !errfound;
}

var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e) {
var keyCode = (isNN) ? e.which : e.keyCode; 
var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
if(input.value.length >= len && !containsElement(filter,keyCode)) {
input.value = input.value.slice(0, len);
input.form[(getIndex(input)+1) % input.form.length].focus();
}
function containsElement(arr, ele) {
var found = false, index = 0;
while(!found && index < arr.length)
if(arr[index] == ele)
found = true;
else
index++;
return found;
}
function getIndex(input) {
var index = -1, i = 0, found = false;
while (i < input.form.length && index == -1)
if (input.form[i] == input)index = i;
else i++;
return index;
}
return true;
}

