﻿//-------- 30 july 2009
//function TemplateArrayData(sTitle,sPrice, sFeatures, sDate , sImage , sSold , sFlash)
//-------- 30 july 2009
function TemplateArrayData(sTitle,sPrice, sFeatures, sDate , sImage , sSold , sFlash, sSpOffer)
{
    this.Title = sTitle || ""; 
    this.Price = sPrice || "";
    this.Features = sFeatures || "";
    this.Date = sDate || "";
    this.Image = sImage || "";
    this.IsSold = sSold || "";
    this.IsFlash = sFlash || "";
    //-------- 30 july 2009
    this.IsSpOffer = sSpOffer || "";
    //-------- 30 july 2009
    
}

function LoadTemplateData()
{

    if(myArray.length >0 )
    {
    
        var sTbl = "<table border='0' cellspacing='1' cellspacing='1' width='100%' >";
        var cssClass = "";
        for (i=0;i<myArray.length;i++)
        {
            if(i%3==0)sTbl += "<TR>";
            
            if (i % 2 == 0)
                cssClass = "bck1";
            else
                cssClass = "bck2";
            
            sTbl += "<TD class='" + cssClass + "' width='33%' valign='top' >";
            //sTbl += GetTableStructure(myArray[i].Title,myArray[i].Price,myArray[i].Image,myArray[i].Date,myArray[i].IsFlash,myArray[i].IsSold,myArray[i].Features,i);
            //-------- 30 july 2009
            sTbl += GetTableStructure(myArray[i].Title,myArray[i].Price,myArray[i].Image,myArray[i].Date,myArray[i].IsFlash,myArray[i].IsSold,myArray[i].Features,i,myArray[i].IsSpOffer);
            //-------- 30 july 2009
            sTbl += "</td>";
            
            
            if(i%3 == 2 || i == myArray.length-1)
                sTbl += "</TR>";
        }
        sTbl += "</table>";
        
        document.getElementById("DivLoadedData").innerHTML = sTbl;
        
        ///window.setInterval("LoadTemplateImages()",3000);
        LoadTemplateImages();
    }
    
}


