/* AUTOCOMPLETE CONFIGURATION */
//DataSource
var myServer = "./autocomplete.aspx";
//var mySchema = ["ResultItem", "KeyDataField"];
var myDataSource = new YAHOO.widget.DS_XHR(myServer, ["\n", "\t"]);
this.myDataSource.responseType = YAHOO.widget.DS_XHR.TYPE_FLAT;
//AutoComplete
var myAutoComp = new YAHOO.widget.AutoComplete("SearchTerm","container", myDataSource);
myAutoComp.queryDelay = 0;
myAutoComp.minQueryLength = 3;
myAutoComp.autoHighlight = false;
myAutoComp.animSpeed = 0.3;
myAutoComp.animVert = true;
myAutoComp.animHoriz = false;
myAutoComp.useShadow = true;
myAutoComp.prehighlightClassName = "yui-ac-prehighlight";

myAutoComp.formatResult = function(oResultItem, sQuery)
{
	var title = oResultItem[0];
	var url = oResultItem[1];
	var sMarkup;		
	//myAutoComp.setFooter("<span id='sitesearchshowall'>View all search results</span>");
	if(url == "None")
	{
		sMarkup = "No results found.";
		myAutoComp.setFooter("");
	}
	else
	{
		//sMarkup = "<a style='text-decoration:none;' href='" + url + "'>" + title + "</a>";
		//myAutoComp.setFooter("<a id='sitesearchshowall' style='text-decoration:none;' href='#'>To view all other search results, click on the GO button</a>");
		myAutoComp.setFooter("<a id='sitesearchshowall' style='text-decoration:none;' onClick='javascript:viewAll();' href='#'>View all other search results</a>");
		sMarkup = title;
	}
	document.getElementById('loading-gif').style.visibility = 'hidden';
	return (sMarkup);
}

  /* What do we want to do when an item in the suggestion container
	   is selected (either by arrowing and hitting enter or by clicking)?
	   We'll subscribe to the itemSelectEvent and when it fires use its
	   arguments to set a new location for the current page. */
	myAutoComp.itemSelectEvent.subscribe(function(type, args) {
 		/* this line works around Opera's preventDefault
 		   bug: */
 		YAHOO.util.Dom.get("gobtn").disabled = true;
 		
 		/* now, we go off to the destination page chosen by
 		   the user from the AutoComplete suggestion list: */
 		 if (args[2][1] != 'None')
 		 {
 		   location.href = (args[2][1]);
     }	
 	});

  /* Here's the wiring for the form submission on our footer link.
     Note that we use the YUI Event Utility to add this listener --
     this is part of YUI Core. */
  //YAHOO.util.Event.on("sitesearchshowall", "click", function(e) {
  	 /* The Dom Collection's get method is similar to
  		document.getElementById in this instance: */
  //	 YAHOO.util.Dom.get("Form").submit();
  	 //document.getElementById("Form").submit();
  //	 searchTerm = document.getElementById("SearchTerm").value;
  //	 searchTerm = searchTerm.replace(" ", "+");
  //	 location.href = 'http://www.abacus24-7.com/search.aspx?SearchTerm=' + searchTerm;
  //});
myAutoComp._updateValue = function() {
	return true;
}

function viewAll()
{
  searchTerm = document.getElementById("SearchTerm").value;
  //searchTerm = searchTerm.replace(" ", "+");
  searchTerm = searchTerm.replace(/ /g, "+");
  location.href = 'http://www.abacus24-7.com/search.aspx?SearchTerm=' + searchTerm;
}
          
// IFrame workaround for IE
//var ua = navigator.userAgent.toLowerCase();
//if(ua.indexOf('msie') != -1 && ua.indexOf('opera') < 0) 
//{
//this.myAutoComp.useIFrame = true;
//YAHOO.util.Dom.get("useiframe").checked = true;
//}				 					
/* END OF AUTOCOMPLETE CONFIGURATION */

