// JavaScript Document

function disableEnterKey(e) {                                          
  var key;     
                                                        
  if (window.event)
    key=window.event.keyCode; 
   else
    key=e.which;     
                                           
  return (key != 13);                                                                                               
}

function trim(str) {
    if(!str || typeof str != 'string')
        return null;

    return str.replace(/^[\s]+/,'').replace(/[\s]+$/,'').replace(/[\s]{2,}/,' ');
}

function removeSpaces(remove_type, component_name) {
        //remove_type-ot nem használjuk, csak benne hagytuk mert sok helyen lett ez a funkció így meghívva!
        
        //Betöltjük egy változóba a szövegszerkesztő mező tartalmát
        var string_tarolo = document.getElementById(component_name).value;
        //átalakítjuk az "enter"-eket, hogy a következő utasítás ne törölje azokat is
        string_tarolo = string_tarolo.replace(/(\n\r|\n|\r)/gm,"<1br />");
        //töröljük a többszörös "space"-eket
        string_tarolo = string_tarolo.replace(/\s+/g, ' ');
        //visszatesszük az "enter"-eket
        re2 = /\<1br \/>/gi;
        string_tarolo = string_tarolo.replace(re2, "\n");                        
        //Ha a kivont "space"-ek után nem üres az átmeneti szöveg tároló...    
        if (string_tarolo != '' && string_tarolo != ' ') {
          //akkor irjuk vissza a mezőbe és a függvény visszatérési értéke igaz
          document.getElementById(component_name).value=string_tarolo;
          return true;}
         else          
          return false; //egyébként hamis                 
}

