function nameFormat(str) {
	var tempArray = str.split(' ');
	return tempArray.join('_').toLowerCase();
}

function joinByUnderscore(str) {
	var tempArray = str.split(' ');
	return tempArray.join('_');
}

function real_url(relative_path, url)
{
	if (url.indexOf("http:") < 0)
		url = relative_path + url;

	return url;
}

function popup(url, width, height) {
	var win = window.open(url, 'image_display', 'toolbar=no,status=no,scrollbars=yes,resizable=no,screenx=0,screeny=0,top=0,left=0,width=' + width + ',height=' + height);
}

function PopupPic(sPicURL) { 
	msgWindow=window.open("./Tools/popup.htm?"+sPicURL, "", "resizable=1,screenx=0,screeny=0,top=20,left=2,HEIGHT=200,WIDTH=200");
}

function PopupPic_New_Version(pop_file, sPicURL, category) { 
	msgWindow=window.open(pop_file + "?" + sPicURL + "?" + category, "", "resizable=1,screenx=0,screeny=0,top=20,left=2,HEIGHT=200,WIDTH=200");
}

function PopupPic_New(popup_rela_path, sPicURL) { 
	msgWindow=window.open(popup_rela_path + "Tools/popup_new.htm?"+sPicURL, "", "resizable=1,HEIGHT=200,WIDTH=200");
}

function popup_resize_help(url, width, height) {
	var win = window.open(url, 'image_display', 'toolbar=no,status=no,scrollbars=yes,resizable=yes,screenx=0,screeny=0,top=10,left=0,width=' + width + ',height=' + height);
	//win.location.reload();
}

function popup_help(url, width, height) {
	var win = window.open(url, 'image_display', 'toolbar=no,status=no,scrollbars=yes,resizable=no,screenx=0,screeny=0,top=10,left=0,width=' + width + ',height=' + height);
	//win.location.reload();
}

function popup_tight_image(image_src)
{
	var tmp_img = new Image();
	tmp_img.src = image_src;
	
	open_popup(image_src, tmp_img.width, tmp_img.height);
}

function draw_tight_image(image_src)
{
	max_width =350;
	var tmp_img = new Image();
	tmp_img.src = image_src;
	
	if (tmp_img.width < max_width)
		max_width = tmp_img.width;
		
	document.write("<img src=" + image_src + " border=0 width=" + max_width + " alt='" + image_src + "'>");
}

function goto_page(selection)
{
	var id = selection.options[selection.selectedIndex].value;
	location.href = id ;
}

function goto_city(selection)
{
	var id = selection.options[selection.selectedIndex].value;
	var id_array = id.split('^');
	if (id.indexOf("Dummy") == -1)
		location.href = "?City=" + id_array[0] + "&State=" + id_array[1];
}

function browser_version()
{
	var version = "ie";
	var browserName = navigator.appName; 
	var browserVer = parseInt(navigator.appVersion);
	
	switch (browserName)
	{
		case "Netscape":
			if (navigator.userAgent.indexOf("Firefox") != -1)
			{
				var versionindex = navigator.userAgent.indexOf("Firefox") + 8;
				if (parseInt(navigator.userAgent.charAt(versionindex)) >= 1)
					version = "firefox_v1_up";
				else
					version = "firefox";
			}
			else
				version = "netscape";
			break
		default:
			if (browserVer <= 3)
				version = "ie_early";
			else
				version = "ie";
	}

	return version;
}

function gen_showroom_page(background_image, main_image)
{
	var str = '';
	
	str += '<html>';
	str += '	<head>';
	str += '		<title>Showroom</title>';
	
	str += '		<link href=../../Config/elements.css rel=stylesheet>';
	str += '		<script language=javascript src=../../Scripts/utils.js></script>';
	
	str += '	</head>';
	str += '	<body>';

	str += '<table width=100% height=100% border=1>';
	str += '<tr>';
	
	str += '	<td id=caption align="center" valign="middle" background=' + background_image  + ' width=100%>';
	str += '		<img name=display src=' + main_image + ' width=400 border=0></a></td>';

	str += '</tr>';
	str += '</table>';

	str += '</body>';
	str += '</html>';

	return str;
}

function display_showroom_page(background_image, main_image)
{
	parent.frames['showroom'].document.open();
	parent.frames['showroom'].document.write(gen_showroom_page(background_image, main_image));
	parent.frames['showroom'].document.close();
}