function reset(){
document.gift.pselect.value = 1;
document.gift.pfrom.value = 1;
document.gift.pto.value = 350;
document.gift.tselect.value = "";
}


function picselect(name,src) {
document[name].src=src;
}


      var currObg;              // stores the current object being manipulated (leftSlider or rightSlider object)
      var leftPos = 0;          // the current left position after mouse is released
      var rightPos = 400;       // the current right position after mouse is released
      var sliderWidth = 7;      // the width of the sliders (includes borders)
      var sliderBarWidth = 410; // the width of the slider bar (does not include borders)
      var mouseStart = -99999   // an arbitrary number used to show that it is the first time we are hitting the moveSlider1 function.
      var pos;                  // position with offset used during the move 
      var min = 1;            // minimum value of the data 
      var max = 350;            // maximum value of the data

      /* funciton moveSlider(obj)
           parameter obj - object reference to the calling object
         This function sets the resets the starting mouse position and sets the document 
         methods used to watch for mouse events.
      */
      function moveSlider(obj) {
        mouseStart = -99999;   // set the beginning mouse position to an unlikely number.
        currObj = obj;         // set the currObj variable to the object that was clicked
        document.onmousemove = moveSlider1; // set the onmousemove method to the function that moves the slider
        document.onmouseup = moveDone;   // set the onmouseup method to the function that stops listening for the mousemove and reclaculates the data
      }
     
      /* function moveslider1
         This function is called by the mousemove event
         checks the current mouse position and compares it 
         to the mouse position when the move was started.
         uses the difference as an offset from the slider's
         staring position to move the slider with the mouse
      */
      function moveSlider1(e){
        if (!e) var e = window.event;  // if IE, then we need to assign e
        if (e.pageX) posX = e.pageX;   // FF, opera, netscape
        else if (e.clientX) {          // IE
          posX = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;  
        }
        if (mouseStart == -99999) mouseStart = posX;  // -99999 is an arbitrary number.  It is unlikely to be hit 
        var offset = posX - mouseStart; // determine the difference from where the mouse started to where it is now
        if (currObj.id=="sliderLeft") {  // If we are moving the left slider
          pos = leftPos + offset;        // the new position should be the current left position + the offset
          if (pos < 0) pos = 0;          // if this makes the left position less than 0 then use 0
          if (pos > rightPos - sliderWidth) pos = rightPos - sliderWidth; // if the position would put us past the right slider then move up to the right slider
          document.getElementById('pfrom').value = Math.round(pos/sliderBarWidth * (max-min) + min); // put the new left position in a text box to be viewed. (this is not required)
          document.getElementById('leftX').innerHTML = "$"+Math.round(pos/sliderBarWidth * (max-min) + min); // put the new left position in a text box to be viewed. (this is not required)

        }
        else {
          pos = rightPos + offset   // the new position should be the current right position + the offset
          if (pos < leftPos + sliderWidth) pos = leftPos + sliderWidth;  // if the new position would take us past the left slider then move next to the left slider
          if (pos > sliderBarWidth ) pos = sliderBarWidth ;  // if the new position is past the end of the bar, position at the end of the bar.
          document.getElementById('pto').value = Math.round(pos/sliderBarWidth * (max-min) + min);  // put the new right position in a text box to be viewed. (this is not required)
          document.getElementById('rightX').innerHTML = "$"+ Math.round(pos/sliderBarWidth * (max-min) + min);  // put the new right position in a text box to be viewed. (this is not required)

        }        
        currObj.style.left = pos + "px";  // move the slider to the new position
      }
     
      /* function moveDone()
         sets the current left/right position memory variable.
         clears the mouse monitoring methods.
         Calls the function to recaculate the data
      */
      function moveDone(e) {
        if (currObj.id == "sliderLeft") leftPos = pos;    // set the current left position to the value of pos
        else rightPos = pos;                              // set the current right position to the value of pos
        document.onmousemove = function() {};             // stop listening for a mousemove event
        document.onmouseup = function() {};               // stop listening for a mouseup event
      }



///////////////////////////////////////////////////////////////////////////////////////

function stopRKey(evt) {
	var evt  = (evt) ? evt : ((event) ? event : null);
	var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
	if ((evt.keyCode == 13) && (node.type=="text")) { return false; }

}
document.onkeypress = stopRKey;

///////////////////////////////////////////////////////////////////////////////////////

function slider(price) {
	document.getElementsByTagName('body')[0].id="home"+price;
	document.gift.pselect.value=price;
}

