// This does our popup window
function feature_win(id, model, type) {
   winprops = "toolbar=0,status=0,scrollbars=0,resizable=0,width=550, height=400";
   page = acc_popup_dir + "accessory_popup.php?num=" +
		   id + "&model=" + model + "&type=" + type;
   preview = window.open( page, "preview", winprops);
   preview.focus();
}

function init_display(){
	old_txt = document.getElementById("desc_" + location.keyVals.num);
	old_txt.style.display = "block";
  the_counter = document.getElementById("the_counter");
  the_counter.innerHTML = get_num(location.keyVals.num);

}

function initGallery(num, daModel, daType){
   selected_thumb = document.getElementById("thumb_"+num);
   selected_thumb.className = "cur";
   selected_desc = document.getElementById("desc_" + num);
   zoom_img = document.getElementById("zoom_link1");
   zoom_icon = document.getElementById("zoom_link2");
	zoom_img.href = "javascript:feature_win(" + num + "," + daModel + ",'" + daType +"');";
	zoom_icon.href = "javascript:feature_win(" + num + "," + daModel + ",'" + daType +"');";
}


function selectThumb(el, daMid, daModel, daType)
{
   num = el.id.replace(/^thumb_/, "")*1; // Get the ID numebr and make it an int
	full_image.src = image_dir + "mids/" + daMid;

   selected_thumb.className = "off"; // set the last one back to off
   selected_thumb = el; // make the old selected the current element.
   selected_thumb.className = "cur";

   selected_desc.style.display = "none";
   selected_desc =  document.getElementById("desc_" + num);
   selected_desc.style.display = "block";
   
	zoom_img.href = "javascript:feature_win(" + num + "," + daModel + ",'" + daType +"');";
	zoom_icon.href = "javascript:feature_win(" + num + "," + daModel + ",'" + daType +"');";
   
	document.getElementById("imgmsg").innerHTML = "Loading...";
}

function img_done() {
   if(typeof( full_image ) == "undefined") {    full_image = document.getElementById("full_image"); }
	document.getElementById("imgmsg").innerHTML = "&nbsp;";
}

function roll(el, state) {
   if(el.className == "cur") return;
	el.className = state;
}

function accessory_track(id){
	id = typeof(id) == "string" ? id.replace(/^\D*(\d+)$/, "$1") : id;
	$.post(accessoryTrackingPath + accessoryObject.accessory[id].image);	
	}