// javascript includes

moQualify = (((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >= 3 )) || ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4 )))

function PreloadThis(img)
{
  if(document.images)
  {
    var a=new Image();
  }
  a.src=img;
  return a;
}

function MouseHandle(img, fm, msg)
{
  if(document.images)
  {
    document.images[fm].src=img;
  }
  status = msg;
  return true;
}

function go1()
{
  if (document.lookup1.product.options[document.lookup1.product.selectedIndex].value != "")
  {
    parent.location = document.lookup1.product.options[document.lookup1.product.selectedIndex].value
  }
}

function go2()
{
  if (document.lookup2.product.options[document.lookup2.product.selectedIndex].value != "")
  {
    parent.location = document.lookup2.product.options[document.lookup2.product.selectedIndex].value
  }
}

function go3()
{
  if (document.lookup3.product.options[document.lookup3.product.selectedIndex].value != "")
  {
    parent.location = document.lookup3.product.options[document.lookup3.product.selectedIndex].value
  }
}

function openpage(page,w,h)
{
  var options = 'width='+w+',height='+h;
  colleges = window.open(page,"colleges",options);
  colleges.window.focus();
}


function openimagewindow(image, windowTitle, fontcolor)
{
		lrgimg = window.open("","lrgimgwin","width=250, height=250, scrollbars=0");
		lrgimg.moveTo(100,100)
		lrgimg.document.write("<html><title>" + windowTitle +"</title><body leftmargin='0' topmargin='0' marginheight='0' marginwidth='0' bgcolor='#ffffff' onload='self.resizeTo(document.popwindow.width+22,document.popwindow.height+60)'>")
		lrgimg.document.write("<table align='center' border='0' cellpadding='0' cellspacing='0'><tr><td><img src='../spirit/graphics/single_pixel.gif' width='1' height='5' alt='' border='0'></td></tr>")
		lrgimg.document.write("<tr><td align='right'><a href='' onclick='javascript:self.close()'><font size='2' color='" + fontcolor + "' face='arial'><B>Close window</B></font></a></td></tr>")
		lrgimg.document.write("<tr><td align='center'><img src='../spirit/graphics/single_pixel.gif' width='1' height='8' alt='' border='0'><br><img src='" + image + "' name='popwindow'></td></tr>")
		lrgimg.document.write("</table></body></html>")
		lrgimg.document.close()
		lrgimg.focus()
}

//----------------------------------------------------------------------------------
//
// mOvr(src,clrOver) - called from mouseover event to change pointer to a hand and
//                     to change the color of the mouseovered item to the specified
//                     color.
//
//----------------------------------------------------------------------------------
var alreadyclicked = 0;

function mOvr(src,clrOver)
{
  if (!src.contains(event.fromElement))
  {
    if (alreadyclicked == 0)
    {
      src.style.cursor = 'hand';
    }
    src.bgColor = clrOver;
  }
}

function mOut(src,clrIn)
{
  if (!src.contains(event.toElement))
  {
    if (alreadyclicked == 0)
    {
      src.style.cursor = 'default';
    }
    src.bgColor = clrIn;
  }
}

function mClk(src)
{
  if(event.srcElement.tagName=='TD')
  {
    //prompt(src.children.tags('A')[0]);
    alreadyclicked = 1;
    src.children.tags('A')[0].click();
    //src.style.cursor = 'busy';
  }
}

//-------------------------------------------------------------------------------------------------
//
// update_form(formname, formtask, misc, block) - called from mouseover event to submit a form with
//                                                the specified form name but first will update the
//                                                value of the hidden form element 'Task' and the
//                                                values of the hidden form elements 'Misc' and
//                                                'Block' if they are specified.
//
//-------------------------------------------------------------------------------------------------
function update_form(formname, formtask, misc, misc2, misc3, misc4, misc5, misc6, misc7)
{
  if (formtask)
  {
    document[formname].elements.Task.value=formtask;
  }
  if (misc)
  {
    document[formname].elements.Misc.value=misc;
  }
  if (misc2)
  {
    document[formname].elements.Misc2.value=misc2;
  }
  if (misc3)
  {
    document[formname].elements.Misc3.value=misc3;
  }
  if (misc4)
  {
    document[formname].elements.Misc4.value=misc4;
  }
  if (misc5)
  {
    document[formname].elements.Misc5.value=misc5;
  }
  if (misc6)
  {
    document[formname].elements.Misc6.value=misc6;
  }
  if (misc7)
  {
    document[formname].elements.Misc7.value=misc7;
  }
  document[formname].submit();
}