function cattype(cat) {

	var lvalue = document.getElementById('pfrom').value;
	var rvalue = document.getElementById('pto').value;
	document.gift.tselect.value=cat;

	if(cat == "him"){
          var parm = "?tselect=him&pto="+rvalue+"&pfrom="+lvalue;
 	  document.getElementById("cathim").innerHTML="<a href=\"javascript:cattype('him');\"><img name=\"him\" src=\"img/forhim2.gif\" width=\"135\" height=\"150\" border=\"0\" onmouseover=\"picselect('him','img/forhim1.gif')\" onmouseout=\"picselect('him','img/forhim2.gif')\" /></a>";

          document.getElementById("cather").innerHTML="<div align=\"right\"><a href=\"javascript:cattype('her');\"><img name=\"her\" src=\"img/forher.gif\" width=\"135\" height=\"150\" border=\"0\" onmouseover=\"picselect('her','img/forher1.gif')\" onmouseout=\"picselect('her','img/forher.gif')\" /></a></div>";
          document.getElementById("catconnoisseur").innerHTML="<a href=\"javascript:cattype('connoisseur');\"><img name=\"connoisseur\" src=\"img/forconnoisseur.gif\" width=\"135\" height=\"150\" border=\"0\" onmouseover=\"picselect('connoisseur','img/forconnoisseur1.gif')\" onmouseout=\"picselect('connoisseur','img/forconnoisseur.gif')\" /></a>";
          document.getElementById("catnovice").innerHTML="<a href=\"javascript:cattype('novice');\"><img name=\"novice\" src=\"img/fornovice.gif\" width=\"135\" height=\"150\" border=\"0\" onmouseover=\"picselect('novice','img/fornovice1.gif')\" onmouseout=\"picselect('novice','img/fornovice.gif')\" /></a>";
	
         getDetails('select_gift.php', parm );

	}
	else if (cat == "her"){
          var parm = "?tselect=her&pto="+rvalue+"&pfrom="+lvalue;
	  document.getElementById("cather").innerHTML="<div align=\"right\"><a href=\"javascript:cattype('her');\"><img name=\"her\" src=\"img/forher2.gif\" width=\"135\" height=\"150\" border=\"0\" onmouseover=\"picselect('her','img/forher1.gif')\" onmouseout=\"picselect('her','img/forher2.gif')\" /></a></div>";
	
          document.getElementById("cathim").innerHTML="<a href=\"javascript:cattype('him');\"><img name=\"him\" src=\"img/forhim.gif\" width=\"135\" height=\"150\" border=\"0\" onmouseover=\"picselect('him','img/forhim1.gif')\" onmouseout=\"picselect('him','img/forhim.gif')\" /></a>";
          document.getElementById("catconnoisseur").innerHTML="<a href=\"javascript:cattype('connoisseur');\"><img name=\"connoisseur\" src=\"img/forconnoisseur.gif\" width=\"135\" height=\"150\" border=\"0\" onmouseover=\"picselect('connoisseur','img/forconnoisseur1.gif')\" onmouseout=\"picselect('connoisseur','img/forconnoisseur.gif')\" /></a>";
          document.getElementById("catnovice").innerHTML="<a href=\"javascript:cattype('novice');\"><img name=\"novice\" src=\"img/fornovice.gif\" width=\"135\" height=\"150\" border=\"0\" onmouseover=\"picselect('novice','img/fornovice1.gif')\" onmouseout=\"picselect('novice','img/fornovice.gif')\" /></a>";
	  getDetails('select_gift.php', parm );

	}
	else if (cat == "connoisseur"){
          var parm = "?tselect=connoisseur&pto="+rvalue+"&pfrom="+lvalue;
	  document.getElementById("catconnoisseur").innerHTML="<a href=\"javascript:cattype('connoisseur');\"><img name=\"connoisseur\" src=\"img/forconnoisseur2.gif\" width=\"135\" height=\"150\" border=\"0\" onmouseover=\"picselect('connoisseur','img/forconnoisseur1.gif')\" onmouseout=\"picselect('connoisseur','img/forconnoisseur2.gif')\" /></a>";

          document.getElementById("cather").innerHTML="<div align=\"right\"><a href=\"javascript:cattype('her');\"><img name=\"her\" src=\"img/forher.gif\" width=\"135\" height=\"150\" border=\"0\" onmouseover=\"picselect('her','img/forher1.gif')\" onmouseout=\"picselect('her','img/forher.gif')\" /></a></div>";
          document.getElementById("cathim").innerHTML="<a href=\"javascript:cattype('him');\"><img name=\"him\" src=\"img/forhim.gif\" width=\"135\" height=\"150\" border=\"0\" onmouseover=\"picselect('him','img/forhim1.gif')\" onmouseout=\"picselect('him','img/forhim.gif')\" /></a>";
          document.getElementById("catnovice").innerHTML="<a href=\"javascript:cattype('novice');\"><img name=\"novice\" src=\"img/fornovice.gif\" width=\"135\" height=\"150\" border=\"0\" onmouseover=\"picselect('novice','img/fornovice1.gif')\" onmouseout=\"picselect('novice','img/fornovice.gif')\" /></a>";
	  getDetails('select_gift.php', parm );	

	}
	else {
          var parm = "?tselect=novice&pto="+rvalue+"&pfrom="+lvalue;
	  document.getElementById("catnovice").innerHTML="<a href=\"javascript:cattype('novice');\"><img name=\"novice\" src=\"img/fornovice2.gif\" width=\"135\" height=\"150\" border=\"0\" onmouseover=\"picselect('novice','img/fornovice1.gif')\" onmouseout=\"picselect('novice','img/fornovice2.gif')\" /></a>";

          document.getElementById("cather").innerHTML="<div align=\"right\"><a href=\"javascript:cattype('her');\"><img name=\"her\" src=\"img/forher.gif\" width=\"135\" height=\"150\" border=\"0\" onmouseover=\"picselect('her','img/forher1.gif')\" onmouseout=\"picselect('her','img/forher.gif')\" /></a></div>";
          document.getElementById("cathim").innerHTML="<a href=\"javascript:cattype('him');\"><img name=\"him\" src=\"img/forhim.gif\" width=\"135\" height=\"150\" border=\"0\" onmouseover=\"picselect('him','img/forhim1.gif')\" onmouseout=\"picselect('him','img/forhim.gif')\" /></a>";
          document.getElementById("catconnoisseur").innerHTML="<a href=\"javascript:cattype('connoisseur');\"><img name=\"connoisseur\" src=\"img/forconnoisseur.gif\" width=\"135\" height=\"150\" border=\"0\" onmouseover=\"picselect('connoisseur','img/forconnoisseur1.gif')\" onmouseout=\"picselect('connoisseur','img/forconnoisseur.gif')\" /></a>";
	  getDetails('select_gift.php', parm );	

	}
}

