////////////////////////// EVE iPORTAL SCRIPT LIBRARY  /////////////////////////

var ie, ie4, ie5, ns, ns4, ns5, ns6, op, ffox, safari, ver
ver=navigator.appVersion;
var commonPassArray = new Array('        ', 'abc123', 'money', 'love', 'thx1138', 'myspace1', 'password1', 'myspace 1', 'blink 182', 'password 1', 'password', 'pass', '1234', '1246', '123', 'liverpool', 'letmein', 'qwerty', '123456','charlie', 'monkey', 'arsenal', 'thomas', '11111111', '22222222', '33333333', '44444444', '55555555', '66666666', '77777777', '88888888', '99999999', '00000000', 'aaaaaaaa', 'bbbbbbbb', 'cccccccc', 'dddddddd', 'eeeeeeee', 'ffffffff', 'gggggggg','hhhhhhhh', 'iiiiiiii', 'jjjjjjjj', 'kkkkkkkk', 'llllllll', 'mmmmmmmm', 'nnnnnnnn', 'oooooooo', 'pppppppp', 'qqqqqqqq', 'rrrrrrrr', 'ssssssss', 'tttttttt', 'uuuuuuuu', 'vvvvvvvv', 'wwwwwwww', 'xxxxxxxx', 'yyyyyyyy' ); 
var numbers = "0123456789"; 
var lower = "abcdefghijklmnopqrstuvwxyz"; 
var upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 
var specialchar = "!.@$£#*()%~<>{}[]"; 

var ajSuccessToken = "<!--AJAX:200-->\r\n"