//-------- 30 july 2009
//function GetTableStructure(title,price,image,date,isflash,issold,features,i)
//-------- 30 july 2009
function GetTableStructure(title,price,image,date,isflash,issold,features,i,isspoffer)
{

    var isNew = false;
    if(itmpPageNumber == 1)
        if (issold.toLowerCase() == 'false' || i < 3)
            isNew = true;
    
    var sTbl = "";
    sTbl = "<table border='0' width='100%' id='template_table_" + i  + "' cellpadding='0' cellspacing='0'><TR><TD valign='top'>";
    sTbl += "<table width='100%' border='0'>"
    sTbl += "<TR><TD colspan='2' class='template_item_title' valign='top'>" + title + "</TD></TR>";
    
    sTbl += "<TR>";
    sTbl += "<TD>";
    sTbl += "<table width='100%' >"
    sTbl += "<tr><td valign='top'>";
    sTbl += "<table border=0 width=100% cellpadding=0 cellspacing=0>"
    sTbl += "<tr><td align=left valign='top'><span class='green_bold'>Created At</span></td></tr>";
    sTbl += "<tr><td align='right' valign='top' ><b><span >" + GetDateFormat (date) + "</span></b></td></tr>";
    sTbl += "</table>"; 
    sTbl += "</td></tr>";
    sTbl += "<tr ><td align='center'>";
    sTbl += "<table border='0'>"
    
    
    if(isNew == true || issold.toLowerCase() == "false")
    {
       sTbl += "<TR>"; 
       if(isNew == true)
            sTbl += "<td><a class='help' onmouseout='UnTip()' onmouseover='if(bEnableTip)ShowNewToolTip();'><img alt='' src='Images/new.jpg' border='0' /></a></td>";
       if(issold.toLowerCase() == "false")
            sTbl += "<td><a class='help' onmouseout='UnTip()' onmouseover='if(bEnableTip)ShowNeverSoldToolTip();'><img alt='' src='Images/star.jpg' border='0' /></a></td>";

       sTbl += "</TR>";
    }
    /*
    if(isNew == true)
    sTbl += "<tr><td><a class='help' onmouseout='UnTip()' onmouseover='if(bEnableTip)ShowNewToolTip();'><img alt='' src='Images/new.jpg' border='0' /></a></td></tr>";
    
    if(issold.toLowerCase() == "false")
    sTbl += "<tr><td><a class='help' onmouseout='UnTip()' onmouseover='if(bEnableTip)ShowNeverSoldToolTip();'><img alt='' src='Images/star.jpg' border='0' /></a></td></tr>";
    */
    
    sTbl += "<TR>";
        if(isflash == "true")
            sTbl += "<td><a class='help' onmouseout='UnTip()' onmouseover='if(bEnableTip)ShowFlashToolTip();'><img alt='' src='Images/flash.jpg' border='0' /></a></td>";
        
        sTbl += "<td><a class='help' onmouseout='UnTip()' onmouseover=if(bEnableTip)ShowInformation(Loadproperty('" + title + "'," + features + ")); ><img src='Images/info.jpg' /></a></td>";
    sTbl += "</TR>";
    
    /*
    if(isflash == "true")
    sTbl += "<tr><td><a class='help' onmouseout='UnTip()' onmouseover='if(bEnableTip)ShowFlashToolTip();'><img alt='' src='Images/flash.jpg' border='0' /></a></td></tr>";
    */
    

    //sTbl += "<tr><td><a class='help' onmouseout='UnTip()' onmouseover=if(bEnableTip)ShowInformation(Loadproperty('" + title + "'," + features + ")); ><img src='Images/info.jpg' /></a></td></tr>";
    
    sTbl += "</table>";
    sTbl += "</td></tr>";
        if(isspoffer == "true")
    sTbl += "<tr><td align='center' colspan='2'><a class='help' onmouseout='UnTip()' onmouseover=if(bEnableTip)ShowInformation(Loadproperty('" + title + "'," + features + ")); ><img border='0' src='Images/special_offer.jpg' /></a></td></tr>";
    
    sTbl += "</table>";
    sTbl += "</TD>";


    
    sTbl += "<TD width='130px' valign='top' align='right'>";
        sTbl += "<table border='0' cellpadding='0' cellspacing='0' width='125px' >";
        sTbl += "<tr><td> <img src='Images/spacer.gif' width='130px' height='1px' /></td></tr>";
        sTbl += "<tr><td align='center' height='214px' valign='middle' width='100%' style=" + '"' + "background-image: url('Images/bck2.jpg')" + '"' + ">";
        
        sTbl += "<span id='template_img_" + i + "'>Loading Image...</span>";
        //sTbl += "<img id='' class='templateimage' onclick='ShowEnlargePic(this);' onmouseover='if(bEnableTip)ShowEnlarge();' onmouseout='UnTip()' src='gc_images/" + image + "' style='border-width:0px;' />";
        sTbl += "</td></tr>";
        sTbl += "</table>";
    sTbl += "</TD>";
    
    sTbl += "</TR>";
    
    sTbl += "</table>";    
    
    sTbl += "</TD</TR>"
    
    sTbl += "<tr ><td  colspan='2' height='18px' class='price_center'>Price: $" + price + "</td></tr>";
    
    sTbl += "<TR><TD><img src='Images/spacer.gif' style='width: 1px; height: 3px' /></td></tr>";
    
    sTbl += "<td align='right' colspan='2'><button class = 'btnorder1' onmouseover=this.className='btnorder2'; onmouseout=this.className='btnorder1'; type='button' onclick=gotopage('" + title + "');>Order</button></td></tr>";
    
    sTbl += "<TR><TD><img src='Images/spacer.gif' style='width: 1px; height: 3px' /></td></tr>";
    
    sTbl += "</table>";
    return sTbl;
}


    function LoadTemplateImages()
    {
        var i;
        for (i=0;i<myArray.length;i++)
        {
            try
            {
                var elem = document.getElementById("template_img_" + i);
                elem.innerHTML = GetImagePath(myArray[i].Image);
            }
            catch(Error)
            {
            }
        }
    }
    
    function GetImagePath(imagepath)
    {
        //var csOut = "<img id='" + imagepath + "' class='trans0' onload=fadeto100(0,'" + imagepath + "','templateimage'); onclick='ShowEnlargePic(this);' onmouseover='if(bEnableTip)ShowEnlarge();' onmouseout='UnTip()' src='gc_images/" + imagepath + "' style='border-width:0px;' />";
        var csOut = "<img id='" + imagepath + "' class='templateimage'  onclick='ShowEnlargePic(this);' onmouseover='if(bEnableTip)ShowEnlarge();' onmouseout='UnTip()' src='gc_images/" + imagepath + "' style='border-width:0px;' />";
        return csOut;
    }