//set variables to default if they are not set

if (mainCategory == ""){mainCategory = "GENERAL";}
if (format == ""){format = "DVD";}
if (listType == ""){listType = "BESTSELLERS";}
if (HeaderColor == ""){HeaderColor = "#1C2B76";}
if (fontHeaderColor == ""){fontHeaderColor = "#FFFFFF";}
if (fontColor == ""){fontColor = "#043067";}
if (fontStyle == ""){fontStyle = "Arial";}
if (fontSize == ""){fontSize = "2";}
if (borderColor == ""){borderColor = "#000000";}
if (backgroundColor == ""){backgroundColor = "#ffffff";}
if (tableWidth == ""){tableWidth = "155";}
if (partnerID == ""){partnerID = "00000000";}

//Check to make sure there are products in the main list
var get_out = 0;

if (itemList.length == 0){
document.writeln("<center>There was an error retrieving the top selling items from DVDEmpire.com - Item List is empty</center>");
get_out = 1;
}
if (get_out != 1){
//set the new list equal to whichever they want
currentList = new Array();
var i = 0;
for (var j=0; j < itemList.length; j++){
if ((itemList[j].main_cat.toUpperCase() == mainCategory.toUpperCase()) && (itemList[j].format.toUpperCase() == format.toUpperCase()) && (itemList[j].listType.toUpperCase() == listType.toUpperCase())){
currentList[i] = new addItem(itemList[j].title, itemList[j].item_link, "", "", "");
i++;
}
}

//should now have at least 1 item if not get out
if (currentList.length == 0){
document.writeln("<center>There was an error retrieving the top selling items from DVDEmpire.com - No Matching Data</center>");
get_out = 1;
}

//if we are still ok write out the top sellers
if (get_out != 1){
//print out the top section first (table def, etc)
document.writeln("<table width='" + tableWidth + "' cellspacing='0' cellpadding='1' border='0' bgcolor='" + backgroundColor + "'>");

document.writeln("<tr bgcolor='" + HeaderColor + "'>");
document.writeln("<td width='100%' align='center'>");
document.writeln("<font face='" + fontStyle + "' size='" + fontSize + "' color='" + fontHeaderColor + "'>");
//create the title bar
var titleBar = "";
if (mainCategory.toUpperCase() != "GENERAL"){
titleBar = mainCategory + " " + format + " " + listType;
} else {
titleBar = format + " " + listType;
}
document.writeln("<b>" + titleBar + "</b>");
document.writeln("</font>");
document.writeln("</td>");
document.writeln("</tr>");

document.writeln("<tr>");
document.writeln("<td align='center' bgcolor='" + borderColor + "'>");
document.writeln("<table width=100% cellpadding='5' cellspacing='0' border='0' bgcolor='" + backgroundColor + "'>");
document.writeln("<tr>");
document.writeln("<td valign='top'>");
document.writeln("<table width=100% cellspacing='2' cellpadding='0' border='0'>");

//now loop through the bestsellers and write them out
var num = 1;
for (var counter = 0; counter < currentList.length; counter++){
document.writeln("<tr>");
document.writeln("<td valign=top align=right>");
document.writeln("<font face='" + fontStyle + "' size='" + fontSize + "' color='" + fontColor + "'>");
document.writeln(num + ". ");
document.writeln("</font>");
document.writeln("</td>");
document.writeln("<td valign=top align=left>");
document.writeln("<font face='" + fontStyle + "' size='" + fontSize + "' color='" + fontColor + "'>");
document.writeln("<a href='" + currentList[counter].item_link + "&partner_id=" + partnerID + "' style='color:" + fontColor + "'>" + currentList[counter].title + "</a>");
document.writeln("</font>");
document.writeln("</td>");
document.writeln("</tr>");
num++;
}

//close out the tables etc
document.writeln("<tr>");
document.writeln("<td height='5' colspan='2'><img src='http://www.dvdempire.com/Graphics/Running/nothing.gif' align='left' width='1' height='5'></td>");
document.writeln("</tr>");

document.writeln("<tr>");

if (mainCategory.toUpperCase() == "ADULT")
document.writeln("<td colspan='2'><font face='" + fontStyle + "' size='1' color='" + fontColor + "'>List Provided By: <a href='http://www.adultdvdempire.com?partner_id=" + partnerID + "' style='color:" + fontColor + "'>AdultDVDEmpire.com</a></font></td>");
else
document.writeln("<td colspan='2'><font face='" + fontStyle + "' size='1' color='" + fontColor + "'>List Provided By: <a href='http://www.dvdempire.com?partner_id=" + partnerID + "' style='color:" + fontColor + "'>DVDEmpire.com</a></font></td>");

document.writeln("</tr>");

document.writeln("</table>");
document.writeln("</td>");
document.writeln("</tr>");
document.writeln("</table>");
document.writeln("</td>");
document.writeln("</tr>");

document.writeln("</table>");
}
}

