var myevent=false;
var arr_f=new Array(1);
arr_f[0]="";

var search_duplicate=false;
var search_duplicate_id="";
/*********************** Variable for product library menu ***********************/
var material_filter_to_model='';
var pattern_filter_to_model='';
var texture_filter_to_model='';
var scale_filter_to_model='';
var color_filter_to_model='';
var color_grouping_filter_to_model='';
var collect_filter_to_model='';
var brands_filter_to_model='';
var designer_filter_to_model='';
var sustain_filter_to_model='';
/* for filter menu */
var material_title='Select one or multiple items';
var material_heading=new Array(2);
    //material_heading[0]="STANDARD";
    //material_heading[1]="SPECIALTY";
    material_heading[0]="";
    material_heading[1]="";
    
var material_column=new Array(2);
    material_column[0]=new Array(7);
    material_column[1]=new Array(6);
    for(i=0;i<material_column[0].length;i++)
        material_column[0][i]=new Array(1);
    for(i=0;i<material_column[1].length;i++)
        material_column[1][i]=new Array(1);
        
    material_column[0][0][0]="Vinyl"; 
    material_column[0][0][1]="1";
    
                                       
     //material_column[0][1][0]="PVC-Free Type II"                                       
    material_column[0][1][0]="TPO" 
    material_column[0][1][1]="1";
    
    material_column[0][2][0]="Non Woven"; 
    material_column[0][2][1]="1";
    
    //material_column[0][3][0]="Non-woven";
   // material_column[0][3][1]="1";
    
    material_column[0][3][0]="Textile"; 
    material_column[0][3][1]="1";

    material_column[0][4][0]="Dry Erase/Projection"; 
    material_column[0][4][1]="1";

    material_column[0][5][0]="Acoustical"; 
    material_column[0][5][1]="1";

    material_column[0][6][0]="Paint";
    material_column[0][6][1]="0";
    
    

    material_column[1][0][0]="Grass Cloth"; 
    material_column[1][0][1]="1";
    
    material_column[1][1][0]="Silk"; 
    material_column[1][1][1]="1";
    
    material_column[1][2][0]="Suede"; 
    material_column[1][2][1]="1";
    
    material_column[1][3][0]="Wood"; 
    material_column[1][3][1]="1";

    material_column[1][4][0]="Cork"; 
    material_column[1][4][1]="1";
    
    material_column[1][5][0]="Patents & Mylars";
    material_column[1][5][1]="1";

   //Please login to view brands available in your area

var material_footer_logout='<p class="logDisplay"><sup style="vertical-align:text-top;">*</sup>Please <a href="#" onclick="dhtmlModalWindow(\'/product_library/login\',\'Login\',\'340\',\'325\')" title="Login">Login</a> brands available in your area.</p>';
var material_footer_login='<p class="logDisplay"><sup style="vertical-align:text-top;">*</sup>Not available in your area.</p>'; 

// Common Variable for login filter status display
var footer_logout='<p id="logDisp"><sup style="vertical-align:text-top;">*</sup>Please <a href="#" onclick="dhtmlModalWindow(\'/product_library/login\',\'Login\',\'340\',\'325\')" title="Login">Login</a> to view brands available in your area.</p>';
var footer_login='<p id="logDisp"><sup style="vertical-align:text-top;">*</sup>Not available in your area.</p>'; 

/* for pattern filter menu */
var pattern_title='Select one or multiple items';
var pattern_heading=new Array(1);
    pattern_heading[0]="";
    
var pattern_column=new Array(1);
    pattern_column[0]=new Array(7);

for(i=0;i<pattern_column[0].length;i++)
        pattern_column[0][i]=new Array(1);
        
    pattern_column[0][0][0]="Stripes and Verticals";
    pattern_column[0][0][1]="1";
    
    pattern_column[0][1][0]="Damasks";
    pattern_column[0][1][1]="1";

    pattern_column[0][2][0]="Solids";
    pattern_column[0][2][1]="1";

    pattern_column[0][3][0]="Geometrics";
    pattern_column[0][3][1]="1";

    pattern_column[0][4][0]="Botanicals/Florals";
    pattern_column[0][4][1]="1";

    pattern_column[0][5][0]="Faux Effects";
    pattern_column[0][5][1]="1";

    pattern_column[0][6][0]="Woven";
    pattern_column[0][6][1]="1";

var pattern_footer='';




var texture_title='Select one or multiple items';
var texture_heading=new Array(1);
    texture_heading[0]="Surface Texture";
    
var texture_column=new Array(1);
    texture_column[0]=new Array(3);

for(i=0;i<texture_column[0].length;i++)
        texture_column[0][i]=new Array(1);
    texture_column[0][0][0]="Heavy Texture";
    texture_column[0][0][1]="1";
    
    texture_column[0][1][0]="Light Texture";
    texture_column[0][1][1]="1";

    texture_column[0][2][0]="Smooth";
    texture_column[0][2][1]="1";

var texture_footer='';



var scale_title='Select one or multiple items';
var scale_heading=new Array(1);
    scale_heading[0]="Scale";
    
var scale_column=new Array(1);
    scale_column[0]=new Array(2);
for(i=0;i<scale_column[0].length;i++)
        scale_column[0][i]=new Array(1);
    scale_column[0][0][0]="Large-scale";
    scale_column[0][0][1]="1";
    
    scale_column[0][1][0]="Small-scale";
    scale_column[0][1][1]="1";
    
var scale_footer='';

var sustain_title='Select one or multiple items';
var sustain_heading=new Array(1);
    //sustain_heading[0]="SUSTAINABILITY";
    sustain_heading[0]="";
    
var sustain_column=new Array(1);
    sustain_column[0]=new Array(4);
for(i=0;i<sustain_column[0].length;i++)
        sustain_column[0][i]=new Array(1);
    sustain_column[0][0][0]="Low-emitting";
    sustain_column[0][0][1]="1";
    
    sustain_column[0][1][0]="Recycled Content";
    sustain_column[0][1][1]="1";
    
    sustain_column[0][2][0]="Rapidly-Renewable";
    sustain_column[0][2][1]="1";
    
    sustain_column[0][3][0]="Anti-Microbial/Anti-Bacterial";
    sustain_column[0][3][1]="1";
    
var sustain_footer='';



/* for color filter menu */

var color_title='Select one or multiple colors';
var color_heading=new Array(2);

    color_heading[0]="";
    color_heading[1]="";

var color_footer='';  
    
var color_column=new Array(2);
    color_column[0]=new Array(12);
    color_column[1]=new Array(6);
for(i=0;i<color_column[0].length;i++)
        color_column[0][i]=new Array(1);
    for(i=0;i<color_column[1].length;i++)
        color_column[1][i]=new Array(1);
            
    color_column[0][0][0]="White";    //    Color 
    color_column[0][0][1]="1";        //    ON State
    color_column[0][0][2]="0";        //     Color Category 0=> color, 1=> color_group
    
    color_column[0][1][0]="Beige";
    color_column[0][1][1]="1";
    color_column[0][1][2]="0";

    color_column[0][2][0]="Blue";
    color_column[0][2][1]="1";
    color_column[0][2][2]="0";

    color_column[0][3][0]="Purple";
    color_column[0][3][1]="1";
    color_column[0][3][2]="0";

    color_column[0][4][0]="Red";
    color_column[0][4][1]="1";
    color_column[0][4][2]="0";

    color_column[0][5][0]="Orange";
    color_column[0][5][1]="1";
    color_column[0][5][2]="0";

    color_column[0][6][0]="Brown";
    color_column[0][6][1]="1";
    color_column[0][6][2]="0";
    
    color_column[0][7][0]="Yellow";
    color_column[0][7][1]="1";
    color_column[0][7][2]="0";

    color_column[0][8][0]="Green";
    color_column[0][8][1]="1";
    color_column[0][8][2]="0";
    
    color_column[0][9][0]="Black";
    color_column[0][9][1]="1";
    color_column[0][9][2]="0";

    color_column[0][10][0]="Grey";
    color_column[0][10][1]="1";
    color_column[0][10][2]="0";
    
    color_column[0][11][0]="Metallic";
    color_column[0][11][1]="1";
    color_column[0][11][2]="0";

    color_column[1][0][0]="Soft-Light";
    color_column[1][0][1]="1";
    color_column[1][0][2]="1";
    
    color_column[1][1][0]="Neutral";
    color_column[1][1][1]="1";
    color_column[1][1][2]="1";

    color_column[1][2][0]="Cool";
    color_column[1][2][1]="1";
    color_column[1][2][2]="1";

    color_column[1][3][0]="Warm";
    color_column[1][3][1]="1";
    color_column[1][3][2]="1";

    color_column[1][4][0]="Vibrant";
    color_column[1][4][1]="1";
    color_column[1][4][2]="1";

    color_column[1][5][0]="Dark";
    color_column[1][5][1]="1";
    color_column[1][5][2]="1";


var collect_title='Select one or multiple item';
var collect_heading=new Array(5);
    collect_heading[0]="Collection";
    collect_heading[1]="&nbsp;";
    collect_heading[2]="DESIGNERS"; 
    collect_heading[3]="BRANDS";
    
