	//Create a boolean variable to check for a valid Internet Explorer instance.
		var xmlhttp = false;
		//Check if we are using IE.
		try {
			//If the Javascript version is greater than 5.
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
		//If not, then use the older active x object.
			try {
				//If we are using Internet Explorer.
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (E) {
				//Else we must be using a non-IE browser.
				xmlhttp = false;
			}
		}
		
		//If we are using a non-IE browser, create a javascript instance of the object.
		if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
			xmlhttp = new XMLHttpRequest();
		}


var html_old ;
var html_old_r ;
var headerHeight=96;
var mouseX;
var mouseY;
var IE = document.all?true:false
var image_shown = false;
var retailer_shown = false;
// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;

// Temporary variables to hold mouse x-y pos.s
var tempX = 0
var tempY = 0

// Main function to retrieve mouse x-y pos.s

function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY
  mouseX = tempX
  mouseY = tempY
  return true
}
function over_(id, image, style, right_side)
{
	if(image_shown==false)
	{
		// divide screen size to half, and cast it to integer, substract 32 to get middle point;
		var middle = parseInt(screen.height/2)-72;
//		alert(middle);
		var div = document.getElementById(id);
		var top, left;
		html_old = '<span class="style"><a href="checkstock.php?style='+style+'">'+style+'</a></span>';
		//html_old = style;
		if(IE){
			if(mouseY>middle)top='-340';
			else top='18';
			if(right_side==0)
			left = '10';
			else
			left = '-260';
		}else {
			if(mouseY>middle)top='-360';
			else top='5';
			if(right_side==0)
			left='80'
			else
			left='-200'
		}
		//div.innerHTML = div.innerHTML+'<div>asdf</div>';
		div.innerHTML = '<span class="style"><a href="checkstock.php?style='+style+'">'+div.innerHTML+'</a></span><div style="position:absolute;margin-top:'+top+'px;margin-left:'+left+'px;">'
		+'<img src = "images/product_images/MED/'+image+'" ></div>';
		
		//alert(div.innerHTML);
		image_shown = true;
		
	}
}
function over_style(id, image, style, right_side, css)
{
	if(image_shown==false)
	{
		// divide screen size to half, and cast it to integer, substract 32 to get middle point;
		var middle = parseInt(screen.height/2)-72;
//		alert(middle);
		var div = document.getElementById(id);
		var top, left;
		html_old = style;
		//html_old = style;
		if(IE){
			if(mouseY>middle)top='-340';
			else top='18';
			if(right_side==0)
			left = '10';
			else
			left = '-260';
		}else {
			if(mouseY>middle)top='-360';
			else top='5';
			if(right_side==0)
			left='80'
			else
			left='-200'
		}
		//div.innerHTML = div.innerHTML+'<div>asdf</div>';
		div.innerHTML = '<span style="'+css+'">'+style+'</span>'+'<div style="position:absolute;margin-top:'+top+'px;margin-left:'+left+'px;">'
		+'<img src = "images/product_images/MED/'+image+'" ></div>';
		
		//alert(div.innerHTML);
		image_shown = true;
		
	}
}

function over_measure(id)
{
	if(image_shown==false)
	{
		var div = document.getElementById(id);
		html_old = div.innerHTML;
		div.innerHTML = div.innerHTML+'<div style="position:absolute;top:-10px;left:580px;">'
		+'<img src = "images/site_images/main/size_model.png"></div>';
		image_shown = true;
	}
}

function out_style(id, css)
{
	var div = document.getElementById(id);
	div.innerHTML = '<span style="'+css+'">'+html_old+'</span>';
	image_shown = false;
}

function out_(id)
{
	var div = document.getElementById(id);
	div.innerHTML = html_old;
	image_shown = false;
}

