/* Showroom Functions */
function clear_showroom ()
{
document.getElementById('image_01').innerHTML = " ";
document.getElementById('heading_01').innerHTML = " ";
document.getElementById('price_t_01').innerHTML = " ";
document.getElementById('price_01').innerHTML = " ";
document.getElementById('year_t_01').innerHTML = " ";
document.getElementById('year_01').innerHTML = " ";
document.getElementById('footer_01').innerHTML= " ";
document.getElementById('status_t_01').innerHTML = " ";
document.getElementById('status_01').innerHTML = " ";
document.getElementById('flag_01').innerHTML = " ";

document.getElementById('image_02').innerHTML = " ";
document.getElementById('heading_02').innerHTML = " ";
document.getElementById('price_t_02').innerHTML = " ";
document.getElementById('price_02').innerHTML = " ";
document.getElementById('year_t_02').innerHTML = " ";
document.getElementById('year_02').innerHTML = " ";
document.getElementById('footer_02').innerHTML= " ";
document.getElementById('status_t_02').innerHTML = " ";
document.getElementById('status_02').innerHTML = " ";
document.getElementById('flag_02').innerHTML = " ";

document.getElementById('image_03').innerHTML = " ";
document.getElementById('heading_03').innerHTML = " ";
document.getElementById('price_t_03').innerHTML = " ";
document.getElementById('price_03').innerHTML = " ";
document.getElementById('year_t_03').innerHTML = " ";
document.getElementById('year_03').innerHTML = " ";
document.getElementById('footer_03').innerHTML= " ";
document.getElementById('status_t_03').innerHTML = " ";
document.getElementById('status_03').innerHTML = " ";
document.getElementById('flag_03').innerHTML = " ";

}

function capWord(word) {
tmpStr = word.toLowerCase();
stringLen = tmpStr.length;
tmpChar = tmpStr.substring(0,1).toUpperCase();
postString = tmpStr.substring(1,stringLen);
tmpStr = tmpChar + postString;
}


function get_id(action)
	{
	if (action == 'frwrd')
		{
		clear_showroom();
		page_count++;
//		document.write(page_count);
//		document.write(total_pages);
		if (page_count == total_pages)
			{
			document.form1.button_frwrd.disabled = true;
			document.form1.button_last.disabled = true;
			}
		document.form1.button_bckwrd.disabled = false;
		document.form1.button_first.disabled = false;
		update();
		}

	if (action == 'bckwrd')
		{
		clear_showroom();
		page_count--;
		if (page_count == 1)
			{
			document.form1.button_bckwrd.disabled = true;
			document.form1.button_first.disabled = true;
			}
		document.form1.button_frwrd.disabled = false;
		document.form1.button_last.disabled = false;
		update();
		}

	if (action == 'first')
		{
		clear_showroom();
		page_count = 1;
		document.form1.button_frwrd.disabled = false;
		document.form1.button_last.disabled = false;
		document.form1.button_bckwrd.disabled = true;
		document.form1.button_first.disabled = true;
		update();
		}

	if (action == 'last')
		{
		clear_showroom();
		page_count = total_pages;
		document.form1.button_frwrd.disabled = true;
		document.form1.button_last.disabled = true;
		document.form1.button_bckwrd.disabled = false;
		document.form1.button_first.disabled = false;
		update();
		}
	}

function update()
{
	if (page_count == total_pages)
		{
//		document.write(page_count);
//		document.write(total_pages);
//		document.write(balance);

		if (balance == 0)
			{
			update_01();
			update_02();
			update_03();
			}
		if (balance == 2)
			{
			update_01();
			update_02();
			}
		if (balance == 1)
			{
			update_01();
			}
		}
		
	if (page_count < total_pages) 
		{ 
		update_01();
		update_02();
		update_03();
		}
	document.getElementById('count_display').innerHTML = " Showing Page " + page_count + " of " + total_pages + " pages";
}

