
function setCurrentBid( param )
{
    this.current_bid = param
}
function setCurrentBidActive( param )
{
    this.is_current_bid = param
}

function setBuyItNow( param )
{
    this.buy_it_now = param
}
function setBuyItNowActive( param )
{
    this.is_buy_it_now = param
}

function setEnding( param )
{
    this.ending = param
}
function setEndingActive( param )
{
    this.is_ending = param
}

function setBids( param )
{
    this.bids = param
}
function setBidsActive( param )
{
    this.is_bids = param
}

function setDesc( param )
{
    this.desc = param
}
function setImgURL( param )
{
    this.img_url = param
}
function setBidLink( param )
{
    this.bidLink = param
}
function setAuctionId( param )
{
    this.auction_id = param
}
function setActive( param )
{
    this.isActive = param
}

function Bid()
{
    this.current_bid=null;
	this.buy_it_now=null;
	this.ending=null;
	this.bids=null;
	this.desc=null;
	this.img_url=null;
	this.bidLink=null;
	this.auction_id=null;
    this.isActive=true;
    
    this.is_current_bid = true;
    this.is_buy_it_now = true;
    this.is_ending = true;
    this.is_bids = true;
    
    this.setCurrentBid = setCurrentBid;
    this.setBuyItNow = setBuyItNow;
    this.setEnding = setEnding;
    this.setBids = setBids;
    this.setDesc = setDesc;
    this.setImgURL = setImgURL;
    this.setBidLink = setBidLink;
    this.setAuctionId = setAuctionId;
    this.setActive = setActive;
    
    this.setCurrentBidActive = setCurrentBidActive;
    this.setBuyItNowActive = setBuyItNowActive;
    this.setEndingActive = setEndingActive;
    this.setBidsActive = setBidsActive;
}










function GalleryCustom()
{
    this.backgroundColor = "#55ABFF";
    this.textColor  = "#000000";
    this.galWidth = "800";
    this.promotionalText = "Please view my other items";
    
    //-- custom 
    this.arrBids = new Array();
    this.lenArrBids = 0;
    //-- ebay 
    this.arrEBAYBids = new Array();
    this.lenEBAYArrBids = 0;
    //-- live update
    this.isLiveUpdate = 'yes';
    this.sourceGallery = '';
    this.typeGallery = ''; // seller, store, searchURL
}

GalleryCustom.instance = null; // Will contain the one and only instance of the class  
      
    // This function ensures that I always use the same instance of the object  
    GalleryCustom.getInstance = function() {  
       if (GalleryCustom.instance == null) {  
           GalleryCustom.instance = new GalleryCustom();  
       }  
     
       return GalleryCustom.instance;  
   }

GalleryCustom.prototype.setIsLiveUpdate = function( val )
{
    this.isLiveUpdate = val;
}
GalleryCustom.prototype.getIsLiveUpdate = function( val )
{
    return this.isLiveUpdate;
}
  
GalleryCustom.prototype.addBid = function( bid )
{
    this.arrBids[this.lenArrBids] = bid;
    this.lenArrBids++;
//    alert(this.lenArrBids);
}

GalleryCustom.prototype.addEBAYBid = function( bid )
{
    this.arrEBAYBids[this.lenEBAYArrBids] = bid;
    this.lenEBAYArrBids++;
//    alert(this.lenArrBids);
}

GalleryCustom.prototype.setBgColor = function( val )
{
    this.backgroundColor = val;
}
GalleryCustom.prototype.setTextColor = function( val )
{
    this.textColor = val;
}
GalleryCustom.prototype.setWidth = function( val )
{
    this.galWidth = val;
}
GalleryCustom.prototype.getWidth = function( )
{
    return this.galWidth;
}
GalleryCustom.prototype.setPromotionalText = function( val )
{
    this.promotionalText = val;
}

GalleryCustom.prototype.clearBids = function( )
{
    for(i=0, end=this.arrBids.length; i<end; i++)
    {
            this.arrBids.pop();
            this.lenArrBids--;
     }
}

GalleryCustom.prototype.clearEBAYBids = function( )
{
    for(i=0, end=this.arrEBAYBids.length; i<end; i++)
    {
            this.arrEBAYBids.pop();
            this.lenEBAYArrBids--;
     }
}

