// File: beetique.js
// Author: Ramola Gokhale

function draw_images(orientation, num_cards_per_row)
{
    if (orientation == 'hv') {
        arr = hv;     
    } else if (orientation == 'ho') {
        arr = ho; 
    } else if (orientation == 'vo') {
        arr = vo; 
    }
   
    var row_cnt = 0;    
    var output = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" >\n";
        
    for (i=0; i<arr.length; ++i) {
    
       if (row_cnt==0) { output += "<tr>\n"; }
    
        var cards = new Array();
	var cards = (arr[i]).split('|');
	//cards[0] => Card ID
	//cards[1] => Card Name
	//cards[2] => Relative Path to Full Image
	//cards[3] => Relative Path to Thumbnail
	//cards[4] => Orientation        
        
        output += 
                "<td>"                                                                                           + "\n" +
                "<a href=\"" + cards[2] + "\" title=\"" + cards[1] + "\" class=\"thickbox\" rel=\"" + orientation + "_images\">" + "\n" +
                "<img src=\"" + cards[3] + "\" alt=\"\"/></a><br />"                                            + "\n" +
                "<a href=\"order.htm?card=" + cards[1]                                                          + 
                "&id="                      + cards[0] + 
                "&orientation="             + cards[4] + 
                "&img_path="                + cards[2] +
                "\">"                       + cards[1] + "</a>"                                                 + "\n" +
                "</td>\n";                     
        cards=null;    
        if ( (row_cnt==(num_cards_per_row-1)) || (i==(arr.length-1)) ) { output += "</tr>\n"; row_cnt=0; }  
        else { row_cnt++; }                 
    }
    
    output += "</table>"; 
    document.write (output); 
    output="";
}