function update_01()
{
	tmp_count = ((page_count-1)*3)+1;

	ADPcontent1="<span style =\"cursor:pointer\" onclick = \"adpFadeout('imagepup');return false;\"><img src=\"display_car_gmi.php?car_id=" + arr_id[tmp_count] + "&img_id=01\" border=\"0\" /></span>";
	ADPcontent12="<span style =\"cursor:pointer\" onclick = \"adpFadeout('imagepup');return false;\"><img src=\"display_car_gmi.php?car_id=" + arr_id[tmp_count] + "&img_id=02\" border=\"0\" /></span>";
	ADPcontent13="<span style =\"cursor:pointer\" onclick = \"adpFadeout('imagepup');return false;\"><img src=\"display_car_gmi.php?car_id=" + arr_id[tmp_count] + "&img_id=03\" border=\"0\" /></span>";
	ADPcontent14="<span style =\"cursor:pointer\" onclick = \"adpFadeout('imagepup');return false;\"><img src=\"display_car_gmi.php?car_id=" + arr_id[tmp_count] + "&img_id=04\" border=\"0\" /></span>";
	create_adp('1D',arr_id[tmp_count]);
	
	document.getElementById('image_01').innerHTML = "<img src=\"display_car_gmi.php?car_id=" + arr_id[tmp_count] + "&img_id=01\" width=\"128\" height=\"96\" border=\"0\" onClick=\"adpFadein('imagepup'); adpContent('imagepup',ADPcontent1);return false;\" style=\"cursor:pointer\">";
	document.getElementById('heading_01').innerHTML = "<span style =\"cursor:pointer\" onClick=\"adpFadein('imagepup'); adpContent('imagepup',ADPcontent1);return false;\"><strong>" + arr_make[tmp_count] + " " + arr_model[tmp_count] + "</span>";
	document.getElementById('price_t_01').innerHTML = "Asking Price: ";
	document.getElementById('price_01').innerHTML = "<strong>" + arr_currency[tmp_count] + arr_price[tmp_count] + "</script></strong>";
	document.getElementById('year_t_01').innerHTML = "Year: ";
	document.getElementById('year_01').innerHTML = "<strong>" + arr_year[tmp_count];
	document.getElementById('status_t_01').innerHTML = "Status: ";
	document.getElementById('status_01').innerHTML = "<strong>" + arr_status[tmp_count];
	document.getElementById('flag_01').innerHTML = "<img src=\"images/flags/" + arr_country[tmp_count] + "_sml.jpg\" width=\"24\" height=\"16\">";
if (arr_status[tmp_count] == "Sold") { document.getElementById('flag_01').innerHTML = "<img src=\"images/flags/" + arr_country[tmp_count] + "_sold.jpg\" width=\"24\" height=\"16\">"; }
	document.getElementById('footer_01').innerHTML = "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td width=\"20%\" align=\"center\"><span style=\"cursor:pointer\" class=\"style8\" onClick=\"adpFadein('imagepup'); adpContent('imagepup',ADPcontent1);return false;\">[ Picture 1 ]</span></td><td width=\"20%\" align=\"center\"><span style=\"cursor:pointer\" class=\"style8\" onClick=\"adpFadein('imagepup'); adpContent('imagepup',ADPcontent12);return false;\" onMouseOver=\"showimage_12();\" onMouseOut=\"hideimage_12();\">[ Picture 2 ]</span></td><td width=\"20%\" align=\"center\"><span style=\"cursor:pointer\" class=\"style8\" onClick=\"adpFadein('imagepup'); adpContent('imagepup',ADPcontent13);return false;\" onMouseOver=\"showimage_13();\" onMouseOut=\"hideimage_13();\">[ Picture 3 ]</span></td><td width=\"20%\" align=\"center\"><span style=\"cursor:pointer\" class=\"style8\" onClick=\"adpFadein('imagepup'); adpContent('imagepup',ADPcontent14);return false;\" onMouseOver=\"showimage_14();\" onMouseOut=\"hideimage_14();\">[ Picture 4 ]</span></td><td width=\"20%\" align=\"center\"><span style=\"cursor:pointer\" class=\"style8\" onClick=\"adpFadein('imagepup'); adpContent('imagepup',ADPcontent1D);return false;\">[ Description ]</span></td></tr></table>";

	document.getElementById('div_pic_12').innerHTML ="<img src=\"display_car_gmi.php?car_id="+arr_id[tmp_count]+"&img_id=02\" width=\"128\" height=\"96\" border=\"1\" />";
	document.getElementById('div_pic_13').innerHTML ="<img src=\"display_car_gmi.php?car_id="+arr_id[tmp_count]+"&img_id=03\" width=\"128\" height=\"96\" border=\"1\" />";
	document.getElementById('div_pic_14').innerHTML ="<img src=\"display_car_gmi.php?car_id="+arr_id[tmp_count]+"&img_id=04\" width=\"128\" height=\"96\" border=\"1\" />";

}