GalleryCustom.prototype.getObj2From = function( )
{
    var strOut = '';
            
        strOut += '<input type="Hidden" name="backgroundColor" value="'+this.backgroundColor+'">';
        strOut += '<input type="Hidden" name="textColor" value="'+this.textColor+'">';
        strOut += '<input type="Hidden" name="galWidth" value="'+this.galWidth+'">';
        strOut += '<input type="Hidden" name="promotionalText" value="'+this.promotionalText+'">';
        
        for(i=0; i<this.arrBids.length; i++)
        {
            if ( this.arrBids[i].bidLink != '' && this.arrBids[i].bidLink != 'http://' && this.arrBids[i].img_url != '' && this.arrBids[i].img_url != 'http://' && this.arrBids[i].desc != '' ) 
            {
                strOut += '<input type="Hidden" name="arr_bidLink['+i+']" value="'+this.arrBids[i].bidLink+'">';
                strOut += '<input type="Hidden" name="arr_img_url['+i+']" value="'+this.arrBids[i].img_url+'">';
                strOut += '<input type="Hidden" name="arr_desc['+i+']" value="'+this.arrBids[i].desc+'">';
                
             }
        }
        
      return strOut;
}

GalleryCustom.prototype.getEBAYObj2From = function( )
{
    var strOut = '';
            
        strOut += '<input type="Hidden" name="backgroundColor" value="'+this.backgroundColor+'">';
        strOut += '<input type="Hidden" name="textColor" value="'+this.textColor+'">';
        strOut += '<input type="Hidden" name="galWidth" value="'+this.galWidth+'">';
        strOut += '<input type="Hidden" name="promotionalText" value="'+this.promotionalText+'">';
        
        for(i=0; i<this.arrBids.length; i++)
        {
            if ( this.arrBids[i].bidLink != '' && this.arrBids[i].bidLink != 'http://' && this.arrBids[i].img_url != '' && this.arrBids[i].img_url != 'http://' && this.arrBids[i].desc != '' ) 
            {
                strOut += '<input type="Hidden" name="arr_bidLink['+i+']" value="'+this.arrBids[i].bidLink+'">';
                strOut += '<input type="Hidden" name="arr_img_url['+i+']" value="'+this.arrBids[i].img_url+'">';
                strOut += '<input type="Hidden" name="arr_desc['+i+']" value="'+this.arrBids[i].desc+'">';
                
             }
        }
        
      return strOut;
}

GalleryCustom.prototype.getHTMLPreview = function( )
{
    var strOut = '';
        strOut += '<form method="post" id="frmGalleryCustomPreview" enctype="multipart/form-data" onsubmit="return false">';
        strOut += '<input type="Hidden" name="doRequest" value="typeCustomGenerate1">';
        
        strOut += this.getObj2From();
        

    for(i=0; i<this.arrBids.length; i++)
    {
        
        if ( this.arrBids[i].bidLink != '' && this.arrBids[i].bidLink != 'http://' && this.arrBids[i].img_url != '' && this.arrBids[i].img_url != 'http://' && this.arrBids[i].desc != '' ) 
        {
                                
                                   strOut += '<div style="display:inline">\
                                                    <table border=0 cellpadding=0 cellspacing=0 width=320 height="170" style="float:left">\
                                                    <tr>\
                                                      <td width="25" height="5">\
                                                      <img border="0" src="images/tran.gif" width="1" height="1">\
                                                      </td>\
                                                      <td colspan="2" class="fields" width="295" height="5"><img border="0" src="images/tran.gif" width="1" height="1"></td>\
                                                    </tr>\
                                                    <tr>\
                                                      <td width="25">\
                                                      </td>\
                                                      <td colspan="2" class="fields" width="295">URL:  '+ this.arrBids[i].img_url +'</td>\
                                                    </tr>\
                                                    <tr>\
                                                      <td width="25" rowspan="2">\
                                                        <p align="center"><input type="checkbox" value="ON" name="itemCustom['+i+']" ' + (this.arrBids[i].isActive?'checked':'') + '  id="itemCustom_' + i + '"></td>\
                                                      <td width="100" rowspan="2"><img border="0" src="'+ this.arrBids[i].img_url +'" width="96" height="72"></td>\
                                                      <td width="195" class="fields">'+ this.arrBids[i].desc +'&nbsp;</td>   \
                                                    </tr>\
                                                    <tr>\
                                                      <td width="195" class="fields">&nbsp;'+ this.arrBids[i].bidLink +'</td>  \
                                                    </tr>\
                                                    <tr>\
                                                      <td colspan="3" height="5">\
                                                        <img border="0" src="images/tran.gif" width="1" height="1"></td>\
                                                    </tr>\
                                                  </table>\
                                 </div>';
                                 
         }
         
    }
    
    strOut += '</form>';
    
    
    return strOut;
}