var collect_column=new Array(5);
    collect_column[0]=new Array(12);
    collect_column[1]=new Array(12);
    
    collect_column[2]=new Array(6);
    collect_column[3]=new Array(6);

   
for(i=0;i<collect_column[0].length;i++)
        collect_column[0][i]=new Array(3);
        
for(i=0;i<collect_column[1].length;i++)
        collect_column[1][i]=new Array(3); 
   
for(i=0;i<collect_column[2].length;i++)
    collect_column[2][i]=new Array(3); 

for(i=0;i<collect_column[3].length;i++)
    collect_column[3][i]=new Array(3);   

          
    /* 1st column */
    collect_column[0][0][0]="Acoustical Wall";    //    Design Name
    collect_column[0][0][1]="1";                //    ON State (1=ON, 0=OFF)
    collect_column[0][0][2]=16;                    //    CMS Content ID

    collect_column[0][1][0]="Digital Nature";
    collect_column[0][1][1]="1";
    collect_column[0][1][2]=17;

    collect_column[0][2][0]="Etchings";
    collect_column[0][2][1]="1";
    collect_column[0][2][2]=25;

    collect_column[0][3][0]="Esquire";
    collect_column[0][3][1]="1";
    collect_column[0][3][2]=18;

    collect_column[0][4][0]="Essentials";
    collect_column[0][4][1]="1";
    collect_column[0][4][2]=18;

    collect_column[0][5][0]="Europa";
    collect_column[0][5][1]="1";
    collect_column[0][5][2]=19;

    collect_column[0][6][0]="Geo Graphic";
    collect_column[0][6][1]="1";
    collect_column[0][6][2]=20;
    
    collect_column[0][7][0]="Haven Binder";
    collect_column[0][7][1]="1";
    collect_column[0][7][2]=36;

    collect_column[0][8][0]="Infinity";
    collect_column[0][8][1]="1";
    collect_column[0][8][2]=22;
    
    collect_column[0][9][0]="Inscriptions";
    collect_column[0][9][1]="1";
    collect_column[0][9][2]=23;

    collect_column[0][10][0]="Linework";
    collect_column[0][10][1]="1";
    collect_column[0][10][2]=27;

    collect_column[0][11][0]="Multi Media";
    collect_column[0][11][1]="1";
    collect_column[0][11][2]=35;
    
    // 2nd Column
    collect_column[1][0][0]="Organics";
    collect_column[1][0][1]="1";
    collect_column[1][0][2]=28;
    
    collect_column[1][1][0]="Permawall";
    collect_column[1][1][1]="1";
    collect_column[1][1][2]=29;
    
    collect_column[1][2][0]="Premier";
    collect_column[1][2][1]="1";
    collect_column[1][2][2]=30;
    
    collect_column[1][3][0]="Refractions";
    collect_column[1][3][1]="1";
    collect_column[1][3][2]=21;

    collect_column[1][4][0]="Suite";
    collect_column[1][4][1]="1";
    collect_column[1][4][2]=32;
    
    collect_column[1][5][0]="Summit";
    collect_column[1][5][1]="1";
    collect_column[1][5][2]=34;

    collect_column[1][6][0]="Textural Embosses 03";
    collect_column[1][6][1]="1";
    collect_column[1][6][2]=38;

    collect_column[1][7][0]="Touchstone";
    collect_column[1][7][1]="1";
    collect_column[1][7][2]=24;

    collect_column[1][8][0]="Vescom 01/02";
    collect_column[1][8][1]="1";
    collect_column[1][8][2]=40;
    
    collect_column[1][9][0]="Vescom Textile 04";
    collect_column[1][9][1]="1";
    collect_column[1][9][2]=41;
    
    collect_column[1][10][0]="Visions";
    collect_column[1][10][1]="1";
    collect_column[1][10][2]=42;
    
    
    collect_column[1][11][0]="Wood Paper Grass";
    collect_column[1][11][1]="1";
    collect_column[1][11][2]=39;
    

/********************************* Designer *******************/    
    
    collect_column[2][0][0]="WG Design Studio";
    collect_column[2][0][1]="1";
    collect_column[2][0][2]=8;
    
    collect_column[2][1][0]="Patty Madden";
    collect_column[2][1][1]="1";
    collect_column[2][1][2]=9;

    collect_column[2][2][0]="Karim Rashid";
    collect_column[2][2][1]="1";
    collect_column[2][2][2]=10;
    
    collect_column[2][3][0]="Laurinda Spear";
    collect_column[2][3][1]="1";
    collect_column[2][3][2]=11;
    
    collect_column[2][4][0]="Gensler";
    collect_column[2][4][1]="1";
    collect_column[2][4][2]=14;
    
    collect_column[2][5][0]="Museum of New Mexico";
    collect_column[2][5][1]="1";
    collect_column[2][5][2]=15;

 /********************************* Brands *******************/       
    collect_column[3][0][0]="Wolf-Gordon";
    collect_column[3][0][1]="1";
    collect_column[3][0][2]=3;
    
    collect_column[3][1][0]="Haven";
    collect_column[3][1][1]="1";
    collect_column[3][1][2]=26;
    
    collect_column[3][2][0]="Vescom";
    collect_column[3][2][1]="1";
    collect_column[3][2][2]=4;
    
    collect_column[3][3][0]="Vycon";
    collect_column[3][3][1]="0";
    collect_column[3][3][2]=5;
    
    collect_column[3][4][0]="Symphony";
    collect_column[3][4][1]="0";
    collect_column[3][4][2]=6;
    
    collect_column[3][5][0]="Scuffmaster";
    collect_column[3][5][1]="0";
    collect_column[3][5][2]=45;          
          
          
          
          
          
          
          
          
          
          
          
          
var collect_footer='';


  function get_collection_text(id)
{
        for(i=0;i<collect_column.length;i++)
        {
            for(j=0;j<collect_column[i].length;j++)
            {
                if( collect_column[i][j][2]==id)
                {
                    str=collect_column[i][j][0]+"|"+i;
                    return (str);
                }
            }
        }
}


/********************** Model Window variable ***********************/

/* Product Library Script file */

function resize_product_preview_ajax(window_height,colorname)
{
        parent.popupwin_pre.setSize(605,window_height); 
        var ver=navigator.appVersion;
        var keyText='; MSIE ';
        var version=parseFloat(ver.substr(ver.indexOf(keyText)+keyText.length,3));
        if(navigator.appName=='Microsoft Internet Explorer' && version<=6.0)
          parent.popupwin_pre.setSize(605,window_height+50); 
        if(navigator.appName=='Microsoft Internet Explorer' && version>6.0)
          parent.popupwin_pre.setSize(605,window_height+50); 
        if(colorname!="") 
            if(navigator.appName=='Microsoft Internet Explorer' && version>6.0)
                parent.popupwin_pre.setSize(605,window_height+67); 
}

function get_combination(search_Input)
{

            var keywords_Array = new Array();
            var total_Keywords_Array = new Array();
            var total_Keywords_Len;
            var loop = 0;
            var word_Len;
            var move_Len;
            var keywords_Str = '';
            total_Keywords_Array = search_Input.split(' ');
            total_Keywords_Len = total_Keywords_Array.length;
            while(loop < total_Keywords_Len){
                word_Len = loop;
                if(word_Len == 0){
                    for(inc=0;inc<total_Keywords_Len;inc++){
                        keywords_Array[keywords_Array.length] = total_Keywords_Array[inc];
                    }
                }
                else if(word_Len == total_Keywords_Len - 1){
                    keywords_Array[keywords_Array.length] = search_Input;
                }
                else{
                    for(inc=0;inc<total_Keywords_Len;inc++){
                        move_Len = inc + word_Len;
                        if(move_Len < total_Keywords_Len){
                            for(cnt=inc;cnt<=move_Len;cnt++){
                                if(cnt < move_Len){
                                    keywords_Str += total_Keywords_Array[cnt]+' ';
                                }
                                else{
                                    keywords_Str += total_Keywords_Array[cnt];
                                }
                            }
                            keywords_Array[keywords_Array.length] =    keywords_Str;
                            keywords_Str = '';
                        }
                    }
                }
                loop++;
            }
     return keywords_Array;
}