/*function removeSpaces(remove_type, component_name){ // RÉGI
        //Ha remove_type = 0 vagy false, akkor kicseréli a többszörös space-kat egy space-ra és törli az összes tab-ot a string-ben
        //Ha remove_type = 1 vagy true, akkor kicseréli a többszörös space-kat és tab-okat egy space-ra a string-ben
        
        var string_tarolo = document.getElementById(component_name).value;

        string_tarolo = string_tarolo.replace(/(\n\r|\n|\r)/gm,"<1br />");
        
        if (remove_type == 0 || remove_type ==  false) {
          string_tarolo = string_tarolo.replace(/\t/g,"");}
         else {
          string_tarolo = string_tarolo.replace(/\t/g," ");}

        re1 = /\s+/g;
        string_tarolo = string_tarolo.replace(re1," ");

        re2 = /\<1br \/>/gi;
        string_tarolo = string_tarolo.replace(re2, "\n");
        
        ss = string_tarolo.replace(/(\n\r|\n|\r)/gm,"");
        ss = ss.replace(re1,"");
        
        if (ss != "") {
          document.getElementById(component_name).value = trim(string_tarolo);
          return true;}
         else
          return false;                
}*/

    function SetAuctionFormat(section_prefix, live_site, rate_type, sorszam, auction_name, auction_id, userid, color) {
       if (color != 'none')
         color='style= color:'+color+';';
        else 
         color='';
       var GetStringWidthDiv1=document.getElementById('GetStringWidthDiv');
       var AucNameTableTD=document.getElementById(section_prefix+'AuctionName_'+sorszam);
       GetStringWidthDiv1.innerHTML='&nbsp;'+auction_name;
       var StringWidth_Pixel=GetStringWidthDiv1.clientWidth + 1;
       
       var string_tarolo = auction_name;      
       if (StringWidth_Pixel > AucNameTableTD.clientWidth) {         
         var StringWidth_Length=auction_name.length;
         while (StringWidth_Pixel > AucNameTableTD.clientWidth) {
            StringWidth_Length--;
            GetStringWidthDiv1.innerHTML='&nbsp;'+auction_name.substr(0,StringWidth_Length)+'...';           
            StringWidth_Pixel=GetStringWidthDiv1.clientWidth + 1;}                                                                                                                         
           
         switch (section_prefix) {            
           case "R":
             if (rate_type == 'bidder')
               string_tarolo='<a '+color+' href="'+live_site+'/index.php?option=com_rbids&task=viewbids&id='+auction_id+'&Itemid=59">'+string_tarolo.substr(0, StringWidth_Length)+'<a>...';
              else
               string_tarolo='<a '+color+' href="'+live_site+'/index.php?option=com_rbids&task=viewbids_comb&id='+auction_id+'&userid='+userid+'&Itemid=83">'+string_tarolo.substr(0, StringWidth_Length)+'<a>...';
           break;
           case "N":
           case "T":
           case "FA":
             if (rate_type == 'auctioneer')
               string_tarolo='<a '+color+' href="'+live_site+'/index.php?option=com_rbids&task=viewbids&id='+auction_id+'&Itemid=59">'+string_tarolo.substr(0, StringWidth_Length)+'<a>...';
              else
               string_tarolo='<a '+color+' href="'+live_site+'/index.php?option=com_rbids&task=viewbids_comb&id='+auction_id+'&userid='+userid+'&Itemid=83">'+string_tarolo.substr(0, StringWidth_Length)+'<a>...';              
           break;
         }
                  
    //     if ((section_prefix == 'N' && rate_type == 'auctioneer') || (section_prefix == 'R' && rate_type == 'bidder') || (section_prefix == 'T' && rate_type == 'auctioneer') || (section_prefix != 'FA'))
    //       string_tarolo='<a '+color+' href="'+live_site+'/index.php?option=com_rbids&task=viewbids&id='+auction_id+'&Itemid=59">'+string_tarolo.substr(0, StringWidth_Length)+'<a>...';
    //      else
    //       string_tarolo='<a '+color+' href="'+live_site+'/index.php?option=com_rbids&task=viewbids_comb&id='+auction_id+'&userid='+userid+'&Itemid=83">'+string_tarolo.substr(0, StringWidth_Length)+'<a>...';
         AucNameTableTD.setAttribute('title', auction_name);}
        else {                                                                
         switch (section_prefix) {
           case "R":
             if (rate_type == 'bidder')
               string_tarolo='<a '+color+' href="'+live_site+'/index.php?option=com_rbids&task=viewbids&id='+auction_id+'&Itemid=59">'+string_tarolo+'<a>';
              else
               string_tarolo='<a '+color+' href="'+live_site+'/index.php?option=com_rbids&task=viewbids_comb&id='+auction_id+'&userid='+userid+'&Itemid=83">'+string_tarolo+'<a>';                                       
           break;
           case "N":
           case "T":
           case "FA":
             if (rate_type == 'auctioneer')
               string_tarolo='<a '+color+' href="'+live_site+'/index.php?option=com_rbids&task=viewbids&id='+auction_id+'&Itemid=59">'+string_tarolo+'<a>';
              else 
               string_tarolo='<a '+color+' href="'+live_site+'/index.php?option=com_rbids&task=viewbids_comb&id='+auction_id+'&userid='+userid+'&Itemid=83">'+string_tarolo+'<a>';             
           break;                                      
         }                       
    //     if ((section_prefix == 'N' && rate_type == 'auctioneer') || (section_prefix == 'R' && rate_type == 'bidder') || (section_prefix == 'T' && rate_type == 'auctioneer') || (section_prefix != 'FA'))
    //       string_tarolo='<a '+color+' href="'+live_site+'/index.php?option=com_rbids&task=viewbids&id='+auction_id+'&Itemid=59">'+string_tarolo+'<a>';
    //      else 
    //       string_tarolo='<a '+color+' href="'+live_site+'/index.php?option=com_rbids&task=viewbids_comb&id='+auction_id+'&userid='+userid+'&Itemid=83">'+string_tarolo+'<a>';
        }          
       AucNameTableTD.innerHTML='&nbsp;' + string_tarolo;                       
       GetStringWidthDiv1.innerHTML='';      
    }
   
    function SetAuctionFormatDIV(section_prefix, live_site, vieweruser_type, sorszam, auction_name, auction_id, userid, color) {                        
       if (color != 'none')
         color='style= color:'+color+';';
        else 
         color='';
       var GetStringWidthDiv1=document.getElementById('GetStringWidthDiv');
       var AucNameDiv=document.getElementById(section_prefix+'AuctionName_'+sorszam);
       GetStringWidthDiv1.innerHTML=auction_name;
       var StringWidth_Pixel=GetStringWidthDiv1.clientWidth + 1;
       
       var string_tarolo = auction_name;      
       if (StringWidth_Pixel > AucNameDiv.clientWidth) {         
         var StringWidth_Length=auction_name.length;
         while (StringWidth_Pixel > AucNameDiv.clientWidth) {
            StringWidth_Length--;
            GetStringWidthDiv1.innerHTML=auction_name.substr(0,StringWidth_Length)+'...';           
            StringWidth_Pixel=GetStringWidthDiv1.clientWidth + 1;}                                                                                                              
         if (vieweruser_type == 'auctioneer')
           string_tarolo='<a '+color+' href="'+live_site+'/index.php?option=com_rbids&task=viewbids&id='+auction_id+'&Itemid=59">'+string_tarolo.substr(0, StringWidth_Length)+'<a>...';
          else
           string_tarolo='<a '+color+' href="'+live_site+'/index.php?option=com_rbids&task=viewbids_comb&id='+auction_id+'&userid='+userid+'&Itemid=83">'+string_tarolo.substr(0, StringWidth_Length)+'<a>...';
         AucNameDiv.setAttribute('title', auction_name);}
        else {                                                       
         if (vieweruser_type == 'auctioneer')
           string_tarolo='<a '+color+' href="'+live_site+'/index.php?option=com_rbids&task=viewbids&id='+auction_id+'&Itemid=59">'+string_tarolo+'<a>';
          else 
           string_tarolo='<a '+color+' href="'+live_site+'/index.php?option=com_rbids&task=viewbids_comb&id='+auction_id+'&userid='+userid+'&Itemid=83">'+string_tarolo+'<a>';
        }          
       AucNameDiv.innerHTML=string_tarolo;                       
       GetStringWidthDiv1.innerHTML='';      
    }
              
function FillRatings1(live_site, star_div, rating) {
    if (isNaN(rating)) 
      rating=0;       

    var star_div_html='';
    for (var j=0;j<Math.floor(rating);j++)
      star_div_html+='<img src="'+live_site+'/components/com_rbids/images/f_rateit_1_v1.png" id="auction_star" border=0>';
    if (rating!=Math.floor(rating))              
      star_div_html+='<img src="'+live_site+'/components/com_rbids/images/f_rateit_h_v1.png" id="auction_star" border=0>';
    for (var j=Math.ceil(rating)+1;j<=5;j++)
      star_div_html+='<img src="'+live_site+'/components/com_rbids/images/f_rateit_0_v1.png" id="auction_star" border=0>';
    
    var star_div_element=document.getElementById(star_div);    
    star_div_element.innerHTML=star_div_html;
}

 

