//***************************************************************************
//
// Written by Jeremy Chambers (jeremy@jeremychambers.com) 
// Last Updated: 2/19/2008 //add leadmaster post
//
// This code drives the Strongwell literature download and order section
//
//***************************************************************************

var thumbnailLocation = "../../../Literature/products/images/thumbnails/";
var orderCount = 0;
var orderNamesArray = new Array ( 350 ); //max lit items increase may hinder performance
var orderTypesArray = new Array ( 350 ); //max lit items increase may hinder performance
var currentDate = new Date();
var experiationDays = 180; // after this many days literature update is not considered new;
var currentMonth = currentDate.getMonth();//Returns 2 digit month
var currentYear = currentDate.getFullYear();  // Returns 4 digit year
var litAlertCount = 0; //for popup
var initialOrderItemID = "";
var openAnchor = 0;
var useStateDdl = true;
var useStateTxt = false;
var useOtherTxt = false;
var useOtherDdl = false;
var useVehicleDdl = true;
var myFile = document.location.toString();
if (myFile.match('#')) 
{ // the URL contains an anchor
  // click the navigation item corresponding to the anchor
  //openAnchor = '#' + myFile.split('#')[1];
  openAnchor =  parseInt(myFile.split('#')[1]);
}


//ajax error writing
$(document).ajaxError(function(){
    if (window.console && window.console.error) {
        console.error(arguments);
    }
});