function send_form(formaction)
{
  document.forms.main.action=formaction;
  document.main.submit();
}

function submit_form(formname)
{
  document[formname].submit();
}

var windowNameArray = null
var windowPntrArray = null
var browserType = "Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)"

function launchWindow( url, HT, WD )
{
  var windowOptions
  var myLocation = url
  var WN = "newWindow"
  var AR = "yes"
  var TB = "no"
  var LC = "no"
  var SB = "no"
  var DR = "no"
  var ST = "no"
  var MB = "no"
  var RS = "yes"
  var CH = "yes"
  switch( arguments.length )
  {
    case 16:
    case 15:
    case 14:
    case 13: CH = arguments[12];
    case 12: RS = arguments[11];
    case 11: MB = arguments[10];
    case 10: ST = arguments[9];
    case  9: DR = arguments[8];
    case  8: SB = arguments[7];
    case  7: LC = arguments[6];
    case  6: TB = arguments[5];
    case  5: AR = arguments[4];
    case  4: WN = arguments[3];
  }

  windowOptions  = "height="
  windowOptions += HT
  windowOptions += ",width="
  windowOptions += WD
  windowOptions += ",alwaysRaised="
  windowOptions += AR
  windowOptions += ",toolbar="
  windowOptions += TB
  windowOptions += ",location="
  windowOptions += LC
  windowOptions += ",scrollbars="
  windowOptions += SB
  windowOptions += ",directories="
  windowOptions += DR
  windowOptions += ",status="
  windowOptions += ST
  windowOptions += ",menubar="
  windowOptions += MB
  windowOptions += ",resizable="
  windowOptions += RS
  windowOptions += ",copyhistory="
  windowOptions += CH
  if( ! windowNameArray )
  {
    windowNameArray = new Array()
    windowPntrArray = new Array()
  }
  for( index=0; index < windowNameArray.length; ++index )
  {
    if( windowNameArray[index] == WN )
    {
      break
    }
  }

  var msieBrowser = navigator.appName.indexOf("Microsoft") != -1
  if( ! windowPntrArray[index] || windowPntrArray[index].closed  )
  {
    windowNameArray[index] = WN
    windowPntrArray[index] = window.open( myLocation, WN ,windowOptions )
  }
  else
  {
    if( msieBrowser )
    {
      windowPntrArray[index].close()
      while( ! windowPntrArray[index].closed )
      {
      }
      windowPntrArray[index] = window.open( myLocation, WN ,windowOptions )
    }
    else
    {
      windowPntrArray[index].focus()
    }
  }
}

function openmodule(filename)
{
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4 ))
  {
    //alert('popup qulified');
    var popupQualify = 1;
  }
  else
  {
   // alert('popup not qualified');
    var popupQualify = -1;
  }

  //var NN = (document.layers ? true : false);
  if ( popupQualify != 1 )
  {
    var options = 'width=400,height=300';
    forgotpassword = window.open('filename.html','filename',options);
    forgotpassword.window.focus();
  }
  else
  {
    dialogoptions  = 'dialogHeight:300px;'
    dialogoptions += 'dialogWidth:400px;'
    dialogoptions += 'scroll:no;'
    dialogoptions += 'status:no;'
    dialogoptions += 'help:no;'
    dialogoptions += 'edge:raised;'
    dialogoptions += 'center:yes;'
    window.showModalDialog('filename.html','', dialogoptions);
  }
}

function toggle_display_state(curobj)
{
  if (curobj)
  {
    if (document.getElementById(curobj).style.display=="none")
    {
      document.getElementById(curobj).style.display="block";
    }
    else
    {
      document.getElementById(curobj).style.display="none";
    }
  }
}

function LmOver(elem, clr)
{   elem.style.backgroundColor = clr;
/*  elem.children.tags('A')[0].style.color = "#f0f0f0"; */
/*  document.getElementById(elem).style.color = "#f0f0f0"; */
    elem.style.cursor = 'hand';
}


function LmOut(elem, clr)
{elem.style.backgroundColor = clr;
/* elem.children.tags('A')[0].style.color = "#f0f0f0"; */
}

function LmDown(elem, clr)
{elem.style.backgroundColor = clr;
/* elem.children.tags('A')[0].style.color = "#f0f0f0";} */
}

function LmUp(path)
{location.href = path;}

