﻿$(document).ready(function(){
   getPartRequest();
});

function getPartRequest(){
		$.ajax({
			type: "GET",
			url: "/PartRequestHandler.aspx",
			dataType: "json",
		    success: function(data){
				if(data.result == "success"){
				    var htmlstr="";
				    for(var index=0;index<data.requestpartdata.length;index++)
                    {
                        var location = "";
                        location = data.requestpartdata[index].location;
                        if(index%2==1)
                        {
                            if(location.search(",")>0)
                            {
                                htmlstr="<div class='roundedDiv'><div><table border='0' cellpadding='0' cellspacing='0' height='40px'><tr><td valign='middle' class='requestData'><b>"+ data.requestpartdata[index].firstname+ "</b><span style='color:#666666'>&nbsp;in&nbsp;</span><b><a style='color:#000' target='' href='http://getusedparts.com/partrequestlistingbycountry.asp?country="+ data.requestpartdata[index].country +"&countryId=" + data.requestpartdata[index].countryid + "&state=" + data.requestpartdata[index].state + "&stateId=" + data.requestpartdata[index].stateid + "&source=fromstate'>" + data.requestpartdata[index].location + "</a></b><span style='color:#666666'>&nbsp;needs&nbsp;a&nbsp;</span><b><a style='color:#000' target='' href='http://getusedparts.com/partrequestdetail.asp?year="+data.requestpartdata[index].year+"&yearId="+data.requestpartdata[index].yearid+"&make="+data.requestpartdata[index].make+"&makeId="+data.requestpartdata[index].makeid+"&model="+data.requestpartdata[index].model+"&modelId="+data.requestpartdata[index].modelid+"&part="+data.requestpartdata[index].part+"&partId="+data.requestpartdata[index].partid+"&reqid="+data.requestpartdata[index].reqid+"'>"+ data.requestpartdata[index].part +"</a></b><span style='color:#666666'>&nbsp;for&nbsp;a&nbsp;</span><b><a style='color:#000' target='' href='http://getusedparts.com/makelisting.asp?year="+ data.requestpartdata[index].year +"&yearId=" + data.requestpartdata[index].yearid+"'>" + data.requestpartdata[index].year +"</a>&nbsp;<a style='color:#000' target='' href='http://getusedparts.com/modellisting.asp?year="+data.requestpartdata[index].year+"&yearId="+data.requestpartdata[index].yearid+"&make="+data.requestpartdata[index].make+"&makeId="+data.requestpartdata[index].makeid +"'>"+data.requestpartdata[index].make+"</a>&nbsp;<b><a style='color:#000' target='' href='http://getusedparts.com/partlisting.asp?year="+data.requestpartdata[index].year +"&yearId="+data.requestpartdata[index].yearid +"&make="+data.requestpartdata[index].make +"&makeId="+data.requestpartdata[index].makeid +"&model="+data.requestpartdata[index].model +"&modelId="+data.requestpartdata[index].modelid+"'>"+ data.requestpartdata[index].model +"</a></b></td></tr></table></div></div>"
                                $('<li/></li>').addClass('item').html(htmlstr).appendTo('#main_ul');
                            }
                            else
                            {
                                htmlstr="<div class='roundedDiv'><div><table border='0' cellpadding='0' cellspacing='0' height='40px'><tr><td valign='middle' class='requestData'><b>"+ data.requestpartdata[index].firstname+ "</b><span style='color:#666666'>&nbsp;in&nbsp;</span><b><a style='color:#000' target='' href='http://getusedparts.com/partrequestlistingbycountry.asp?country="+ data.requestpartdata[index].country +"&countryId=" + data.requestpartdata[index].countryid + "&source=fromcountry'>" + data.requestpartdata[index].location + "</a></b><span style='color:#666666'>&nbsp;needs&nbsp;a&nbsp;</span><b><a style='color:#000' target='' href='http://getusedparts.com/partrequestdetail.asp?year="+data.requestpartdata[index].year+"&yearId="+data.requestpartdata[index].yearid+"&make="+data.requestpartdata[index].make+"&makeId="+data.requestpartdata[index].makeid+"&model="+data.requestpartdata[index].model+"&modelId="+data.requestpartdata[index].modelid+"&part="+data.requestpartdata[index].part+"&partId="+data.requestpartdata[index].partid+"&reqid="+data.requestpartdata[index].reqid+"'>"+ data.requestpartdata[index].part +"</a></b><span style='color:#666666'>&nbsp;for&nbsp;a&nbsp;</span><b><a style='color:#000' target='' href='http://getusedparts.com/makelisting.asp?year="+ data.requestpartdata[index].year +"&yearId=" + data.requestpartdata[index].yearid+"'>" + data.requestpartdata[index].year +"</a>&nbsp;<a style='color:#000' target='' href='http://getusedparts.com/modellisting.asp?year="+data.requestpartdata[index].year+"&yearId="+data.requestpartdata[index].yearid+"&make="+data.requestpartdata[index].make+"&makeId="+data.requestpartdata[index].makeid +"'>"+data.requestpartdata[index].make+"</a>&nbsp;<b><a style='color:#000' target='' href='http://getusedparts.com/partlisting.asp?year="+data.requestpartdata[index].year +"&yearId="+data.requestpartdata[index].yearid +"&make="+data.requestpartdata[index].make +"&makeId="+data.requestpartdata[index].makeid +"&model="+data.requestpartdata[index].model +"&modelId="+data.requestpartdata[index].modelid+"'>"+ data.requestpartdata[index].model +"</a></b></td></tr></table></div></div>"
                                $('<li/></li>').addClass('item').html(htmlstr).appendTo('#main_ul');
                            }
                        }
                        else
                        {
                            if(location.search(",")>0)
                            {
                                htmlstr="<div class='roundedDivAlt'><div><table border='0' cellpadding='0' cellspacing='0' height='40px'><tr><td valign='middle' class='requestData'><b>"+ data.requestpartdata[index].firstname+ "</b><span style='color:#666666'>&nbsp;in&nbsp;</span><b><a style='color:#000' target='' href='http://getusedparts.com/partrequestlistingbycountry.asp?country="+ data.requestpartdata[index].country +"&countryId=" + data.requestpartdata[index].countryid + "&state=" + data.requestpartdata[index].state + "&stateId=" + data.requestpartdata[index].stateid + "&source=fromstate'>" + data.requestpartdata[index].location + "</a></b><span style='color:#666666'>&nbsp;needs&nbsp;a&nbsp;</span><b><a style='color:#000' target='' href='http://getusedparts.com/partrequestdetail.asp?year="+data.requestpartdata[index].year+"&yearId="+data.requestpartdata[index].yearid+"&make="+data.requestpartdata[index].make+"&makeId="+data.requestpartdata[index].makeid+"&model="+data.requestpartdata[index].model+"&modelId="+data.requestpartdata[index].modelid+"&part="+data.requestpartdata[index].part+"&partId="+data.requestpartdata[index].partid+"&reqid="+data.requestpartdata[index].reqid+"'>"+ data.requestpartdata[index].part +"</a></b><span style='color:#666666'>&nbsp;for&nbsp;a&nbsp;</span><b><a style='color:#000' target='' href='http://getusedparts.com/makelisting.asp?year="+ data.requestpartdata[index].year +"&yearId=" + data.requestpartdata[index].yearid+"'>" + data.requestpartdata[index].year +"</a>&nbsp;<a style='color:#000' target='' href='http://getusedparts.com/modellisting.asp?year="+data.requestpartdata[index].year+"&yearId="+data.requestpartdata[index].yearid+"&make="+data.requestpartdata[index].make+"&makeId="+data.requestpartdata[index].makeid +"'>"+data.requestpartdata[index].make+"</a>&nbsp;<b><a style='color:#000' target='' href='http://getusedparts.com/partlisting.asp?year="+data.requestpartdata[index].year +"&yearId="+data.requestpartdata[index].yearid +"&make="+data.requestpartdata[index].make +"&makeId="+data.requestpartdata[index].makeid +"&model="+data.requestpartdata[index].model +"&modelId="+data.requestpartdata[index].modelid+"'>"+ data.requestpartdata[index].model +"</a></b></td></tr></table></div></div>"
                                $('<li></li>').addClass('item').html(htmlstr).appendTo('#main_ul');
                            }
                            else
                            {
                                htmlstr="<div class='roundedDivAlt'><div><table border='0' cellpadding='0' cellspacing='0' height='40px'><tr><td valign='middle' class='requestData'><b>"+ data.requestpartdata[index].firstname+ "</b><span style='color:#666666'>&nbsp;in&nbsp;</span><b><a style='color:#000' target='' href='http://getusedparts.com/partrequestlistingbycountry.asp?country="+data.requestpartdata[index].country +"&countryId=" + data.requestpartdata[index].countryid + "&source=fromcountry'>"+ data.requestpartdata[index].location + "</a></b><span style='color:#666666'>&nbsp;needs&nbsp;a&nbsp;</span><b><a style='color:#000' target='' href='http://getusedparts.com/partrequestdetail.asp?year="+data.requestpartdata[index].year+"&yearId="+data.requestpartdata[index].yearid+"&make="+data.requestpartdata[index].make+"&makeId="+data.requestpartdata[index].makeid+"&model="+data.requestpartdata[index].model+"&modelId="+data.requestpartdata[index].modelid+"&part="+data.requestpartdata[index].part+"&partId="+data.requestpartdata[index].partid+"&reqid="+data.requestpartdata[index].reqid+"'>"+ data.requestpartdata[index].part +"</a></b><span style='color:#666666'>&nbsp;for&nbsp;a&nbsp;</span><b><a style='color:#000' target='' href='http://getusedparts.com/makelisting.asp?year="+ data.requestpartdata[index].year +"&yearId=" + data.requestpartdata[index].yearid+"'>" + data.requestpartdata[index].year +"</a>&nbsp;<a style='color:#000' target='' href='http://getusedparts.com/modellisting.asp?year="+data.requestpartdata[index].year+"&yearId="+data.requestpartdata[index].yearid+"&make="+data.requestpartdata[index].make+"&makeId="+data.requestpartdata[index].makeid +"'>"+data.requestpartdata[index].make+"</a>&nbsp;<b><a style='color:#000' target='' href='http://getusedparts.com/partlisting.asp?year="+data.requestpartdata[index].year +"&yearId="+data.requestpartdata[index].yearid +"&make="+data.requestpartdata[index].make +"&makeId="+data.requestpartdata[index].makeid +"&model="+data.requestpartdata[index].model +"&modelId="+data.requestpartdata[index].modelid+"'>"+ data.requestpartdata[index].model +"</a></b></td></tr></table></div></div>"
                                $('<li></li>').addClass('item').html(htmlstr).appendTo('#main_ul');
                            }
                        }
                    }                    
                    $('.items').vTicker({speed: 2000, animation: 'fade',showItems:3,direction: 'down',height: 135});
				}
		    }
		});
}