function update_02()
{
	tmp_count = ((page_count-1)*3)+2;
	ADPcontent2="<a href=\"#\" onclick = \"adpFadeout('imagepup');return false;\"><img src=\"display_car_gmi.php?car_id=" + arr_id[tmp_count] + "&img_id=01\" border=\"0\" /></a>";
	ADPcontent22="<a href=\"#\" onclick = \"adpFadeout('imagepup');return false;\"><img src=\"display_car_gmi.php?car_id=" + arr_id[tmp_count] + "&img_id=02\" border=\"0\" /></a>";
	ADPcontent23="<a href=\"#\" onclick = \"adpFadeout('imagepup');return false;\"><img src=\"display_car_gmi.php?car_id=" + arr_id[tmp_count] + "&img_id=03\" border=\"0\" /></a>";
	ADPcontent24="<a href=\"#\" onclick = \"adpFadeout('imagepup');return false;\"><img src=\"display_car_gmi.php?car_id=" + arr_id[tmp_count] + "&img_id=04\" border=\"0\" /></a>";
	create_adp('2D',arr_id[tmp_count]);
	document.getElementById('image_02').innerHTML = "<img src=\"display_car_gmi.php?car_id=" + arr_id[tmp_count] + "&img_id=01\" width=\"128\" height=\"96\" border=\"0\" onClick=\"adpFadein('imagepup'); adpContent('imagepup',ADPcontent2);return false;\" style=\"cursor:pointer\">";
	document.getElementById('heading_02').innerHTML = "<span style =\"cursor:pointer\" onClick=\"adpFadein('imagepup'); adpContent('imagepup',ADPcontent2);return false;\"><strong>" + arr_make[tmp_count] + " " + arr_model[tmp_count] + "</span>";
	document.getElementById('price_t_02').innerHTML = "Asking Price: ";
	document.getElementById('price_02').innerHTML = "<strong>" + arr_currency[tmp_count] + arr_price[tmp_count] + "</script></strong>";
	document.getElementById('year_t_02').innerHTML = "Year: ";
	document.getElementById('year_02').innerHTML = "<strong>" + arr_year[tmp_count];
	document.getElementById('status_t_02').innerHTML = "Status: ";
	document.getElementById('status_02').innerHTML = "<strong>" + arr_status[tmp_count];
	document.getElementById('flag_02').innerHTML = "<img src=\"images/flags/" + arr_country[tmp_count] + "_sml.jpg\" width=\"24\" height=\"16\">";
	if (arr_status[tmp_count] == "Sold") { document.getElementById('flag_02').innerHTML = "<img src=\"images/flags/" + arr_country[tmp_count] + "_sold.jpg\" width=\"24\" height=\"16\">"; }
	document.getElementById('footer_02').innerHTML = "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td width=\"20%\" align=\"center\"><span style=\"cursor:pointer\" class=\"style8\" onClick=\"adpFadein('imagepup'); adpContent('imagepup',ADPcontent2);return false;\">[ Picture 1 ]</span></td><td width=\"20%\" align=\"center\"><span style=\"cursor:pointer\" class=\"style8\" onClick=\"adpFadein('imagepup'); adpContent('imagepup',ADPcontent22);return false;\" onMouseOver=\"showimage_22();\" onMouseOut=\"hideimage_22();\">[ Picture 2 ]</span></td><td width=\"20%\" align=\"center\"><span style=\"cursor:pointer\" class=\"style8\" onClick=\"adpFadein('imagepup'); adpContent('imagepup',ADPcontent23);return false;\" onMouseOver=\"showimage_23();\" onMouseOut=\"hideimage_23();\">[ Picture 3 ]</span></td><td width=\"20%\" align=\"center\"><span style=\"cursor:pointer\" class=\"style8\" onClick=\"adpFadein('imagepup'); adpContent('imagepup',ADPcontent24);return false;\" onMouseOver=\"showimage_24();\" onMouseOut=\"hideimage_24();\">[ Picture 4 ]</span></td><td width=\"20%\" align=\"center\"><span style=\"cursor:pointer\" class=\"style8\" onClick=\"adpFadein('imagepup'); adpContent('imagepup',ADPcontent2D);return false;\">[ Description ]</span></td></tr></table>";

	document.getElementById('div_pic_22').innerHTML ="<img src=\"display_car_gmi.php?car_id="+arr_id[tmp_count]+"&img_id=02\" width=\"128\" height=\"96\" border=\"1\" />"
	document.getElementById('div_pic_23').innerHTML ="<img src=\"display_car_gmi.php?car_id="+arr_id[tmp_count]+"&img_id=03\" width=\"128\" height=\"96\" border=\"1\" />"
	document.getElementById('div_pic_24').innerHTML ="<img src=\"display_car_gmi.php?car_id="+arr_id[tmp_count]+"&img_id=04\" width=\"128\" height=\"96\" border=\"1\" />"


}