function turn_on_filter_for_search(arr,total)
{

      var table,cells,i,j;
      table = document.getElementById("material_product_library_filter"); 
                     cells = table.getElementsByTagName("a"); 
                    for(j=0; j< total;j++){
                        for (i = 0; i < cells.length; i++) { 
                               testvalue=arr[j].toLowerCase();
                               /* Special Case for Accoustical Wall */
                               if((j+1)<total)
                               {
                                    if(testvalue=="acoustical" && arr[j+1].toLowerCase()=="wall")
                                       continue;
                               }
                               
                                testvalue= testvalue.replace("&","&amp;");
                               //search_keyword=(search_keyword.replace(new RegExp( str_repl, "gi" ),""));  
                               //  alert(testvalue);
                                
                            if((cells[i].innerHTML).toLowerCase()==testvalue){
                                cells[i].className="alp";
                                cells[i].style.background="white";
                                cells[i].style.fontWeight = 'Normal';
                                do_filter(cells[i],"material_filter");
                                
                                
                             //    material_filter_to_model +="["+arr[j]+"]";
                            }
                        }
                    }
                    
       table = document.getElementById("pattern_product_library_filter"); 
                 cells = table.getElementsByTagName("a"); 
                for( j=0; j< total;j++){
                    for ( i = 0; i < cells.length; i++) { 
                        if((cells[i].innerHTML).toLowerCase()==arr[j].toLowerCase()){  
                            cells[i].className="alp";
                            cells[i].style.background="white"; 
                            cells[i].style.fontWeight = 'Normal';
                            do_filter(cells[i],"pattern_filter");
                         //   pattern_filter_to_model +="["+arr[j]+"]";
                        }
                    }
                }              
       
         table = document.getElementById("texture_product_library_filter"); 
                cells = table.getElementsByTagName("a"); 
                for( j=0; j< total;j++){
                    for ( i = 0; i < cells.length; i++) { 
                        
                       if((cells[i].innerHTML).toLowerCase()==arr[j].toLowerCase()){  
                     //   alert("c val"+cells[i].innerHTML);     
                            cells[i].className="alp";
                            cells[i].style.background="white";
                            cells[i].style.fontWeight = 'Normal';
                            do_filter(cells[i],"texture_filter");
                         //   texture_filter_to_model +="["+arr[j]+"]";
                         //   alert("T val "+texture_filter_to_model);     
                            
                        }
                    }
                }
                
         table = document.getElementById("color_product_library_filter"); 
                 cells = table.getElementsByTagName("a"); 
                for( j=0; j< total;j++){
                    for ( i = 0; i < cells.length; i++) { 
                        if((cells[i].innerHTML).toLowerCase()==arr[j].toLowerCase()){  
                            cells[i].className="alp";
                            cells[i].style.background="white";
                            cells[i].style.fontWeight = 'Normal';
                            if(i<color_column[0])
                                do_filter(cells[i],"color_filter","0");
                            else
                                do_filter(cells[i],"color_filter","1");
                            
                        }
                    }
                }
                
        /*   table = document.getElementById("color_product_library_filter"); 
                 cells = table.getElementsByTagName("a"); 
                for(j=0; j< total;j++){
                    for ( i = 0; i < cells.length; i++) { 
                        if(cells[i].innerHTML==arr[j]){
                            cells[i].className="alp";
                            cells[i].style.background="white";
                            do_filter(cells[i],"color_filter");
                         //   color_grouping_filter_to_model +="["+arr[j]+"]";
                        }
                    }
                }
             */
            table = document.getElementById("scale_product_library_filter"); 
                 cells = table.getElementsByTagName("a"); 
                for( j=0; j< total;j++){
                    for ( i = 0; i < cells.length; i++) { 
                        if((cells[i].innerHTML).toLowerCase()==arr[j].toLowerCase()){  
                            cells[i].className="alp";
                            cells[i].style.background="white";
                            cells[i].style.fontWeight = 'Normal';
                            do_filter(cells[i],"scale_filter");
                           // scale_filter_to_model +="["+arr[j]+"]";
                        }
                    }
                }
                
           table = document.getElementById("sustain_product_library_filter"); 
                 cells = table.getElementsByTagName("a"); 
                for( j=0; j< total;j++){
                    for ( i = 0; i < cells.length; i++) {     
                        if((cells[i].innerHTML).toLowerCase()==arr[j].toLowerCase()){  
                            cells[i].className="alp";
                            cells[i].style.background="white"; 
                            cells[i].style.fontWeight = 'Normal';
                            do_filter(cells[i],"sustain_filter");
                         //  sustain_filter_to_model +="["+arr[j]+"]"; 
                        }
                    }
                }
         
           table = document.getElementById("collect_product_library_filter"); 
                 cells = table.getElementsByTagName("a"); 
                for( j=0; j< total;j++){
                    for ( i = 0; i < cells.length; i++) { 
                       if((cells[i].innerHTML).toLowerCase()==arr[j].toLowerCase()){ 
                       
                           
                            cells[i].className="alp";
                            cells[i].style.background="white";
                            cells[i].style.fontWeight = 'Normal';
                            if(i<collect_column[0].length)
                                do_filter(cells[i],"collect_filter","0");
                            else
                                do_filter(cells[i],"collect_filter","1");
                         
                           
                           
                        }
                    }
                }
                                       
            table = document.getElementById("designer_product_library_filter"); 
                 cells = table.getElementsByTagName("a"); 
                for( j=0; j< total;j++){
                    for ( i = 0; i < cells.length; i++) { 
                       if((cells[i].innerHTML).toLowerCase()==arr[j].toLowerCase()){  
                            cells[i].className="alp";
                            cells[i].style.background="white";
                            cells[i].style.fontWeight = 'Normal';
                            if(i<collect_column[2].length)
                                do_filter(cells[i],"designer_filter","2");
                            else
                                do_filter(cells[i],"designer_filter","3");
                         //   collect_filter_to_model +="["+arr[j]+"]";
                        }
                    }
                }    
                                        
         /*    table = document.getElementById("brand_product_library_filter"); 
                 cells = table.getElementsByTagName("a"); 
                for( j=0; j< total;j++){
                    for ( i = 0; i < cells.length; i++) { 
                       if((cells[i].innerHTML).toLowerCase()==arr[j].toLowerCase()){  
                            cells[i].className="alp";
                            cells[i].style.background="white";
                            do_filter(cells[i],"brand_filter",0);
                         //   collect_filter_to_model +="["+arr[j]+"]";
                        }
                    }
                }                
           */     
              
}



        function show_login_popup(url)
        {
            messageObj.setSource(url);
            messageObj.setCssClassMessageBox(false);
            messageObj.setSize(340,340);
            messageObj.setShadowDivVisible(false);    // Enable shadow for these boxes
            messageObj.display();
        
        }

        function show_product_view(url)
        {
            height=560;
            width=780;
                title="a";
               _height=parseInt(height)+5;
               
                if(navigator.appName=='Microsoft Internet Explorer'){
                    popupwin_preview = dhtmlmodal.open('product_preview_popup', 'iframe',url,title, 'center=1, height='+(_height)+'px, resize=0, scrolling=0, width='+width+'px', '');
               
                }else{
                    popupwin_preview = dhtmlmodal.open('product_preview_popup', 'iframe', url,title, 'center=1, height='+height+'px, resize=0, scrolling=0, width='+width+'px', ''); 
               
                }
               
               popupwin_preview.moveTo("middle",10);  
                
        }
        function show_email(url)
        {
                height=400;
                width=580;
                title="a";
               _height=parseInt(height)+15;
                if(navigator.appName=='Microsoft Internet Explorer'){
                    popupwin = dhtmlmodal.open('email_popup', 'iframe',url,title, 'center=1, height='+(_height)+'px, resize=1, scrolling=1, width='+width+'px', '');
                }else{ 
                    popupwin = dhtmlmodal.open('email_popup', 'iframe', url,title, 'center=1, height='+height+'px, resize=1, scrolling=1, width='+width+'px', '');
                }

            //alert(url);
        //    popupwin =dhtmlmodal.open("email_popup", "iframe", url, "  ", "width=580px,height=420px,resize=1,scrolling=1,center=1", "")

                //popupwin = dhtmlmodal.open('email_popup', 'iframe', url,'', 'center=1, height=200, resize=1, scrolling=1, width=200');

            /*messageObj.setSource(url);
            messageObj.setCssClassMessageBox(false);
            messageObj.setSize(540,420);
            messageObj.setShadowDivVisible(false);    // Enable shadow for these boxes
            messageObj.display();*/
        }    
        
        function show_remainder(url)
        {
                height=180;
                width=340;
                title="a";
               _height=parseInt(height)+5;
                if(navigator.appName=='Microsoft Internet Explorer'){
                    popupwin = dhtmlmodal.open('remain_popup', 'iframe',url,title, 'center=1, height='+(_height)+'px, resize=0, scrolling=0, width='+width+'px', '');
                }else{ 
                    popupwin = dhtmlmodal.open('remain_popup', 'iframe', url,title, 'center=1, height='+height+'px, resize=0, scrolling=0, width='+width+'px', '');
                }

        /*    
            messageObj.setSource(url);
            messageObj.setCssClassMessageBox(false);
            messageObj.setSize(240,200);
            messageObj.setShadowDivVisible(false);    // Enable shadow for these boxes
            messageObj.display();*/
        }
    
    /*    function show_product_preview(url)
        {
            messageObj.setSource(url);
            messageObj.setCssClassMessageBox(false);
            messageObj.setSize(540,520);
            messageObj.setShadowDivVisible(false);    // Enable shadow for these boxes
            messageObj.display();
        
        }
        function closeMessage()
        {
            messageObj.close();    
        }*/

        function show_per_page(where)
        {
            
            if(where)
            {
            
                var obj_name=where+"_number_per_page";
                var display_obj=document.getElementById(obj_name);
        
                display_obj.style.position = "absolute";
                display_obj.style.left="722px";
                display_obj.style.display='block';
            }
            else
                alert('object not found');
                
                
        }
        
        
        
        
        
        function change_per_page(myobj)
        {

            var top_obj=document.getElementById('top_page_number_span');
            var bottom_obj=document.getElementById('bottom_page_number_span');
            var display_obj=document.getElementById("top_number_per_page");
            var display_obj1=document.getElementById("bottom_number_per_page");            
            var myobj1=document.getElementById(myobj);                                

            top_obj.innerHTML=myobj1.innerHTML+"&nbsp";
            bottom_obj.innerHTML=myobj1.innerHTML+"&nbsp";
            display_obj.style.display='none';
            display_obj1.style.display='none';
            
            //xajax_test(2,"1","1");
            xajax_filter_change("3",myobj1.innerHTML,"");
        }
        
        function show_sort_order(where)
        {
            if(where)
            {
                var obj_name=where+"_sort_order_page";
                var display_obj=document.getElementById(obj_name);
                display_obj.style.position = "absolute";
                display_obj.style.left="830px";
                display_obj.style.display='block';
        
            }
            else
                alert('object not found');
        
        }
        function change_sort_order(myobj)
        {
    
            var top_obj=document.getElementById('top_sort_order_span');
            var bottom_obj=document.getElementById('bottom_sort_order_span');
            var display_obj=document.getElementById("top_sort_order_page");
            var display_obj1=document.getElementById("bottom_sort_order_page");    
            
            display_obj.style.display='none';
            display_obj1.style.display='none';    
        
            var myobj1=document.getElementById(myobj);
            
            top_obj.innerHTML=myobj1.innerHTML+"&nbsp";
            bottom_obj.innerHTML=myobj1.innerHTML+"&nbsp";
            switch(myobj1.id)
            {
              case "sr_1":
             
                xajax_filter_change("4","1","");            
                break;
              case "sr_2":
            
                xajax_filter_change("4","2","");
                break;
              case "sr_3":
             
                xajax_filter_change("4","3","");
                break;
            }              
        }

