function trim(str) {
	var whitespace = new String(" \t\n\r");
	var s = new String(" " + str + " ");
	if (whitespace.indexOf(s.charAt(0)) != -1) {
		var j=0, i = s.length;
            while (j < i && whitespace.indexOf(s.charAt(j)) != -1) {
			j++;
		}
            s = s.substring(j, i);
	}

	if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
		var i = s.length - 1;       
            while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1) {
			i--;
		}
            s = s.substring(0, i+1);
	}
	return s;
}

function win_pic(URL, w, h) { 
	swidth = (screen.width-w)/2;
	sheight = (screen.availHeight-h)/2
	var win_pic = window.open(URL,'win_pic','width='+w+',height='+h+',top=' + sheight + ',left=' + swidth + ',resizable=yes,scrollbars=yes,menubar=yes');
	win_pic.focus();
}

function win(picSrc) { 
   swidth = (screen.width-600)/2;
   sheight = (screen.availHeight-600)/2
   openStr = "photo.php?pic=" + picSrc;
   var Win = window.open(openStr,'Win','width=600,height=600,top=' + sheight + ',left=' + swidth + ',resizable=yes,scrollbars=yes');
   Win.focus();
}
function winpass(URL) { 
   swidth = (screen.width-800)/2;
   sheight = (screen.availHeight-500)/2
   var Winpass = window.open(URL,'Winpass','width=800,height=500,top=' + sheight + ',left=' + swidth + ',resizable=yes,scrollbars=yes');
   Winpass.focus();
}
function switch_photo(imgName, imgSrc) { 
	document.images[imgName].src = "/photos/product_photos/" + imgSrc;
}