///////////////////////////////////////////////////////////////////////////////////////

var http_request = false;

function getDetails(url, parameters) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
            // set type accordingly to anticipated content type
            // http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }

////////////////

// alert( url + parameters);
// exit

     if(url == "hgc_control.html"){
       http_request.onreadystatechange = alertContentsHGC;

     }else if (url == "select_gift2.php"){
        http_request.onreadystatechange = alertContentsTAB;

     }else{
       http_request.onreadystatechange = alertContents;
     }
     
      http_request.open('GET', url + parameters, true);
      http_request.send(null);
}

////////////////////////////////////////////////////////////////////////////////
function alertContentsHGC(){
   if(http_request.readyState == 0 || http_request.readyState == 1 || http_request.readyState == 2 || http_request.readyState == 3){
   }
   if (http_request.readyState == 4 || http_request.readyState=="complete") {
     document.getElementById("hgc").innerHTML=http_request.responseText
   }
}

function alertContentsTAB(){
   if(http_request.readyState == 0 || http_request.readyState == 1 || http_request.readyState == 2 || http_request.readyState == 3){
   }
   if (http_request.readyState == 4 || http_request.readyState=="complete") {
     document.getElementById("tresults").innerHTML=http_request.responseText
   }
}

function alertContents(){
   if(http_request.readyState == 0 || http_request.readyState == 1 || http_request.readyState == 2 || http_request.readyState == 3){
   }

   if (http_request.readyState == 4 || http_request.readyState=="complete") {
     document.getElementById("sresults").innerHTML=http_request.responseText
   }
}

//////////////////////////////////////////////////////////////////////

function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}


//////////////////////////////////////////////////////////////////////

function get(obj,fname) {


 // alert(fname);

var getstr = "?";
var errors = "";


for(i=0; i<document.forms[fname].elements.length; i++) {


   if (document.forms[fname].elements[i].type == "hidden") {
      var hidvalue = document.forms[fname].elements[i].value
	if( hidvalue == "null" || hidvalue == "" ){
	  } else {
	 getstr += document.forms[fname].elements[i].name + "=" + document.forms[fname].elements[i].value + "&";

      }
   }
}




// Handel Errors
if( errors != "" ){  /// wrong
  alert(errors)
    } else {	

var addr_str = getstr.substring(0,getstr.length-1)

/////////////////////////////////////////////////////////

if( fname == "gift") {
     // alert(addr_str);
      getDetails('select_gift.php', addr_str);
}

///////////////////
 }
}



/////////////////////////////////////////////////////////////
function hideres(value){
     document.getElementById("sresults").innerHTML="";
}