function check_page_number(e,id)
{

    var keynum;
    var keychar;
    var numcheck;
    
    if(window.event) // IE
        keynum = e.keyCode;
    else if(e.which) // Netscape/Firefox/Opera
        keynum = e.which;
    keychar = String.fromCharCode(keynum);
    
   
    if(keynum==13)
    {    var cur_page=0;
        if(id=='top_pagenumber')
            cur_page=document.getElementById('bottom_pagenumber').value;
        else
            cur_page=document.getElementById('top_pagenumber').value;
            
        var mm=document.getElementById(id).value;
        if(mm=='')
            return false;
        if(parseInt(mm)==0)
            return false;
        curval=parseInt(mm);
        var tp=document.getElementById('top_total_number');
        total_p=parseInt(tp.innerHTML);
        if(curval>total_p)
            return false;
        else
        {

            if(curval<cur_page)
            {
                xajax_filter_change("2",cur_page,-(cur_page - curval));
            }
            else
            {
                xajax_filter_change("2",cur_page,(curval - cur_page));            
            }
        }
    }
    else if(keynum==8 || keynum==46)
        return  true;
   else if(keynum>=96 && keynum<=105)
      return true;
    else if(keynum<48 || keynum>57)
        return false;

}


function findPos(obj) {
    var curleft = curtop = 0;
    if (obj.offsetParent) {
        do {
            curleft += obj.offsetLeft;
            curtop += obj.offsetTop;
        } while (obj = obj.offsetParent);
    }
    return [curleft,curtop];
}

function close_all_filters()
{
    document.getElementById('material_product_library_filter').style.display='none';
    document.getElementById('pattern_product_library_filter').style.display='none';
    document.getElementById('color_product_library_filter').style.display='none';
    document.getElementById('scale_product_library_filter').style.display='none';
    document.getElementById('collect_product_library_filter').style.display='none';
    document.getElementById('texture_product_library_filter').style.display='none';
     document.getElementById('sustain_product_library_filter').style.display='none';
     
     document.getElementById('designer_product_library_filter').style.display='none';
  //   document.getElementById('brand_product_library_filter').style.display='none';
     
        
}


