function init_ajax_obj() {
	var ajax_obj;
	try{
		// Opera 8.0+, Firefox, Safari
		ajax_obj = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajax_obj = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajax_obj = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser does not support Ajax!");
				return false;
			}
		}
	}
	return ajax_obj;
}
function add_prod_to_wishlist(in_loopnum,ProductID) {
	var ajax_obj=init_ajax_obj();
	// Create a function that will receive data sent from the server
	ajax_obj.onreadystatechange = function(){
		if(ajax_obj.readyState == 4){
			//now put the html for removing
			if (ajax_obj.responseText=='ins_ok') {
				document.getElementById('add_to_wishlisthtml'+in_loopnum).id='remove_from_wishlisthtml'+in_loopnum;
				document.getElementById('remove_from_wishlisthtml'+in_loopnum).innerHTML='<a href="javascript:///"OnClick="remove_prod_from_wishlist('+in_loopnum+','+ProductID+')"""><img src="/images/wish_list_in_icon.gif" alt="Click to remove item from your Wish List" border="0" align="absmiddle" /></a>';
			}
			else if (ajax_obj.responseText=='exp_') {
				//the user has clicked after session("Memberid") has expired
				document.location.href='/members/login.asp?GOTO=wishlist&wishlistProductID='+ProductID+'&errmsg=Please login first to manage items in your wish list';
			}
		}
		else {
			document.getElementById('add_to_wishlisthtml'+in_loopnum).innerHTML='<div><img src="/images/indicator.gif" /></div>';
		}
	}
	ajax_obj.open("GET", "/members/wishlist_ajax.asp?add_prod_to_wishlist=1&ProductID="+ProductID, true);
	ajax_obj.send(null);
}
function remove_prod_from_wishlist(in_loopnum,ProductID) {
	var ajax_obj=init_ajax_obj();
	// Create a function that will receive data sent from the server
	ajax_obj.onreadystatechange = function(){
		if(ajax_obj.readyState == 4){
			//now put the html for adding
			if (ajax_obj.responseText=='del_ok') {
				document.getElementById('remove_from_wishlisthtml'+in_loopnum).id='add_to_wishlisthtml'+in_loopnum;
				document.getElementById('add_to_wishlisthtml'+in_loopnum).innerHTML='<a href="javascript:///"OnClick="add_prod_to_wishlist('+in_loopnum+','+ProductID+')"""><img src="/images/wish_list_out_icon.gif" alt="Click to add item to your Wish List" border="0" align="absmiddle" /></a>';
			}
			else if (ajax_obj.responseText=='exp_') {
				//the user has clicked after session("Memberid") has expired
				document.location.href='/members/login.asp?GOTO=wishlist&wishlistProductID='+ProductID+'&errmsg=Please login first to manage items in your wish list';
			}
		}
		else {
			document.getElementById('remove_from_wishlisthtml'+in_loopnum).innerHTML='<div><img src="/images/indicator.gif" /></div>';
		}
	}
	ajax_obj.open("GET", "/members/wishlist_ajax.asp?remove_prod_from_wishlist=1&ProductID="+ProductID, true);
	ajax_obj.send(null);
}

function showpicture(ProductID,in_linenum,in_prodnum) {
	var ajax_obj=init_ajax_obj();
	// Create a function that will receive data sent from the server
	ajax_obj.onreadystatechange = function(){
		if(ajax_obj.readyState == 4){
			document.getElementById('showpic'+in_linenum).innerHTML=ajax_obj.responseText;
		}
		else {
			document.getElementById('showpic'+in_linenum).innerHTML='<div><img src="/images/indicator.gif" /></div>';
			//clear all other images we may rollover without rollout first
			//in range of 10 prods
			for(i=1;i<=10;i++) {
				if(document.getElementById('showpic'+(in_linenum-i)) != null)
				document.getElementById('showpic'+(in_linenum-i)).innerHTML='';
				if(document.getElementById('showpic'+(in_linenum+i)) != null)
				document.getElementById('showpic'+(in_linenum+i)).innerHTML='';
			}
		}
	}
	ajax_obj.open("GET", "/showpic_ajax.asp?ProductID="+ProductID, true);
	ajax_obj.send(null);
}
function hidepicture(in_linenum) {
	document.getElementById('showpic'+in_linenum).innerHTML='';
}