GalleryCustom.prototype.getEBAYHTMLPreview = function( )
{
    var strOut = '';
        strOut += '<form method="post" id="frmEBAYPreview" enctype="multipart/form-data" onsubmit="return false">';
        strOut += '<input type="Hidden" name="doRequest" value="frmEBAYPreview">';
        
        strOut += '<input type="Hidden" name="isLiveUpdate" value="'+this.isLiveUpdate+'">';
        strOut += '<input type="Hidden" name="sourceGallery" value="'+this.sourceGallery+'">';
        strOut += '<input type="Hidden" name="typeGallery" value="'+this.typeGallery+'">';
        
        strOut += this.getEBAYObj2From();
        

    for(i=0; i<this.arrEBAYBids.length; i++)
    {
        
        if ( this.arrEBAYBids[i].bidLink != '' && this.arrEBAYBids[i].bidLink != 'http://' && this.arrEBAYBids[i].img_url != '' && this.arrEBAYBids[i].img_url != 'http://' && this.arrEBAYBids[i].desc != '' ) 
        {
                                
//                                '.(this.arrEBAYBids[i].isActive?'checked':'').'

                                    var cur_bid_checked = '';
                                    var buy_it_now_checked = '';
                                    var ending_checked = '';
                                    var bids_checked = '';
                                    if ( this.arrEBAYBids[i].is_current_bid )
                                      cur_bid_checked = 'checked';
                                    if ( this.arrEBAYBids[i].is_buy_it_now )
                                      buy_it_now_checked = 'checked';
                                    if ( this.arrEBAYBids[i].is_ending )
                                      ending_checked = 'checked';
                                    if ( this.arrEBAYBids[i].is_bids )
                                      bids_checked = 'checked';
                      

                                   strOut += '<div style="display:inline">\
                                                <table border="0" cellpadding="0" cellspacing="0" width="320" height="170" style="float:left">\
                                                <tr>\
                                                  <td width="25" height="5">\
                                                  <img border="0" src="images/tran.gif" width="1" height="1">\
                                                  </td>\
                                                  <td colspan="4" class="fields" width="295" height="5"><img border="0" src="images/tran.gif" width="1" height="1"></td>\
                                                </tr>\
                                                <tr>\
                                                  <td width="25">\
                                                  </td>\
                                                  <td colspan="4" class="fields" width="295">'+ this.arrEBAYBids[i].auction_id +'</td>\
                                                </tr>\
                                                <tr>\
                                                  <td rowspan="4" width="25">\
                                                    <p align="center"><input type="checkbox" value="ON" name="itemEBAY[' + this.arrEBAYBids[i].auction_id + ']" ' + (this.arrEBAYBids[i].isActive?'checked':'') + ' id="itemEBAY_' + this.arrEBAYBids[i].auction_id + '"></td>\
                                                  <td rowspan="4" width="100"><img border="0" src="'+ this.arrEBAYBids[i].img_url +'" width="96" height="72"></td>\
                                                  <td width="25"><input type="checkbox" value="ON" name="cur_bid[' + this.arrEBAYBids[i].auction_id + ']" '+cur_bid_checked+' id="cur_bid_' + this.arrEBAYBids[i].auction_id + '"></td>  \
                                                  <td class="fields" align="left" width="85">Current Bid</td>      \
                                                  <td class="fields" align="left" width="85" rowspan="4"><a href="javascript:uncheckallForItem( \'' + this.arrEBAYBids[i].auction_id + '\' )">Uncheck All</a></td>\
                                                </tr>\
                                                <tr>\
                                                  <td width="25"><input type="checkbox" value="ON" name="buy_it_now[' + this.arrEBAYBids[i].auction_id + ']" '+buy_it_now_checked+' id="buy_it_now_' + this.arrEBAYBids[i].auction_id + '"></td>\
                                                  <td class="fields" align="left" width="85">Buy it Now</td>\
                                                </tr>\
                                                <tr>\
                                                  <td width="25"><input type="checkbox" value="ON" name="ending[' + this.arrEBAYBids[i].auction_id + ']" '+ending_checked+' id="ending_' + this.arrEBAYBids[i].auction_id + '"></td>\
                                                  <td class="fields" align="left" width="85">Ending</td>\
                                                </tr>\
                                                <tr>\
                                                  <td width="25"><input type="checkbox" value="ON" name="bids[' + this.arrEBAYBids[i].auction_id + ']" '+bids_checked+' id="bids_' + this.arrEBAYBids[i].auction_id + '"></td>\
                                                  <td class="fields" align="left" width="85"># Bids</td>\
                                                </tr>\
                                                <tr>\
                                                  <td width="25"></td>\
                                                  <td colspan="4" class="fields" width="295">'+ this.arrEBAYBids[i].desc +'</td>\
                                                </tr>\
                                                <tr>\
                                                  <td width="25" height="5">\
                                                  <img border="0" src="images/tran.gif" width="1" height="1">\
                                                  </td>\
                                                  <td colspan="4" class="fields" width="295" height="5"><img border="0" src="images/tran.gif" width="1" height="1"></td>\
                                                </tr>\
                                              </table>\
                             </div>';
                                 
         }
         
    }
    
    strOut += '</form>';
    
    
    return strOut;
}