function over_r(id, store, info, right_side)
{
	if(retailer_shown==false)
	{
		// divide screen size to half, and cast it to integer, substract 32 to get middle point;
		var middle = parseInt(screen.height/2)-72;

		var div = document.getElementById(id);
		var top, left;
		html_old_r = store;
		if(IE){
			if(mouseY>middle)top='-155';
			else top='18';
			if(right_side==0)
			left = '10';
			else
			left = '-260';
		}else {
			if(mouseY>middle)top='-170';
			else top='5';
			if(right_side==0)
			left='80'
			else
			left='-200'
		}
		html_old_r = store;
		div.innerHTML = div.innerHTML+'<div class = "retailerinfo" style="margin-top:'+top+'px;margin-left:'+left+'px;">'
										+info+'</div>';
//		alert(div.innerHTML);
		retailer_shown = true;
		
	}
}

function out_r(id)
{
	var div = document.getElementById(id);
	div.innerHTML = html_old_r;
	retailer_shown = false;
}

function isChecked(form)
{
	var checked = false;
	for(i=0;i<form.length; i++)
	{
		ele =document.forms[1].elements[i];
		if(ele.type == "checkbox")
		{
			if(ele.checked==true) {
			checked = true;
			break;
			}
		}
	}
	return checked;
}

function selectCheckBoxes(form, selection){
	for(i=0;i<form.length; i++)
	{
		ele =form.elements[i];
		if(ele.type == "checkbox") ele.checked = selection;
	}
}

function checkEmpty(id, msg)
{
	var ele = document.getElementById(id);
	if(ele.value==''){
		alert(msg);
		ele.focus();
		return false;
	}
	return true;
}

function isInteger(str)
{
	var a=0;
	while(a<str.length)
	{
		if( str.charAt(a)< '0' || str.charAt(a) > '9' )
			return false;
		a++;
	}
	return true;
}

function isNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }
function changeColor(id, action){
 	var row = document.getElementById(id);
 	
 	if(action == 2){
		if(row.className == "whiteRow")
		row.style.color="#f7f7f7";
		else
		row.style.color="gray";
	}
	else
	{
		if(row.className == "whiteRow")
		row.style.color="#c0504d";
		else
		row.style.color="#c0504d";
	}
}


function wopen(url, name, w, h, loc, menu, status, toolbar, scroll, resize)
{
  // Fudge factors for window decoration space.
  // In my tests these work well on all platforms & browsers.
  w += 32;
  h += 96;
  wleft = (screen.width - w) / 2;
  wtop = (screen.height - h) / 2;
  // IE5 and other old browsers might allow a window that is
  // partially offscreen or wider than the screen. Fix that.
  // (Newer browsers fix this for us, but let's be thorough.)
  if (wleft < 0) {
    w = screen.width;
    wleft = 0;
  }
  if (wtop < 0) {
    h = screen.height;
    wtop = 0;
  }
  
  win = window.open(url,
    name,
    'width=' + w + ', height=' + h + ', ' +
    'left=' + wleft + ', top=' + wtop + ', ' +
    'location='+loc+', menubar='+menu+', ' +
    'status='+status+', toolbar='+toolbar+', scrollbars='+scroll+', resizable='+resize);
  // Just in case width and height are ignored
  win.resizeTo(w, h);
  // Just in case left and top are ignored
  win.moveTo(wleft, wtop);
  win.focus();
}


function showWindowSize()
{
	if (parseInt(navigator.appVersion)>3) {
	 if (navigator.appName=="Netscape") {
	  winW = window.innerWidth-16;
	  winH = window.innerHeight-16;
	  alert('net');
	 }
	 if (navigator.appName.indexOf("Microsoft")!=-1) {
	  winW = document.body.offsetWidth-20;
	  winH = document.body.offsetHeight-20;
	  alert('micro');
	 }
	}
	
	alert(winW +', '+winH);
}

function previewCode(company)
{
	var cmb = document.getElementById('code');
	//alert(cmb.selectedIndex);
	var code = cmb.options[cmb.selectedIndex].value;
	
	windowOpen('activation_printpreview_code.php?company='+company+'&code='+code,'preview', 900, 600,'1');
	
	return false;
}