//    function show_filter_window(menu,heading,num_cols,column_heading,column_value,footer,width,y)
    function show_filter_window(menu,width)
    {
        var mymenu='';
        var menu_name=menu+'_product_library_filter';
        var menu_filter=document.getElementById(menu_name);
        var mm=document.getElementById("ah_"+menu);
        var oHeight=0;
        close_all_filters();
        if(menu_filter)
        {
            menu_filter.style.position='absolute';
            menu_filter.style.width=width+'px';
            document.getElementById(menu+'_product_library_filter_shadow').style.width=width+'px';
            menu_filter.style.display='block';
            
            if(document.getElementById)
            {
                oHeight = document.getElementById(menu_name).offsetHeight;
            
            }
            else if (document.layers)
            {
                oHeight = document.layers[menu_name].clip.height;
            }

            win_top=(findPos(mm)[1]-(oHeight/2))+10;
            arrow_height=(-(oHeight/2))+10;
            if(navigator.appName=="Microsoft Internet Explorer"){
                arrow_height+=5;
            }
            document.getElementById(menu+"_menu_arrow_mark").style.top=arrow_height+"px";
            menu_filter.style.top=win_top+"px";
              /*          
            win_top=-(oHeight/2)-5;
            arrow_height=(-(oHeight/2))+10;
            if(navigator.appName=="Microsoft Internet Explorer"){
                arrow_height+=5;
            }
            document.getElementById(menu+"_menu_arrow_mark").style.top=arrow_height+"px";
            menu_filter.style.left=180+"px";
            if(menu=="sustain" || menu=="collect" || menu=="designer" || menu=="brand")
                menu_filter.style.left=190+"px";    
            */
            //document.getElementById(menu+"_menu_arrow_mark").style.top=(win_top+arrow_height)+"px";
        }
    }
    
    last_obj="";
    last_main_target="";
    last_url_value="";
    last_action="add";
    
    function show_remove_filter_item()
    {
    
       
        if(last_main_target!="")
        {
            txt="";
            if(last_action=="add")
            {   if(last_main_target=="new_design")
                    txt="Adding New Design ";
                else
                {
                txtid=document.getElementById(last_obj.id); 
                txt="Adding "+txtid.innerHTML+" ";
                }
            }
            else
            {
                if(last_main_target=="new_design")
                    txt="Removing New Design ";
                else
                {
                    txtid=document.getElementById(last_obj); 
                    txt="Removing "+txtid.innerHTML+" ";
                }
            }
            s=last_main_target.split("_");
            menu=last_main_target;
            var menu_name=menu+'_filter_warning';
            var menu_filter=document.getElementById(menu_name);
            close_all_filters();
            var mm=document.getElementById("ah_"+s[0]);
            x=findPos(mm)[1];
            if(menu_filter)
            {
                 menu_filter.style.position='absolute';
                 menu_filter.style.display='block';
                 cont=document.getElementById(last_main_target+"_filter_warning_content");
                 cont.innerHTML=txt;
                 if(navigator.appName=='Microsoft Internet Explorer')
                    win_top=x - 25;
                 else
                    win_top=x - 30;
                 menu_filter.style.top=win_top+"px";
                 
            }   
        }
        else
            object_click="Y" ;
    }
   
    function change_warning()
    {
        object_click="Y";
        if(last_action=="add")
        {
          if(last_main_target=="new_design")
              remove_new_design();
          else
          {
            //alert("here "+last_main_target+last_obj.id+last_url_value);
            remove_filter(last_main_target,last_obj.id,last_url_value);
          }
        }
        else
        {  
          if(last_main_target=="new_design")
              show_new_design();
          else
            do_filter(last_obj,last_main_target,last_url_value);
        }
    } 
    
    function remove_new_design()
    {
        
        document.getElementById('new_design_block').style.display='none';
        xajax_filter_change("1","newdesign_filter","remove"); 
    }
 
 
     function show_new_design()
    {
        last_obj=null;
        last_main_target='new_design';
        
        document.getElementById('new_design_block').style.display='block';
        xajax_filter_change("1","newdesign_filter",""); 
    }

   
   function Refresh_Mysamples(place,id)
   {
      
       url=parent.document.location.pathname;
       uri=url.split("/");
       if(uri[1]=="mysamples")
       {  
          if(uri.length==2)
                parent.xajax_get_saved_samples('mysamples',0,parent.document.getElementById('top_page_number').value,0,"1"); 
          else
            if(place==uri[2] && place=="sample_set" && uri[3]==id)
                parent.xajax_get_saved_samples("sample_set",uri[3],parent.document.getElementById('top_page_number').value,0,1); 
            else if(place==uri[2] && place=="sample_order") 
            {
                parent.xajax_get_saved_samples("sample_order",0,1,0,1); 
            }
       }
   }
   
    
    
     function show_add_sample_preview(sku)
    {
        ele=document.getElementById('add_setDiv_preview');
        var mm=document.getElementById("sample_button_div");
          x=findPos(mm);
        
        
        ele.style.position="absolute";
        if(navigator.appName=='Microsoft Internet Explorer')
        {
              win_top=x[1] + 30;
             win_left=x[0] + 2;
        }
        else
        {
             win_top=x[1] + 30;
             win_left=x[0] + 2;
        }
        ele.style.display='block';  
        ele.style.top=win_top+"px"; 
        ele.style.left=win_left+"px"; 
    }
    
    function show_add_sample_preview_detail(sku)
    {
       //alert(navigator.userAgent);
	   ele=document.getElementById('add_setDiv_preview');
        var mm=document.getElementById("sample_button_div");
        x=findPos(mm);

		var ver=navigator.userAgent;
		var keyText='Firefox/';
		var version=ver.substr(ver.indexOf(keyText));
		var ffv=version.split('/');
		var ffversion=parseFloat(ffv[1]);
		
		var ieVer=navigator.appVersion;
		var keyText='; MSIE ';
		var ieVersion=parseFloat(ieVer.substr(ieVer.indexOf(keyText)+keyText.length,3));
        
        ele.style.position="absolute";
       /* if(navigator.appName=='Microsoft Internet Explorer' && ieVersion <7){
              win_top=x[1] - 218;
			  ele.style.margin="0px 0px 0px -3px";
		}else if(navigator.appName=='Microsoft Internet Explorer' && ieVersion ==7){
              win_top=x[1] - 223;
		}else if(navigator.userAgent.indexOf('MSIE 8.0')){
			 win_top=x[1] - 220;
		}else if(navigator.userAgent.indexOf('Firefox/3.6')!=-1){
			 win_top=x[1] - 215;
		}else if(navigator.appName=='Netscape' && ffversion>3){
             //win_top=x[1] - 190;
			 win_top=x[1] - 215;
		}else  if(navigator.appName=='Netscape' && ffversion<3){
			
			win_top=x[1]+30;
		}*/
		//alert(navigator.userAgent);
		
        ele.style.display='block';  
        ele.style.top=win_top+"px"; 
		// alert(ele.style.top);
    }
    
    
    
    function do_filter(obj,main_target,url_value)
    {
		document.getElementById(main_target).style.display='';
		  //alert(obj.id+" "+main_target+" "+url_value);
           v=document.getElementById(obj);
           if(v!=null)
                obj=v; 
          
          last_obj=obj;
          last_main_target=main_target;
          last_url_value=url_value;
        
     //   alert(obj.id+" "+main_target+" "+url_value);
        
        
        var target_obj=document.getElementById(main_target);
        if (obj.className=="beta" )
        {
            obj.className="alp";
            obj.style.background="white";
            obj.style.fontWeight = 'normal';
            last_action="remove";
            remove_filter(main_target,obj.id,url_value);
        }
        else if(obj.className=="alp")
        {
           
            obj.className="beta";
            obj.style.background="#ebf2f8"; 
            obj.style.fontWeight = 'bold';
            last_action="add";
            add_filter(target_obj,obj,main_target,url_value);
        }
        else
        {
            
            obj.className="beta";
            obj.style.background="#ebf2f8";
            obj.style.fontWeight = 'bold';
            last_action="add";
            add_filter(target_obj,obj,main_target,url_value);
        }
        
    }
    function add_filter(t_obj,obj,main_target,url_value)
    {
     
      
      //  if(main_target !='collect_filter')
      //  { 
     
       // var new_val = "<li id='inn_"+obj.id+"'>"+obj.innerHTML+"<a href='#' onclick=\"remove_filter(\'"+main_target+"\','"+obj.id+"','"+url_value+"');\"><img src='/images/into_mark.jpg' style='float:right;position:relative;margin-top:8px;_margin-top:-15px;'/></a></li><div class='clear'></div>";
       if(main_target=='sustain_filter' || main_target=='collect_filter'){
        var new_val = "<li id='inn_"+obj.id+"' style='padding-bottom:4px;.padding-bottom:0px;_padding-bottom:4px;'><span style='float:left;display:inline-block;width:150px;'>"+obj.innerHTML+"</span><a style='float:right;display:inline-block;' href='#' onclick=\"remove_filter(\'"+main_target+"\','"+obj.id+"','"+url_value+"');\"><img src='/images/into_mark.jpg' /></a><div class='clear'></div></li><div class='clear'></div>";
        
        t_obj.innerHTML +=new_val;
       }else{
        var new_val = "<li id='inn_"+obj.id+"'><span style='float:left;display:inline-block;'>"+obj.innerHTML+"</span><a style='float:right;display:inline-block;' href='#' onclick=\"remove_filter(\'"+main_target+"\','"+obj.id+"','"+url_value+"');\"><img src='/images/into_mark.jpg' /></a><div class='clear'></div></li><div class='clear'></div>";
        t_obj.innerHTML +=new_val;
       }
        
     
        /**********   Try to call Xajax Function Here *************/ 
        if(main_target=='material_filter' && !from_refresh)
        {
            testvalue =obj.innerHTML;
            testvalue= testvalue.replace("&amp;","&");
            material_filter_to_model +="["+testvalue+"]";
            xajax_filter_change("1",main_target,material_filter_to_model);
        }
        if(main_target=='pattern_filter' && !from_refresh)
        {
            pattern_filter_to_model +="["+obj.innerHTML+"]"; 
            xajax_filter_change("1",main_target,pattern_filter_to_model); 
        }
        if(main_target=='texture_filter' && !from_refresh)
        {
            texture_filter_to_model +="["+obj.innerHTML+"]";
            xajax_filter_change("1",main_target,texture_filter_to_model); 
        }

        if(main_target=='scale_filter' && !from_refresh)
        {
         
            scale_filter_to_model +="["+obj.innerHTML+"]";
            xajax_filter_change("1",main_target,scale_filter_to_model); 
        }

        if(main_target=='sustain_filter' && !from_refresh)
        {
            sustain_filter_to_model +="["+obj.innerHTML+"]";
            xajax_filter_change("1",main_target,sustain_filter_to_model); 
        } 
        
         if(main_target=='collect_filter' && !from_refresh)
        {
             switch(url_value)
             {
             case "0":
             case "1":  
                collect_filter_to_model +="["+obj.innerHTML+"]";
                xajax_filter_change("1",main_target,collect_filter_to_model);
                break;
        /*    case "2":
                brands_filter_to_model +="["+obj.innerHTML+"]";
                xajax_filter_change("1",main_target+"_brand",brands_filter_to_model); 
                break;
            case "3":
                designer_filter_to_model +="["+obj.innerHTML+"]";
                xajax_filter_change("1",main_target+"_design",designer_filter_to_model);    
                break;                                                                      */
            }
        }
        
        if(main_target=='designer_filter' && !from_refresh)
        {
           // main_target= 'collect_filter';
          //  designer_filter_to_model +="["+obj.innerHTML+"]";
            //xajax_filter_change("1",main_target+"_design",designer_filter_to_model);
          //  xajax_filter_change("1",main_target,designer_filter_to_model);
             switch(url_value)
             {
                case "2":
                     designer_filter_to_model +="["+obj.innerHTML+"]";
                     xajax_filter_change("1",main_target,designer_filter_to_model); 
                    break;
                case "3":
                    brands_filter_to_model +="["+obj.innerHTML+"]"; 
                     xajax_filter_change("1",'brand_filter',brands_filter_to_model);  
                    break;
             }
             
        }
   /*  
      if(main_target=='brand_filter' && !from_refresh)
        {
           // main_target= 'collect_filter';
            brands_filter_to_model +="["+obj.innerHTML+"]";
            //xajax_filter_change("1",main_target+"_brand",brands_filter_to_model);
            xajax_filter_change("1",main_target,brands_filter_to_model);
        }
        
     */   
     
        if(main_target=='color_filter' && !from_refresh)
        {
                switch(url_value)
             {
             case "0":
             
                color_filter_to_model +="["+obj.innerHTML+"]";
                xajax_filter_change("1",main_target,color_filter_to_model); 
                break;
             case "1":
                
                color_grouping_filter_to_model +="["+obj.innerHTML+"]";
                xajax_filter_change("1",main_target+"_group",color_grouping_filter_to_model); 
                break;
             }
            
        }    
     
    }
    
    function remove_filter(t_obj,obj,url_value)
    {
          
          last_main_target=t_obj;  
          last_obj=obj;
          last_url_value=url_value;
          last_action="remove";
          
        var target_obj=document.getElementById(t_obj);

        var other_target_obj=document.getElementById(obj);
        other_target_obj.style.background="white";
        other_target_obj.className="alp";
        other_target_obj.style.fontWeight= 'normal';
        
        var obj_name='inn_'+obj;
        var myobj=document.getElementById(obj_name);
        target_obj.removeChild(myobj);
         
        if(search_keyword!='')
        {
            str_repl=other_target_obj.innerHTML;
            
            if(str_repl=="Patents &amp; Mylars")
                search_keyword=(search_keyword.replace(new RegExp( "Patents & Mylars", "gi" ),""));
            else
                search_keyword=(search_keyword.replace(new RegExp( str_repl, "gi" ),""));
            
            // alert("Replace search key "+search_keyword); 
            xajax_filter_change("0","search_button",search_keyword); 
        }
      
        
        if(t_obj=='material_filter')
        {
             if(arr_f[0]==other_target_obj.innerHTML)
                 xajax_filter_change("1","favour_filter","remove");
             else{
                str_rpl="["+ other_target_obj.innerHTML+"]";
                material_filter_to_model=material_filter_to_model.replace(str_rpl,'');
                xajax_filter_change("1",t_obj,material_filter_to_model);
             }
        }
        if(t_obj=='pattern_filter')
        {
            if(arr_f[0]==other_target_obj.innerHTML)
                 xajax_filter_change("1","favour_filter","remove");
             else{
               str_rpl="["+ other_target_obj.innerHTML+"]";
                pattern_filter_to_model=pattern_filter_to_model.replace(str_rpl,'');
                xajax_filter_change("1",t_obj,pattern_filter_to_model);
             }
        }
        if(t_obj=='texture_filter')
        {
           // alert('befor here'+texture_filter_to_model+"  "+t_obj); 
            if(arr_f[0]==other_target_obj.innerHTML)
                 xajax_filter_change("1","favour_filter","remove");
             else{
               str_rpl="["+ other_target_obj.innerHTML+"]";
                texture_filter_to_model=texture_filter_to_model.replace(str_rpl,'');
             //   alert('here'+texture_filter_to_model+"  "+t_obj); 
                xajax_filter_change("1",t_obj,texture_filter_to_model);
             }
        }
        if(t_obj=='scale_filter')
        {
            if(arr_f[0]==other_target_obj.innerHTML)
                 xajax_filter_change("1","favour_filter","remove");
             else{
               str_rpl="["+ other_target_obj.innerHTML+"]";
                scale_filter_to_model=scale_filter_to_model.replace(str_rpl,'');
                xajax_filter_change("1",t_obj,scale_filter_to_model);
             }
        }        
        
        if(t_obj=='color_filter')
        {
             switch(url_value)
             {
             case "0":
              if(arr_f[0]==other_target_obj.innerHTML)
                 xajax_filter_change("1","favour_filter","remove");
             else{
                str_rpl="["+ other_target_obj.innerHTML+"]";
                color_filter_to_model=color_filter_to_model.replace(str_rpl,'');
              //  alert("0 called");
                xajax_filter_change("1",t_obj,color_filter_to_model);
             }
                break;
             case "1":
              if(arr_f[0]==other_target_obj.innerHTML)
                 xajax_filter_change("1","favour_filter","remove");
             else{
                str_rpl="["+ other_target_obj.innerHTML+"]";
                color_grouping_filter_to_model=color_grouping_filter_to_model.replace(str_rpl,'');
              //  alert("1 called");
                xajax_filter_change("1",t_obj+"_group",color_grouping_filter_to_model);
             }
                break;
             } 
          
        }
        if(t_obj=='sustain_filter')
        {
            if(arr_f[0]==other_target_obj.innerHTML)
                 xajax_filter_change("1","favour_filter","remove");
             else{
               str_rpl="["+ other_target_obj.innerHTML+"]";
                sustain_filter_to_model=sustain_filter_to_model.replace(str_rpl,'');
                xajax_filter_change("1",t_obj,sustain_filter_to_model);
             }
        }
        if(t_obj=='collect_filter')
        {
              
             switch(url_value)
             {
             case "0":
             case "1":  
                      if(arr_f[0]==other_target_obj.innerHTML)
                         xajax_filter_change("1","favour_filter","remove");
                     else{
                       str_rpl="["+ other_target_obj.innerHTML+"]";
                        collect_filter_to_model=collect_filter_to_model.replace(str_rpl,'');
                        xajax_filter_change("1",t_obj,collect_filter_to_model);
                     }
                break;
        /*    case "2":
                     if(arr_f[0]==other_target_obj.innerHTML)
                         xajax_filter_change("1","favour_filter","remove");
                     else{
                         str_rpl="["+ other_target_obj.innerHTML+"]";
                        brands_filter_to_model=brands_filter_to_model.replace(str_rpl,'');
                        xajax_filter_change("1",t_obj+"_brand",brands_filter_to_model);
                     }
                break;
            case "3":
                     if(arr_f[0]==other_target_obj.innerHTML)
                         xajax_filter_change("1","favour_filter","remove");
                     else{
                        str_rpl="["+ other_target_obj.innerHTML+"]";
                        designer_filter_to_model=designer_filter_to_model.replace(str_rpl,'');
                        xajax_filter_change("1",t_obj+"_design",designer_filter_to_model);
                     }
                break;    */
            }
        }
        if(t_obj=='designer_filter')
        {     
              switch(url_value)
             {
              case "2": 
                      
                    if(arr_f[0]==other_target_obj.innerHTML)
                         xajax_filter_change("1","favour_filter","remove");
                     else{
                        str_rpl="["+ other_target_obj.innerHTML+"]";
                        designer_filter_to_model=designer_filter_to_model.replace(str_rpl,'');
                        xajax_filter_change("1",t_obj,designer_filter_to_model);
                     }
                break;
              case "3":
                       if(arr_f[0]==other_target_obj.innerHTML)
                         xajax_filter_change("1","favour_filter","remove");
                     else{
                          str_rpl="["+ other_target_obj.innerHTML+"]";
                        brands_filter_to_model=brands_filter_to_model.replace(str_rpl,'');
                        xajax_filter_change("1",'brand_filter',brands_filter_to_model);
                     }
                break;
             }
         }
   /*  
      if(t_obj=='brand_filter')
        {
             //   t_obj='collect_filter';
                str_rpl="["+ other_target_obj.innerHTML+"]";
                brands_filter_to_model=brands_filter_to_model.replace(str_rpl,'');
                xajax_filter_change("1",t_obj,brands_filter_to_model);
        }        
        
     */   
    }
    
    
    function call_page(pgnum)
    {
        var curid=document.getElementById('bottom_pagenumber');
        var total=document.getElementById('bottom_total_number');
        var totalpage=parseInt(total.innerHTML);
        if(curid.value==1 && pgnum==-1)
        {    
            //alert("Not Valid");
            return;
        }
        if((pgnum==1) && (curid.value==totalpage))
        {    
            //alert("Not Valid");
            return;
        }
        xajax_filter_change("2",curid.value,pgnum);            
    }
    
    function call_color_page(name,pgnum,cur,displaysku,colorname)
    {
        var curid=document.getElementById('current_color_page');
        var total=document.getElementById('total_color_page');
        
        
        
        var totalpage=parseInt(total.value);
        if(curid.value==1 && pgnum==-1)
        {    
            //alert("Not Valid");
            return;
        }
        if((pgnum==1) && (curid.value==totalpage) && cur!='S')
        {    
            //alert("Not Valid");
            return;
        }
    
      if(cur=='S')
          xajax_call_color_page(name,0,pgnum,displaysku,colorname);            
      else
          xajax_call_color_page(name,curid.value,pgnum,displaysku,colorname);            
    }
    
    
        

    
    
    function ischild(evt,myroot)
    {
        //var parent_id = evt.target.parentNode.id;
        var mypar=document.getElementById(myroot);
        mypar.style.display='block';
    }
    
    function close_me(win_id)
    {
        document.getElementById(win_id).style.display='none';
    }
    
    function number_per_popup(where)
    {


        var pop_val="<div id='"+where+"_number_per_page'  onmouseover=\"ischild(event,'"+where+"_number_per_page');\" onmouseout=\"close_me('"+where+"_number_per_page');\">";
    
            pop_val+='<div id="'+where+'_num_shadow" class="num_shadow">';
            pop_val+='<div id="'+where+'_content" class="content" >';

                pop_val+='<a href="javascript:change_per_page(\'pg_24\');" id="pg_24">24 PER PAGE</a>&nbsp<img src="/images/downarrow.gif" />';
                pop_val+='<p style="margin-bottom:2px;"><a href="javascript:change_per_page(\'pg_48\');" id="pg_48">48 PER PAGE</a></p>';
                pop_val+='<p style="margin-bottom:2px;"><a href="javascript:change_per_page(\'pg_96\');" id="pg_96">96 PER PAGE</a></p>';
                pop_val+= '<p style="margin-bottom:2px;"><a href="javascript:change_per_page(\'pg_192\');" id="pg_192">192 PER PAGE</a></p>';
            pop_val+='</div>';
            pop_val+='</div>';
            pop_val+='</div>';


        return pop_val;
    
    }
    function sort_order_popup(where)
    {
            var pop_val="<div id='"+where+"_sort_order_page' onmouseover=\"ischild(event,'"+where+"_sort_order_page');\" onmouseout=\"close_me('"+where+"_sort_order_page');\">";
            pop_val+='<div class="sort_shadow">';
            pop_val+='<div class="content">';
            pop_val+='<span style="display:block;"><a href="javascript:change_sort_order(\'sr_3\');" id="sr_3">SORT BY RELEVANCE</a>&nbsp<img src="/images/downarrow.gif" /></span>';  
            pop_val+='<a href="javascript:change_sort_order(\'sr_1\');" id="sr_1">SORT BY MOST RECENT</a>';
            pop_val+='<p style="margin-bottom:2px;"><a href="javascript:change_sort_order(\'sr_2\');" id="sr_2">SORT BY PRODUCT NAME</a></p>';
            pop_val+='</div>';
            pop_val+='</div>';
            pop_val+='</div>';

            return pop_val;
    }

    
 function Remove_filter_warning(menu)
 {
      var    display_val='<div id="'+menu+'_filter_warning" class="product_filter_warning">';
             display_val+='<div id="'+menu+'_filter_warning_shadow" class="Shadow">';
             display_val+='<div class="content">';
             display_val+='<div><span id="'+menu+'_filter_warning_content"> </span>will result in no products being displayed</div>';
             display_val+='<div class="button_contain">';
             display_val+='<input type="button" value="OK" class="submit_but"  onclick="document.getElementById(\''+menu+'_filter_warning\').style.display=\'none\';object_click=\'Y\'; "/>';
             display_val+='<input type="button" value="CANCEL" class="cancel_but" onclick="change_warning();document.getElementById(\''+menu+'_filter_warning\').style.display=\'none\'" />';
             display_val+='<div class="clear"></div>';
             display_val+='</div>';
             display_val+='<div id="'+menu+'_menu_arrow_mark" style="position:relative;left:-18px;width:20px;top:-40px;"><img  src="/images/menu_arrow_mark.gif" /></div>';
             display_val+='</div></div>';
       return display_val; 
       //alert(display_val);
 }  
 
 function Remove_filter_warning_write(menu,id){
     var    display_val='<div id="'+menu+'_filter_warning" class="product_filter_warning">';
             display_val+='<div id="'+menu+'_filter_warning_shadow" class="Shadow">';
             display_val+='<div class="content">';
             display_val+='<div><span id="'+menu+'_filter_warning_content"> </span>will result in no products being displayed</div>';
             display_val+='<div class="button_contain">';
             display_val+='<input type="button" value="OK" class="submit_but"  onclick="document.getElementById(\''+menu+'_filter_warning\').style.display=\'none\';object_click=\'Y\'; "/>';
             display_val+='<input type="button" value="CANCEL" class="cancel_but" onclick="change_warning();document.getElementById(\''+menu+'_filter_warning\').style.display=\'none\'" />';
             display_val+='<div class="clear"></div>';
             display_val+='</div>';
             display_val+='<div id="'+menu+'_menu_arrow_mark" style="position:relative;left:-18px;width:20px;top:-40px;"><img  src="/images/menu_arrow_mark.gif" /></div>';
             display_val+='</div></div>';
       //return display_val; 
       document.getElementById(id).innerHTML = document.getElementById(id).innerHTML+display_val;
 }
     