GalleryCustom.prototype.setEBAYBidStatus = function( auction_id, status )
{
    for(i=0; i<this.arrEBAYBids.length; i++)
    {
        if ( this.arrEBAYBids[i].auction_id == auction_id || auction_id == -1 )
            this.arrEBAYBids[i].setActive( status );
    }
}

GalleryCustom.prototype.setEBAYBidDesc = function( auction_id, desc )
{
    var ii;
    for(ii=0; ii<this.arrEBAYBids.length; ii++)
    {
        if ( this.arrEBAYBids[ii].auction_id == auction_id)
            this.arrEBAYBids[ii].setDesc( desc );
    }
}

GalleryCustom.prototype.setEBAYBidPropertie = function( auction_id, propertie, status )
{
    for(i=0; i<this.arrEBAYBids.length; i++)
    {
        if ( this.arrEBAYBids[i].auction_id == auction_id || auction_id == -1 )
        {
        
            if ( propertie == 'current_bid' )
                this.arrEBAYBids[i].setCurrentBidActive( status );
            if ( propertie == 'buy_it_now' )
                this.arrEBAYBids[i].setBuyItNowActive( status );
            if ( propertie == 'ending' )
                this.arrEBAYBids[i].setEndingActive( status );
            if ( propertie == 'bids' )
                this.arrEBAYBids[i].setBidsActive( status );
        }
    }
}