// Start function when DOM has completely loaded 
$(document).ready(function(){
   
   //hidden form components   
   $('#state').hide();
   $('#li_other').hide();
   //hide loading message
   $('#loadingMessage').hide();
   
   
   
	//tabs  
	$('#tabs > ul').tabs();
 	//set english first tab open
	$('#tabs ul').tabs('select', 0);

   //accordions
   $('#englishLiteratureAccordion').accordion({
		header: '.ui-accordion-header',
		clearStyle: true,		
		active: true, 
		alwaysOpen: false,
		navigation: true,
		fillSpace: true
	});
	
	$('#englishLiteratureAccordion').bind('accordionchange', function(event, ui) {
		if (openAnchor > 0)
		{
			//$.scrollTo( ("#18"), 800, {easing:'elasout'} );
			//$(ui).each( function(x){alert(x)});
			$.scrollToElement( $("#A" + openAnchor) );
			
		}
	});
	
	
   
   $('#frenchLiteratureAccordion').accordion({
		header: '.ui-accordion-header',
		clearStyle: true,		
		active: true, 
		alwaysOpen: false 
	});
   $('#italianLiteratureAccordion').accordion({
		header: '.ui-accordion-header',
		clearStyle: true,		
		active: true, 
		alwaysOpen: false 
	});
    $('#portugueseLiteratureAccordion').accordion({
		header: '.ui-accordion-header',
		clearStyle: true,		
		active: true, 
		alwaysOpen: false 
	});
	$('#spanishLiteratureAccordion').accordion({
		header: '.ui-accordion-header',
		clearStyle: true,		
		active: true, 
		alwaysOpen: false 
	});
	
	
	
	//reveal
	$(".ui-accordion-group").show();
			
			if (openAnchor > 0)
			{
				
				$("#englishLiteratureAccordion").accordion("activate",  (openAnchor - 1));
				
			}
	
	//dialog boxs
	$("#orderConfirmDialog").dialog({ 
    	autoOpen: false,
		resizable: false,
		height:200,
		width:500,		
		modal: true, 
    	overlay: { opacity: 0.5, background: "black" } 
		
	});
	$("#orderConfirmDialog").css("display", "block");
	
	$("#litOrderFormDialog").dialog({ 
    	autoOpen: false,
		resizable: false,
		height:600,
		width:500,		
		modal: true, 
    	overlay: { opacity: 0.5, background: "black" } 
		
	});	
	$("#litOrderFormDialog").css("display", "block");
	
	
	//buttons
	$("#proceedCancelBtn").click(function(){
		$("#orderConfirmDialog").dialog("close");
	});
	
	$("#proceedBtn").click(function(){
		$("#orderConfirmDialog").dialog("close");
		var textToAdd = $("#" + initialOrderItemID).children(".litThumbnail").text();		
		$("#" + initialOrderItemID).children(".litOrderBtnContainer").toggleClass("ordered");
		$("#" + initialOrderItemID).children(".litOrderBtnContainer").html("<span style='font-size:90%'>Added to Order</span>");		
		var newListItem = '<li id="litID' + initialOrderItemID + '" class="litOrderListItem"><div style="float:left; width:160px;">' + textToAdd + '</div><div style="width:18px; float:right; text-align:right;"><img id="Delete' + initialOrderItemID + '" class="deleteBtn" src="images/del-up.gif"/></div><div class="clear"></div></li>';	
		$(newListItem).appendTo("#orderList")
		$("#Delete" + initialOrderItemID).hover(function () {$(this).attr("src", "images/del-over.gif");},function () {$(this).attr("src", "images/del-up.gif");});
		$("#Delete" + initialOrderItemID).click(function(){
			//reset main list
			var switchThisID = $(this).attr("id");
			switchThisID = switchThisID.replace("Delete", "");			
			$("#" + switchThisID).children(".litOrderBtnContainer").toggleClass("ordered");
			$("#" + switchThisID).children(".litOrderBtnContainer").html(getType(switchThisID));			
			//remove from list
			$(this).parent().parent().remove();
			orderCount--;
			if (orderCount <1){$("#orderContainer").hide('slow')};
		});
		
		
		$("#litID" + initialOrderItemID).show('fast');
		orderCount++;
		if (orderCount >0){$("#orderContainer").show('slow')};		
	});
	
  	$("#litOrderFormSubmitBtn").hover(function () {$(this).css("background", "url(images/submitOrderBtnBlank2.png) top left no-repeat");},function () {$(this).css("background", "url(images/submitOrderBtnBlank.png) top left no-repeat");});
	$("#formCloseBtn").hover(function () {$(this).attr("src", "images/closeBtn2.png");},function () {$(this).attr("src", "images/closeBtn1.png");});
	$("#formCloseBtn").click(function () {		
		$("#litOrderFormDialog").dialog("close");		
		$("#litOrderForm").show();										
		$("#successContainer").hide();
		$("#errorContainer").hide();
	});
	$("#errorCloseBtn").hover(function () {$(this).attr("src", "images/closeBtn2.png");},function () {$(this).attr("src", "images/closeBtn1.png");});
	$("#errorCloseBtn").click(function () {
		$("#litOrderFormDialog").dialog("close");
		$("#litOrderForm").show();										
		$("#successContainer").hide();
		$("#errorContainer").hide();
	});
	//CREATION OF PRODUCT LITERATURE ITEMS
   $.get("../../../Literature/products/product_literature_library.xml",{},function(xml){		
		// Create Document List Items
		$('litItem',xml).each( function(i) {
			//litID = $(this).find("id").text();
			var litID = i+1;
			var litTitle = $(this).find("title").text();
			var litName = $(this).find("name").text();
			var litProduct = $(this).find("product").text();
			var litLanguage = $(this).find("language").text();
			var litThumbnail = $(this).find("thumbnail").text();
			var litlink = $(this).find("link").text();
			var litOrderable = $(this).find("orderable").text();
			var litDate = $(this).find("updated").text();
			var litNew = $(this).find("new").text();
			var litType = $(this).find("type").text();			
			//dynamically generate id of container to add to
			var addToContainer= "#" + litLanguage + " " + litProduct; //ie #english-structural-shapes-and-plate
			addToContainer = addToContainer.replace(/ /g, "-");
			addToContainer = addToContainer.toLowerCase(); 			
			//add product to containers
			addToProductLine( litProduct, addToContainer, litlink, litThumbnail, litTitle, litID, litOrderable, litDate, litNew, litType, litName );			
			//populate orderNamesArray
			orderNamesArray[parseInt(litID)] =  litName;
			//populate orderTypesArray
			orderTypesArray[parseInt(litID)] = litType;
			
		}); //end creation of document list items   			
			//lit Order Btns NEW
   			$('.litOrderBtnContainer').hover(function () {$(this).css({ backgroundColor:"#e6e6e6" });},function () {$(this).css({ backgroundColor:"#fff" });});
				$('.litOrderBtnContainer').click(function () { 
					
					if ($(this).hasClass("ordered")){
						//previously ordered, must remove
						$(this).toggleClass("ordered");
						//add back Order + type:
						$(this).html(getType($(this).parent().attr("id")));
						$("#litID" + $(this).parent('.literatureItem').attr("id")).hide("fast", function () {
							// after hide remove
							$(this).remove();
						  });

						orderCount--;
						if (orderCount < 1){$("#orderContainer").hide('slow')};
					} else if (litAlertCount <1){
						litAlertCount++;
						//set initial item
						initialOrderItemID = $(this).parent().attr("id");
						//do alert
						$("#orderConfirmDialog").dialog("open");
												
					} else {		
						//add to ordered
						$(this).toggleClass("ordered");
						$(this).html("<span style='font-size:90%'>Added to Order</span>");						
						var newListItem = '<li id="litID' + $(this).parent('.literatureItem').attr("id") + '" class="litOrderListItem"><div style="float:left; width:160px;">' + $(this).prev().children().children('.titleContainer').text() + '</div><div style="width:18px; float:right; text-align:right;"><img id="Delete' + $(this).parent('.literatureItem').attr("id") + '" class="deleteBtn" src="images/del-up.gif"/></div><div class="clear"></div></li>';
						$(newListItem).appendTo("#orderList");
						$("#Delete" + $(this).parent('.literatureItem').attr("id")).hover(function () {$(this).attr("src", "images/del-over.gif");},function () {$(this).attr("src", "images/del-up.gif");});
						$("#Delete" + $(this).parent('.literatureItem').attr("id")).click(function(){
							//reset main list
							var switchThisID = $(this).attr("id");
							switchThisID = switchThisID.replace("Delete", "");			
							$("#" + switchThisID).children(".litOrderBtnContainer").toggleClass("ordered");
							$("#" + switchThisID).children(".litOrderBtnContainer").html(getType(switchThisID));			
							//remove from list
							$(this).parent().parent().remove();
							orderCount--;
							if (orderCount <1){$("#orderContainer").hide('slow')};			
						});
						$("#litID" + $(this).parent('.literatureItem').attr("id")).show('fast');
						orderCount++;
						if (orderCount >0){$("#orderContainer").show('slow')};
					}								
			});
			//submit order button			
			$('#orderSubmitBtn').hover(function () {$(this).attr({src: "images/submitOrderBtn2.png"});},function () {$(this).attr({src: "images/submitOrderBtn.png"});});
   			$('#orderSubmitBtn').click(function () { 
					//popup order form
					
					$("#litOrderFormDialog").dialog("open");					
					$("#litOrderForm").show();										
					$("#successContainer").hide();
					$("#errorContainer").hide();
					  
					// validate the litOrderForm form on keyup and submit
					$("#litOrderForm").validate({
							rules: {
								last_name: "required",
								company: "required",
								position: "required",
								address: "required",
								city: "required",
								zip: "required",
								phone: "required",								
								email: {
									required: true,
									email: true
								},
								
								ddl_vehicles: {
      								required: function(element) {
       									return useVehicleDdl
										;
										//return $("#ddl_vehicles").val();
      								}
    							},
								
								ddl_state: {
      								required: function(element) {
       									return useStateDdl;
      								}
    							},
								
								ddl_other: {
      								required: function(element) {
       									return useOtherDdl;
      								}
    							},
								
								txt_other: {
      								required: function(element) {
       									return useOtherTxt;
      								}
    							}

								
							},
							messages: {
								last_name: "Required",
								company: "Required",
								position: "Required",
								address: "Required",
								city: "Required",
								zip: "Required",
								phone: "Required",
								email: "Required",
								ddl_vehicles: "Required",
								ddl_state: "Required",
								ddl_other: "Required",
								txt_other: "Required"							
							},						
							submitHandler: function(form) { 
					  		
							  // step 1: onload - capture the submit event on the form.
							  $(function() { // onload...do
									//disable submit button
									
									$('#litOrderFormSubmitBtn').attr("disabled", "true");
								
								//$('#litOrderForm').submit(function() {
								  
								  // now we're going to capture *all* the fields in the
								  // form and submit it via ajax.
								  
								  // :input is a macro that grabs all input types, select boxes
								  // textarea, etc.  Then I'm using the context of the form from 
								  // the initial '#litOrderForm' to narrow down our selector
								  var inputs = [];
								  $(':input', this).each(function() {
									//check if checkbox
									if (this.type == 'checkbox'){
										inputs.push(this.name + '=' + escape(this.checked));
									} else{								
										inputs.push(this.name + '=' + escape(this.value));
									}
								  })
								  //add order
								  //delimeted with |
								  var orderString = "";
								  $("li.litOrderListItem").each(function (i) 
								  {
										//pull from name rather than text as to make it easier for media center, ie french brochures
										var realID = $(this).attr("id").replace("litID", "");
										realID = realID.replace("new-", "");
										realID = realID.replace("updated-", "");
										orderString += orderNamesArray[parseInt(realID)] + '|';
								  
								  });
								  inputs.push(orderString);
								  combinedFormData = "?";
								  if (useOtherDdl){
									  combinedFormData +="vehicle=" + escape($("#ddl_other").val()) + "&";
									  combinedFormData +="vehicleName=" + escape($("#ddl_other").find('option').filter(':selected').text()) + "&";			  

								  }
								  else { 
								  	combinedFormData +="vehicle=" + escape($("#ddl_vehicles").val()) + "&"; 
									combinedFormData +="vehicleName=" + escape($("#ddl_vehicles").find('option').filter(':selected').text()) + "&";
								  }								  
								  if(useOtherTxt){combinedFormData +="otherMarketingInfo=" + escape($("#txt_other").val()) + "&";}								 
								  combinedFormData +="first_name=" + escape($("#first_name").val()) + "&";
								  combinedFormData +="last_name=" + escape($("#last_name").val()) + "&";
								  combinedFormData +="company=" + escape($("#company").val()) + "&";
								  combinedFormData +="position=" + escape($("#position").val()) + "&";
								  combinedFormData +="address=" + escape($("#address").val()) + "&";
								  combinedFormData +="city=" + escape($("#city").val()) + "&";
								  if(useStateDdl){combinedFormData +="state=" + escape($("#ddl_state").val()) + "&";}
								  if(useStateTxt){combinedFormData +="state=" + escape($("#state").val()) + "&"; }
								  combinedFormData +="zip=" + escape($("#zip").val()) + "&";
								  combinedFormData +="country=" + escape($("#ddl_country").val()) + "&";
								  
								  
								  combinedFormData +="phone=" + escape($("#phone").val()) + "&";
								  combinedFormData +="email=" + escape($("#email").val()) + "&";
								  combinedFormData +="order=" + orderString + "&";
								  combinedFormData +="profile=" + escape($("#formProfileSubscribe").attr('checked'));
								  								  
								  // now if I join our inputs using '&' we'll have a query string
								  //url: "http://www.strongwell.com/forms/literature_order_form/literatureOrderGenerator.aspx"
								  $.ajax({															
										url: "../../../forms/literature_order_form/literatureOrderGenerator.aspx" + combinedFormData ,
										method:'get',
										timeout: 3000,
										error: function(e) {
										  $(document).unCheckCheckboxes();
											//remove list
											$("#orderContainer").hide();
											$("#orderList li").remove();
											orderCount = 0;
											//hide process form message
											$("#processFormContainer").hide();
											$("#litOrderForm").hide();
											//show success
											$("#successContainer").hide();
											$("#errorContainer").show();
										},//end error
										success: function(r) { 
											
											window.location = "../../../literature/products/success.shtml";
											/*
											$(document).unCheckCheckboxes();
											$("#orderContainer").hide();
											$("#orderList li").remove();
											orderCount = 0;
											$("#processFormContainer").hide();
											$("#litOrderForm").hide();
											$("#successContainer").show();	
											//reset all back to original order types
											$.each($(".ordered"), function() {
											  $(this).html(getType($(this).parent().attr("id")));
											});
											//remove all ordered classes
											$(".ordered").toggleClass("ordered");
											$('#litOrderFormSubmitBtn').removeAttr("disabled");
											*/
											
										}//end success
								  	})//end ajax


									


								  // by default - we'll always return false so it doesn't redirect the user.
								  return false;
								//})
							  })

					
							}});//end submithandler



					
			});
   
   
   			
   		
	}); //end getting of xml data
   
   //$('#vertLayoutTable').attr({scrollTop:0,scrollLeft:0});

   //build country list
 	buildCountryList();	
   //build state list
   buildStateList("USA");
   //build marketing vehicle list
   buildVehicleList();   
   //build tradeshow list
   
   
   

   
   $("#ddl_country").click(function () {
       
	   //alert("change");
	   switch($("#ddl_country").val())
	   {
			case "USA":
		   		buildStateList("USA");
				useStateDdl = true;
				useStateTxt = false;
				$("#state").fadeOut("fast", function () {
        			// use callee so don't have to name the function
					$("#ddl_state").fadeIn("fast"); 
      			});					
		  	 	break;
			case "CAN":
		   		buildStateList("CAN");
				useStateDdl = true;
				useStateTxt = false;
				$("#state").fadeOut("fast", function () {
        			// use callee so don't have to name the function
					$("#ddl_state").fadeIn("fast"); 
      			});	
				
		  	 	break;
			case "":
				useStateDdl = false;
				useStateTxt = true;
				break;			
			default:
				useStateDdl = false;
				useStateTxt = true;
				$("#ddl_state").fadeOut("fast", function () {
        			// use callee so don't have to name the function
					$("#state").fadeIn("fast"); 
      			});					
				break;
	   }	   
   })
   
   $("#ddl_vehicles").click(function () {
       
	   switch($("#ddl_vehicles").val())
	   {
			case "":
				useVehicleDdl = true;				
				useOtherTxt = false;
				useOtherDdl = false;
				$("#li_other").hide();
				$("#ddl_other").hide(); 
				$("#txt_other").hide();
				break;
			case "2010OOD":
			case "2010OTHER":
			case "2010OP":
			case "SE07":
		   		useVehicleDdl = false;
				useOtherTxt = true;
				useOtherDdl = false;
				$("#li_other").show();
				$("#ddl_other").fadeOut("fast", function () {
        			// use callee so don't have to name the function
					$("#txt_other").fadeIn("fast"); 
      			});					
		  	 	break;
			case "TS":
		   		useVehicleDdl = false;
				useOtherTxt = false;
				useOtherDdl = true;
				buildOtherList("TS");
				$("#li_other").show();
				$("#txt_other").fadeOut("fast", function () {
        			// use callee so don't have to name the function
					$("#ddl_other").fadeIn("fast"); 
      			});	
		  	 	break;
			default:
				useVehicleDdl = true;
				useOtherTxt = false;
				useOtherDdl = false;
				$("#li_other").hide();
				$("#ddl_other").hide(); 
				$("#txt_other").hide(); 
				break;
	   }	   
   })

   
   
  
}); //end document ready main function

 
function buildCountryList()
{
  	$.get("../../../forms/countries.xml", function(countryXml)
	{
		$('country', countryXml).each( function(i) 
		{
			var myValue = $(this).attr("value");
			var myText = $(this).attr("name");			
			$("#ddl_country").append("<option value='" + myValue +"'>"+ myText + "</option>");

		});
		
	});		
}