function gen_menu(menu,heading,num_cols,column_heading,column_value,footer,start_pos)
{
 
  /*
        menu - menu id
        Heading - Title for the menu
        num_cols - number of colms
        Column_heading - column heading
        column_value  - column value (2 dimension array value,enabled/disabled)
        footer - footer text to display
        width - width of the window
        y   -  posistion y axis
    */
    var loop_i,loop_j;
    var col_w;
    var    display_val='<div id="'+menu+'_product_library_filter" class="product_library_filter" onmousedown="myevent=true;">';
        display_val+='<div id="'+menu+'_product_library_filter_shadow" class="Shadow">';
        display_val+='<div class="content">';
        display_val+='<div class="top_position" style="1margin-bottom:15px;1margin-top:5px;width:96%;height:10px;padding-bottom:15px;_padding-bottom:10px;">';
        display_val+='<div style="float:left;">';
        display_val+=heading+'</div>';
        display_val+='<img src="/images/popup_close.gif" style="cursor:pointer;float:right;margin-top:4px;" onclick="document.getElementById(\''+menu+'_product_library_filter\').style.display=\'none\';"/>';
        display_val+='</div>';
        display_val+='<div class="clear">';
        display_val+='</div>';
        display_val+='<div class="filtermenuContent">';
        display_val+='<table cellpadding="0" cellspacing="0" class="column" width="100%" border="0">';
        display_val+='<tr>';

         col_w=90/num_cols;

        for(loop_i=start_pos;loop_i<(num_cols+start_pos);loop_i++)
        {
            display_val+='<td valign="top" width="'+col_w+'%" >';
            display_val+='<label>'+column_heading[loop_i]+'</label><ul>';
            
            for(loop_j=0;loop_j<column_value[loop_i].length;loop_j++)
            {
            
                if(column_value[loop_i][loop_j][1]==1 && loop_j==0)
                    display_val+='<li style="border-top:1px solid #ccc;border-bottom:1px dotted #ccc;height:22px;"><a href="#" id="s'+menu+'_'+loop_i+'_'+loop_j+'" class="alp" onclick="do_filter(this,\''+menu+'_filter\',\''+ loop_i +'\');">'+column_value[loop_i][loop_j][0]+'</a></li>';
                else if(column_value[loop_i][loop_j][1]==1 && loop_j>0)
                    display_val+='<li style="border-top:none;border-bottom:1px dotted #ccc;height:22px;"><a href="#"  id="s'+menu+'_'+loop_i+'_'+loop_j+'" class="alp" onclick="do_filter(this,\''+menu+'_filter\',\''+loop_i+'\');">'+column_value[loop_i][loop_j][0]+'</a></li>';
                else
                    display_val+='<li style="border-top:none;border-bottom:1px dotted #ccc;padding-left:3px;height:22px;">'+column_value[loop_i][loop_j][0]+'<sup style="vertical-align:text-top;">*</sup></li>';
            }
                display_val+='</ul></td>';
            if(num_cols>1)
                display_val+='<td width="3%" align="center">&nbsp;</td>';
        }
        
        display_val+='</tr></table>';
        display_val+='<div class="clear"></div>';
        display_val+=footer;
        display_val+='<div class="clear"></div>';
        display_val+='</div>';
        display_val+='<div id="'+menu+'_menu_arrow_mark" style="position:relative;left:-18px;width:20px;"><img  src="/images/menu_arrow_mark.gif" /></div>';
        display_val+='</div></div></div>';
      //  alert(display_val);
        return display_val;
        
        //
        
        //document.write(display_val);
}

