function minHeight(objectID, minHeight) {	
	if (document.getElementById) {
		var c_height = document.getElementById(objectID).offsetHeight;
		
		if (c_height < minHeight) {
			document.getElementById(objectID).style.height = minHeight + 'px';
		}
	}
}
function startDrag(e){
 // determine event object
 if(!e){var e=window.event};
 // determine target element
 var targ=e.target?e.target:e.srcElement;
 if(targ.className!='draggable'){return};
 // calculate event X,Y coordinates
    offsetX=e.clientX;
    offsetY=e.clientY;
 // assign default values for top and left properties
 if(!targ.style.left){targ.style.left='0px'};
 if(!targ.style.top){targ.style.top='0px'};
 // calculate integer values for top and left properties
    coordX=parseInt(targ.style.left);
    coordY=parseInt(targ.style.top);
    drag=true;
 // move div element
    document.onmousemove=dragDiv;
}
// continue dragging
function dragDiv(e){
 if(!drag){return};
 if(!e){var e=window.event};
 var targ=e.target?e.target:e.srcElement;
 // move div element
   targ.style.left=coordX+e.clientX-offsetX+'px';
   targ.style.top=coordY+e.clientY-offsetY+'px';
   return false;
}
// stop dragging
function stopDrag(){
 drag=false;
}

function changeBGToPublic(div, color) {}

function getSDP(p) {
	var x = document.getElementById("sdp").value;
	if (x > -1) window.location.href= p + "?state=" + x;
}

function desc(x){
	  s = new Array(
		"Washington", //#0
		"Oregon", //#1
		"California", //#2
		"Nevada", //#3
		"Idaho", //#4
		"Montana", //#5
		"Wyoming", //#6
		"Utah", //#7
		"Arizona", //#8
		"Colorado", //#9
		"New Mexico", //#10
		"North Dakota", //#11
		"South Dakota", //#12
		"Nebraska", //#13
		"Kansas", //#14
		"Oklahoma", //#15
		"Texas", //#16
		"Minnesota", //#17
		"Iowa", //#18
		"Missouri", //#19
		"Arkansas", //#20
		"Louisiana", //#21
		"Wisconsin", //#22
		"Illinois", //#23
		"Indiana", //#24
		"Kentucky", //#25
		"Tennessee", //#26
		"Mississippi", //#27
		"Ohio", //#28
		"Alabama", //#29
		"Florida", //#30
		"Georgia", //#31
		"South Carolina", //#32
		"North Carolina", //#33
		"Virginia", //#34
		"Washington, D.C.", //#35
		"West Virginia", //#36
		"Maryland", //#37
		"Delaware", //#38
		"New Jersey", //#39
		"Pennsylvania", //#40
		"New York", //#41
		"Connecticut", //#42
		"Rhode Island", //#43
		"Massachusetts", //#44
		"Vermont", //#45
		"New Hampshire", //#46
		"Maine", //#47
		"Hawaii", //#48
		"Alaska", //#49
		"Michigan", //#50
		"Ontario", //#51
		"Prince Edward Island", //#52
		"Newfoundland", //#53
		"Nova Scotia", //#54
		"New Brunswick", //#55
		"Quebec", //#56
		"Manitoba", //#57
		"Saskatchewan", //58
		"Alberta", //#59
		"British Columbia", //#60
		"Northwest Territories", //#61
		"Yukon Territory" //#62	
	);

	if (x > -1 && x != 35) {
		document.getElementById('descr').innerHTML = s[x] + "&nbsp;&nbsp;&nbsp;";	
		document.getElementById('descr').style.display = "inline";
	} else {
		document.getElementById('descr').style.display = "none";
	}
}
function openPhotoGallery() {
	var rows = document.getElementsByTagName("tr");
	for(i = 0; i < rows.length; i++) {
		if (rows[i].style.display == "none") rows[i].style.display = "block";
	}
	document.getElementById("photoLink").innerHTML = '<a href="javascript:closePhotoGallery()">close</a>';
}
function closePhotoGallery() {
	var rows = document.getElementsByTagName("tr");
	for(i = 0; i < rows.length; i++) {
		if (rows[i].className == "photoThumb") rows[i].style.display = "none";
	}
	document.getElementById("photoLink").innerHTML = '<a href="javascript:openPhotoGallery()">view all photos</a>';
}
function changeClass(el, newClass, exception) {
	if (document.getElementById(el).className != exception) document.getElementById(el).className = newClass;
}
function switchTab(el, tab, product_id) {
	if (document.getElementById(el).className == "tabSelected") return;
	var tabs = document.getElementsByTagName("li");
	for(i = 0; i < tabs.length; i++) {
		if (tabs[i].className == "tabSelected") tabs[i].className = "tab";
	}
	document.getElementById(el).className = "tabSelected";
	printTabContent(tab, product_id);
}
function printTabContent(t, p) {
	x_printTabContent(t, p, printTabContent_cb);
}
function printTabContent_cb(z) {
	document.getElementById("tabContentArea").innerHTML = z;
	adjustHeights("content");	
}
function adjustHeights(con) {
	return;
	var minMenu = 505;
	var m = document.getElementById("menu").offsetHeight;
	var c = document.getElementById(con).offsetHeight;
	if (con == "index-content") c += 20;
	//alert("menu: "+m+", content: "+c);
	if (c > m) { 
		minHeight("menu", c); 
	} else {
		//document.getElementById("menu").style.height = c + "px";
		//minHeight("content", m);
		if (c > minMenu) {
			document.getElementById("menu").style.height = c + "px"; 
		}
		
	}
}

function measureTableWidth(id) {
	var w = document.getElementById(id).offsetWidth;
	if (w > 460) {
		var c = document.getElementById("productTableContainer_"+id.replace("table_", ""));
		c.className = "extTable";		
	}
}
function openBigTable(id) {
	var w = document.getElementById("table_"+id).offsetWidth;
	if (w > 460) {
		var h = document.getElementById("table_"+id).offsetHeight;
		h = h + 50;
		w = w + 100;
		window.open("table.php?table_id="+id+"&width="+w,"","width="+w+",height="+h);
	}
}
function measureTableWidths() {
	t = document.getElementsByTagName("table");
	for(i = 0; i < t.length; i++) {
		if (t[i].className == "productTable") measureTableWidth(t[i].id);
	}
}

function recordSearchWords(s, u, i) {
	x_recordSearchWords(s, u, i, recordSearchWords_cb);
}
function recordSearchWords_cb(z) {}