function check_signup (formpassed)
{
    var result_validate = validate_signup(formpassed);
    var result_card = CheckCardNumber(formpassed);
    // alert ('result_validate: ' + result_validate);
    // alert ('result_card: ' + result_card);
    if ((result_validate) && (result_card))
    {
        return true;
    }
    else
    {
        return false;
    }
}
function check_seminar (formpassed)
{
    var result_validate = validate_seminar(formpassed);
    var result_card = 1;
    with (formpassed)
    {
        //alert (seminar_charge.value);
        if (seminar_charge.value == 'no cost')
        {
            //alert ('skip cc check');
        }
        else
        {
            //alert ('perform cc check');
            
            if (validate_required(CardName,"Name on Card must be completed.")==false)
            {CardName.focus();return false;}

            result_card = CheckCardNumber(formpassed);
        }
    
    }
    
    // alert ('result_validate: ' + result_validate);
    // alert ('result_card: ' + result_card);
    if ((result_validate) && (result_card))
    {
        return true;
    }
    else
    {
        return false;
    }
}

function validate_sendfile(thisform)
{
    with (thisform)
    {
        if (validate_required(name,"name must be completed.")==false)
        {name.focus();return false;}
        if (name.value == "enter name")
        {name.focus();return false;}

        if (validate_email(email,"check your email.")==false)
        {email.focus();return false;}
        
        if (email.value == "enter email address")
        {email.focus();return false;}
    }
}
function validate_newsletter(thisform)
{
    with (thisform)
    {
        if (validate_required(name,"name must be completed.")==false)
        {name.focus();return false;}
        if (name.value == "enter name")
        {name.focus();return false;}

        if (validate_email(email,"check your email.")==false)
        {email.focus();return false;}
        
        if (email.value == "enter email address")
        {email.focus();return false;}
    }
}
function validate_signup(thisform)
{
    with (thisform)
    {
        if (validate_required(first_name,"first name must be completed.")==false)
        {first_name.focus();return false;}

        if (validate_required(last_name,"last name must be completed.")==false)
        {last_name.focus();return false;}

        if (validate_email(email,"check your email.")==false)
        {email.focus();return false;}

        if (validate_checkbox(accept_terms,"Please review and accept the terms of service and privacy policy.")==false)
        {accept_terms.focus();return false;}
        return true;
    }
}
function validate_seminar(thisform)
{
    with (thisform)
    {
        if (validate_required(first_name,"first name must be completed.")==false)
        {first_name.focus();return false;}

        if (validate_required(last_name,"last name must be completed.")==false)
        {last_name.focus();return false;}

        if (validate_required(organization_name,"organization must be completed.")==false)
        {organization_name.focus();return false;}


        if (validate_required(phone,"phone must be completed.")==false)
        {phone.focus();return false;}

        if (validate_email(email,"check your email.")==false)
        {email.focus();return false;}

        return true;
    }
}
function validate_getstarted(formpassed)
{
    var result_validate = validate_getstarted_top(formpassed);
    var result_card = 1;
    with (formpassed)
    {
        if ((email_options[0].checked) || (start_blog[0].checked) || (start_recordit[0].checked))
        {
            result_card = CheckCardNumber(formpassed);

            if (validate_checkbox(accept_terms,"Please review and accept the terms of service and privacy policy.")==false)
            {accept_terms.focus();return false;}
        }
        else
        {
            // alert ('no need to check');
            // alert ('start_blog.checked: ' + start_blog[0].checked);
        }
    }
    // alert ('result_validate: ' + result_validate);
    // alert ('result_card: ' + result_card);
    if ((result_validate) && (result_card))
    {
        // alert ('submit form');
        return true;
    }
    else
    {
        return false;
    }
}
function validate_getstarted_top(thisform)
{
    with (thisform)
    {
        if (validate_required(first_name,"first name must be completed.")==false)
        {first_name.focus();return false;}

        if (validate_required(last_name,"last name must be completed.")==false)
        {last_name.focus();return false;}

        if (validate_email(email,"check your email.")==false)
        {email.focus();return false;}

        return true;
    }
}

function validate_required(field,alerttxt)
{
    with (field)
    {
        if (value==null||value=="")
        {
            alert(alerttxt);return false;
        }
        else
        {
            return true;
        }
    }
}
function validate_email(field,alerttxt)
{
    with (field)
    {
        apos=value.indexOf("@");
        dotpos=value.lastIndexOf(".");
        if (apos<1||dotpos-apos<2) 
          {alert(alerttxt);return false;}
        else {return true;}
    }
}
function validate_checkbox(field,alerttxt)
{
    with (field)
    {
        if (checked)
        {
            return true;
        }
        else
        {
            alert(alerttxt);return false;
        }
    }
}