//if (top.frames.length == 0) 
//top.document.location = "/sorry.cfm"; 

var phone_field_length=0;
function TabNext(obj,event,len,next_field) {
	if (event == "down") {
		phone_field_length=obj.value.length;
		}
	else if (event == "up") {
		if (obj.value.length != phone_field_length) {
			phone_field_length=obj.value.length;
			if (phone_field_length == len) {
				next_field.focus();
			}
		}
	}
}

function GeneratePassword() {
    if (parseInt(navigator.appVersion) <= 3) {
        alert("Sorry this only works in 4.0+ browsers");
        return true;
    }
    var length=8;
    var sPassword = "";
    length = 6;
    var noPunction = "checked";
    var randomLength = "";
    if (randomLength) {
        length = Math.random();
        length = parseInt(length * 100);
        length = (length % 7) + 6
    }

    for (i=0; i < length; i++) {
        numI = getRandomNum();
        if (noPunction) { while (checkPunc(numI)) { numI = getRandomNum(); } }
        sPassword = sPassword + String.fromCharCode(numI);
		
    }
    document.client.client_password.value = sPassword
    return true;
}

function getRandomNum() {
    // between 0 - 1
    var rndNum = Math.random()
    // rndNum from 0 - 1000
    rndNum = parseInt(rndNum * 1000);
    // rndNum from 33 - 127
    rndNum = (rndNum % 94) + 33;
    return rndNum;
}

function checkPunc(num) {
    if ((num >=33) && (num <=47)) { return true; }
    if ((num >=58) && (num <=64)) { return true; }
    if ((num >=91) && (num <=96)) { return true; }
    if ((num >=123) && (num <=126)) { return true; }
    return false;
}

function checkAll(elementName){
     var boolValue = elementName.checked;
     for (var i=0;i<document.orderList.elements.length;i++)
     {
       var e = document.orderList.elements[i];
       if (e.name != elementName.name)
         e.checked = boolValue;
     }
}

function formatCurrency(num) {

	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
		num = "0";
		sign = (num == (num = Math.abs(num)));
		num = Math.floor(num*100+0.50000000001);
		cents = num%100;
		num = Math.floor(num/100).toString();
	if(cents<10)
		cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	//num = num.substring(0,num.length-(4*i+3))+','+	//Min removed Jun 01, 2004
	num.substring(num.length-(4*i+3));
	return (((sign)?'':'-') + num + '.' + cents);
}


function show(obj)
{	
	if(!document.all && document.getElementById) {
		if(document.getElementById(obj)) document.getElementById(obj).style.display='';
	}else {
        	if(document.all[obj]) document.all[obj].style.display='';
	}
}

function hide(obj)
{
	if(!document.all && document.getElementById) {
		if(document.getElementById(obj)) document.getElementById(obj).style.display='none';
	}
	else {	
		if(document.all[obj]) document.all[obj].style.display='none';
	}
}


function ccwin(url)
{
newWindow = window.open(url,"NewWindow","toolbar=no,width=230,height=180;,directories=no,status=no,scrollbars=no,resize=no,menubar=no" )
}
function newin1(url)
{
newWindow = window.open(url,"NewWindow","toolbar=no,width=500,height=350,directories=no,status=no,scrollbars=yes,resizable=yes,menubar=no" )
}
function newin2(url)
{
newWindow = window.open(url,"NewWindow","toolbar=no,width=700,height=600,directories=no,status=no,scrollbars=yes,resizable=no,menubar=no" )
}
function newin3(url)
{
newWindow = window.open(url,"NewWindow","toolbar=no,width=500,height=200,directories=no,status=no,scrollbars=yes,resizable=yes,menubar=no" )
}
function newin4(url)
{
newWindow = window.open(url,"NewWindow","toolbar=no,width=200,height=120,left=790,top=200,directories=no,status=no,scrollbars=no,resizable=no,menubar=no" )
}
function newin5(url)
{
newWindow = window.open(url,"NewWindow","toolbar=no,width=500,height=100,directories=no,status=no,scrollbars=yes,resizable=yes,menubar=no" )
}
function newin6(url)
{
newWindow = window.open(url,"NewWindow","toolbar=no,width=500,height=600,directories=no,status=no,scrollbars=yes,resizable=yes,menubar=no" )
}
function newin7(url)
{
newWindow = window.open(url,"NewWindow","toolbar=no,width=695,height=650,directories=no,status=no,scrollbars=yes,resizable=no,menubar=no" )
}
// Set the horizontal and vertical position for the popup
PositionX = 400;
PositionY = 100;

// Set these value approximately 20 pixels greater than the
// size of the largest image to be used (needed for Netscape)
defaultWidth  = 500;
defaultHeight = 500;

// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows
var AutoClose = true;

if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;
function popImage(imageURL,imageTitle){
if (isNN){imgWin=window.open('about:blank','',optNN);}
if (isIE){imgWin=window.open('about:blank','',optIE);}
with (imgWin.document){
writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(100,100);');
writeln('width=100-(document.body.clientWidth-document.images[0].width);');
writeln('height=100-(document.body.clientHeight-document.images[0].height);');
writeln('window.resizeTo(width,height);}');writeln('if (isNN){');       
writeln('window.innerWidth=document.images["Min"].width;');writeln('window.innerHeight=document.images["Min"].height;}}');
writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
if (!AutoClose) writeln('</head><body bgcolor=ffffff scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
else writeln('</head><body bgcolor=ffffff scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
writeln('<img name="Min" src="'+imageURL+'" style="display:block"></body></html>');
close();		
}}
