var httppath = "http://63.99.79.104/"

function opener(page){
window.open(page, "popup", "location=no,menubar=no,resizable=no,width=525,height=400,scrollbars=yes");
}

function validateTextSize(element,size)
{
  if (element.value.length > size)
  {
    alert("You have exceeded " + size + " characters, which is the maximum number of characters allowed for this field.");
	element.focus();
	return false;
  }
  
  return true;
}

function swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function swapImage() { //v3.0
  var i,j=0,x,a=swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function findObj(n, d) { //v4.0
  var p,i,x;  
  if(!d) d=document; 
  if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; 
  for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); 
  return x;
}

function changeProp(objName,theProp,theValue) { //v3.0
  if(theValue == 'black'){
       newValue="#000000";}
  if(theValue == 'white'){
       newValue="#FFFFFF";}
  if(theValue == 'sidenav'){
       newValue="#b3b3b3";}
  if(theValue == 'grey'){
       newValue="#b3b3b3";}
  if(theValue == 'orange'){
       newValue="#FFBF00";}
  var obj = findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)) eval("obj."+theProp+"='"+newValue+"'");
}

function openPopup(doc,width,height,shouldScroll){
  if(!doc) return;
  doc = replaceSpace(doc);
  if(!width) var width = "";
  if(!height) var height = "";
  var isScrolling = (doc.indexOf(",")>-1||shouldScroll)?"yes,scrollbars=yes":"no";
  if(!shouldScroll)isScrolling = "no";
  var params = "location=no,menubar=no,resizable="+isScrolling+",width="+width+",height="+height;
  var windowObj = window.open(doc, "Popup", params);
  windowObj.focus();
}

function openForum(doc){
  if(!doc) return;
  doc = replaceSpace(doc);
  var params = "location=no toolbar=yes scrollbars=yes resizable=yes width=575 height=375";
  var windowObj = window.open(doc, "Popup", params);
  windowObj.focus();
}

function validateForm( sFormName ) {
  var oForm = eval("document."+sFormName);
  var aRequired = oForm.RequiredList.value.split(",");
  var nCount = 0;
  var pw = "";

    for( var i=0; i<aRequired.length; i++ ) {
      oField = eval("oForm." + aRequired[i]);
      bProblem = false;
      switch( oField.type ) {
        case "text":
              bProblem = (oField.value == "");
              break;
        case "textarea":
              bProblem = (oField.value == "");
              break;
        case "password":
              if( pw == "" && oField.value != ""){ pw = oField.value;}
                  bProblem = (oField.value == "" || oField.value != pw);
              break;
        case "select-one":
              bProblem = (oField.selectedIndex == 0) || oField.options[oField.selectedIndex].value == "";
              break;
        case "checkbox":
              bProblem = (oField.checked != true);
              break;
         default:
              bProblem = true;
              break;
      }
    	bProblem ? oField.style.background = 'red' : oField.style.background='white';
        nCount += bProblem;
    }
    return nCount == 0;
}

function replaceSpace(sString){
 if(!sString) return;
 return sString.replace(/\s/g,"%20");
}

function leaveSite(newURL){
var msg = "You have selected an option that will open a new browser window.\n\n" +
	      "To return to the Ryobi Tools website click File | Exit on the new browser window.\n\n" +
	      "To continue, click OK or click Cancel to return to www.RyobiTools.com.";
	      
 if (confirm(msg)){
  window.open(newURL);}
}

function submitCalendar(oForm,sMonth,sYear){
	oForm.MO.value = sMonth;
	oForm.YR.value = sYear;
	oForm.submit()
}

function submitLoginForm(oForm){
    sUser  = oForm.user.value  = oForm.user.value.replace(/\s/g,"");
    sPW    = oForm.pw.value    = oForm.pw.value.replace(/\s/g,"");
    if( sUser.length == 0 ) { alert("Name required"); return false; }
    if( sPW.length == 0 )   { alert("Password required"); return false; }
    return true;
}