function gen_menu_write(menu,heading,num_cols,column_heading,column_value,footer,start_pos,id)
{
 
  /*
        menu - menu id
        Heading - Title for the menu
        num_cols - number of colms
        Column_heading - column heading
        column_value  - column value (2 dimension array value,enabled/disabled)
        footer - footer text to display
        width - width of the window
        y   -  posistion y axis
    */
	//document.getElementById(menu+'_filter').style.display='';
    var loop_i,loop_j;
    var col_w;
    var    display_val='<div id="'+menu+'_product_library_filter" class="product_library_filter" onmousedown="myevent=true;">';
        display_val+='<div id="'+menu+'_product_library_filter_shadow" class="Shadow">';
        display_val+='<div class="content">';
        display_val+='<div class="top_position" style="1margin-bottom:15px;1margin-top:5px;width:96%;height:10px;padding-bottom:15px;_padding-bottom:10px;">';
        display_val+='<div style="float:left;">';
        display_val+=heading+'</div>';
        display_val+='<img src="/images/popup_close.gif" style="cursor:pointer;float:right;margin-top:4px;" onclick="document.getElementById(\''+menu+'_product_library_filter\').style.display=\'none\';"/>';
        display_val+='</div>';
        display_val+='<div class="clear">';
        display_val+='</div>';
        display_val+='<div class="filtermenuContent">';
        display_val+='<table cellpadding="0" cellspacing="0" class="column" width="100%" border="0">';
        display_val+='<tr>';

         col_w=90/num_cols;

        for(loop_i=start_pos;loop_i<(num_cols+start_pos);loop_i++)
        {
            display_val+='<td valign="top" width="'+col_w+'%" >';
            display_val+='<label>'+column_heading[loop_i]+'</label><ul>';
            
            for(loop_j=0;loop_j<column_value[loop_i].length;loop_j++)
            {
            
                if(column_value[loop_i][loop_j][1]==1 && loop_j==0)
                    display_val+='<li style="border-top:1px solid #ccc;border-bottom1:1px dotted #ccc;margin-top:5px;"><a href="#" id="s'+menu+'_'+loop_i+'_'+loop_j+'" class="alp" onclick="do_filter(this,\''+menu+'_filter\',\''+ loop_i +'\');">'+column_value[loop_i][loop_j][0]+'</a></li>';
                else if(column_value[loop_i][loop_j][1]==1 && loop_j>0)
                    display_val+='<li style="border-top:none;border-bottom1:1px dotted #ccc;height1:22px;"><a href="#"  id="s'+menu+'_'+loop_i+'_'+loop_j+'" class="alp" onclick="do_filter(this,\''+menu+'_filter\',\''+loop_i+'\');">'+column_value[loop_i][loop_j][0]+'</a></li>';
                else
                    display_val+='<li style="border-top:none;border-bottom1:1px dotted #ccc;padding-left:3px;height1:22px;">'+column_value[loop_i][loop_j][0]+'<sup style="vertical-align:text-top;">*</sup></li>';
            }
                display_val+='</ul></td>';
            if(num_cols>1)
                display_val+='<td width="3%" align="center">&nbsp;</td>';
        }
        
        display_val+='</tr></table>';
        display_val+='<div class="clear"></div>';
        display_val+=footer;
        display_val+='<div class="clear"></div>';
        display_val+='</div>';
        display_val+='<div id="'+menu+'_menu_arrow_mark" style="position:relative;left:-18px;width:20px;"><img  src="/images/menu_arrow_mark.gif" /></div>';
        display_val+='</div></div></div>';
      //  alert(display_val);
        //return display_val;
		//alert(document.getElementById(id).innerHTML+display_val);
        document.getElementById(id).innerHTML = document.getElementById(id).innerHTML+display_val;
        
        //
        
        //document.write(display_val);
}