function update_03()
{
	tmp_count = ((page_count-1)*3)+3;
	ADPcontent3="<a href=\"#\" onclick = \"adpFadeout('imagepup');return false;\"><img src=\"display_car_gmi.php?car_id=" + arr_id[tmp_count] + "&img_id=01\" border=\"0\" /></a>";
	ADPcontent32="<a href=\"#\" onclick = \"adpFadeout('imagepup');return false;\"><img src=\"display_car_gmi.php?car_id=" + arr_id[tmp_count] + "&img_id=02\" border=\"0\" /></a>";
	ADPcontent33="<a href=\"#\" onclick = \"adpFadeout('imagepup');return false;\"><img src=\"display_car_gmi.php?car_id=" + arr_id[tmp_count] + "&img_id=03\" border=\"0\" /></a>";
	ADPcontent34="<a href=\"#\" onclick = \"adpFadeout('imagepup');return false;\"><img src=\"display_car_gmi.php?car_id=" + arr_id[tmp_count] + "&img_id=04\" border=\"0\" /></a>";
	create_adp('3D',arr_id[tmp_count]);
	document.getElementById('image_03').innerHTML = "<img src=\"display_car_gmi.php?car_id=" + arr_id[tmp_count] + "&img_id=01\" width=\"128\" height=\"96\" border=\"0\" onClick=\"adpFadein('imagepup'); adpContent('imagepup',ADPcontent3);return false;\" style=\"cursor:pointer\">";
	document.getElementById('heading_03').innerHTML = "<span style =\"cursor:pointer\" onClick=\"adpFadein('imagepup'); adpContent('imagepup',ADPcontent3);return false;\"><strong>" + arr_make[tmp_count] + " " + arr_model[tmp_count] + "</span>";
	document.getElementById('price_t_03').innerHTML = "Asking Price: ";
	document.getElementById('price_03').innerHTML = "<strong>" + arr_currency[tmp_count] + arr_price[tmp_count] + "</script></strong>";
	document.getElementById('year_t_03').innerHTML = "Year: ";
	document.getElementById('year_03').innerHTML = "<strong>" + arr_year[tmp_count];
	document.getElementById('status_t_03').innerHTML = "Status: ";
	document.getElementById('status_03').innerHTML = "<strong>" + arr_status[tmp_count];
	document.getElementById('flag_03').innerHTML = "<img src=\"images/flags/" + arr_country[tmp_count] + "_sml.jpg\" width=\"24\" height=\"16\">";
	if (arr_status[tmp_count] == "Sold") { document.getElementById('flag_03').innerHTML = "<img src=\"images/flags/" + arr_country[tmp_count] + "_sold.jpg\" width=\"24\" height=\"16\">"; }
	document.getElementById('footer_03').innerHTML = "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td width=\"20%\" align=\"center\"><span style=\"cursor:pointer\" class=\"style8\" onClick=\"adpFadein('imagepup'); adpContent('imagepup',ADPcontent3);return false;\">[ Picture 1 ]</span></td><td width=\"20%\" align=\"center\"><span style=\"cursor:pointer\" class=\"style8\" onClick=\"adpFadein('imagepup'); adpContent('imagepup',ADPcontent32);return false;\" onMouseOver=\"showimage_32();\" onMouseOut=\"hideimage_32();\">[ Picture 2 ]</span></td><td width=\"20%\" align=\"center\"><span style=\"cursor:pointer\" class=\"style8\" onClick=\"adpFadein('imagepup'); adpContent('imagepup',ADPcontent33);return false;\" onMouseOver=\"showimage_33();\" onMouseOut=\"hideimage_33();\">[ Picture 3 ]</span></td><td width=\"20%\" align=\"center\"><span style=\"cursor:pointer\" class=\"style8\" onClick=\"adpFadein('imagepup'); adpContent('imagepup',ADPcontent34);return false;\" onMouseOver=\"showimage_34();\" onMouseOut=\"hideimage_34();\">[ Picture 4 ]</span></td><td width=\"20%\" align=\"center\"><span style=\"cursor:pointer\" class=\"style8\" onClick=\"adpFadein('imagepup'); adpContent('imagepup',ADPcontent3D);return false;\">[ Description ]</span></td></tr></table>";

	document.getElementById('div_pic_32').innerHTML ="<img src=\"display_car_gmi.php?car_id="+arr_id[tmp_count]+"&img_id=02\" width=\"128\" height=\"96\" border=\"1\" />"
	document.getElementById('div_pic_33').innerHTML ="<img src=\"display_car_gmi.php?car_id="+arr_id[tmp_count]+"&img_id=03\" width=\"128\" height=\"96\" border=\"1\" />"
	document.getElementById('div_pic_34').innerHTML ="<img src=\"display_car_gmi.php?car_id="+arr_id[tmp_count]+"&img_id=04\" width=\"128\" height=\"96\" border=\"1\" />"

}