GalleryCustom.prototype.getEBAYEditArea = function( )
{
    var strOut = '';
    var k = 1;
    for(i=0; i<this.arrEBAYBids.length; i++)
    {
        
        if ( this.arrEBAYBids[i].bidLink != '' && this.arrEBAYBids[i].bidLink != 'http://' && this.arrEBAYBids[i].img_url != '' && this.arrEBAYBids[i].img_url != 'http://' && this.arrEBAYBids[i].desc != '' && this.arrEBAYBids[i].isActive ) 
        {
            kidx = ( k<10 ) ? '0'+k : k;
            strOut += '<div style="display:inline">';
                    if ( this.arrEBAYBids[i].is_current_bid )
                      strOut += '<input type="hidden" value="ON" name="cur_bid[' + k + ']" id="cur_bid_' + k + '">';
                    if ( this.arrEBAYBids[i].is_buy_it_now )
                      strOut += '<input type="hidden" value="ON" name="buy_it_now[' + k + ']" id="buy_it_now_' + k + '">';
                    if ( this.arrEBAYBids[i].is_ending )
                      strOut += '<input type="hidden" value="ON" name="ending[' + k + ']" id="ending_' + k + '">';
                    if ( this.arrEBAYBids[i].is_bids )
                      strOut += '<input type="hidden" value="ON" name="bids[' + k + ']" id="bids_' + k + '">';
                    
            strOut += '<table border="0" cellpadding="0" cellspacing="0" style="float:left">\
                    <tr>\
                      <td width="30" height="8" colspan="5"><img border="0" src="images/tran.gif" width="1" height="1"></td>\
                    </tr>\
                    <tr>\
                      <td width="5"><img border="0" src="images/tran.gif" width="1" height="1"></td>\
                      <td class="fields" align="right">Auction '+kidx+'</td>\
                      <td width="10"><img border="0" src="images/tran.gif" width="1" height="1"></td>\
                      <td><input type="text" size="30" style="font-family: Arial; font-size: 10pt" name="ebayAuction['+k+']" id="ebayAuction_'+k+'" value="'+this.arrEBAYBids[i].auction_id+'"></td>\
                      <td width="10"><img border="0" src="images/tran.gif" width="1" height="1"></td>\
                    </tr>\
                    <tr>\
                      <td width="5"><img border="0" src="images/tran.gif" width="1" height="1"></td>\
                      <td class="fields" align="right">Description '+kidx+'</td> \
                      <td width="10"><img border="0" src="images/tran.gif" width="1" height="1"></td>\
                      <td><input type="text" size="30" style="font-family: Arial; font-size: 10pt" name="ebayDesc['+k+']" id="ebayDesc_'+k+'" value="'+this.arrEBAYBids[i].desc+'"></td>\
                      <td width="10"><img border="0" src="images/tran.gif" width="1" height="1"></td>\
                    </tr>\
                    <tr>\
                      <td width="30" height="8" colspan="5"><img border="0" src="images/tran.gif" width="1" height="1"></td>\
                    </tr>\
                  </table></div>';
             k++;
        }
    }  
    
    return strOut;  
}


GalleryCustom.prototype.getEBAYItemCount = function( )
{
    var k = 0;
    for(i=0; i<this.arrEBAYBids.length; i++)
    {
        if ( this.arrEBAYBids[i].bidLink != '' && this.arrEBAYBids[i].bidLink != 'http://' && this.arrEBAYBids[i].img_url != '' && this.arrEBAYBids[i].img_url != 'http://' && this.arrEBAYBids[i].desc != '' && this.arrEBAYBids[i].isActive ) 
        {
             k++;
        }
    }  
    return k;  
}









//-- DEBUG INFO
GalleryCustom.prototype.getBid = function( idx )
{
    return this.arrBids[idx];
}

GalleryCustom.prototype.isOk = function( )
{
    alert('test ok');
}
GalleryCustom.prototype.debug = function( )
{
    for(i=0; i<this.arrBids.length; i++)
    {
        alert(this.arrBids[i].bidLink);
    }
}

GalleryCustom.prototype.debugEBAY = function( )
{
    for(i=0; i<this.arrEBAYBids.length; i++)
    {
        alert(this.arrEBAYBids[i].bidLink);
    }
}








    // I create the class  
    function CatNames() {  
        this.names = new Array(); // The array that will contain the names  
    }  
      
    CatNames.instance = null; // Will contain the one and only instance of the class  
      
    // This function ensures that I always use the same instance of the object  
    CatNames.getInstance = function() {  
       if (CatNames.instance == null) {  
           CatNames.instance = new CatNames();  
       }  
     
       return CatNames.instance;  
   }  
     
   // Function to add a cat name  
   CatNames.prototype.add = function(catName) {  
       this.names.push(catName);  
   }  
     
   // Function to remove the last cat name  
   CatNames.prototype.removeLast = function() {  
       return this.names.pop();  
   }  
     
   // Function to alert all cat names  
   CatNames.prototype.alertAllCats = function() {  
//       alert(this.names.join(","));  
   }  
  
  
  
   var names = CatNames.getInstance();  
   
     names.add("Mistigri");  
     names.add("Bibi");  
     names.add("Gary"); 
     
     var names = CatNames.getInstance();  
     names.alertAllCats();
     
     var name1 = CatNames.getInstance();  
     name1.alertAllCats();