//alert( 'User-agent:  ' + navigator.userAgent )
//alert( 'Browser Ver:  ' + ver )
//alert( 'this.dom:  ' + this.dom )
ie = (document.all);
ie60=(ver.indexOf("MSIE 6.0")>-1)?1:0;
ie55=(ver.indexOf("MSIE 5.5")>-1)?1:0;
ie50=(ver.indexOf("MSIE 5.0")>-1)?1:0;
ie5=(ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
ie4=(document.all && !this.dom)?1:0;
ns = (navigator.appName == "Netscape" && navigator.appVersion.charAt(0) == "4")
ns4=(document.layers && !this.dom)?1:0;
ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
ns6 = (document.getElementById && !document.all);
op = (navigator.userAgent.indexOf('Opera') > -1);
ffox = (navigator.userAgent.indexOf( 'Firefox' ) > -1 );
safari = (navigator.userAgent.indexOf( 'Safari' ) > -1 );

	function disable_right_click (e)
		{
			// GET THE BROWSER TYPE
			var browser = navigator.appName.substring ( 0, 3 );

			var event_number = 0;

			if ( browser == "Mic" )
				event_number = event.button;
			else if ( browser == "Net" )
				event_number = e.which;

			if ( event_number == 2 || event_number == 3 )
				{
				alert ( "Copyrighted!" );
				return ( false );
				}

			return ( true );
		}


		function check_mousekey ()
		{
			var mouse_key = 93;
			var keycode = event.keyCode;

			if ( keycode == mouse_key )
				alert ( "Mouse Key Is Disabled" );
		}


		function trap_page_mouse_key_events ()
		{
			// GET THE BROWSER TYPE
			var browser = navigator.appName.substring ( 0, 3 );

			if ( document.images )
				{
				for ( var pic=0; pic<document.images.length; pic++ )
					document.images[pic].onmousedown = null;
				}

			// SEQUENCE FOR MICROSOFT BROWSERS
			if ( browser == "Mic" )
				{
				// TRAP THE PAGE ONMOUSEDOWN EVENT HANDLER
				document.onmousedown = disable_right_click;

				// SET THE FOCOUS ONTO THIS PAGE
				self.focus ();

				// TRAP THE PAGE ONKEYDOWN EVENT HANDLERS
				document.onkeydown = check_mousekey;
				}

			// SEQUENCE FOR NETSCAPE BROWSERS
			else if ( browser == "Net" )
				{
				// TRAP THE PAGE ONMOUSEDOWN EVENT HANDLER
				document.onmousedown = disable_right_click;
				document.captureEvents ( Event.MOUSEDOWN );
				}
		}



// Browser Check
function chkBrowser() {
    this.ver=navigator.appVersion;
    this.dom=document.getElementById?1:0;
    this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
    this.ie4=(document.all && !this.dom)?1:0;
    this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
    this.ns4=(document.layers && !this.dom)?1:0;
    this.bVer=(this.ie5 || this.ie4 || this.ns4 || this.ns5);return this;

    //--- Determine Browser Version
    this.ns6 = (document.getElementById && !document.all);
    this.ie = (document.all);
    //this.IE4 = (document.all && !document.getElementById)
    this.ns = (navigator.appName == "Netscape" && navigator.appVersion.charAt(0) == "4")
    this.op = (navigator.userAgent.indexOf('Opera') > -1)
}

bVer=new chkBrowser();
//ns4 = (document.layers)? true:false;
//ie4 = (document.all)? true:false;


// Preload Images
function preload() {
    if (!ns4) {
        if (!document.images) return;
            var ar = new Array();
            var arguments = preload.arguments;
            for (var i = 0; i < arguments.length; i++) {
                ar[i] = new Image();
                ar[i].src = arguments[i];
            }


        // Load clock and greeting
        clock();
        greeting();
    }
}


// Set Clock
function clock()
{       if (!document.layers && !document.all)  return

        var DigitalClock = new Date();
      var month = DigitalClock.getMonth();
      var day = DigitalClock.getDate();
        var hours = DigitalClock.getHours();
        var minutes = DigitalClock.getMinutes();
        var seconds = DigitalClock.getSeconds();
        var dn = "a.m.";

        if (hours > 12)
        {       dn = "p.m.";
                hours = hours - 12;     }

        if (hours == 0) hours = 12;

        if (minutes <= 9)       minutes = "0" + minutes;

        if (seconds <= 9)       seconds = "0" + seconds;

        //change font size here to your desire
      monName = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
      dispTime = monName[month] + " " + day + ", " + hours + ":" + minutes + " " + dn;

        if (document.layers)
        {       document.layers.pendule.document.write(dispTime);
                document.layers.pendule.document.close();     }

        else if (document.all)
                pendule.innerHTML = dispTime;

setTimeout("clock()",6000)

}

// Set Greeting
function greeting() {

    var digital = new Date();
    var hours = digital.getHours();

    if (hours > 17) {
        greeting = "evening";
    } else {
        if (hours > 11) {
            greeting = "afternoon";
        } else {
            greeting = "morning";
        }
    }

    if (document.layers) {
        document.layers['greet'].document.write(greeting);
        document.layers['greet'].document.close();
    } else {
        if (document.all) {
            greet.innerHTML = greeting;
        }
    }
}


// Confirm Action
function confirm_action(message,location) {
    if (confirm(message)) {
        if (location) {
            window.location=location;
            return false;
        }
    } else {
        return false;
    }
}

//SIMPLE HIDE-UNHIDE

function HideThis(z) 
{
	document.getElementById(z).style.display = "none";
}

function ShowThis(z) 
{
	document.getElementById(z).style.display = "block";
}

function ToggleThis(z) 
{
	if(document.getElementById(z).style.display == "none") 
	{ 
		document.getElementById(z).style.display = "block"; 
	}
	else 
	{ 
		document.getElementById(z).style.display = "none"; 
	}
}



// Pop up window function (controls focus and centers window)
var popped

function popwin(href,name,toolbar,location,directories,status,menubar,scrollbars,resizable,copyhistory,width,height,newwin) {

    if (width == 0 || height == 0) {
        var width = screen.width - 10;
        var height  = screen.height - 80;
        var LeftPosition = 1;
        var TopPosition = 1;
    } else {
        var LeftPosition = (screen.width) ? (screen.width-width)/2 : 0;
        var TopPosition = (screen.height) ? (screen.height-height)/2 : 0;
    }

    if (!popped || popped.closed || newwin == 1) {
        popped = window.open(href,name,"toolbar=" + toolbar + ",location=" + location + ",directories=" + directories + ",status=" + status + ",menubar=" + menubar + ",scrollbars=" + scrollbars + ",resizable=" + resizable + ",copyhistory=" + copyhistory + ",width=" + width + ",height=" + height + ",top=" + TopPosition + ",left=" + LeftPosition);
        popped.focus();
    } else {
        popped.focus();
    }
}


// Retrieve Cookie
function getCookie (name) {
    var dcookie = document.cookie;
    var cname = name + "=";
    var clen = dcookie.length;
    var cbegin = 0;
        while (cbegin < clen) {
            var vbegin = cbegin + cname.length;
                if (dcookie.substring(cbegin, vbegin) == cname) {
                    var vend = dcookie.indexOf (";", vbegin);
                        if (vend == -1) vend = clen;
                    return unescape(dcookie.substring(vbegin, vend));
                }
            cbegin = dcookie.indexOf(" ", cbegin) + 1;
                if (cbegin == 0) break;
        }
    return null;
}


// Set Cookie
function setCookie (name, value, expires, domain) {
        if (!expires) expires = new Date();
        document.cookie = name + "=" + escape (value) + ((domain) ? "; domain=" + domain : "") + "; expires=" + expires.toGMTString();
}


// Toggle box function
function changeBox(ID) {

    // Update Box
    var box = eval("document.all."+ID+".style")
    var img = eval("document.all.arrow_"+ID)
    var color = getCookie("COLORS");

    if (box.display=="none") {
        box.display="block";
        img.src="../art/portalfoldertab_Up.gif";
    } else {
        //'box.display="none";
        //'img.src="../art/portalfoldertab_Down.gif";

    }

    // Set Cookie to remeber Box state (open||closed)
    var expdate = new Date();
    expdate.setTime(expdate.getTime() +  (365 * 24 * 60 * 60 * 1000));

    if (getCookie("BOXSTATES")) {
        re = new RegExp(",*"+ID+"-(block|none)");
        str = getCookie("BOXSTATES");
        newstr = str.replace(re, "");
        setCookie('BOXSTATES',ID+"-"+box.display+","+newstr,expdate,'.x-tier.net');
    } else {
        setCookie('BOXSTATES',ID+"-"+box.display,expdate,'.x-tier.net');
    }
}


// Toggles More/Less News for News Feeds
function MoreNews(ID) {

    var CategoryID = eval("Category"+ID);
    var MoreNewsID = eval("MoreNews"+ID);

    if (CategoryID.style.display == "block") {
            CategoryID.style.display='none';
            MoreNewsID.innerText='More >>';
    } else {
            CategoryID.style.display='block';
            MoreNewsID.innerText='<< Less';
    }

}

// Toggles Hide/Show News
function HideNews(ID, img, scheme, innerLoop) {

    // Set variables
    var NewsID = eval("News"+ID);
    var MoreNewsID = eval("MoreNews"+ID);
    var NewsCategoryIDa = eval("NewsCategory"+ID+"a");
    var NewsCategoryIDb = eval("NewsCategory"+ID+"b");
    if (innerLoop != 0) {
        var CategoryID = eval("Category"+ID);
    }

    // Hide / Show script
    if (NewsID.style.display == "block") {
        NewsID.style.display='none';
        NewsCategoryIDa.style.borderBottomWidth='0px';
        NewsCategoryIDb.style.borderBottomWidth='0px';
        img.src='/c2k/portal/images/'+scheme+'/arrow_down_2.gif';
        if (innerLoop != 0) {
            MoreNewsID.innerText='';
            CategoryID.style.display='none';
        }
    } else {
        NewsID.style.display='block';
        NewsCategoryIDa.style.borderBottomWidth='1px';
        NewsCategoryIDb.style.borderBottomWidth='1px';
        img.src='/c2k/portal/images/'+scheme+'/arrow_up_2.gif';
        if (innerLoop != 0) {
            MoreNewsID.innerText='More >>';
        }
    }

    // Set Cookie to remeber News state (open||closed)
    var expdate = new Date();
    expdate.setTime(expdate.getTime() +  (365 * 24 * 60 * 60 * 1000));

    if (getCookie("NEWSSTATES")) {
        re = new RegExp(",*"+"News"+ID+"-(block|none)");
        str = getCookie("NEWSSTATES");
        newstr = str.replace(re, "");
        setCookie('NEWSSTATES',"News"+ID+"-"+NewsID.style.display+","+newstr,expdate,'.intranet.sprintspectrum.com');
    } else {
        setCookie('NEWSSTATES',"News"+ID+"-"+NewsID.style.display,expdate,'.intranet.sprintspectrum.com');
    }
}


// Toggle 5 day weather forecast
function fiveday(ID) {
    obj = eval(ID);
    if (obj.style.display == "none") {
        obj.style.display='block';
    } else {
        obj.style.display='none';
    }
}

// Search: Keyword Validation
function validateKeyword(form) {
    if (form.keyword.value.length == 0) {
        alert("Please enter a keyword!");
        form.keyword.focus();
        return false;
    }
}

// Search: Tips popup window
function tips(){
    helpwindow = window.open('searchtips.cfm', 'helpwin', 'width=500,height=250,toolbar=no,scrollbars=yes')
}

// Search: Hide Show function for Native file extension //
function NativeDoc(value) {
    if (value.options[value.selectedIndex].value == "docinfo") {
        Doctypes.style.display='block';
    } else {
        Doctypes.style.display='none';
    }
}




// Top Navigation
function getHref(type) {
    self.location="top.cfm?type=" + type;
    window.top.bottom.location="main.cfm?type=" + type;
}

// Close Window
function closewin() {
        window.top.opener.location.href="/";
        window.top.close();
}

//Zipcode validation
function ZipValidate(form) {
    if (isNaN(parseFloat(form.zipcode.value)) ||  form.zipcode.value.length !=5) {
        alert("Please enter a valid 5-digit zipcode");
        form.zipcode.focus();
        return false;
    }
    // Disable submit button
    disableForm(form);
}

//Stock Ticker validation
function TickerValidate(form) {
    if (form.Symbol.value.length == 0) {
        alert("Please enter a Ticker Symbol");
        form.Symbol.focus();
        return false;
    }
    // Disable submit button
    disableForm(form);
}

//Links validation
function LinkValidate(form) {
    if (form.LinkName.value.length == 0) {
        alert("Please enter a Name");
        form.LinkName.focus();
        return false;
    }
    if (form.LinkURL.value.length == 0) {
        alert("Please enter a URL");
        form.LinkURL.focus();
        return false;
    }
    // Disable submit button
    disableForm(form);
}

// Change out Colors images
function changeColor(Color) {
    document.images.Colors.src='../images/myconnected/'+Color+'.gif';
}

// hide-show functionality
var head="display:''"
function doit(header) {
        var head=header.style
        if (head.display=="none")
            head.display=""
        else
            head.display="none"
}

// Delete Confirmation
function confirm_delete(message,location) {
    if (confirm(message)) {
        window.top.bottom.location=location;
        return false;
    } else {
        return false;
    }
}

function delete_confirm(message,location) {
    if (confirm(message)) {
        window.location=location;
        return false;
    } else {
        return false;
    }
}


// Disable submit button
function disableForm(theform) {
    if (document.all || document.getElementById) {
        for (i = 0; i < theform.length; i++) {
            var tempobj = theform.elements[i];
            if (tempobj.type.toLowerCase() == "submit" || tempobj.type.toLowerCase() == "reset")
                tempobj.disabled = true;
        }
        return true;
    }else {
        return false;
    }
}


  var height = 20; // height of the menu headers
  var iheight = 19; // height of the menu_items

  var bgc = "white" // background color of the item
  var tc = "Black" // text color of the item

  var over_bgc = "silver";
  var over_tc = "navy";

  var speed = 0;
  var timerID = "";
  var N = (document.all) ? 0 : 1;
  var width = 152



  var self_menu = new Array();
  
function write_menu()
{
  smc = 0; // count the position of the self_menu
  document.write("<div style='position:absolute'>");
  mn = 0;
  mni = 1;
  start = -1;

  for(i=0;i<Link.length;i++)
  {
   la = Link[i].split("|");

   if (la[0] == "0")
   {
    if(start == 0)
     {
      document.write("</div>");
      h =  csmc * iheight;
      tmn = mn; //-h
      self_menu[smc] = new Array(tmn,h,0,-2);
      smc++;
      mn--;
     }
     csmc = 0;
    document.write("<div class='menu' style='top:"+mn+";height:"+height+"' id='down"+smc+"' onclick='pull_down("+smc+","+mni+")'>&nbsp;"+ la[1] + "</div>");
    self_menu[smc] = new Array(mn,height,0,mni);
    smc++;
    mni++;
    mn+=height;
    start = 1;
   }
   else
   {
    if(start == 1)
     {
      if(N)mn+=2;
       document.write("<div class='item_panel' id='down"+smc+"' style='top:"+mn+"'>");
       start = 0;
     }

    document.write("<a href='"+la[2]+"'");
    if (la[3] != "") document.write(" target='" + la[3] + "' ");
    document.write("><div class='item' id='d"+i+"' style='height:"+iheight);
    if (N) document.write(";width:150");
    document.write("' onmouseover='color(this.id)' onmouseout='uncolor(this.id)'>&nbsp;&nbsp;"+ la[1] + "</div></a>");
    csmc++;
   }
  }
  if (start == 0)
   {
     document.write("</div>");
     h =  csmc * iheight;
     tmn = mn + 5; //-h
     self_menu[smc] = new Array(tmn,h,0);
     name = "down" + (self_menu.length-1);
     obj = document.getElementById(name);
     obj.style.borderBottomColor = "gray";
     obj.style.borderBottomWidth = 1;
     obj.style.borderBottomStyle = "solid";
   }
  document.write("</div>");
}


function color(obj)
{
 document.getElementById(obj).style.backgroundColor = over_bgc;
 document.getElementById(obj).style.color = over_tc
}

function uncolor(obj)
{
 document.getElementById(obj).style.backgroundColor = bgc;
 document.getElementById(obj).style.color = tc
}

function pull_down(nr,c)
{
    if (timerID == "")
    {
        to = self_menu[nr+1][1]
        begin = nr + 2;
        if (timerID != "") clearTimeout(timerID);

        if (self_menu[nr+1][2] == 0)
        {
            self_menu[nr+1][2] = 1;
            if(nr == self_menu.length-2) {to++;}
            
            
            epull_down(begin,to,0);
        }
        else
        {
            to = 0;
            self_menu[nr+1][2] = 0;
            name = "down"+(nr+2);
            open_item = 0;
            for(i=0;i<nr;i++)
            {
                if(self_menu[i][2] == 1)
                {
                    open_item += self_menu[i][1];
                }
            }
            
            if (N == false) {open_item-= (c*1)};
            
            if (nr== self_menu.length-2) {val = self_menu[self_menu.length-1][1];to=-1;}
            else  val = parseInt(document.getElementById(name).style.top) -(open_item)-(c*height);
            
            epull_up(begin,to,val);
            
        }
    }
}


function epull_down(nr,to,nowv)
{
    //alert( "nr:  " + nr + "\nto:  " + to + "\nnowv:  " + nowv );
    nowv = to;
    
    name = "down" + (nr-1);
    
    obj = document.getElementById(name).style.clip = "rect(0," + width + "," + (nowv+1) + ",0)";
    
    for (i=nr; i<self_menu.length; i++)
    {
        //alert( "down" + i );
        name = "down" + i;
        obj = document.getElementById(name);
        obj.style.top = parseInt(obj.style.top) + nowv;
    }
    //nowv++;
    
    //if(nowv < to) timerID = setTimeout("epull_down("+nr+","+to+","+nowv+")",speed);
    //else timerID = "";
    
}

function epull_up( nr, to, nowv)
{
    //alert( "nr:  " + nr + "\nto:  " + to + "\nnowv:  " + nowv );
    //to = nowv;
    //nowv = to;
    //alert( nowv);
    
    name = "down" + (nr-1);
    obj = document.getElementById(name).style.clip = "rect(0,"+width+","+to+",0)";
    
    for (i=nr; i<self_menu.length; i++)
    {
        //alert( "down" + i );
        name = "down" + i;
        obj = document.getElementById(name);
        //alert( "top before:  " + obj.style.top );
        //alert( "nowv:  " + nowv );
        obj.style.top = parseInt(obj.style.top) - nowv
        //alert( "top after:  " + parseInt(obj.style.top ) );
    }
    
    //nowv--;
    
    //if(nowv > to) timerID = setTimeout("epull_up("+nr+","+to+","+nowv+")",speed);
    
    //else timerID = "";
}

function startup(nr)
{
 write_menu();
 if (nr != 0)
 {
 for(i=0;i<self_menu.length;i++)
 {
  if(self_menu[i][3] == nr) pull_down(i,nr)
  i==self_menu.length;
 }
 }
}



function setLinkColor( linkName, color )
{
    //alert( linkName );
    //alert( color );



    var len = document.links.length;
    var i = 0;

    //alert (len)
    for( i=0; i<len; i++ )
    {
        if( document.links[i].name == linkName )
        {
            document.links[i].style.color = color;
            break;
        }
    }

}


function goToLink( frm, link )
{
    //alert( "goToLink(" + frm + ", " + link + ")" )
    frm.action = "/cgi-bin/apprtr.asp?" + link;
    frm.submit();
    //alert( "frm.action: " + frm.action);
    //location.rep
    return true;
    
}

function submitFormAppID( frm, app, id )
{
    frm.action = '/cgi-bin/apprtr.asp?a=' + app + '&id=' + id;
    //alert( frm.action)
    frm.submit();
}

function submitFormAppIDAX( frm, app, id )
{
    frm.action = '/cgi-bin/apprtr.asp?ax=' + app + '&id=' + id;
    //alert( frm.action)
    frm.submit();
}

function submitFormAppIDMode( frm, mode, popupBool, winName, options, app, id )
{
   try
   {
   
    frm.action = '/cgi-bin/apprtr.asp?' + mode + '=' + app + '&id=' + id;
    //alert('action:  ' + frm.action)

    if( options == "" )
    { 
        //alert('set options')
        w = screen.width * 0.75;
        h = screen.height * 0.75;
        options = "scrollbars=yes,toolbar=yes,resizable=yes,width=" + w + ",height=" + h
    }
    
    frm.target = winName;
 
    if( popupBool )
    {
        //alert('options:  ' + options)
        try
        {
            popup = window.open( "", winName, options );
            frm.target = winName;
            //frm.target = p
            frm.submit();
            //frm.target = "";
            popup.focus();
        }
        catch(e)
        {
        }
    }
    else
    {
        //alert('submit')
        frm.submit();
    }
   }
   catch( f )
   {
       //alert( f.description);
   }
}


function submitFormAppID2( frm, app, id, popup, winName, options )
{
   
    if( popup )
    {
        frm.action = '/cgi-bin/apprtr.asp?ax=' + app + '&id=' + id;
    }
    else
    {
        frm.action = '/cgi-bin/apprtr.asp?a=' + app + '&id=' + id;
    }
    //alert('action:  ' + frm.action)

    if( options == "" )
    { 
        //alert('set options')
        w = screen.width * 0.75;
        h = screen.height * 0.75;
        options = "scrollbars=yes,toolbar=yes,resizable=yes,width=" + w + ",height=" + h
    }

    if( popup )
    {
        //alert('options:  ' + options)
        try
        {
            popup = window.open( "", winName, options );
            frm.target = winName;
            frm.submit();
            frm.target = "";
            popup.focus();
        }
        catch(e)
        {
        }
        
       //--- return false for Firefox
        if( safari )
        {
            return false;
        }            

    }
    else
    {
        //--- return false for Firefox
        if( safari )
        {
            return false;
        }            

        //alert('submit')
        frm.submit();
    }
}




function submitForm1( frm, app, id, urlStr )
{

    frm.action = '/cgi-bin/apprtr.asp?a=' + app + '&id=' + id + urlStr;
    //alert( frm.action )
    frm.submit();
}


function actionreroute( frm, app, id)
{

   frm.action = '/cgi-bin/apprtr.asp?a=' + app + '&id=' + id;
   frm.submit();
    
}

//
function menuItemClick( id )
{
    //alert( id );

    obj = (document.all) ? document.all(id) : document.getElementById(id);
    with( obj )
    {
        if( event.srcElement.id != id )
        {
            if( target == "_top" )
            {
                top.location = href;
            }
            else if( target == "_parent" )
            {
                parent.location=href;
            }
            else if( target == "_blank" )
            {
                window.open( href );
            }
            else if( target > "" && top.frames[target] )
            {
                top.frames[target].location = href;
            }
            else if( target > "" )
            {
                eval( 'window.open("' + href + '","' + target + '")' );
            }
            else
            {
                location=href;
            }
        }
    }
}



/**
 *  Select all list items from a select list where the value of
 *  the option has a length greater than zero
 */
function selAllListItems1( list )
{
    for(var i=0; i<list.length; i++)
    {
        if( list.options[i].value.length > 0 )
        {
            list.options[i].selected = true;
        }
        else
        {
            list.options[i].selected = false;
        }
    }
}

/**
 *  Default selection of the list to the specified val
 */
function selListItemByVal( list, val )
{
    for(var i=0; i<list.length; i++)
    {
        if( list.options[i].value == val )
        {
            list.options[i].selected = true;
        }
        else
        {
            list.options[i].selected = false;
        }
    }
}

/**
 * Set the value of the spcified hidden field to the value passed
 */
function dynamicHiddenFieldSet( hiddenField, val )
{
    hiddenField.value = val
    return true
}


/**
 * Set the value of the spcified hidden field to the value passed
 */
function submitAlphaSelector( hiddenField, val )
{
    //alert( hiddenField.name )
    //alert( val )
    
    try
    {
        dynamicHiddenFieldSet( hiddenField, val )
        dynamicHiddenFieldSet( document.navForm.idx, 1 )
        
    }
    catch( e )
    {
    //alert( e.description )
        alert( "Error Submitting Form" )
        return false;
    }
    
    
    try
    {
        dynamicHiddenFieldSet( document.navForm.filterStr, "" )
    }
    catch( e )
    {
        //alert( e.description )
        //alert( "Error Submitting Form" )
        //return false;
    }
    
    return true
}



/**
 * Move an item from the "fromList" into the "toList"  This
 * will remove the item in the fromList
 */
function moveSelListItem(fromList, toList)
{
    for( var j=0; j<fromList.length; j++ )
    {
        if( fromList.options[j].selected == true && fromList.options[j].value != "" )
        {
            alreadyInToList = false;
            for (var i=0; i<toList.length; i++)
            {
                if (toList.options[i].value == fromList.options[j].value)
                {
                    alreadyInToList = true;
                }
            }
            if( alreadyInToList == false )
            {
                var newOpt = new Option(fromList.options[j].text, fromList.options[j].value);
                toList.options[toList.length] = newOpt;
            }
        }
    }
    for( var j=fromList.length-1; j>=0; j-- )
    {
        if( fromList.options[j].selected == true && fromList.options[j].value != "" )
        {
            fromList.options[j] = null;
        }
    }
}



/**
 * Copy an item from the "fromList" into the "toList"  This
 * will remove the item in the fromList
 */
function copySelListItem(fromList, toList)
{
    //'alert('hi')
    /** Iterate over the "FROM" list */
    for( var j=0; j<fromList.length; j++ )
    {
        //--- If the option is selected and the length of the value of the item is not zero
        if( fromList.options[j].selected == true && fromList.options[j].value != "" )
        {
            alreadyInToList = false;
            for (var i=0; i<toList.length; i++)
            {
                if (toList.options[i].value == fromList.options[j].value)
                {
                    alreadyInToList = true;
                }
            }
            if( alreadyInToList == false )
            {
                //'alert( 'pos: ' + j )
                var newOpt = new Option(fromList.options[j].text, fromList.options[j].value);
                toList.options[toList.length] = newOpt;
                //'alert('newValText: ' + newOpt.text )
                //'alert('newVal: ' + newOpt.value )
            }
        }
    }
}


/**
 * Remove Items from the select list
 */
function removeSelListItem( selList )
{
    for( var j=selList.length-1; j>=0; j-- )
    {
        if( selList.options[j].selected == true && selList.options[j].value != "" )
        {
            selList.options[j] = null;
        }
    }

}


/**
 * This is a JavaScript utilitily method that will sellect and deselect all
 * checkboxes on a page.  The method expects you to pass in the name of the
 * checkbox field used for the boxes, and it expects all the check boxes
 * to use the same name.  This allows the method to determine how many boxes
 * there are and use an index to loop over them and check or uncheck them
 */
function selectAllCheckboxes( checkbox )
{
    if( checkbox.checked != null )
    {
        checkbox.checked = true
    }
    else
    {
        var numBoxes = checkbox.length
        for( i=0; i<numBoxes; i++ )
        {
            checkbox[i].checked = true;
        }
    }
}


/**
 * This is a JavaScript utilitily method that will sellect and deselect all
 * checkboxes on a page.  The method expects you to pass in the name of the
 * checkbox field used for the boxes, and it expects all the check boxes
 * to use the same name.  This allows the method to determine how many boxes
 * there are and use an index to loop over them and check or uncheck them
 */

function selectAllCheckboxes2( checkbox, toggleCB )
{

    if( toggleCB != null )
    {
        if(checkbox.checked != null )
        {

            if( toggleCB.checked )
            {
                if( !toggleCB.disabled )
                {
                    checkbox.checked = true
                }
            }
            else
            {
                checkbox.checked = false
            }
        }
        else
        {
            if( toggleCB.checked )
            {
                var numBoxes = checkbox.length
                for( i=0; i<numBoxes; i++ )
                {
                    if( checkbox[i] != null )
                    {
                        if( !checkbox[i].disabled )
                        {
                            checkbox[i].checked = true;
                        }
                    }
                    else if( checkbox != null )
                    {
                        if( !checkbox.disabled )
                        {
                            checkbox.checked= true;
                        }
                    }

                }
            }
            else
            {
                var numBoxes = checkbox.length
                for( i=0; i<numBoxes; i++ )
                {
                    if( checkbox[i] != null )
                    {
                        checkbox[i].checked = false;
                    }
                }
            }
        }
    }
}


/**
 * This is a JavaScript utilitily method that will sellect and deselect all
 * checkboxes on a page.  The method expects you to pass in the name of the
 * checkbox field used for the boxes, and it expects all the check boxes
 * to use the same name.  This allows the method to determine how many boxes
 * there are and use an index to loop over them and check or uncheck them
 */
function unselectAllCheckboxes( checkbox )
{
    if( checkbox.checked != null )
    {
        checkbox.checked = false
    }
    else
    {
        var numBoxes = checkbox.length
        for( i=0; i<numBoxes; i++ )
        {
            checkbox[i].checked=false;
        }
    }
}


//--- Open a popup window and pass the fieldName that data should be
//--- returned to the parent window for.
function openPopup( app, id, formName, fieldName, boxwidth, boxheight )
{
    var Xoff = eval(screen.width - boxwidth)/5;
    var Yoff = eval(screen.height - boxheight)/5;
    var w = window.open('/cgi-bin/apprtr.asp?ax=' + app + '&id=' + id + '&frmName=' + formName + '&pfn=' + fieldName, 'PopUp', 'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,width=' + boxwidth + ',height=' + boxheight + ',screenX=' + Xoff + ',screenY=' + Yoff);
    w.focus();
}

//--- Open a popup window and pass the param string for the url
function openPopup2( app, id, urlStr, boxwidth, boxheight, windowName )
{
    var Xoff = eval(screen.width - boxwidth)/5;
    var Yoff = eval(screen.height - boxheight)/5;
    var w = window.open('/cgi-bin/apprtr.asp?ax=' + app + '&id=' + id + urlStr, windowName, 'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,width=' + boxwidth + ',height=' + boxheight + ',screenX=' + Xoff + ',screenY=' + Yoff);
    w.focus();
}


//--- Display a color chart picking form
function colorPicker( formName, fieldName, suffix )
{
    
    var boxwidth=0;
    var boxheight=0;
    if (suffix=='b')
    {
        boxwidth=345;
        boxheight=250;
    }
    else
    {
        boxwidth=340;
        boxheight=200;
    }

    var Xoff = eval(screen.width - boxwidth)/5;
    var Yoff = eval(screen.height - boxheight)/5;
    window.open('apprtr.asp?ax=colorpop' + suffix + '&formName=' + formName + '&fieldName=' + fieldName, 'ColorChart', 'toolbar=0,location=0,directories=0,status=0,menubar=0,alwaysRaised=yes,scrollbars=0,resizable=0,width=' + boxwidth + ',height=' + boxheight + ',screenX=' + Xoff + ',screenY=' + Yoff);

    
}



function setParentField(value, fieldName, appendBool)
{

    var str
    str = eval( 'str = top.opener.document.navForm.' + fieldName + '.value' )

    if( appendBool == true )
    {
        if( str == "" )
        {
            str = value
        }
        else
        {
            str = str + "," + value
        }
    }
    else
    {
        str = value
    }
    eval( 'top.opener.document.navForm.' + fieldName + '.value = "' + str + '";' )

   // window.close();
}

function setParentFieldAndClose(value, fieldName)
{

    var str
    str = eval( 'str = top.opener.document.navForm.' + fieldName + '.value' )

    if( str == "" )
    {
        str = value
    }
    else
    {
        str = str + "," + value
    }
    eval( 'top.opener.document.navForm.' + fieldName + '.value = "' + str + '";' )

    window.close();
}

var isHTMLMode = false  


function isHTMLModeOpAllowed()
{
		if (isHTMLMode) {
			alert("Please uncheck 'Edit HTML'");
			return false;
		}

        return true;
}

function setHTMLMode( bMode )
{
	var sTmp;
	isHTMLMode = bMode;
	if (isHTMLMode) {
        
        var obj = null;
        obj = document.getElementById( "htmlspn" )
        if( obj != null )
            obj.innerHTML = "Design Mode/<B>View HTML</B>";

		sTmp = XpadEasel.document.body.innerHTML;
		XpadEasel.document.body.innerText = sTmp;
		
	} else {
        var obj = null;
        obj = document.getElementById( "htmlspn" )
        if( obj != null )
            obj.innerHTML = "<B>Design Mode</B>/View HTML";
		
        sTmp = XpadEasel.document.body.innerText;
		XpadEasel.document.body.innerHTML = sTmp;
		//sTmp = XpadEasel.innerText;
		//XpadEasel.innerHTML = sTmp;
	}
//		alert('4');
	
	XpadEasel.focus();
}

    function formSubmitHandler_XpadEntity()
    {
        if ("" + previousForm_XpadEntity != "undefined")
        {
            previousForm_XpadEntity();
        }

        update_XpadEntity();
    }

    function update_XpadEntity()
    {
        document.all ["XpadEntity"].value = frames ["XpadEasel"].document.body.innerHTML;
        return;
    }

	function cmdExec(cmd,opt)
	{  
		if (isHTMLMode) {
			alert("Please uncheck 'Edit HTML'");  
			return;  
		}  
		XpadEasel.document.execCommand(cmd, "", opt);  
		XpadEasel.focus();  
	} 

    function setXpadGeneralCommands (thisStyle,thisrefresh)
    {
		if (isHTMLMode) {
			alert("Please uncheck 'Edit HTML'");
			return;
		}
    
        frames ['XpadEasel'].focus ();
        var selection = frames ['XpadEasel'].document.selection.createRange();
        if (selection.text == "");
        {
            selection = frames ['XpadEasel'].document;
        }
        selection.execCommand (thisStyle);
        frames ['XpadEasel'].focus();
        selection.execCommand (thisrefresh);
        frames ['XpadEasel'].focus();
        return;
    }

    function visibleBorders()
    {
        //tbContentElement.ShowBorders = !tbContentElement.ShowBorders;
        //tbContentElement.focus();
        alert('1');
        alert( XpadEasel );
        XpadEasel.ShowBorders = !frames ['XpadEasel'].ShowBorders;
        XpadEasel.focus()
    }


    function setXpadSaveAs (thisStyle)
    {
        frames ['XpadEasel'].focus ();
        var selection = frames ['XpadEasel'].document.selection.createRange();
        if (selection.text == "");
        {
            selection = frames ['XpadEasel'].document;
        }
        selection.execCommand (thisStyle);
        frames ['XpadEasel'].focus();

        return;
    }
    function setXpadInsertImage (thisCommand, thisImage)
    {
		if (isHTMLMode) {
			alert("Please uncheck 'Edit HTML'");
			return;
		}
        frames ['XpadEasel'].focus ();
        var selection = frames ['XpadEasel'].document.selection.createRange();
        if (selection.text == "");
        {
            selection = frames ['XpadEasel'].document;
        }
        selection.execCommand (thisCommand, thisImage);
        frames ['XpadEasel'].focus();

        return;
    }

	function setXpadImageLocal()
    {
	
		if (isHTMLMode) {
			alert("Please uncheck 'Edit HTML'");
			return;
        }
		//'var sImgSrc = showModalDialog("/cgi-bin/apprtr.asp?ax=XFiler&id=contentimglkup&cdir=/&frmName=navForm&pfn=","", "dialogHeight: 500px; dialogWidth: 400px; dialogTop: px; dialogLeft: px; edge: Raised; center: Yes; help: No; resizable: Yes; status: No;");
        openPopup2( 'XFiler', 'contentimglkup', '&cdir=/&frmName=navForm&pfn=', 500, 400 );
		
    }

    function setXpadImageFromPopup( sImgSrc )
    {
        
		frames ['XpadEasel'].focus ();
		//var selection = frames['XpadEasel'].document.selection.createRange();
		//if( selection.text == "" );
                //{
                //  selection = frames['XpadEasel'].document;
                // }

		if(sImgSrc!=null)
                {
                  //alert( 'from popup:  ' + sImgSrc );
                  cmdExec("InsertImage",sImgSrc );
                  //selection.execCommand( "InsertImage", sImgSrc )
                }
	}    

  function setXpadInsertTable()
  {
		if (isHTMLMode) {
			alert("Please uncheck 'Edit HTML'");
			return;
		}
  	var rows =  parseInt(prompt('Rows   :', 2));
  	var cols =  parseInt(prompt('Columns:', 3));
  	
  	if (rows && cols && rows>0 && cols>0)
	{  	
	}
  	else
  	{
  		return false;
  	}
  	
  		
  	//make a table 
  	var table = document.createElement("table");
  	table.border=1;
    table.width=100;
    table.height=50
  	
  	var tbody = document.createElement("tbody");
  	table.appendChild(tbody);
  	
  	for (var i = 0; i < rows; ++i)
  	{
  		var tr = document.createElement("tr");
  		tbody.appendChild(tr);
  		for (var j = 0; j < cols; ++j)
  		{
  			var td = document.createElement("td");
            td.className = 'systext'
  			tr.appendChild(td);
//  			if (browser.isGecko)
//  				td.appendChild(document.createElement("br")); //no br, no display
  		}
  	}
  	
//alert('9');  
//	alert( table.outerHTML );
	
	//XpadEasel.innerHTML = XpadEasel.innerHTML + table.outerHTML
        XpadEasel.document.body.innerHTML = XpadEasel.document.body.innerHTML + table.outerHTML

	//XpadEasel.innerHTML = sTmp;  	
//  	setRTEObj(e);
  	
  	//insert to selected range 
//  	if (rte.range && browser.isIE) 
//  		rte.range.pasteHTML(table.outerHTML);
//  	else 
//  		rte.range.insertNode(table);
  		

//    DHTMLEdit.execCommand(DECMD_INSERTTABLE,
//                          OLECMDEXECOPT_DONTPROMPTUSER,
//                          XpadEasel);
  }

    function setXpadFontColor()
    {
		if (isHTMLMode) {
			alert("Please uncheck 'Edit HTML'");
			return;
		}
    
        frames ['XpadEasel'].focus();
        var selection = frames ['XpadEasel'].document.selection.createRange();
        if (selection.text == "");
        {
            selection = frames ['XpadEasel'].document;
        }
        selection.execCommand ('ForeColor', true, document.all ['XpadFontColor'].options [document.all ['XpadFontColor'].selectedIndex].value);
        frames ['XpadEasel'].focus();


        return;
    }
    function setXpadBackColor()
    {
    
		if (isHTMLMode) {
			alert("Please uncheck 'Edit HTML'");
			return;
		}
        frames ['XpadEasel'].focus();
        var selection = frames ['XpadEasel'].document.selection.createRange ();
        if (selection.text == "");
        {
            selection = frames ['XpadEasel'].document;
        }
        selection.execCommand ('BackColor', true, document.all ['XpadBackColor'].options [document.all ['XpadBackColor'].selectedIndex].value);
        frames ['XpadEasel'].focus();


        return;
}

function setXpadFontSize()
    {
    
		if (isHTMLMode) {
			alert("Please uncheck 'Edit HTML'");
			return;
		}
        frames ['XpadEasel'].focus();
        var selection = frames ['XpadEasel'].document.selection.createRange ();
        if (selection.text == "");
        {
            selection = frames ['XpadEasel'].document;
        }
        selection.execCommand ('FontSize', true, document.all ['XpadFontSize'].options [document.all ['XpadFontSize'].selectedIndex].value);
        frames ['XpadEasel'].focus();


        return;
}
function setXpadFontFace()
    {
    
		if (isHTMLMode) {
			alert("Please uncheck 'Edit HTML'");
			return;
		}
        frames ['XpadEasel'].focus();
        var selection = frames ['XpadEasel'].document.selection.createRange ();
        if (selection.text == "");
        {
            selection = frames ['XpadEasel'].document;
        }
        selection.execCommand ('FontName', true, document.all ['XpadFontFace'].options [document.all ['XpadFontFace'].selectedIndex].value);
        frames ['XpadEasel'].focus();


        return;
}

function setNewParagraph (thisPara, thisId)
    {
		if (isHTMLMode) {
			alert("Please uncheck 'Edit HTML'");
			return;
		}
        frames ['XpadEasel'].focus ();
        var selection = frames ['XpadEasel'].document.selection.createRange ();
        if (selection.text == "");
        {
            selection = frames ['XpadEasel'].document;
        }
        selection.execCommand (thisPara, thisId);
        frames ['XpadEasel'].focus();

        return;
    }

    function setInOutJustify (thisIOJustify)
    {
		if (isHTMLMode) {
			alert("Please uncheck 'Edit HTML'");
			return;
		}
        frames ['XpadEasel'].focus ();
        var selection = frames ['XpadEasel'].document.selection.createRange ();
        if (selection.text == "");
        {
            selection = frames ['XpadEasel'].document;
        }
        selection.execCommand (thisIOJustify);
        frames ['XpadEasel'].focus();

        return;
    }

function orderCredit(frm)
  {

            var cust=document.getElementById("order_cust")
            var acc= cust.options[cust.selectedIndex].text
            var cr = cust.options[cust.selectedIndex].value
            var creditAmt
            
            if (cr == null)
            {
            	cr=0
            }
            
            if (cr<0)
            {
            
                creditAmt =formatNumThis(Math.abs(cr),2)
								frm.appcredit.value = creditAmt
								frm.orderCr.value = creditAmt
								frm.orderDiscamt.value="0.00"
								frm.orderDis.value="0.00"
								alert("Customer Account: "+ acc + " has $" + creditAmt + " of available credit.\n\n The Order Entry Form Fields 'Avail Credit' and 'Credits' \n have been updated to reflect this.")
						}
	            
           else
            {
                    frm.appcredit.value="0.00"
                    frm.orderCr.value="0.00"
                    frm.orderDiscamt.value="0.00"
                    frm.orderDis.value="0.00"
              
                
                
            }       
    
}

function orderDiscount(frm)
{
        var discount = parseInt(frm.orderDiscamt.value)
        var formatted 
            
               
        if (discount >0)
        {
                formatted =formatNumThis(discount,2)
                frm.orderDiscamt.value=formatted
                frm.orderDis.value=formatted
              }
              else
                {
                    frm.orderDiscamt.value= "0.00"
                    frm.orderDis.value= "0.00"
                }
                    
}

function orderApplyCr(frm)
{
                var availCr = parseInt(frm.appcredit.value)
                var formatted 
      
        
                if (availCr >0)
                {
                    formatted=formatNumThis(availCr,2)
                    frm.appcredit.value=formatted
                    frm.orderCr.value=formatted
                }
                else
                {
                    frm.appcredit.value= "0.00"
                    frm.orderCr.value= "0.00"
                }

}



function formatOrderQty(frm)
{
        var amtt = parseInt(frm.orderAmt.value)
        var qtyy = parseInt(frm.orderQty.value)
            var newAmt=0
            
            newAmt = (amtt * qtyy)
            frm.orderTot.value= formatNumThis(newAmt,2)
                
                
}
function totOrder(frm)
{
       var credit =parseInt(frm.orderCr.value)
       var discount =parseInt(frm.orderDiscamt.value) 
       var orderamount =parseInt(frm.orderAmt.value)
       var tax=parseInt(frm.orderTax.value)
       var total=parseInt(frm.orderTot.value)
       var qty = parseInt(frm.orderQty.value)
       
      
       
                orderamount = orderamount * qty
                total = orderamount - (credit+discount)
                frm.orderTot.value=formatNumThis(total,2)
                
}
 
function formatOrderAmount(frm)
{
     var numThis = parseInt(frm.orderAmt.value)
     formatted = formatNumThis(numThis,2)
     frm.orderAmt.value = formatted
     frm.orderTot.value= formatted
     
}

function formatNumThis(original_number, decimals) 
{
    var result1 = original_number * Math.pow(10, decimals)
    var result2 = Math.round(result1)
    var result3 = result2 / Math.pow(10, decimals)
    return addZeros(result3, decimals)
}

function addZeros(valNum, precisionThis) {

    var numThis = valNum.toString()
    
    var numDecimal = numThis.indexOf(".")

    if (numDecimal == -1) {
        
        numLen = 0
        
        numThis += precisionThis > 0 ? "." : ""
    }
    else {

        numLen = numThis.length - numDecimal - 1
    }
    
    var precisionLen = precisionThis - numLen
    
    if (precisionLen > 0) {
        
        for (var counter = 1; counter <= precisionLen; counter++) 
            numThis += "0"
        }
    return numThis
}


function show(id) {
    document.getElementById(id).style.visibility = "visible";
}
function hide(id) {
    document.getElementById(id).style.visibility = "hidden";
}

function insRow(frm)
{

	
var x=document.getElementById('oDetail').insertRow(-1)
var a=x.insertCell(0)
var b=x.insertCell(1)
var c=x.insertCell(2)
var d=x.insertCell(3)
var e=x.insertCell(4)
var f=x.insertCell(5)
var g=x.insertCell(6)
var h=x.insertCell(7)
var i=x.insertCell(8)
var j=x.insertCell(9)
var k=x.insertCell(10)
var l=x.insertCell(11)
var m=x.insertCell(12)
var n=x.insertCell(13)
var o=x.insertCell(14)
var p=x.insertCell(15)

var idxx =parseInt(frm.lineItem.value)

 if(idxx =="" || idxx == null)
 {
 	idxx=1
 }
 else
 {
 	idxx++
 	
 }
 
 frm.lineItem.value=idxx
  
	a.innerHTML="" + ("<font class=systext>"+idxx + "</font>")
	b.innerHTML="<input class=textbox id=" + idxx + " type=text size = 10 name = " + idxx + "desc>"
	c.innerHTML="<input class=textbox type=text size = 10 name = " + idxx + "type>"
	d.innerHTML="<input class=textbox type=text size = 10 name = " + idxx + "id>"
	e.innerHTML="<input class=textbox type=text size = 1 name = " + idxx + "wh>"
	f.innerHTML="<input class=textbox type=text size = 4 name = " + idxx + "ord>"
	g.innerHTML="<input class=textbox type=text size = 4 name = " + idxx + "sch>"
	h.innerHTML="<input class=textbox type=text size = 4 name = " + idxx + "bo>"
	i.innerHTML="<input class=textbox type=text size = 3 name = " + idxx + "ui>"
	j.innerHTML="<input class=textbox type=text size = 4 name = " + idxx + "code>"
	k.innerHTML="<input class=textbox type=text size = 8 name = " + idxx + "price>"
	l.innerHTML="<input class=textbox type=text size = 4 name = " + idxx + "oh>"
	m.innerHTML="<input class=textbox type=text size = 1 name = " + idxx + "tax>"
	n.innerHTML="<input class=textbox type=text size = 1 name = " + idxx + "class>"
	o.innerHTML="<input class=textbox type=text size = 8 name = " + idxx + "amt>"
	p.innerHTML="<button class=appbutton type=button value=Delete onclick=removeRow(this.parentNode.parentNode.rowIndex,this.form)><img src=../art/CRUD/delete.gif width=10 height=10 align=absmiddle>&nbsp;Remove</button>"

}




function removeRow(i,frm)
{
	
	var idxx =parseInt(frm.lineItem.value)
	
	if(idxx =="" || idxx == null)
	 {
	 	idxx=0
	 	
	 }
	 else if (idxx >0)
	 {
			if(idxx-(i-1) == 1 && i>0)
			{

					var name=confirm("Remove Order Detail Item # "+i+".\n\nAre You Sure?")

					if (name==true)
					{
								idxx--
								document.getElementById('oDetail').deleteRow(i)

					}
					else
					{

					}

			}
			else
			{
				alert('ERROR: Order Detail Item Sequence Integrity! Removing items must\nbe accomplished sequentially from the largest to the smallest.\n\nEXAMPLE: An item number of #' + (i+1) + ' must be removed before\nan item number of #'+ i +' is removed.\n\n--------------------\nClick the Help Button for more information.')
			}
	 
   }
   
   frm.lineItem.value=idxx
}
function detailHelp()
{
	alert('Order Detail Entry Help:\n\nEnter the Sales Order Detail Line Items. If a mistake is made, such as a double entry\nand the detail items are side-by-side e.g. #3 and #4 then simply remove\nthe duplicate row (in this example row #4)\n\nUNLESS the duplicate row is separated by more than one row, e.g. #5 and #10.\nThis then would cause a loss of data as rows can only be removed from largest to\nsmallest to maintain Sequential Integrity e.g. rows #9,#8,#7,#6 would have to\nbe removed (and their data lost) before row #5 could be removed.\n-------------------------------------------\nIn this case save the changes then update this order using the menu above and\nsimply delete the duplicate row.')


}











function Graph(width, height, stacked) 
{
	this.stacked = stacked;
	this.width = width || 400;
	this.height = height || 200;
	this.rows = new Array();
	this.addRow = _addRowGraph;
	this.setXScale = _setXScaleGraph;
	this.setXScaleValues = _setXScaleValuesGraph;
	this.setTime = _setStartTimeGraph;
	this.setDate = _setStartDateGraph;
	this.build = _buildGraph;
	this.setLegend = _setLegendGraph;
	this.writeLegend = _writeLegendGraph;
	this.offset = 0;
	return this;
}

function _setLegendGraph() {
this.legends = arguments;
}

function _addRowGraph() {
this.rows[this.rows.length] = new Array();
var row = this.rows[this.rows.length-1];
for(var i = 0; i < arguments.length; i++)
row[row.length] = arguments[i];
}


function _rescaleGraph(g) {
g.posMax = 0, g.negMax = 0, g.c = 0;
for(var i = 0; i < g.rows.length; i++) {
for(var j = 0; j < g.rows[i].length; j++) {
g.c++;
if(g.rows[i][j] > g.posMax) g.posMax = g.rows[i][j];
if(g.rows[i][j] < g.negMax) g.negMax = g.rows[i][j];
}
}
g.vscale = g.height/(g.posMax-g.negMax);
g.hscale = Math.floor(g.width/g.c-1/g.rows[0].length);
}


function _stackRescaleGraph(g) {
var m, n, c = 0;
g.posMax = 0, g.negMax = 0;
for(var i = 0; i < g.rows[0].length; i++) {
m = 0; n = 0;
c++;
for(var j = 0; j < g.rows.length; j++) {
if(g.rows[j][i] > 0) m += g.rows[j][i];
else n += g.rows[j][i];
}
if(m > g.posMax) g.posMax = m;
if(n < g.negMax) g.negMax = n;
}
g.vscale = g.height/(g.posMax-g.negMax);
g.hscale = Math.floor(g.width/c)-1;
}

function _relRescaleGraph(g) {
var m, c = 0;
g.vscale = g.height/100;
for(var i = 0; i < g.rows[0].length; i++) {
m = 0;
c++;
for(var j = 0; j < g.rows.length; j++) {
if(g.rows[j][i] < 0) g.rows[j][i] = 0;
m += g.rows[j][i];
}
var s = 100/m; var k = 0;
for(var j = 1; j < g.rows.length; j++) {
g.rows[j][i] *= s;
g.rows[j][i] = Math.round(10*g.rows[j][i])/10;
if(j != 0) k += g.rows[j][i]*g.vscale;
}
g.rows[0][i] = Math.round(10*(g.height-k)/g.vscale)/10;
}
g.hscale = Math.floor(g.width/c)-1;
g.posMax = 100; g.negMax = 0;
}

function _writeLegendGraph() {
var st = "";
st += "<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=4><TR><TD><FONT CLASS=systext FACE='Arial,Helvetica' SIZE=-1>";
for(var i = 0; i < this.legends.length; i++) {
if(!this.legends[i]) continue;
if(i >= this.rows.length) break;
st += "<IMG SRC=../art/applications/xtrata/"+i+".gif BORDER=1 HSPACE=3>"+this.legends[i]+"<BR>\n";
}
st += "</FONT></TD></TR></TABLE>";
return st;
}


function _buildRegGraph(g, doc) {
var str = "";
str += "<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0>\n";
if(g.title) {
str += "<TR>\n";
if(g.scale) str += "<TD COLSPAN=3></TD>\n";
if(g.yLabel) str += "<TD></TD>\n";
str += "<TH VALIGN=TOP HEIGHT=30 COLSPAN="+(g.c)+">\n";
str += "<FONT CLASS=systext FACE='Arial,Helvetica' SIZE=-1>";
str += g.title;
str += "</FONT></TH></TR>\n";
}
if(g.yLabel) {
g.yLabel = g.yLabel.split("");
g.yLabel = g.yLabel.join("<BR>\n");
str += "<TR>\n";
var r = 2; if(g.negMax && g.posMax) r++;
str += "<TH ROWSPAN="+r+" ALIGN=LEFT WIDTH=20 NOWRAP>\n";
str += "<FONT CLASS=systext FACE='Arial,Helvetica' SIZE=-1>"+g.yLabel+"</FONT></TD>\n";
}
if(g.posMax > 0) {
if(!g.yLabel) str += "<TR>\n";
if(g.scale) str += _writeScaleGraph(g, 0, g.posMax);
str += "<TD VALIGN=BOTTOM";
if(g.bgColor) str += " BGCOLOR=\""+g.bgColor+"\"";
str += ">";
for(var j = 0; j < g.rows[0].length; j++) {
for(var i = 0; i < g.rows.length; i++) {
if(parseInt(g.vscale*g.rows[i][j]) > 0) {
str += "<IMG BORDER=0 SRC=../art/applications/xtrata/"+i+".gif ";
str += "ALT=\"";
if(g.legends && g.legends[i]) str += g.legends[i]+": ";
str += (g.rows[i][j]+g.offset);
if(g.dates) str += ", "+g.dates[j];
str += "\" ";
str += "WIDTH="+parseInt(g.hscale)+" ";
str += "HEIGHT="+parseInt(g.vscale*g.rows[i][j])+" ";
str += ">";
} else
str += "<IMG SRC=../art/applications/xtrata/\"clear.gif\" WIDTH="+parseInt(g.hscale)+" HEIGHT=5>";
str += "</TD>\n<TD VALIGN=BOTTOM";
if(g.bgColor) str += " BGCOLOR=\""+g.bgColor+"\"";
str += ">";
}
str += "<IMG SRC=../art/applications/xtrata/\"clear.gif\" WIDTH=1 HEIGHT=5>";
}
str += "</TD>\n";
}
if(g.legends && g.posMax != 0) {
str += "<TD WIDTH=5 NOWRAP ROWSPAN=3></TD>\n";
str += "<TD ROWSPAN=3>";
str += g.writeLegend();
str += "</TD>\n";
}
if(g.scale || g.xScale) {
if(g.posMax) str += "</TR><TR>\n";
else str += "<TR><TD COLSPAN=2></TD>\n";
str += "<TD BGCOLOR=#000000 COLSPAN="+(g.c+1)+">";
str += "<IMG SRC=../art/applications/xtrata/\"black.gif\" HEIGHT=1 WIDTH=";
str += parseInt(g.rows[0].length*g.hscale)+" ></TD></TR>\n";
}
if(g.xScale && !g.negMax)
str += _writeXScaleGraph(g);
if(g.negMax < 0) {
if(g.posMax != 0 && !g.scale) str += "</TR>";
str += "<TR>\n";
if(g.scale) str += _writeNegScaleGraph(g, g.negMax, 0);
str += "<TD VALIGN=TOP";
if(g.bgColor) str += " BGCOLOR=\""+g.bgColor+"\"";
str += ">";
for(var j = 0; j < g.rows[0].length; j++) {
for(var i = 0; i < g.rows.length; i++) {
if(parseInt(g.vscale*g.rows[i][j]) < 0) {
str += "<IMG VSPACE=0 HSPACE=0 BORDER=0 ALIGN=TOP SRC=../art/applications/xtrata/"+i+".gif WIDTH="+
parseInt(g.hscale)+" HEIGHT="+
parseInt(-1*g.vscale*g.rows[i][j]);
str += " ALT=\"";
if(g.legends && g.legends[i]) str += g.legends[i]+": ";
str += (g.rows[i][j]+g.offset);
if(g.dates) str += ", "+g.dates[j];
str += "\" >";
} else
str += "<IMG SRC=../art/applications/xtrata/\"clear.gif\" ALIGN=TOP BORDER=0 WIDTH="+parseInt(g.hscale)+
" HEIGHT=5>";
str += "</TD>\n<TD VALIGN=TOP";
if(g.bgColor) str += " BGCOLOR=\""+g.bgColor+"\"";
str += ">";
}
str += "<IMG SRC=../art/applications/xtrata/\"clear.gif\" ALIGN=TOP WIDTH=1 BORDER=0 HEIGHT=5>";
}
str += "</TD>\n";
if(g.legends && g.posMax == 0) {
str += "<TD WIDTH=5 NOWRAP ROWSPAN=2></TD><TD>";
str += g.writeLegend();
str += "</TD>\n";
}
}
str += "</TD></TR>\n";
if(g.xLabel) {
str += "<TR>\n";
if(g.scale) str += "<TD COLSPAN=3></TD>\n";
if(g.yLabel) str += "<TD></TD>\n";
str += "<TH COLSPAN="+g.c+" HEIGHT=25 VALIGN=BOTTOM><FONT CLASS=systext FACE='Arial,Helvetica' SIZE=-1>";
str += g.xLabel;
str += "</FONT></TH></TR>\n";
}
str += "</TABLE>\n";
doc.write(str); 
}
function _setXScaleGraph(s, skip, inc) {
this.xScale = true;
this.s = s || 0;
this.skip = skip || 1;
this.inc = inc || 1;
}


function _setXScaleValuesGraph() {
this.xScale = true;
this.s = 0;
this.skip = 1;
this.inc = 1;
this.dates = new Array();
for(var i = 0; i < arguments.length; i++)
this.dates[this.dates.length] = arguments[i];
}

function _setStartTimeGraph(hour, min, skip, inc) {
this.xScale = true;
this.sTime = new Date(0, 0, 0, hour, min);
this.skip = skip || 1;
this.inc = inc || 1;
}

function _setStartDateGraph(month, day, year, skip, inc) {
this.xScale = true;
this.sDate = new Date(year, month-1, day);
this.skip = skip || 1;
this.inc = inc || skip || 1;
this.showDate = true;
}

function _setDatesArrayGraph(g) {
if(g.dates) return;
g.dates = new Array();
for(var i = 0; i < g.rows[0].length; i++) {
var dateStr = "";
if(g.sDate) {
if(g.showDay) {
eval('switch(g.sDate.getDay()) {'+
'case 0: dateStr += "Sun"; break;'+
'case 1: dateStr += "Mon"; break;'+
'case 2: dateStr += "Tue"; break;'+
'case 3: dateStr += "Wed"; break;'+
'case 4: dateStr += "Thu"; break;'+
'case 5: dateStr += "Fri"; break;'+
'case 6: dateStr += "Sat"; break;'+
'}');
dateStr += " ";
}
if(g.longDate && g.showDate) {
dateStr += g.sDate.getDate()+"-";
eval('switch(g.sDate.getMonth()) {'+
'case 0: dateStr += "Jan"; break;'+
'case 1: dateStr += "Feb"; break;'+
'case 2: dateStr += "Mar"; break;'+
'case 3: dateStr += "Apr"; break;'+
'case 4: dateStr += "May"; break;'+
'case 5: dateStr += "Jun"; break;'+
'case 6: dateStr += "Jul"; break;'+
'case 7: dateStr += "Aug"; break;'+
'case 8: dateStr += "Sep"; break;'+
'case 9: dateStr += "Oct"; break;'+
'case 10: dateStr += "Nov"; break;'+
'case 11: dateStr += "Dec"; break;'+
'}');
} else if(g.showDate) dateStr += (g.sDate.getMonth()+1)+"/"+g.sDate.getDate();
if(g.showYear && g.showDate) {
if(g.longDate) dateStr += "-";
else dateStr += "/";
}
if(g.showYear) {
if(g.longYear) dateStr += g.sDate.getFullYear();
else dateStr += (g.sDate.getFullYear()%100);
}
g.sDate.setDate(g.sDate.getDate()+ g.inc);
} else if(g.sTime) {
var hrs = g.sTime.getHours();
if(!g.armyTime) {
var pm = false;
if(hrs == 0) { hrs = 12; }
else if(hrs >= 12) { if(hrs > 12) hrs -= 12; pm = true; }
} else 
if(hrs < 10) hrs = "0" + hrs;
dateStr = hrs + ":";
var min = g.sTime.getMinutes();
if(min < 10) min = "0" + min;
dateStr += min;
if(!g.armyTime) { !pm ? dateStr += "am" : dateStr += "pm" ; }
g.sTime.setMinutes(g.sTime.getMinutes()+ g.inc); 
} else dateStr = g.s+i*g.inc;
g.dates[i] = dateStr;
}
}


function _writeXScaleGraph(g) {
var st = "";
if(!g.c) g.c = g.rows[0].length*2-1;
st += "<TR>\n";
if(g.scale) st += "<TD COLSPAN=2></TD>\n";
if(g.yLabel) st += "<TD></TD>\n";
st += "<TD VALIGN=TOP COLSPAN="+(g.c+1)+">";
st += "<IMG SRC=../art/applications/xtrata/black.gif HEIGHT=10 WIDTH=1>";
st += "<IMG SRC=../art/applications/xtrata/clear.gif HEIGHT=1 WIDTH=1>";
var n = g.rows[0].length;
var mult = g.rows.length;
if(g.stacked || g.relative) mult = 1;
for(var i = 0; i < n; i++) {
st += "<IMG SRC=../art/applications/xtrata/clear.gif HEIGHT=1 WIDTH="+(g.hscale*mult)+">";
if((i+1) % g.skip)
st += "<IMG SRC=../art/applications/xtrata/clear.gif HEIGHT=10 WIDTH=1>";
else
st += "<IMG SRC=../art/applications/xtrata/black.gif HEIGHT=10 WIDTH=1>";
}
st += "</TD></TR><TR>\n";
if(g.scale) st += "<TD COLSPAN=3></TD>\n";
if(g.yLabel) st += "<TD></TD>\n";
var cspan = g.rows.length;
if(g.stacked || g.relative) cspan = 2;
cspan *= g.skip;
if(g.sDate || g.sTime) _setDatesArrayGraph(g);
var t = 0;
for(var i = 0; i < Math.floor(g.rows[0].length/g.skip); i++) {
st += "<TD VALIGN=TOP";
st += " COLSPAN="+cspan; t += cspan;
st += "><FONT CLASS=systext FACE='Arial,Helvetica' SIZE=-3><I>";
st += g.dates[i*g.skip] || "";
st += "</I></FONT></TD>\n";
}
var len = g.rows[0].length;
if(!g.stacked) len *= g.rows.length;
if(i < Math.ceil(g.rows[0].length/g.skip)) {
st += "<TD VALIGN=TOP";
st += " COLSPAN="+(len-t);
st += "><FONT CLASS=systext FACE='Arial,Helvetica' SIZE=-3><I>";
st += g.dates[i*g.skip];
st += "</I></FONT></TD>\n";
}
st += "</TR>\n"; 
return st;
}


function _writeNegScaleGraph(g, min, max) {
var h = Math.ceil(g.height/(g.posMax-g.negMax)*g.scale);
var p = -1*g.negMax/(g.posMax-g.negMax);
var n = Math.floor(g.height*p/h);
var st = "";
if(h < 15) {
if(!g.posMax)
alert("Warning! Scale is too small! Please make\nthe scale larger or make the graph taller.");
st += "<TD></TD><TD></TD><TD></TD>\n"
return st;
}
st += "<TD VALIGN=TOP ALIGN=RIGHT>";
var H = h - 3;
for(var i = 0; i < n; i++) {
st += "<FONT CLASS=systext FACE=Arial,Helvetica SIZE=-3><I>"+(g.scale*-1*(i+1)+g.offset)+"</I></FONT>";
st += "<IMG SRC=../art/applications/xtrata/clear.gif WIDTH=1 HEIGHT="+H+"><BR>\n";
}
st += "</TD>\n";
st += "<TD VALIGN=TOP>";
for(var i = 0; i < n; i++) {
st += "<IMG SRC=../art/applications/xtrata/clear.gif WIDTH=1 HEIGHT="+(h-1)+"><BR>\n";
st += "<IMG SRC=../art/applications/xtrata/black.gif WIDTH=6 HEIGHT=1><BR>\n";
}
st += "</TD>\n";
st += "<TD VALIGN=TOP>";
st += "<IMG SRC=../art/applications/xtrata/black.gif WIDTH=1 HEIGHT="+(g.height*p)+">";
st += "<IMG SRC=../art/applications/xtrata/clear.gif WIDTH=1 HEIGHT="+(g.height*p)+">";
st += "</TD>\n"
return st;
}
function _writeScaleGraph(g, min, max) {
var h;
var p = g.posMax/(g.posMax-g.negMax);
h = Math.ceil(g.height/(g.posMax-g.negMax)*g.scale);
var n = Math.floor(g.height*p/h);
var st = "";
if(h < 15) {
alert("Warning! Scale is too small! Please make\nthe scale larger or make the graph taller.");
st += "<TD ROWSPAN=2></TD><TD ROWSPAN=2></TD><TD></TD>\n"
return st;
}
st += "<TD VALIGN=BOTTOM ROWSPAN=2 ALIGN=RIGHT>";
var H = h - 3;
for(var i = 0; i < n; i++) {
st += "<FONT CLASS=systext FACE=Arial,Helvetica SIZE=-3><I>"+(g.scale*(n-1)-g.scale*i+g.offset);
if(g.relative) st += "%";
st += "</I></FONT>";
st += "<IMG SRC=../art/applications/xtrata/clear.gif WIDTH=1 HEIGHT="+H+"><BR>\n";
}
st += "</TD>\n";
st += "<TD VALIGN=BOTTOM ROWSPAN=2>";
for(var i = 0; i < n; i++) {
st += "<IMG SRC=../art/applications/xtrata/black.gif WIDTH=6 HEIGHT=1><BR>\n";
st += "<IMG SRC=../art/applications/xtrata/clear.gif WIDTH=1 HEIGHT="+(h-1)+"><BR>\n";
}
st += "<IMG SRC=../art/applications/xtrata/black.gif WIDTH=6 HEIGHT=1><BR>\n";
st += "</TD>\n";
st += "<TD VALIGN=BOTTOM>";
st += "<IMG SRC=../art/applications/xtrata/black.gif WIDTH=1 HEIGHT="+(g.height*p)+">";
st += "<IMG SRC=../art/applications/xtrata/clear.gif WIDTH=1 HEIGHT="+(g.height*p)+">";
st += "</TD>\n"
return st;
}
function _buildStackGraph(g) {
if(!g.c) g.c = g.rows[0].length*2-1;
var str = "";
str += "<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0>\n";
if(g.title) {
str += "<TR>\n";
if(g.scale) str += "<TD COLSPAN=3></TD>\n";
if(g.yLabel) str += "<TD></TD>\n";
str += "<TH VALIGN=TOP HEIGHT=30 COLSPAN="+(g.c)+">";
str += "<FONT CLASS=systext FACE='Arial,Helvetica' SIZE=-1>";
str += g.title;
str += "</FONT></TH></TR>\n";
}
if(g.yLabel) {
g.yLabel = g.yLabel.split("");
g.yLabel = g.yLabel.join("<BR>\n");
str += "<TR>\n";
var rspan = 2; if(g.negMax && g.posMax) rspan++;
str += "<TH ROWSPAN="+rspan+" ALIGN=LEFT NOWRAP WIDTH=20>";
str += "<FONT CLASS=systext FACE='Arial,Helvetica' SIZE=-1>"+g.yLabel+"</FONT></TH>\n";
}
if(g.posMax > 0) {
if(!g.yLabel) str += "<TR>\n";
if(g.scale) str += _writeScaleGraph(g, 0, g.posMax);
for(var j = 0; j < g.rows[0].length; j++) {
str += "<TD VALIGN=BOTTOM";
if(g.bgColor) str += " BGCOLOR=\""+g.bgColor+"\"";
str += ">";
var k = 0, y = 0, drawn = false;
for(var i = 1; i < g.rows.length; i++)
if(parseInt(g.vscale*g.rows[i][j]) > 0)
k += parseInt(g.vscale*g.rows[i][j]);
if(g.rows.length > 0 && g.relative && (g.height > k)) {
str += "<IMG SRC=../art/applications/xtrata/0.gif WIDTH="+parseInt(g.hscale)+" HEIGHT="+(g.height-k)+" ";
str += "ALT=\"";
if(g.legends && g.legends[0]) str += g.legends[0]+": ";
str += Math.round((g.height-k)/g.vscale*10)/10+"%";
if(g.dates) str += ", "+g.dates[j];
str += "\" ><BR>\n";
y++;
drawn = true;
}
for(var i = y; i < g.rows.length; i++) {
if(parseInt(g.vscale*g.rows[i][j]) > 0) {
str += "<IMG SRC=../art/applications/xtrata/"+i+".gif WIDTH="+parseInt(g.hscale)+" HEIGHT="+
parseInt(g.vscale*g.rows[i][j])+" ";
str += "ALT=\"";
if(g.legends && g.legends[i]) str += g.legends[i]+": ";
str += g.rows[i][j];
if(g.relative) str += "%";
if(g.dates) str += ", "+g.dates[j];
str += "\" ><BR>\n";
drawn = true;
}
}
if(!drawn) str += "<IMG SRC=../art/applications/xtrata/clear.gif WIDTH="+parseInt(g.hscale)+" HEIGHT=1>";
str += "</TD>\n";
str += "<TD";
if(g.bgColor) str += " BGCOLOR=\""+g.bgColor+"\"";
str += "><IMG SRC=../art/applications/xtrata/clear.gif WIDTH=1 HEIGHT=5></TD>\n";
}
}
if(g.legends && g.posMax != 0) {
str += "<TD WIDTH=5 NOWRAP ROWSPAN=3></TD>\n<TD ROWSPAN=3>";
str += g.writeLegend();
str += "</TD>\n";
}
if(g.scale || g.xScale) {
str += "</TR><TR>\n<TD BGCOLOR=#000000 COLSPAN="+(g.rows[0].length*2);
str += "><IMG SRC=../art/applications/xtrata/black.gif HEIGHT=1 WIDTH=";
str += parseInt(g.rows[0].length*g.hscale)+" ></TD></TR>\n";
}
if(g.xScale && !g.negMax) {
str += _writeXScaleGraph(g);
}
if(g.negMax < 0) {
if(g.posMax != 0) str += "</TR>\n";
str += "<TR>\n";
if(g.scale) str += _writeNegScaleGraph(g, g.negMax, 0);
for(var j = 0; j < g.rows[0].length; j++) {
str += "<TD VALIGN=TOP";
if(g.bgColor) str += " BGCOLOR=\""+g.bgColor+"\"";
str += ">";
var drawn = false;
for(var i = 0; i < g.rows.length; i++) {
if(parseInt(g.vscale*g.rows[i][j]) < 0) {
str += "<IMG VSPACE=0 HSPACE=0 BORDER=0 ALIGN=TOP SRC=../art/applications/xtrata/"+i+".gif WIDTH="+
parseInt(g.hscale)+" HEIGHT="+
parseInt(-1*g.vscale*g.rows[i][j])+" ";
str += "ALT=\"";
if(g.legends && g.legends[i]) str += g.legends[i]+": ";
str += g.rows[i][j];
if(g.relative) str += "%";
if(g.dates) str += ", "+g.dates[j];
str += "\" ><BR>\n"; 
drawn = true;
}
}
if(!drawn) str += "<IMG SRC=../art/applications/xtrata/clear.gif WIDTH="+parseInt(g.hscale)+" HEIGHT=1>";
str += "</TD>\n";
str += "<TD";
if(g.bgColor) str += " BGCOLOR=\""+g.bgColor+"\"";
str += "><IMG SRC=../art/applications/xtrata/clear.gif WIDTH=1 HEIGHT=5></TD>";
}
if(g.legends && g.posMax == 0) {
str += "<TD WIDTH=5 NOWRAP ROWSPAN=2></TD>\n<TD>";
str += g.writeLegend();
str += "</TD>\n";
}
}
str += "</TD></TR>\n";
if(g.xLabel) {
str += "<TR>\n";
if(g.scale) str += "<TD COLSPAN=3></TD>\n";
if(g.yLabel) str += "<TD></TD>\n";
str += "<TH COLSPAN="+g.c+" HEIGHT=25 VALIGN=BOTTOM><FONT CLASS=systext FACE='Arial,Helvetica' SIZE=-1>";
str += g.xLabel;
str += "</FONT></TH></TR>\n";
}
str += "</TABLE>\n";
doc.write(str); 
}
function _adjustOffsetGraph(g) {
if(g.relative) return;
for(var i = 0; i < g.rows.length; i++)
for(var j = 0; j < g.rows[i].length; j++)
g.rows[i][j] -= g.offset;
}
function _buildGraph(d) {
doc = d || document;
if(!this.rows) return;
if(this.rows.length == 0) {
doc.write("<TABLE><TR><TD><TT>[empty graph]</TT></TD></TR></TABLE>\n");
return;
}
_adjustOffsetGraph(this);
if(this.xScale) _setDatesArrayGraph(this);
if(this.relative) {
_relRescaleGraph(this);
_buildStackGraph(this, doc);
return;
}
if(this.stacked) {
_stackRescaleGraph(this);
_buildStackGraph(this, doc);
return;
}
_rescaleGraph(this);
_buildRegGraph(this, doc);
}

function valLoginId(myForm) 
{
	

if((myForm.citLoginID.value.length < 6) ||
	   (myForm.citLoginID.value.indexOf('@',0) <=1) ||
	   (myForm.citLoginID.value.indexOf('.',0) ==1) ||
	   (myForm.citLoginID.value.indexOf('.',0) ==2) ||
	   (myForm.citLoginID.value.lastIndexOf('@') != myForm.citLoginID.value.indexOf('@',0)) ||
	   (myForm.citLoginID.value.lastIndexOf('@') > (myForm.citLoginID.value.length - 5)) ||
	   (myForm.citLoginID.value.lastIndexOf('.') > (myForm.citLoginID.value.length - 3)) ||
	   (myForm.citLoginID.value.lastIndexOf('.') < (myForm.citLoginID.value.length - 4)) ||
	   (myForm.citLoginID.value.indexOf('..',0) > -1) ||
	   (myForm.citLoginID.value.indexOf('@.',0) > -1) ||
	   (myForm.citLoginID.value.indexOf('.@',0) > -1) ||
	   (myForm.citLoginID.value.indexOf(',',0) > -1))
	{
		alert('Your Account Id (email address) "' + myForm.citLoginID.value + '"\is not a valid format for our system.');
		myForm.citLoginID.value = myForm.validation.value;
		return (false)
	}

	
}
function valEmail2(myForm) 
{
	

if((myForm.email2.value.length < 6) ||
	   (myForm.email2.value.indexOf('@',0) <=1) ||
	   (myForm.email2.value.indexOf('.',0) ==1) ||
	   (myForm.email2.value.indexOf('.',0) ==2) ||
	   (myForm.email2.value.lastIndexOf('@') != myForm.email2.value.indexOf('@',0)) ||
	   (myForm.email2.value.lastIndexOf('@') > (myForm.email2.value.length - 5)) ||
	   (myForm.email2.value.lastIndexOf('.') > (myForm.email2.value.length - 3)) ||
	   (myForm.email2.value.lastIndexOf('.') < (myForm.email2.value.length - 4)) ||
	   (myForm.email2.value.indexOf('..',0) > -1) ||
	   (myForm.email2.value.indexOf('@.',0) > -1) ||
	   (myForm.email2.value.indexOf('.@',0) > -1) ||
	   (myForm.email2.value.indexOf(',',0) > -1))
	{
		alert('Your Business and/or Secondary Email "' + myForm.email2.value + '"\is not a valid format for our system.');
		myForm.email2.value = myForm.validation3.value;
		return (false)
	}

	
}
function valEmail1(myForm) 
{
	

if((myForm.email1.value.length < 1) ||
	   (myForm.email1.value.indexOf('@',0) <1) ||
	   (myForm.email1.value.indexOf('.',0) <1) ||
	   (myForm.email1.value.indexOf('.',0) <1) ||
	   (myForm.email1.value.lastIndexOf('@') != myForm.email1.value.indexOf('@',0)) ||
	   (myForm.email1.value.lastIndexOf('@') > (myForm.email1.value.length - 5)) ||
	   (myForm.email1.value.lastIndexOf('.') > (myForm.email1.value.length - 3)) ||
	   (myForm.email1.value.lastIndexOf('.') < (myForm.email1.value.length - 4)) ||
	   (myForm.email1.value.indexOf('..',0) > -1) ||
	   (myForm.email1.value.indexOf('@.',0) > -1) ||
	   (myForm.email1.value.indexOf('.@',0) > -1) ||
	   (myForm.email1.value.indexOf(',',0) > -1))
	{
		alert('Your Personal and/or Primary Email "' + myForm.email1.value + '"\is not a valid format for our system.');
		myForm.email1.value = myForm.validation2.value;
		return (false)
	}

	
}

function valZp(myForm)

{

	

	if (myForm.zp.length < 5)
	{
		alert("Please provide a correct zip code length.");
		myForm.zp.value = " ";
		myForm.st.value = "";
		newAccountVal(myForm)
		return true;
	}
	else if (isNaN(myForm.zp.value))
	{
		alert("Please provide a numerical zip code.");
		myForm.zp.value = " ";
		myForm.st.value = "";
		newAccountVal(myForm)
		return true;
	}

	
	switch(myForm.st.value)
	{
		case "04-AL":
			if ((myForm.zp.value >= 35000 && myForm.zp.value <= 35299) ||
				(myForm.zp.value >= 35400 && myForm.zp.value <= 36999))
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "08-AK":
			if (myForm.zp.value >= 99500 && myForm.zp.value <= 99999)
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "10-AZ":
			if ((myForm.zp.value >= 85000 && myForm.zp.value <= 85099) || (myForm.zp.value >= 85200 && myForm.zp.value <= 85399) ||
				(myForm.zp.value >= 85500 && myForm.zp.value <= 85799) || (myForm.zp.value >= 85900 && myForm.zp.value <= 86099) ||
				(myForm.zp.value >= 86300 && myForm.zp.value <= 86599))
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "04-AR":
			if ((myForm.zp.value >= 71600 && myForm.zp.value <= 72999) || myForm.zp.value == 75502)
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "06-CA":
			if ((myForm.zp.value >= 90000 && myForm.zp.value <= 90899) || (myForm.zp.value >= 91000 && myForm.zp.value <= 92899) || 
				(myForm.zp.value >= 93000 && myForm.zp.value <= 96199)) 
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "09-CO":
			if (myForm.zp.value >= 80000 && myForm.zp.value <= 81699) 
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "01-CT":
			if (myForm.zp.value >= 6000 && myForm.zp.value <= 6999)
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "01-DE":
			if (myForm.zp.value >= 19700 && myForm.zp.value <= 19999)
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "01-DC":
			if (myForm.zp.value >= 20000 && myForm.zp.value <= 20599)
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "02-FL":
			if ((myForm.zp.value >= 32000 && myForm.zp.value <= 33999) || (myForm.zp.value >= 34100 && myForm.zp.value <= 34299) ||
				(myForm.zp.value >= 34400 && myForm.zp.value <= 34499) || (myForm.zp.value >= 34600 && myForm.zp.value <= 34699) ||
				(myForm.zp.value >= 34700 && myForm.zp.value <= 34799) || (myForm.zp.value >= 34900 && myForm.zp.value <= 34999)) 
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "02-GA":
			if ((myForm.zp.value >= 30000 && myForm.zp.value <= 31999) || (myForm.zp.value >= 39800 && myForm.zp.value <= 39999))
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "07-HI":
			if (myForm.zp.value >= 96700 && myForm.zp.value <= 96899)
			{
				
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "11-ID":
			if (myForm.zp.value >= 83200 && myForm.zp.value <= 83899)
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "04-IL":
			if (myForm.zp.value >= 60000 && myForm.zp.value <= 62999)
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "01-IN":
			if (myForm.zp.value >= 46000 && myForm.zp.value <= 47999)
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "03-IA":
			if (myForm.zp.value >= 50000 && myForm.zp.value <= 52899)
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "04-KS":
			if (myForm.zp.value >= 66000 && myForm.zp.value <= 67999)
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "01-KY":
			if ((myForm.zp.value >= 40000 && myForm.zp.value <= 42799) || myForm.zp.value == 45275)
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "04-LA":
			if ((myForm.zp.value >= 70000 && myForm.zp.value <= 71499) || myForm.zp.value == 71749)
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "01-ME":
			if (myForm.zp.value >= 3900 && myForm.zp.value <= 4999 || myForm.zp.value == 3801)
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "01-MD":
			if ((myForm.zp.value >= 20600 && myForm.zp.value <= 21999) || myForm.zp.value == 20331)
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "01-MA":
			if ((myForm.zp.value >= 1000 && myForm.zp.value <= 2799) || (myForm.zp.value >= 5500 && myForm.zp.value <= 5599))
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "01-MI":
			if (myForm.zp.value >= 48000 && myForm.zp.value <= 49999)
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "03-MN":
			if (myForm.zp.value >= 55000 && myForm.zp.value <= 56799)
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "04-MS":
			if (myForm.zp.value >= 38600 && myForm.zp.value <= 39799)
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "04-MO":
			if (myForm.zp.value >= 63000 && myForm.zp.value <= 65899)
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "11-MT":
			if (myForm.zp.value >= 59000 && myForm.zp.value <= 59999)
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "03-NE":
			if (myForm.zp.value >= 68000 && myForm.zp.value <= 69399)
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "06-NV":
			if (myForm.zp.value >= 88900 && myForm.zp.value <= 89899)
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "01-NH":
			if (myForm.zp.value >= 3000 && myForm.zp.value <= 3899)
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "01-NJ":
			if (myForm.zp.value >= 7000 && myForm.zp.value <= 8999)
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "10-NM":
			if (myForm.zp.value >= 87000 && myForm.zp.value <= 88499)
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "01-NY":
			if ((myForm.zp.value >= 400 && myForm.zp.value <= 599) || (myForm.zp.value == 6390) ||
				(myForm.zp.value >= 10000 && myForm.zp.value <= 14999))
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "02-NC":
			if (myForm.zp.value >= 27000 && myForm.zp.value <= 28999)
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "03-ND":
			if (myForm.zp.value >= 58000 && myForm.zp.value <= 58899)
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "01-OH":
			if (myForm.zp.value >= 43000 && myForm.zp.value <= 45999)
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "04-OK":
			if ((myForm.zp.value >= 73000 && myForm.zp.value <= 73299) || (myForm.zp.value >= 73400 && myForm.zp.value <= 74999))
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "05-OR":
			if (myForm.zp.value >= 97000 && myForm.zp.value <= 97999)
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "01-PA":
			if ((myForm.zp.value >= 15000 && myForm.zp.value <= 19699))
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "01-RI":
			if (myForm.zp.value >= 2800 && myForm.zp.value <= 2999)
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "02-SC":
			if (myForm.zp.value >= 29000 && myForm.zp.value <= 29999)
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "03-SD":
			if (myForm.zp.value >= 57000 && myForm.zp.value <= 57799)
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "02-TN":
			if (myForm.zp.value >= 37000 && myForm.zp.value <= 38599)
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "04-TX":
			if ((myForm.zp.value >= 73300 && myForm.zp.value <= 73399) || (myForm.zp.value >= 75000 && myForm.zp.value <= 79999) || 
				(myForm.zp.value == 73949))
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "10-UT":
			if (myForm.zp.value >= 84000 && myForm.zp.value <= 84799)
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "01-VT":
			if ((myForm.zp.value >= 5000 && myForm.zp.value <= 5499) || (myForm.zp.value >= 5600 && myForm.zp.value <= 5999)) 
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "01-VA":
			if ((myForm.zp.value == 20041) || (myForm.zp.value >= 20100 && myForm.zp.value <= 20199) || 
				(myForm.zp.value == 20301) || (myForm.zp.value == 20370) || (myForm.zp.value >= 22000 && myForm.zp.value <= 24699))
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "05-WA":
			if ((myForm.zp.value >= 98000 && myForm.zp.value <= 98699) || (myForm.zp.value >= 98800 && myForm.zp.value <= 99499))
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "02-WV":
			if (myForm.zp.value >= 24700 && myForm.zp.value <= 26899)
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "03-WI":
			if ((myForm.zp.value >= 53000 && myForm.zp.value <= 54999) || (myForm.zp.value == 49936))
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		case "11-WY":
			if (myForm.zp.value >= 82000 && myForm.zp.value <= 83499)
			{
				newAccountVal(myForm)
				return true;
			} 
			break;
		default:
		 	alert("Your State & Zip Code do not match! Please re-select your State and/or Zip Code.");
			return false;
	}
	

			alert("Your State & Zip Code do not match! Please re-select your State and/or Zip Code.");
			myForm.zp.value = "";
			myForm.st.value = "04-KS";
			newAccountVal(myForm)
			return true;
			
			
}


function sumTime(thisForm) 
{
	var summed1= parseFloat("0");
	var summed2=parseFloat("0");
	var summed3=parseFloat("0");
	var summed4= parseFloat("0");
	var summed5=parseFloat("0");
	var summed6=parseFloat("0");
	var summed7= parseFloat("0");
	var summed8=parseFloat("0");
	var summed9=parseFloat("0");
	var summed10=parseFloat("0");	

	var summed11= parseFloat("0");
	var summed12=parseFloat("0");
	var summed13=parseFloat("0");
	var summed14= parseFloat("0");
	var summed15=parseFloat("0");
	var summed16=parseFloat("0");
	var summed17= parseFloat("0");
	var summed18=parseFloat("0");
	var summed19=parseFloat("0");
	var summed20=parseFloat("0");
	var summed21=parseFloat("0");
		
	var summedTotal=parseFloat("0");
	var summedTotal2=parseFloat("0");
	var summedTotal3=parseFloat("0");
	var timeTotal=parseFloat("0");	
	
	//Row 1

			if (isNaN(thisForm.sun1.value) || thisForm.sun1.value <0)
			{
				alert("'" + thisForm.sun1.value + "' is not valid!  Please enter a valid number for your hours.");
				thisForm.sun1.value = 0;
				return false;
			}
			else
			{
							if(thisForm.sun1.value == null || thisForm.sun1.value == "")
							{
								thisForm.sun1.value == 0
							}
				
							summed1 = parseFloat(summed1 + thisForm.sun1.value);
			
			}
			
			if (isNaN(thisForm.mon1.value) || thisForm.mon1.value <0)
			{
				alert("'" + thisForm.mon1.value + "' is not valid!  Please enter a valid number for your hours.");
				thisForm.mon1.value = 0;
				return false;
			}
			else
			{
							if(thisForm.mon1.value == null || thisForm.mon1.value == "")
							{
								thisForm.mon1.value == 0
							}

							summed2 = parseFloat(summed2 + thisForm.mon1.value);
						
			}
			
			if (isNaN(thisForm.tue1.value) || thisForm.tue1.value <0)
			{
				alert("'" + thisForm.tue1.value + "' is not valid!  Please enter a valid number for your hours.");
				thisForm.tue1.value = 0;
				return false;
			}
			else
			{
							if(thisForm.tue1.value == null || thisForm.tue1.value == "")
							{
								thisForm.tue1.value == 0
							}

							summed3 = parseFloat(summed3 + thisForm.tue1.value);
						
			}
			
			if (isNaN(thisForm.wed1.value) || thisForm.wed1.value <0)
			{
				alert("'" + thisForm.wed1.value + "' is not valid!  Please enter a valid number for your hours.");
				thisForm.wed1.value = 0;
				return false;
			}
			else
			{
							if(thisForm.wed1.value == null || thisForm.wed1.value == "")
							{
								thisForm.wed1.value == 0
							}

							summed4 = parseFloat(summed4 + thisForm.wed1.value);
						
			}
			
			if (isNaN(thisForm.thu1.value) || thisForm.thu1.value <0)
			{
				alert("'" + thisForm.thu1.value + "' is not valid!  Please enter a valid number for your hours.");
				thisForm.thu1.value = 0;
				return false;
			}
			else
			{
							if(thisForm.thu1.value == null || thisForm.thu1.value == "")
							{
								thisForm.thu1.value == 0
							}

							summed5 = parseFloat(summed5 + thisForm.thu1.value);
						
			}
			
			if (isNaN(thisForm.fri1.value) || thisForm.fri1.value <0)
			{
				alert("'" + thisForm.fri1.value + "' is not valid!  Please enter a valid number for your hours.");
				thisForm.fri1.value = 0;
				return false;
			}
			else
			{
							if(thisForm.fri1.value == null || thisForm.fri1.value == "")
							{
								thisForm.fri1.value == 0
							}

							summed6 = parseFloat(summed6 + thisForm.fri1.value);
						
			}
			
			if (isNaN(thisForm.sat1.value) || thisForm.sat1.value <0)
			{
				alert("'" + thisForm.sat1.value + "' is not valid!  Please enter a valid number for your hours.");
				thisForm.sat1.value = 0;
				return false;
			}
			else
			{
							if(thisForm.sat1.value == null || thisForm.sat1.value == "")
							{
								thisForm.sat1.value == 0
							}

							summed7 = parseFloat(summed7 + thisForm.sat1.value);
						
			}
			
//Row 2		
			if (isNaN(thisForm.sun2.value) || thisForm.sun2.value <0 )
			{
				alert("'" + thisForm.sun2.value + "' is not valid!  Please enter a valid number for your hours.");
				thisForm.sun2.value = 0;
				return false;
			}
			else
			{

							if(thisForm.sun2.value == null || thisForm.sun2.value == "")
							{
								thisForm.sun2.value == 0
							}

							summed8 = parseFloat(summed8 + thisForm.sun2.value);
			
			}
			
			if (isNaN(thisForm.mon2.value) || thisForm.mon2.value <0)
			{
				alert("'" + thisForm.mon2.value + "' is not valid!  Please enter a valid number for your hours.");
				thisForm.mon2.value = 0;
				return false;
			}
			else
			{
							if(thisForm.mon2.value == null || thisForm.mon2.value == "")
							{
								thisForm.mon2.value == 0
							}

							summed9 = parseFloat(summed9 + thisForm.mon2.value);
						
			}
			
			if (isNaN(thisForm.tue2.value) || thisForm.tue2.value <0)
			{
				alert("'" + thisForm.tue2.value + "' is not valid!  Please enter a valid number for your hours.");
				thisForm.tue2.value = 0;
				return false;
			}
			else
			{
							if(thisForm.tue2.value == null || thisForm.tue2.value == "")
							{
								thisForm.tue2.value == 0
							}

							summed10 = parseFloat(summed10 + thisForm.tue2.value);
						
			}
			
			if (isNaN(thisForm.wed2.value) || thisForm.wed2.value <0)
			{
				alert("'" + thisForm.wed2.value + "' is not valid!  Please enter a valid number for your hours.");
				thisForm.wed2.value = 0;
				return false;
			}
			else
			{
							if(thisForm.wed2.value == null || thisForm.wed2.value == "")
							{
								thisForm.wed2.value == 0
							}

							summed11 = parseFloat(summed11 + thisForm.wed2.value);
						
			}
			
			if (isNaN(thisForm.thu2.value) || thisForm.thu2.value <0)
			{
				alert("'" + thisForm.thu2.value + "' is not valid!  Please enter a valid number for your hours.");
				thisForm.thu2.value = 0;
				return false;
			}
			else
			{
							if(thisForm.thu2.value == null || thisForm.thu2.value == "")
							{
								thisForm.thu2.value == 0
							}

							summed12 = parseFloat(summed12 + thisForm.thu2.value);
						
			}
			
			if (isNaN(thisForm.fri2.value) || thisForm.fri2.value <0)
			{
				alert("'" + thisForm.fri2.value + "' is not valid!  Please enter a valid number for your hours.");
				thisForm.fri2.value = 0;
				return false;
			}
			else
			{
							if(thisForm.fri2.value == null || thisForm.fri2.value == "")
							{
								thisForm.fri2.value == 0
							}

							summed13 = parseFloat(summed13 + thisForm.fri2.value);
						
			}
			
			if (isNaN(thisForm.sat2.value) || thisForm.sat2.value <0)
			{
				alert("'" + thisForm.sat2.value + "' is not valid!  Please enter a valid number for your hours.");
				thisForm.sat2.value = 0;
				return false;
			}
			else
			{
							if(thisForm.sat2.value == null || thisForm.sat2.value == "")
							{
								thisForm.sat2.value == 0
							}

							summed14 = parseFloat(summed14 + thisForm.sat2.value);
						
			}			
			
			
//Row 3
			if (isNaN(thisForm.sun3.value) || thisForm.sun3.value <0)
			{
				alert("'" + thisForm.sun3.value + "' is not valid!  Please enter a valid number for your hours.");
				thisForm.sun3.value = 0;
				return false;
			}
			else
			{
							if(thisForm.sun3.value == null || thisForm.sun3.value == "")
							{
								thisForm.sun3.value == 0
							}
							
							summed15 = parseFloat(summed15 + thisForm.sun3.value);
			
			}
			
			if (isNaN(thisForm.mon3.value) || thisForm.mon3.value <0)
			{
				alert("'" + thisForm.mon3.value + "' is not valid!  Please enter a valid number for your hours.");
				thisForm.mon3.value = 0;
				return false;
			}
			else
			{
							if(thisForm.mon3.value == null || thisForm.mon3.value == "")
							{
								thisForm.mon3.value == 0
							}

							summed16 = parseFloat(summed16 + thisForm.mon3.value);
						
			}
			
			if (isNaN(thisForm.tue3.value) || thisForm.tue3.value <0)
			{
				alert("'" + thisForm.tue3.value + "' is not valid!  Please enter a valid number for your hours.");
				thisForm.tue3.value = 0;
				return false;
			}
			else
			{
							if(thisForm.tue3.value == null || thisForm.tue3.value == "")
							{
								thisForm.tue3.value == 0
							}

							summed17 = parseFloat(summed17 + thisForm.tue3.value);
						
			}
			
			if (isNaN(thisForm.wed3.value) || thisForm.wed3.value <0)
			{
				alert("'" + thisForm.wed3.value + "' is not valid!  Please enter a valid number for your hours.");
				thisForm.wed3.value = 0;
				return false;
			}
			else
			{
							if(thisForm.wed3.value == null || thisForm.wed3.value == "")
							{
								thisForm.wed3.value == 0
							}

							summed18 = parseFloat(summed18 + thisForm.wed3.value);
						
			}
			
			if (isNaN(thisForm.thu3.value) || thisForm.thu3.value <0)
			{
				alert("'" + thisForm.thu3.value + "' is not valid!  Please enter a valid number for your hours.");
				thisForm.thu3.value = 0;
				return false;
			}
			else
			{
							if(thisForm.thu3.value == null || thisForm.thu3.value == "")
							{
								thisForm.thu3.value == 0
							}

							summed19 = parseFloat(summed19 + thisForm.thu3.value);
						
			}
			
			if (isNaN(thisForm.fri3.value) || thisForm.fri3.value < 0)
			{
				alert("'" + thisForm.fri3.value + "' is not valid!  Please enter a valid number for your hours.");
				thisForm.fri3.value = 0;
				return false;
			}
			else
			{
							if(thisForm.fri3.value == null || thisForm.fri3.value == "")
							{
								thisForm.fri3.value == 0
							}

							summed20 = parseFloat(summed20 + thisForm.fri3.value);
						
			}
			
			if (isNaN(thisForm.sat3.value) || thisForm.sat3.value < 0)
			{
				alert("'" + thisForm.sat3.value + "' is not valid!  Please enter a valid number for your hours.");
				thisForm.sat3.value = 0;
				return false;
			}
			else
			{
							if(thisForm.sat3.value == null || thisForm.sat3.value == "")
							{
								thisForm.sat3.value == 0
							}

							summed21 = parseFloat(summed21 + thisForm.sat3.value);
						
			}
			
			summedTotal = parseFloat(summed1+summed2+summed3+summed4+summed5+summed6+summed7+summed8+summed9+summed10+summed11+summed12+summed13+summed14+summed15+summed16+summed17+summed18+summed19+summed20+summed21);
      timeTotal= summedTotal+summedTotal2+summedTotal3;
			
			thisForm.timeTotal.value = parseFloat(summedTotal);
			
			
}

function lockElement (form,element) {

	var submitted = 0;
        form.elements[element].disabled=true;
        form.submit();
        
}
function valNewPass(thisForm, str)
{

	var num;
	var newNum;
	num = thisForm.newpw.value
	
     
	if( num.length == 0 )
	{
		return false;
	}  

		if( (num.length <8 ) || str == "") 
		{
			alert("Your New Password must be at least 8 letters and/or numbers!  Please re-enter your password");
			thisForm.newpw.value = "";
			thisForm.newpw.focus();
			return false;
		}
	


 }
function valConfirmPass(thisForm, str)
{

	if( num.length == 0 )
	{
		return false;
	}  

	var num;
	var comparepw;
	
	num = thisForm.conpw.value
	comparepw =  thisForm.newpw.value
	     
			
		if( comparepw != num) 
		{
			
			alert("Your New Password and Confirm Password do not match!  Please re-enter your passwords.");
			thisForm.newpw.value = "";
			thisForm.conpw.value = "";
			thisForm.newpw.focus();
			return false;
		
		}
		
		else
		{
			newAccountVal(thisForm)
			return true;
		}
		


 }     

function valPhone(thisForm, str)
{

	var num;
	var newNum;
	num = thisForm.phone.value


    if( num != null && num != "" )
    {
       //--- Strip parens and dashes
       var re = /-/g;
       num = num.replace( re,"");
       re = /\(/g;
       num = num.replace( re,"");
       re = /\)/g;
       num = num.replace( re,"");
       re = / /g;
       num = num.replace( re,"");

    }   

    if( num.length == 0 )
	{
return false;
}  
	
     if(str == "")
     {
	if(!isNaN(num))
	{
		thisForm.account.disabled = true;
		
		if( (num.length != 10) && (num.substring(0,1) != "(") ) 
		{
			alert("'" + thisForm.phone.value + "' has to be 10 digits!  Please enter the Area Code and Number.");
		 	//thisForm.phone.value = "";
			thisForm.phone.focus();
	                thisForm.phone.select();
		 	
		}
		else
		{
			newNum = '(' + num.substring(0,3) + ')' + num.substring(3,6) + '-' + num.substring(6,10);
 			thisForm.phone.value = newNum;
 			
 		}
 	}
 	else
 	{
 		alert("'" + thisForm.phone.value + "' is not a number!  Please use numbers only");
 		//thisForm.phone.value = "";
		thisForm.phone.focus();
                thisForm.phone.select();
 		
 	}
   
 	
 	newAccountVal(thisForm)
     }
     else
     {
     
 	if(!isNaN(num))
	{
		
		if( (num.length != 10) && (num.substring(0,1) != "(") ) 
		{
			alert("'" + thisForm.phone.value + "' has to be 10 digits!  Please enter the Area Code and Number.");
		 	//thisForm.phone.value = "";
			thisForm.phone.focus();
	                thisForm.phone.select();

		 	return false;
		}
		else
		{
			newNum = '(' + num.substring(0,3) + ')' + num.substring(3,6) + '-' + num.substring(6,10);
 			thisForm.phone.value = newNum;
 			thisForm.account.disabled = false;
 		}
 	}
 	else  
 	{
 		alert("Please reenter number");
 		//thisForm.phone.value = "";
                thisForm.phone.focus();
                thisForm.phone.select();
 		return false;
 	}
  	
     }
     
 	
}


function newAccountVal(thisForm)
{
	

	var lenFirst;

	var lenLast;
	var lenStreet;
	var lenStreet2

	var lenCity;
	var valid;
	
	
	lenFirst = thisForm.newCF.value;

	lenLast = thisForm.newCL.value;
	lenStreet = thisForm.newCS.value;
	lenStreet2 = thisForm.newCSS.value;
	lenCity = thisForm.newCC.value;
	
		
	thisForm.account.disabled = false;
	

	if (lenFirst <= 1 || lenFirst == "")
	{
		thisForm.account.disabled = true;
		thisForm.newCF.value = "";
		return true;
	}
	else if (lenLast <= 1 || lenLast == "")
	{
		thisForm.account.disabled = true;
		thisForm.newCL.value = "";
		return true;
	}
	else if (lenStreet <= 1 || lenStreet == "")
	{
		thisForm.account.disabled = true;
		thisForm.newCSS.value = "none";
		return true;
	}
	else if (lenStreet2 <= 1 || lenStreet2 == "")
	{
		thisForm.account.disabled = true;
		return true;
	}	
	else if (lenCity <= 1 || lenCity == "")
	{
		thisForm.account.disabled = true;
		thisForm.newCC.value = "";
		return true;
	}	
	

	else if (thisForm.zp.value == "")
	{
		thisForm.account.disabled = true;
		return true;
	}
	

	else if (thisForm.phone.value == "")
	{
		thisForm.account.disabled = true;
		return true;
	}	

	else
	{
		//thisForm.account.disabled = false;
	}
	
		

}


function ccVal(thisForm) 
{  
        var ccn = thisForm.ccn.value;
        var len = ccn.length;  
	var isCCN = parseInt(ccn); 
	var count = 0;   
	var tfFlag = false;
	var calc; 


	if( ccn.length == 0 )
	{
		return false;
	}  

	
	


		if(isNaN(ccn))

	  {
		alert("Numbers Only Please!");
		tfFlag = false;
		isCCN=0;
		
	  }
	  
	if((len == 0) && (tfFlag))
	{  
  		tfFlag = false;
	}

	else
	{  
  		if(len >= 15 && len <=18)
  		{ 
    			for(var t=len;t>0;t--)
    			{  
      				calc = parseInt(isCCN) % 10;  
      				calc = parseInt(calc); 
      				count += calc;  
      				t--;  
      				isCCN = isCCN / 10;
      				calc = parseInt(isCCN) % 10;
      				calc = calc *2;                  
      		
      				switch(calc)
      				{
        				case 10: calc = 1; 
        				break;
        				
        				case 12: calc = 3; 
        				break;
        				
        				case 14: calc = 5; 
        				break;  
        				
        				case 16: calc = 7; 
        				break;     
        				
        				case 18: calc = 9; 
        				break;      
        				
        				default: calc = calc;      
      				}                                               
   			
   				isCCN = isCCN / 10;  
    				count += calc; 
  			} 
  		
  			if ((count%10)==0)
  			{  
    				tfFlag = true; 
  			} 
  			
  			else
  			{
    				tfFlag = false; 
    			}
  		}	
	}
	
	if(tfFlag) 
	{
  		thisForm.step3.disabled = false;
  		
  		if ((ccn.substring(0,2) == 34 || ccn.substring(0,2) == 37) && (ccn.length == 15))
  		{
  			thisForm.ccname.value="Amex";
  		
  		}
  		
  		else if ((ccn.substring(0,1) == 4) && (ccn.length == 16 || ccn.length == 13))

  		{
			thisForm.ccname.value="Visa";
  		}
   		
   		else if ((ccn.substring(0,2) == 51 || ccn.substring(0,2) == 55) && (ccn.length == 16))

  		{
			thisForm.ccname.value="MasterCard";
  		}
  		
  		else if ((ccn.substring(0,4) == 6011) && (ccn.length == 16))

  		{
			thisForm.ccname.value="Discover";
  		}
		
		else
		{
		}
		
  		
	}
	

	if(!tfFlag)
	{
	  	alert("Please Enter a Valid Credit Card Number!");
	  	thisForm.ccn.value="";
	  	thisForm.step3.disabled = true;
		thisForm.ccn.focus();
	}
	

	return tfFlag; 
	
}

function prefillShip(thisForm)
{

	thisForm.twelve.value = thisForm.two.value;
	thisForm.thirteen.value = thisForm.three.value;
	thisForm.fourteen.value = thisForm.five.value;
	thisForm.fifteen.value = thisForm.six.value;
	thisForm.sixteen.value = thisForm.seven.value;
	thisForm.seventeen.value = thisForm.eight.value;
	thisForm.eighteen.value = thisForm.nine.value;
	  
}

function processThisContactForm() {
    // SpamBot Handler
    // Change the form action to the real submission page
    document.getElementById('contactusform').action = "../../cgi-bin/apprtr.asp?a=xtcf";
    // Submit the form
    document.getElementById('contactusform').submit();
}
function checkPassword(password) { 
 
    var permutations = 0; 
 
    if (contains(password, numbers) > 0) { 
        permutations += 10; 
    } 
 
    if (contains(password, lower) > 0) { 
        permutations += 26; 
    } 
 
    if (contains(password, upper) > 0) { 
        permutations += 26; 
    } 
 
    if (contains(password, specialchar) > 0) { 
        permutations += specialchar.length; 
    } 
 
    // work out the total permutations 
    var totalPermutations = Math.pow(permutations, password.length); 
 
    // if the password is a commonPassArray password, then everthing changes... 
    if (isCommonPassArrayPassword(password)) { 
        totalPermutations = 75000 // about the size of the dictionary 
    } 
 
    // work out how long it would take to crack this (@ 200 attempts per second) 
    var timeInSeconds = (totalPermutations / 200) / 2; 
 
    // this is how many days? (there are 86,400 seconds in a day. 
    var timeInDays = timeInSeconds / 86400 
 
    // how long we want it to last 
    var lifetime = 365; 
 
    // how close is the time to the projected time? 
    var percentage = timeInDays / lifetime; 
 
    var lessRiskyPercentage = cap(Math.round(percentage * 100), 100); 
    if (totalPermutations != 75000 && lessRiskyPercentage < (password.length * 5)) { 
        lessRiskyPercentage += password.length * 5; 
    } 
 
    var progressBar = document.getElementById("progressBar"); 
    progressBar.style.width = lessRiskyPercentage + "%"; 
 
    if (percentage > 1) { 
        // strong password 
        progressBar.style.backgroundColor = "#3bce08"; 
        return; 
    } 
 
    if (percentage > 0.5) { 
        // reasonable password 
        progressBar.style.backgroundColor = "#ffd801"; 
        return; 
    } 
 
    if (percentage > 0.10) { 
        // weak password 
        progressBar.style.backgroundColor = "yellow"; 
        return; 
    } 
 
    // useless password! 
    if (percentage <= 0.10) { 
        // weak password 
        progressBar.style.backgroundColor = "red";
          progressBar.font = "weak";  
        return; 
    } 
 
 
} 
 
function cap(number, max) { 
    if (number > max) { 
        return max; 
    } else { 
        return number; 
    } 
} 
 
function isCommonPassArrayPassword(password) { 
 
    for (i = 0; i < commonPassArray.length; i++) { 
        var commonPassArrayPassword = commonPassArray[i]; 
        if (password == commonPassArrayPassword) { 
            return true; 
        } 
    } 
 
    return false; 
 
} 
 
function contains(password, validChars) { 
 
    count = 0; 
 
    for (i = 0; i < password.length; i++) { 
        var char = password.charAt(i); 
        if (validChars.indexOf(char) > -1) { 
            count++; 
        } 
    } 
 
    return count; 
} 

function preValThis(thisForm) {

three=/^[a-zA-Z0-9]{3}$/;
illeg=/^[`~!}[$%^&()+|\:"'?/><,-;{]{1,}$/;

if (three.test(thisForm.newpw.value))

	{
	alert(thisForm.newpw.value + 'Please Redo - you cannot have 3 consecutive numbers or letters');
	}

if (illeg.test(thisForm.newpw.value))

	{
	alert(thisForm.newpw.value + 'Please Redo - you may not use prohibited characters');
	}

}


/**
handles captcha ajax callback
*/
function captchaJS( theForm )
{
    
    //alert( "arr:  " + arr )
    //--- Create detail
    var url = "/cgi-bin/apprtr.asp?aj=captcha"
        
    //alert( url );
   // var doSub = false;
        
    try
    {
        new Ajax.Request( url, {
                             asynchronous : false,
                             method: "POST",
                             parameters : { id: 'captchaCheck',
                             recaptcha_challenge_field: document.getElementById( 'recaptcha_challenge_field' ).value,
                             recaptcha_response_field: theForm.recaptcha_response_field.value
                             }, 
                             onSuccess : function( request )
                                         {

			                                if( "false" == request.responseText )
			                                {
			                                    alert('You must correctly type text from image');
			                                    Recaptcha.reload();
			                                    theForm.recaptcha_response_field.focus();
			                                    
			                                }
			                                else
			                                {
			                                    theForm.captchaToken.value = request.responseText;
			                                    //postCaptchaSuccess( theForm, request );
			                                    doSub = true;
			                                }
                                         },
                               
                         onFailure :     function( request )
                                         {
                                            alert('You must correctly type text from image');
                                            Recaptcha.reload();
                                            theForm.recaptcha_response_field.focus();
                                         }
                           }
        );
        

    }
    catch( e )
    {
        alert( e.description );
    }

    //alert( doSub );
    return doSub;
    //alert( 'captcha complete' )
}




//--- SELECT LIST FUNCTIONS FOR CITIZEN SELECTION POPUP
function ADD_MEMBER_onclick( groupListStr )
{
    var groupList
    
    try
    {
	    groupList = eval( groupListStr )
	    
	    var resAry = null;
	    var args = new Array();
	    var inList
	
	    resAry = showModalDialog( "/cgi-bin/apprtr.asp?ax=gadmin&id=citselpopup&fieldname1=" + groupListStr ,
	            args,
	            "font-family:Verdana; font-size:12; dialogWidth:400px; dialogHeight:400px");
	
	    //alert( "resAry results:  " +  resAry.length )
	    
	    if( resAry )
	    {
	    
		    //--- Add items to groupList if not already there
		    for( i=0; i<resAry.length; i++ )
		    {
		        tmpCit = resAry[i]
		                        
		        //alert( "citizenID:  " + tmpCit[0] + " \nName:  " + tmpCit[1] );
		        
		        //--- find citizenid in list
		        inList = false
		        for( j=0; j<groupList.options.length; j++ )
		        {
		            if( tmpCit[0] == groupList.options[j].value )
		            {
		                inList = true;
		            }
		        }
		        if( inList == false )
		        {
		            //alert( 'add to options list' );
		            var k = groupList.options.length
		            
		            var newOpt = new Option( tmpCit[1], tmpCit[0] );
		            
		            groupList.options[ k ] = newOpt;
		                      
		        }
		        
		    }
		    //s = new String( arr["SelectedCitizenIDs"] )
		
		    //alert( s );

        }
    }
    catch( e )
    {
        alert( e.description )
    }

}


function REMOVE_MEMBER_onclick( groupListStr )
{

    var groupList
    
    try
    {

	    groupList = eval( groupListStr )
	
	    var remList = new Array()
	    var tmpIndex = 0
	
	    //--- Add items to groupList if not already there
	    for( i=groupList.length-1; i>=0; i-- )
	    {
	        if( groupList.options[i].selected )
	        {
	            //alert( groupList.options[i].value )   
	            remList[ tmpIndex ] = i
	            tmpIndex++;
	        }
	    }
	    
	    
	    //--- Add items to groupList if not already there
	    for( i=0; i<remList.length; i++ )
	    {
	        //alert( remList[i] )
	        groupList.options[ remList[i] ] = null; 
	    }
	
	
    }
    catch( e )
    {
        alert( e.description )
    }
    
}



function CREATE_onclick( groupListStr, groupHiddenStr )
{

    var groupList
    var groupHidden
        
    try
    {

//        alert( 'groupListStr:  ' + groupListStr )
//        alert( 'groupHiddenStr:  ' + groupHiddenStr )
        
        groupList = eval( groupListStr )
        groupHidden = eval( groupHiddenStr )

//        alert( "groupList: " + groupList )
//        alert( "groupHidden:  " + groupHidden )
        
 //       alert( groupList.options.length )
	    
	    for( i=0; i<groupList.options.length; i++ )
	    {
//	        alert( "adding:  " + groupList.options[i].value )
	        
	        if( i==0 ) 
	        {
	            groupHidden.value = groupList.options[i].value
	        }
	        else
	        {
	            groupHidden.value = groupHidden.value + "," + groupList.options[i].value
	        }
	    }
	
//	    alert( "groupHidden:  " + groupHidden.value );
    
    }
    catch( e )
    {
        alert( e.description )
    }

    
    return true


}


function strTrim( str )
{
    if( str )
        return str.replace(/^\s+|\s+$/g, '');
    else
        return "";
}



function onChangeMobileProvider( frmMobProv, formNumber )
{
    try
    {
        //alert( "onChangeMobileProvider" );

        //alert( formNumber.value )
        var smsNumber = formNumber.value
        var mobileProvider = frmMobProv.selectedIndex
        var mobileProviderVal = frmMobProv[ mobileProvider ].value;
        
        //alert( mobileProvider );
        //alert( mobileProviderVal );
        //alert( frm.mobileProvider.length );
        
        if( "other" == mobileProviderVal )
        {
            formNumber.maxLength = 100
            formNumber.size = 30
        }
        else
        {    
            formNumber.maxLength = 10
            formNumber.size = 12            
        }
        
    }
    catch( e )
    {
        alert( e.description )
    }
    
}


function onChangeSMSDeviceNumber( frmMobProv, formNumber )
{
    
    try
    {
        
        //alert( "onChangeSMSDeviceNumber" );
        //alert( formNumber.value )
        var smsNumber = formNumber.value
        var mobileProvider = frmMobProv.selectedIndex
        var mobileProviderVal = frmMobProv[ mobileProvider ].value;
        
        if( "other" != mobileProviderVal )
        {
            if( smsNumber.length > 0 )
            {
                //alert( smsNumber )
            
                if( isNaN( smsNumber )  )
                {
                    alert( "SMS device number should be 10 digits" )
                    //frm.email2.value = ""
                    formNumber.focus();
                    formNumber.select();

                    return false;

                }

                if( smsNumber.length != 10 )
                {
                    alert( "SMS device number should be 10 digits" )
                    formNumber.focus();
                    formNumber.select();
                    return false;
                }
                
            }
            else
            {
                //alert( "empty")
                //frm.email2.mobileProvider.selectedIndex = 0
            }       
        }

    }
    catch( e )
    {
        alert( e.description )
    }
    
    return true;

}




function testSMSOutbound( theid )
{

    //alert( theid );
    
    try
    {


        //var theButton = document.getElementById( "inboundMessageButtonSpan" )
        
        //var numUnreadMsgs = "0"
        
        //--- DO Call to get number of unread messages
        new Ajax.Request( "/cgi-bin/apprtr.asp?aj=eContingency", 
                    {
                         asynchronous : true,
                         method: "POST",
                         parameters : { id: 'testSMSMessage', 
                                        testID: theid 
                                       }, 
                         onSuccess : function( request ) {
                                           var tmpStr = request.responseText
                                           var idx = tmpStr.indexOf( ajSuccessToken );
                                           var retVal
                                           if( idx == 0 ) 
                                           {
                                               retVal = tmpStr.substr( ajSuccessToken.length, ( tmpStr.length-ajSuccessToken.length ) )
                                               //alert( "Result = '" + numUnreadMsgs + "'" )
                                           }
                                           else
                                           {
                                               retVal = ""
                                           }
                                           
                                           if( retVal.length > 0 )
                                           {
                                            alert( "A test message has been sent to:  \n\n" + retVal );
                                            }
                                            else
                                            {
                                                alert( "SMS Email Address Not Found!  \n\nPlease edit your General Settings to set your Mobile Device SMS Number." );
                                            }
                                           //alert( retVal );
                                       },
                         onFailure : function( request ) {
                           
                                        //$("sp_waiting").hide();
                                        //thisButton.disabled = false;
                                        alert( "An error ccured while creating/distributing your message!"   );
                                        //alert( request.responseText );
                                        //$(xyz).replace( request.responseText );
                                        //return false;
                                    }
                    }
        );
        
        
    }
    catch( e )
    {
        alert ( "Error:  " & e.description )
    }
    

}

  function addOptionSemanticonText( checkbox, selectbox,text,value)
  {

     
   
   var len = selectbox.length                 
//   alert( 'length:  ' + len );
//   alert( 'checked:  ' + checkbox.checked );
     
   //  if (checkbox.checked)
   //  {
   //  	alert( text )
   //  }
   
   
        var itemExists = false



   // add option
   if( checkbox.checked )
   {

      for(i=0; i<len; i++) 
      {
//         alert( 'i:  ' + i );
//         alert( 'option: ' + selectbox.options[i].value );
//         alert( 'compare text:  ' + text );

         if( selectbox.options[i].text == text ){

            itemExists = true;
         }

      }

//      alert( 'does item exist:  ' + itemExists );


      if( !itemExists ) 
      {
//       alert( "add option" );
         var optn = document.createElement("OPTION");
         optn.text = text;
         optn.value = value;
         selectbox.options.add( optn );
//       alert( "option added" );
      }

   }
   else  // remove option
   {

      for(i=0; i<len; i++) 
      {

         if( selectbox.options[i].text == text ){

            selectbox.options[i] = null;
         }

      }


   }


}
