﻿$(document).ready(function(){
/*	$("#menu > div", this).mouseover(function(){
		$(this).addClass("parentMenuListHover");
		});
	
	$("#menu > div", this).mouseout(function(){
		$(this).removeClass("parentMenuListHover");
		});
		
	$("#menu > img").hover(function(){
		$(this).fadeTo("fast", .1);
		});
*/		
	});




function loadMenu(){
	$(document).ready(function(){
		$.ajax({
	        type: 'GET',
			url: 'xml/landhome.xml',
			dataType: 'xml',
			success: function(xml){
				$(xml).find("home").each(function(xml){
					var model = $(this).attr("model");
					var thumbnail = $(this).find("thumbnail").text();
					
					var bed = $(this).find("bed").text();
					var bath = $(this).find("bath").text();
						bedbath = bed + " bed " + bath + " bath"
						
					var status = $(this).find("status").text();
					
					$('#menu').append("<div class='itempreview' onclick=\"displayItem('"+model+"');\"><img src='gfx/spacer.gif' id='Sold"+model+"' class='itempreviewSold' /><img alt='"+model+"' id='Thumb"+model+"' src='gfx/liquidation/"+model+"/"+thumbnail+"' title='Click for Information about Model #"+model+"' />" + "<br style='clear:both; line-height: 3pt;'/>" + "<p>"+bedbath+"</p></div>" );

					if(status == "sold"){
						$("#Sold"+model+"").attr("src", "gfx/liquidation/sold.png");
						}
					else if(status == "pending"){
						$("#Sold"+model+"").attr("src", "gfx/liquidation/pending.png");
						}
					else{
						$("#Sold"+model+"").attr("src", "gfx/spacer.gif");
						}

					
					});
					
			}

		});
	
	});
}


function displayItem(id){
	$(document).ready(function(){
		$.ajax({
		        type: 'GET',
				url: 'xml/landhome.xml',
				dataType: 'xml',
				success: function(xml){
					$(xml).find("home").each(function(xml){
						var modelName = $(this).attr("model");
						if($(this).attr("model") == id){
							
							var vin = $(this).find("vin").text();
							var make = $(this).find("make").text();
							var year = $(this).find("year").text();
							var size = $(this).find("size").text();
							var bed = $(this).find("bed").text();
							var bath = $(this).find("bath").text();
							
							var description = $(this).find("description").text();
							var oldprice = $(this).find("oldprice").text();
							var currentprice = $(this).find("currentprice").text();
														
							$('#model').text(modelName);
							$('#vin').text(vin);
							$('#make').text(make);
							$('#year').text(year);

							$('#size').text("Frame: " + size);
							$('#bed').text("Bed: " + bed);
							$('#bath').text("Bath: " + bath);

							$('#description').text(description);
							$('#oldprice').text(oldprice);
							$('#currentprice').addClass("currentprice").text(currentprice);
							
							$('#photo1').fadeTo("fast", .1);
							$('#photo2').fadeTo("fast", .1);
							
							var photo1 = $(this).find("photo1").text();
							var photo2 = $(this).find("photo2").text();
							
							$('#photo1').attr("src", "gfx/liquidation/"+id + "/" + photo1).fadeTo("slow", 1);
							$('#photo2').attr("src", "gfx/liquidation/"+id + "/" + photo2).fadeTo("slow", 1);
							
							var status = $(this).find("status").text();

							
							if(status == "sold"){
								$('#sold_photoEXT').attr("src", "gfx/liquidation/soldBig.png");
								}
							else if(status == "pending"){
								$('#sold_photoEXT').attr("src", "gfx/liquidation/pendingBig.png");
								}
							else{
								$('#sold_photoEXT').attr("src", "gfx/spacer.gif");
								}
							

							}

						});
					
				}//close success function for ajax();
			
			});//close ajax() function;

	});//close jquery wrapper;
}