function windowOpen(url, name, w,h, scrollable) {
 // Fudge factors for window decoration space.
  // In my tests these work well on all platforms & browsers.
  w += 32;
  h += 96;
  wleft = (screen.width - w) / 2;
  wtop = (screen.height - h) / 2;
  // IE5 and other old browsers might allow a window that is
  // partially offscreen or wider than the screen. Fix that.
  // (Newer browsers fix this for us, but let's be thorough.)
  if (wleft < 0) {
    w = screen.width;
    wleft = 0;
  }
  if (wtop < 0) {
    h = screen.height;
    wtop = 0;
  }
    myWindow = window.open(url, name,"width=" + w + ",height=" + h+",top=" + wtop +",left=" + wleft + ",screenX=0,screenY=0, scrollbars="+scrollable);
}

function showImage(url, name, w,h, scrollable) {
 // Fudge factors for window decoration space.
  // In my tests these work well on all platforms & browsers.
  wleft = (screen.width - w) / 2;
  wtop = (screen.height - h) / 2;
  // IE5 and other old browsers might allow a window that is
  // partially offscreen or wider than the screen. Fix that.
  // (Newer browsers fix this for us, but let's be thorough.)
  if (wleft < 0) {
    w = screen.width;
    wleft = 0;
  }
  if (wtop < 0) {
    h = screen.height;
    wtop = 0;
  }
    myWindow = window.open(url, name,"width=" + w + ",height=" + h+",top=" + wtop +",left=" + wleft + ",screenX=0,screenY=0, scrollbars="+scrollable);
}



function test_wopen(url, name, w, h, loc, menu, status, toolbar, scroll, resize)
{
  // Fudge factors for window decoration space.
  // In my tests these work well on all platforms & browsers.
  w += 32;
  h += 96;
  wleft = (screen.width - w) / 2;
  wtop = (screen.height - h) / 2;
  // IE5 and other old browsers might allow a window that is
  // partially offscreen or wider than the screen. Fix that.
  // (Newer browsers fix this for us, but let's be thorough.)
  if (wleft < 0) {
    w = screen.width;
    wleft = 0;
  }
  if (wtop < 0) {
    h = screen.height;
    wtop = 0;
  }
  
  win = window.open(url,
    name,
    'width=' + w + ', height=' + h + ', ' +
    'left=' + wleft + ', top=' + wtop + ', ' +
    'location='+loc+', menubar='+menu+', ' +
    'status='+status+', toolbar='+toolbar+', scrollbars='+scroll+', resizable='+resize);
  // Just in case width and height are ignored
  win.resizeTo(w, h);
  // Just in case left and top are ignored
  win.moveTo(wleft, wtop);
  win.focus();
  return win;
}

function showSubStates(states, url, show_hash)
{
	var st = document.getElementById('substates');
	st.innerHTML = '';
	var c = '';
	
	for(i=0;i<states.length; i++)
	{
		if(show_hash==0)
		c += '<div class="substate" onclick="document.location.href=\''+url+ '?state='+states[i]+'\'">'+states[i]+'</div>';
		else
		c += '<div class="substate" onclick="document.location.href=\''+url+ '#'+states[i]+'\'">'+states[i]+'</div>';
	}
	st.innerHTML = c;
}

function loadForm(e)
{
	alert(1);
	/*var code;
	if (!e) var e = window.event;
	if (e.keyCode) code = e.keyCode;
	else if (e.which) code = e.which;
	var character = String.fromCharCode(code);
	var key = document.getElementById("keywords").value;
	
	// producing if(character=='1' || character=='2' ||character=='3') like conditions 
	if(character=='1' || character=='2' || character=='3' || character=='4' || character=='5' )
	document.location.href="../search.php?search="+character+"&keywords="+key;
	else 
	alert('Allowed search shortcut key is between 1-5. Try again.');*/
}
