function checkKeywordValue(formObj)
{
    keywordString = formObj.Keyword.value;
    if (keywordString.length <= 1)
    {
        alert ("You must enter two or more characters");
        return (false);
    }
    else
    {
        return (true);

    }
}

function checkPowerSearchValue(formObj)
{

      Model = formObj.Model.value;
    if (formObj.TypeID[formObj.TypeID.selectedIndex].text == "[Not Specified]" && Model <= 1 && formObj.ManufacturerID[formObj.ManufacturerID.selectedIndex].text == "[Not Specified]" )
    {
        alert ("Please specify a type of equipment, a manufacturer, or a model to proceed.");
          return (false);
      }

    else
    {
        return (true);

    }
}

function checkEmailValues(formObj)
{
    Name = formObj.Name.value;
    Email = formObj.Email.value;
    EmailConfirmation = formObj.EmailConfirmation.value;

    Comment = formObj.Comment.value;

    if (Name.length < 1)
    {
        alert ("Name, E-mail, E-mail Confirmation and Comment are required fields");
        return (false);
    }
    else if (Email.length < 1)
    {
        alert ("Name, E-mail, E-mail Confirmation and Comment are required fields");
        return (false);
    }
    else if (Email!= EmailConfirmation)
    {
        alert ("E-mail and E-mail confirmation must be the same");
        return (false);
    }
    else if (Comment.length < 1)
    {
        alert ("Name, E-mail, E-mail Confirmation and Comment are required fields");
        return (false);
    }
    else
    {
        return (true);
    }
}

function addBookmark()
{
    if(navigator.appName == "Netscape")
    {
        alert("Press Ctrl+D to create a bookmark in netscape");
    }
    else
    {
        window.external.AddFavorite('http://usediron.point2.com',"Point2 UsedIron");
    }
}


function dolaunch(url)
{
    location.href=url
}

function popwindow(src, name, toolbar, status, scrollbars, location, width, height, resizable, menubar, left, top)
{
    popWindow = window.open(src, name,"toolbar="+toolbar+",status="+status
                            +",scrollbars="+scrollbars+",location="+location
                            +",width="+width+",height="+height
                            +",resizable="+resizable+",menubar="+menubar
                            +",left="+left+",top="+top);
    if (popWindow.focus)
    {
        popWindow.focus();
    }
}

// sets the options for a select box, from an array
// @param theSelect the select box to fill
// @param theValues the array of Option objects to use

function setSelectOptions(theSelect, theValues)
{
    // remove old options from theSelect
    for(i=theSelect.options.length; i>=theValues.length; i--) {
        theSelect.options[i] = null;
    }

    // populate theSelect with theValues
    for(i=0; i<theValues.length; i++) {
        theSelect.options[i] = new Option(theValues[i][0], theValues[i][1], false, false);
    }
}

function cloneObject(what) {
    for (i in what) {
        this[i] = what[i];
    }
}

// Selects all of the checkboxes for a given form
// @param theForm the form to select all checkboxes for
function selectAllCheckboxes(theForm)
{
    for (i = 0; i < theForm.elements.length; i++)
    {
        if (theForm.elements[i].type == 'checkbox')
        {
            theForm.elements[i].checked = true;
        }
    }
}

// Deselects all of the checkboxes for a given form
// @param theForm the form to deselect all checkboxes for
function deselectAllCheckboxes(theForm)
{
    for (i = 0; i < theForm.elements.length; i++)
    {
        if (theForm.elements[i].type == 'checkbox')
        {
            theForm.elements[i].checked = false;
        }
    }
}

//check at least one checkbox is checked.
function checkAtLeastOneSelected(theForm){

    for (i = 0; i < theForm.elements.length; i++)
    {
        if (theForm.elements[i].type == 'checkbox')
        {
	    if (theForm.elements[i].checked) 
	    {
		return true;
	    }
        }
    }
    //no checkbox is checked.
    alert("You must select at least one check box to proceed.");
    return false;
};

// Converts the values from a set of checkboxes into a comma delimted string.
// If no checkboxes have been checked, returns "''".
//
// @param theForm a form that has checkboxes
function compressToString(theForm)
{
    var string = "''";
    
    if (theForm == null)  return "''";
    
    for (i = 0; i < theForm.elements.length; i++)
    {
        if (theForm.elements[i].type == 'checkbox' && theForm.elements[i].checked == true && theForm.elements[i].value)
        {
            string += "," + theForm.elements[i].value;
        }
    }
    
    // Remove extra comma.
    if (string != "''") string = string.substr(1);
    
    return string;
}

// Converts the values from a set of checkboxes into a Tilda delimted string.
// If no checkboxes have been checked, returns "''".
//
// @param theForm a form that has checkboxes
function compressToStringTildSeperator(theForm)
{
    var string = "''";
    
    if (theForm == null)  return "''";
    
    for (i = 0; i < theForm.elements.length; i++)
    {
        if (theForm.elements[i].type == 'checkbox' && theForm.elements[i].checked == true && theForm.elements[i].value)
        {
            string += "~" + theForm.elements[i].value;
        }
    }
    
    // Remove extra comma.
    if (string != "''") string = string.substr(1);
    
    return string;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//Returns the value of the url parameter you specify
function getURLParam( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
  	results[1] = results[1].replace(/%20/, " ");
    return results[1];
}

//Gets the news source for the blog
function GetBlogPosts(num)
{
	//Looping vars
	var iPost = num;
	var maxPosts = blogPosts.length;
	
	var currentPost = blogPosts[iPost]
	
	//post information
	var title = currentPost[0];
	var url = currentPost[1];
	var publishedDate = currentPost[2];
	var desc = currentPost[3];
	
	//Set the published Date
	var dateStamp = document.getElementById("dateStamp");
	dateStamp.innerHTML = "<span class=\"nowrap\">" + publishedDate + "</span>";
	//Set the title
	var blogHeadline = document.getElementById("blogHeadline");
	blogHeadline.innerHTML = "<span class='headlineTitle'>" + "<a href=" + url + ">" + title + "</a>" + "</span> <a href=" + url + ">" + desc + "</a>" +
							 "<img src=\"/Xhtml/Images/Ticker/goToBlogArrow.gif\" alt=\"Read Blog Post\" width=\"18\" height=\"9\" />" + 
							 " " + (iPost + 1) + " of " + maxPosts;
	
	//Go to the next post
	iPost += 1
	
	//If we're at the last, reset the loop
	if(iPost == maxPosts)
	{
		iPost = 0
	}
	
	//Callback to start the function again, 6 second iteration
	window.setTimeout("GetBlogPosts(" + iPost + ")", 6000);
}

//Reloads the iFrame for the Just Listed Ads
function reloadFrame()
{
	frame = document.getElementsByName("justListedFrame")[0];
	frame.src = "Equipment/ByJustListed.html?printable=yes&frames=yes&Top=" + 
				Math.round(Math.random()*19);
	setTimeout("reloadFrame()", 8000);
}

//Function to ensure 2 email addresses are identical, before submission occurs.
function assertEmailsMatch(form)
{
	var email1 = form.Email.value;
	var email2 = form.Email2.value;
	
	if(email1 == email2)
	{
		return true;
	}
	else
	{
		//Show the Error Message
		document.getElementById("ConfirmationError").style.display = 'block';
		return false;	
	}
}

//Parses specific GET parameters.
function returnGetParam( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

//Function to redirect the user to a page after a given amount of time
function redirectTo(location)
{
	window.location=location;		
}