function gen_dropmenu(menuformat,menu,heading,num_cols,column_heading,column_value,start_col,column_space)
{
    /*
        menu - menu id
        Heading - Title for the menu
        num_cols - number of colms
        Column_heading - column heading
        column_value  - column value (2 dimension array value,enabled/disabled)
        footer - footer text to display
        width - width of the window
        y   -  posistion y axis
    */
    
    var loop_i,loop_j;
    var col_w;
    var space_per_col;
    var page;
    var menu_title;
    var close_menu;  
    if(menu=='material')
    {
        page='product_library/material';
        menu_title='Material Category';
        close_menu='drop1';
    }else if(menu=='pattern'){
        page='product_library/pattern';
        menu_title='Pattern';
        close_menu='drop2';
    }else if(menu=='color'){
        page='product_library/color';
        menu_title='';
        close_menu='drop3';
    }else if(menu=='collect'){
        page='collections_designers/selectpage';
        menu_title='Collections & Designers';
        close_menu='';
    }else if(menu=='sustain'){
        page='product_library/sustain';
        menu_title='Sustainability';
        close_menu='drop4';
    }else{
    }
    
    
    var display_val='<table cellpadding="0" cellspacing="0" class="column" width="100%" border="0">';
        if(menuformat=='pickmenu' && menu!="color"){
        display_val+='<tr>';
        display_val+='<td colspan="'+(num_cols+1)+'" valign="top">';
        display_val+='<div id="closeDiv" style="margin-bottom:15px;padding-bottom:10px;clear:both;"><span style="float:left;"><strong>'+menu_title+'</strong></span> <span style="float:right;"><img src="/images/close_button.jpg" alt="close" title="Close" onclick="document.getElementById(\''+close_menu+'\').style.display=\'none\'" style="cursor:pointer;"/></span></div>';
        display_val+='</td>';
        display_val+='</tr>';
        }else if(menu=="color"){
        display_val+='<tr>';
        display_val+='<td colspan="'+(num_cols)+'" valign="top"><strong>Color</strong></td><td colspan="'+(num_cols+1)+'" valign="top">';
        display_val+='<div id="closeDiv" style="margin-bottom:15px;padding-bottom:10px;clear:both;"><span style="float:left;"><strong>Grouping</strong></span> <span style="float:right;"><img src="/images/close_button.jpg" alt="close" title="Close" onclick="document.getElementById(\''+close_menu+'\').style.display=\'none\'" style="cursor:pointer;"/></span></div>';
        display_val+='</td>';
        display_val+='</tr>';
        }
        space_per_col=column_space;
        display_val+='<tr>';
        col_w=space_per_col/(num_cols - start_col);
        //alert("Test : "+col_w);
        var temp_cnt=0;        // Temporary count for border set up
        for(loop_i=start_col;loop_i<num_cols;loop_i++)
        {
            temp_cnt++;
            if(temp_cnt!=(num_cols-start_col))    // Setting Border for column
                display_val+='<td valign="top" width="'+col_w+'%" style="border-right:1px #cccccc solid;">';
            else
                display_val+='<td id="lnkTest" valign="top" width="'+col_w+'%">';
            
            display_val+='<label>'+column_heading[loop_i]+'</label><ul>';
            
            for(loop_j=0;loop_j<column_value[loop_i].length;loop_j++)
            {
                if(column_value[loop_i][loop_j][1]==1 && loop_j==0){
                    if(menu=="material"){
                       txt=column_value[loop_i][loop_j][0];
                       if(txt=="Patents & Mylars")
                                txt="Patents_Mylars"
                            
                        display_val+='<li style=""><a href="/'+page+'/'+txt+'" id="'+menu+'_'+loop_i+'_'+loop_j+'" class="alp" style="color:#006699;">'+column_value[loop_i][loop_j][0]+'</a></li>';
                    }else if(menu=="collect"){
                        if(loop_i==3)
                       display_val+='<li style=""><a href="/product_library/collection/2'+'/'+column_value[loop_i][loop_j][0]+'" id="'+menu+'_'+loop_i+'_'+loop_j+'" class="alp" style="color:#006699;">'+column_value[loop_i][loop_j][0]+'</a></li>';
                       else
                        display_val+='<li style=""><a href="/'+page+'/'+column_value[loop_i][loop_j][2]+'" id="'+menu+'_'+loop_i+'_'+loop_j+'" class="alp" style="color:#006699;">'+column_value[loop_i][loop_j][0]+'</a></li>';
                        
                    }else if(menu=="pattern"){
                        display_val+='<li style=""><a href="/'+page+'/'+column_value[loop_i][loop_j][0]+'" id="'+menu+'_'+loop_i+'_'+loop_j+'" class="alp" style="color:#006699;">'+column_value[loop_i][loop_j][0]+'</a></li>';
                    }else if(menu=="color"){
                        if(column_value[loop_i][loop_j][2]==1)
                            page='product_library/color_group';
                        display_val+='<li style=""><a href="/'+page+'/'+column_value[loop_i][loop_j][0]+'" id="'+menu+'_'+loop_i+'_'+loop_j+'" class="alp" style="color:#006699;">'+column_value[loop_i][loop_j][0]+'</a></li>';
                    }else if(menu=="sustain"){
                        display_val+='<li style=""><a href="/'+page+'/'+column_value[loop_i][loop_j][0]+'" id="'+menu+'_'+loop_i+'_'+loop_j+'" class="alp" style="color:#006699;">'+column_value[loop_i][loop_j][0]+'</a></li>';
                    }
                    else{
                        
                    }
                }else if(column_value[loop_i][loop_j][1]==1 && loop_j>0){
                    if(menu=="material"){
                     txt=column_value[loop_i][loop_j][0];
                       if(txt=="Patents & Mylars")
                                txt="Patents_Mylars"
                                
                        display_val+='<li style=""><a href="/'+page+'/'+txt+'" id="'+menu+'_'+loop_i+'_'+loop_j+'" class="alp" style="color:#006699;">'+column_value[loop_i][loop_j][0]+'</a></li>';
                    }else if(menu=="collect"){
                       if(loop_i==3)
                       display_val+='<li style=""><a href="/product_library/collection/2'+'/'+column_value[loop_i][loop_j][0]+'" id="'+menu+'_'+loop_i+'_'+loop_j+'" class="alp" style="color:#006699;">'+column_value[loop_i][loop_j][0]+'</a></li>';
                       else
                        display_val+='<li style=""><a href="/'+page+'/'+column_value[loop_i][loop_j][2]+'" id="'+menu+'_'+loop_i+'_'+loop_j+'" class="alp" style="color:#006699;">'+column_value[loop_i][loop_j][0]+'</a></li>';
                    }else if(menu=="pattern"){
                        display_val+='<li style=""><a href="/'+page+'/'+column_value[loop_i][loop_j][0]+'" id="'+menu+'_'+loop_i+'_'+loop_j+'" class="alp" style="color:#006699;">'+column_value[loop_i][loop_j][0]+'</a></li>';
                    }else if(menu=="color"){
                        if(column_value[loop_i][loop_j][2]==1)
                            page='product_library/color_group';
                        display_val+='<li style=""><a href="/'+page+'/'+column_value[loop_i][loop_j][0]+'" id="'+menu+'_'+loop_i+'_'+loop_j+'" class="alp" style="color:#006699;">'+column_value[loop_i][loop_j][0]+'</a></li>';
                    }else if(menu=="sustain"){
                        display_val+='<li style=""><a href="/'+page+'/'+column_value[loop_i][loop_j][0]+'" id="'+menu+'_'+loop_i+'_'+loop_j+'" class="alp" style="color:#006699;">'+column_value[loop_i][loop_j][0]+'</a></li>';
                    }else{
                        
                    }
                }else{
                        display_val+='<li style="padding-left:0px;">'+column_value[loop_i][loop_j][0]+'<sup style="vertical-align:text-top;">*</sup></li>';
                }
            }
            display_val+='</ul></td>';
            if(num_cols>1)
                display_val+='<td width="3%" align="center">&nbsp;</td>';
        }
        
        display_val+='</tr></table>';
        display_val+='<div class="clear"></div>';
        return display_val;
}          