/* jQuery events*/
/*$().ready(function() {
	$("#Form2").submit(function (){
		if( $("#SearchTerm2").val() == "")
		{
			alert('Please enter at least 3 characters in the search field!');
			return false;
		}
		else
		{							
			$("#SearchTerm2").attr({
			id: "SearchTerm",
			name: "SearchTerm"
			})
			return true;
		}
	});
	$("#searchrollbig").click(function () {
	  $("#SearchTerm2").attr({
		id: "SearchTerm",
		name: "SearchTerm"
	  })
	  $("#Form2").submit();
	}).mouseover(function() {
	  $("#searchrollbig").css({"cursor":"pointer"});
	  $("#searchrollbig").attr({
		src: "images/bigsearchon.jpg"
	  })
	}).mouseout(function(){
	  $("#searchrollbig").css({"cursor":"default"});
	  $("#searchrollbig").attr({
		src: "images/bigsearchoff.jpg"
	  })
	}); 	
});
*/
/* end of jQuery events */

$().ready(function() {
  $("#Form2").submit(function (){
  		if( $("#SearchTerm2").val() == "")
  		{
  			alert('Please enter at least 3 characters in the search field!');
  			return false;
  		}
  		else
  		{							
  			$("#SearchTerm2").attr({
  			id: "SearchTerm",
  			name: "SearchTerm"
  			})
  			return true;
  		}
  	});
    $("#searchroll").click(function () {
      $("#Form").submit();
    }).mouseover(function() {
      $("#searchroll").css({"cursor":"pointer"});
      $("#searchroll").attr({
        src: "images/go-on.jpg"
      })
    }).mouseout(function(){
      $("#searchroll").css({"cursor":"default"});
      $("#searchroll").attr({
        src: "images/go-off.jpg"
      })
    });
    
    $("#searchrollbig").click(function () {
      $("#Form2").submit();
    }).mouseover(function() {
      $("#searchrollbig").css({"cursor":"pointer"});
      $("#searchrollbig").attr({
        src: "images/bigsearchon.jpg"
      })
    }).mouseout(function(){
      $("#searchrollbig").css({"cursor":"default"});
      $("#searchrollbig").attr({
        src: "images/bigsearchoff.jpg"
      })
    });
});
          
function bookmark() {
	var title=document.title;
	var url=location.href;
	if (window.sidebar) window.sidebar.addPanel(title, url,"");
  else if( window.opera && window.print ) {
  	var mbm = document.createElement('a');
  	mbm.setAttribute('rel','sidebar');
  	mbm.setAttribute('href',url);
  	mbm.setAttribute('title',title);
  	mbm.click();
  }
	else if( document.all ) 
    window.external.AddFavorite( url, title);
  }
function bookmark1() {
	var title='Abacus24-7 Printer Ink Cartridges & Electronic Accessories';
	var url='http://www.abacus24-7.com';
	if (window.sidebar) window.sidebar.addPanel(title, url,"");
  else if( window.opera && window.print ) {
  	var mbm = document.createElement('a');
  	mbm.setAttribute('rel','sidebar');
  	mbm.setAttribute('href',url);
  	mbm.setAttribute('title',title);
  	mbm.click();
  }
	else if( document.all ) window.external.AddFavorite( url, title);
}

/*
Random Image Link Script
*/
function random_imglink(){
  var myimages=new Array()
  //specify random images below. You can have as many as you wish
  myimages[1]="images/image-1.jpg"
  myimages[2]="images/image-2.jpg"
  myimages[3]="images/image-3.jpg"
  myimages[4]="images/image-4.jpg"
  myimages[5]="images/image-5.jpg"
  //specify corresponding links below
  var imagelinks=new Array()
  imagelinks[1]="listByOEM.aspx?navid=10106"
  imagelinks[2]="listByOEM.aspx?navid=10178"
  imagelinks[3]="listByOEM.aspx?navid=10089"
  imagelinks[4]="listByOEM.aspx?navid=10125"
  imagelinks[5]="driver.aspx?topic=printer-ink_ink-cartridges_toner-cartridges_inkjet-cartridges"
  var ry=Math.floor(Math.random()*myimages.length)
  if (ry==0)
     ry=1
     document.write('<a href='+'"'+imagelinks[ry]+'"'+'><img src="'+myimages[ry]+'" border=0></a>')
}