function buildVehicleList()
{
  	$("#ddl_vehicles").append("<option value=''>...select</option>");
	$.get("../../../forms/marketing-vehicles.xml", function(vehicleXml)
	{
		$('vehicle',vehicleXml).each( function(i) 
		{
			
			var myValue = $(this).attr("value");
			if (myValue == "invalid selection"){myValue = "";}			
			var myText = $(this).attr("name");			
			$("#ddl_vehicles").append("<option value='" + myValue +"'>"+ myText + "</option>");
		});
		
	});		
}


function buildOtherList(vehicle)
{
  	$.get("../../../forms/marketing-vehicles.xml", function(optionXml)
	{
		$("#ddl_other").empty();
		$("#ddl_other").append("<option value=''>...select</option>");
		$('option',optionXml).each( function(j)
		{
			if( vehicle == $(this).parent().attr("value"))
			{
			 	var myValue = $(this).attr("value");
				if (myValue == "invalid selection"){myValue = "";}	
				var myText = $(this).attr("name");
				$("#ddl_other").append("<option value='" + myValue +"'>"+ myText + "</option>");					
			}
		});
	});		
}


function buildStateList(country)
{
  	
	$("#ddl_state").empty();
	$("#ddl_state").append("<option value=''>...select</option>");
	$.get("../../../forms/states.xml", function(stateXml)
	{
		$('state',stateXml).each( function(i) 
		{
			if (country == $(this).attr("country"))
			{
				var myValue = $(this).attr("value");
				var myText = $(this).attr("name");			
				$("#ddl_state").append("<option value='" + myValue +"'>"+ myText + "</option>");
			}

		});
		
	});		
}
	

