﻿// ------------------------------------------------------------------------------------------
// Copyright AspDotNetStorefront.com, 1995-2007.  All Rights Reserved.
// http://www.aspdotnetstorefront.com
// For details on this license please visit  the product homepage at the URL above.
// THE ABOVE NOTICE MUST REMAIN INTACT. 
// ------------------------------------------------------------------------------------------

function makeHttpRequest(url, element, calltype) {
  var http_request = false;
  if (window.XMLHttpRequest) { // Mozilla, Safari,...
    http_request = new XMLHttpRequest();
    if (http_request.overrideMimeType) {
      http_request.overrideMimeType('text/xml');
    }
  } 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('Browser doesn\'t support Ajax. Site will NOT FULLY function properly.');
    return false;
  }
  http_request.onreadystatechange = 
  function() 
  {
    if (http_request.readyState == 4) 
    {
      if (http_request.status == 200) 
      {
        //loadXML(http_request.responseText,calltype);
        loadXML(http_request.responseXML,calltype);
      } else 
      {
        alert('There was a problem with the request. (Code: ' + http_request.status + ')');
      }
    }
  }
  http_request.open('GET', url, true);
  http_request.send(null);
}

function loadXML(xml,calltype)
{
	if(calltype == 'producttooltip')
	{
		var string = '<table>'; //xml;
		
		var root = xml.getElementsByTagName('root')[0];
		for (i = 0; i < root.childNodes.length; i++)
		{
    		var node = root.childNodes[i].tagName;
    		if(node == "Price")
    		{
    		 var pos = node.indexOf(".");
    		 var slength = node.length;
    		 var price = root.getElementsByTagName(node)[0].childNodes[0].nodeValue;
    		 var sprice = price.substring(0,slength-pos);
    		 //string +="Price: $" + sprice  + "</td></tr>";
    		}
    		else if(node == "Name")
    		{
    		 //string +="<td style=\'font-size:small\'><bold>Product Name: " + root.getElementsByTagName(node)[0].childNodes[0].nodeValue + "</bold><br></br>";
    		 string +="<td style=\'font-size:small\'><bold>" + "Call for additional information or assistance with your design." + "</bold><br></br>We are here to offer you the best price and service.";
    		}
    		else if(node == "SKU")
    		{
    		 //string +="  SKU: " + root.getElementsByTagName(node)[0].childNodes[0].nodeValue + "<br /><br />";
    		}
    		else if(node == "ImageFileNameOverride")
    		{   		 
    		 string +="<tr><td><img width='300px' alt='" + root.getElementsByTagName(node)[0].childNodes[0].nodeValue + "' src='" + root.getElementsByTagName(node)[0].childNodes[0].nodeValue + "'/></td>";
    		}
    		else if(node == "Description")
    		{
    		 //string += root.getElementsByTagName(node)[0].childNodes[0].nodeValue + "<br /><br />";
    		}
    		else
    		{
		     string += root.getElementsByTagName(node)[0].childNodes[0].nodeValue;
		    }
		}
		string +="</table>";
		if (document.getElementById('dhtmltooltip'))
		{
			document.getElementById('dhtmltooltip').innerHTML = string;
			Ohddrivetip(string,600);
		}
	}
	
	
}

function getProductToolTip(ProductId)
{
	if(document.getElementById('dhtmltooltip') == undefined)
	{
		return;
	}
	var dhtmltooltip = document.getElementById('dhtmltooltip');

  
   var url = "ImageGen.aspx?ProductID=" + ProductId;
   //alert(ProductId);
   
   
   
          //alert(ProductId);
  makeHttpRequest(url,undefined,'producttooltip');
       
       //ddrivetip('hello',500);
       //tipobj.innerHTML = "hello world";    
   //document.getElementById('tipobj').innerHTML = "hello world";    
}