// Functions:

function addToProductLine( litProductToAdd, litLocationToAdd, litLinkToAdd, litThumbnailToAdd, litTitleToAdd, litIDToAdd, litOrderable, litDate, litNew, litType,litName )
{
	var htmlToAppend = '<li class="literatureItem" id="' + litIDToAdd + '">';
	htmlToAppend += '<div class="litThumbnail">';	
	//htmlToAppend += '<a href="' + litLinkToAdd + '" target="_blank">';
	//UPDATE - GOOGLE TRACKING
	htmlToAppend += '<a href="' + litLinkToAdd + '" target="_blank" onClick="javascript:urchinTracker(&#39;literature/products/' + litName + '&#39;)" >';
	htmlToAppend += '<div class="thumbnailContainer">';
	htmlToAppend += '<img src="' + thumbnailLocation + litThumbnailToAdd + '" alt="Click to download..." />';
	htmlToAppend += '</div>';
	htmlToAppend += '<div class="titleContainer">' + litTitleToAdd + ''  + '</div>';
	htmlToAppend += '</a></div>';
	//if orderable
	if (litOrderable == "true") 
	{
		htmlToAppend += '<div class="litOrderBtnContainer">Order&nbsp;';
		//add type to button
		htmlToAppend += litType;
		htmlToAppend += '</div>';
	} else 
	{
		htmlToAppend += '<div class="litOrderNotAvailableContainer"></div>';
	}
	htmlToAppend += '</li>';

	//append list
	$(litLocationToAdd).append(htmlToAppend);
	
	//if NEW OR UPDATED transform litdate into date object
	var litUpdatedDate = new Date(litDate);
	var expirationDate=new Date();
	expirationDate.setDate(expirationDate.getDate()-experiationDays);
	//is new?
	if(litNew == "true"){
		var idToChange = "#" + litIDToAdd;
		$(idToChange).addClass("newLiterature");
		//add item to new and recently updated section
		var newHtmlToAppend = '<li class="literatureItem newLiterature" id="new-' + litIDToAdd + '">';
		newHtmlToAppend += '<div class="litThumbnail">';	
		//newHtmlToAppend += '<a href="' + litLinkToAdd + '" target="_blank"">';
		//UPDATE - GOOGLE TRACKING
		newHtmlToAppend += '<a href="' + litLinkToAdd + '" target="_blank" onClick="javascript:urchinTracker(&#39;literature/products/' + litName + '&#39;)" >';
		newHtmlToAppend += '<div class="thumbnailContainer">';
		newHtmlToAppend += '<img src="' + thumbnailLocation + litThumbnailToAdd + '" alt="Click to download..." />';
		newHtmlToAppend += '</div>';
		newHtmlToAppend += '<div class="titleContainer">' + litTitleToAdd + ''  + '</div>';
		newHtmlToAppend += '</a></div>';
		//if orderable
		if (litOrderable == "true") 
		{
			newHtmlToAppend += '<div class="litOrderBtnContainer">Order&nbsp;';
			newHtmlToAppend += litType;
			newHtmlToAppend += '</div>';
		} else 
		{
			newHtmlToAppend += '<div class="litOrderNotAvailableContainer"></div>';
		}
		newHtmlToAppend += '</li>';
		//append new list
		//english only for now
		$("#english-new-and-recently-updated").append(newHtmlToAppend);
		
	} else if (litUpdatedDate >= expirationDate){
		var idToChange = "#" + litIDToAdd;
		$(idToChange).addClass("recentlyUpdatedLiterature");
		//add to updated list
		var updatedHtmlToAppend = '<li class="literatureItem recentlyUpdatedLiterature" id="updated-' + litIDToAdd + '">';
		updatedHtmlToAppend += '<div class="litThumbnail">';	
		//updatedHtmlToAppend += '<a href="' + litLinkToAdd + '" target="_blank"">';
		//UPDATE - GOOGLE TRACKING
		updatedHtmlToAppend += '<a href="' + litLinkToAdd + '" target="_blank" onClick="javascript:urchinTracker(&#39;literature/products/' + litName + '&#39;)" >';
		updatedHtmlToAppend += '<div class="thumbnailContainer">';
		updatedHtmlToAppend += '<img src="' + thumbnailLocation + litThumbnailToAdd + '" alt="Click to download..." />';
		updatedHtmlToAppend += '</div>';
		updatedHtmlToAppend += '<div class="titleContainer">' + litTitleToAdd + ''  + '</div>';
		updatedHtmlToAppend += '</a></div>';
		//if orderable
		if (litOrderable == "true") 
		{
			updatedHtmlToAppend += '<div class="litOrderBtnContainer">Order&nbsp;';
			updatedHtmlToAppend += litType;
			updatedHtmlToAppend += '</div>';
		} else 
		{
			updatedHtmlToAppend += '<div class="litOrderNotAvailableContainer"></div>';
		}
		updatedHtmlToAppend += '</li>';
		$("#english-new-and-recently-updated").append(updatedHtmlToAppend);
	}	
}


function getType(itemUnOrderedID){
	var myID = itemUnOrderedID ;
	var myType = "";
	//clean itemUnOrderedID
	myID = myID.replace("new-", "");
	myID = myID.replace("updated-", "");
	//find type
	myType = orderTypesArray[parseInt(myID)];
	//buld solution
	var mySolution = "Order " + myType;	
	return mySolution;
}

function deleteListItem(){
	var currentID;
	currentID = "this plus" + $(this).parent().attr("id");
	
}

function deleteBtnImageSwitch(){
		
}


