
// make jQuery safe with other js libraraies (prototype is loaded on this page)
jQuery.noConflict();

// this will execute after pageload complete, so all elements are already in the DOM and accesible. 
jQuery(document).ready(function(){
  
    // find any element with this id : _ItemDetails1_hfCompany or this id: hfCompany
    // exit if not existing
    if(jQuery('#_ItemDetails1_hfCompany').length == 0 && jQuery('#hfCompany').length == 0) return;
    

    var arrCompany = ["symphonyflowers","iflowertrade","wholesaledemo","flowercause-92008","plaza flowers direct-19403","south country floral","bloomnet"];
      // if exists check that input value is == flowercause-92008    
    var switchvalue = jQuery('#hfCompany').length > 0 ? jQuery('#hfCompany').val() : jQuery('#_ItemDetails1_hfCompany').val();
      
    //alert(switchvalue);
if(jQuery.inArray(switchvalue, arrCompany) == -1) return;
    //if(switchvalue == 'flowercause-92008' ) {
        
        // do all the necessary design modifications here 
         //alert(switchvalue);
         
var CopyRight = 'This site is best viewed with Cookies and JavaScript enabled. Operated by '
 CopyRight += '<a class="FooterSubLink" href="http://www.iflowertrade.com" target="_blank"><u>iFlowerTrade</u>&#8482;</a>'
 jQuery('.CopyRight').html(CopyRight)

        var arrDivision = [" d flower fob miami","calif overnight","california grower direct","colombia fed ex direct ","colombia overnight","default","farners west","fedex","floralogic miami direct  ","floralogic miami overnight","florist direct","flowerfair","goldenrose","irvineflorist","mellano flower fair direct","mellano retail overnight","mellano wholesale direct","private marketplace direct","south america pre-book","tambo direct","plaza fob","south country ups","miami overnight","sa fedEx international","sa farm direct","california next day","galleriafarms"];
        var divisionswitch = jQuery('#hfDivision').length > 0 ? jQuery('#hfDivision').val() : jQuery('#_ItemDetails1_hfDivision').val();
        
        //alert(divisionswitch);
        if(jQuery.inArray(divisionswitch, arrDivision) == -1) return;
        //alert(divisionswitch);

        
        jQuery("#bodyMain").hide();
    
        var basename = window.location.pathname.replace(/^.*\/|\.[^.]*$/g, '').toLowerCase();

        jQuery('input[type="submit"]').css({'cursor':'pointer'})
        
        switch(basename) {
            
            case 'default':
    
                jQuery('#TopLinks').hide();
                var buttonvalue = jQuery('#_Layout6SearchButton1_Logout_btnLogOut').val(); 
                if(buttonvalue == 'Login') jQuery('#_Layout6SearchButton1_btnAdvSearch').hide();
                break;
    
            case '':
    
                jQuery('#TopLinks').hide();
                var buttonvalue = jQuery('#_Layout6SearchButton1_Logout_btnLogOut').val(); 
                if(buttonvalue == 'Login') jQuery('#_Layout6SearchButton1_btnAdvSearch').hide();
                break;
            
            case 'register':
    
                jQuery('#TopLinks').hide();
                jQuery('#_Layout6SearchButton1_btnAdvSearch').hide();
                jQuery('#table4 tr:first-child td:first-child').css({'background-color':'#003f90','padding':'10px'});
                break;
    
            case 'lostpassword':
    
                jQuery('#TopLinks').hide();
                jQuery('#_Layout6SearchButton1_btnAdvSearch').hide();
                jQuery('#table3 tr:first-child').before('<tr><td colspan="4" id="title">Password Reminder</td></tr>');
                jQuery('#title').css({'background-color':'#003f90','padding':'10px', 'font-family':'Arial', 'color':'white', 'font-weight': 'bold'});
    
                break;
        
            case 'login':
            
           
        
               // jQuery('#idHeader').hide();
//                jQuery('#TopLinks').hide();
  //              jQuery('.SearchButton').hide();
    //            jQuery('.cartHeader')
      //              .text('Sign in using our Secure Server')
        //            .css({'color':'white', 'padding':'10px', 'font-family':'Arial', 'font-weight':'700'});
          //      break;

 var table = '<div id="loginContainer"></div>';
  jQuery('#bodyContentMain').prepend(table);
 
  jQuery('#table5').appendTo('#loginContainer');
  jQuery('#table5').prepend('<tr><th colspan="2">Sign in using our Secure Server</th></tr>')
  jQuery('#table5').append('<tr><td></td><td id="submitContainer" style="text-align:left"></td></tr>')
  jQuery('#btnContinue').appendTo('#submitContainer');
  jQuery('#table5')
      .append('<tr><td></td><td style="text-align:left"><a href="LostPassword.aspx">forgot your password?</a></td></tr>')
       jQuery('#table5')
      .append('<tr><td colspan="2">Your order is safe and secure. All transactions on this web site are secure, indicated by the icon located at the bottom of your browser window.</td></tr>')
  jQuery('#table5')
      .append('<tr><td colspan="2" style="text-align:center"><img src="./images/img_verisign.jpg"></td></tr>')
  var clr = jQuery('#btnContinue').css('background-color')
  jQuery('#table5 th')
                    .css({'color':'white', 'font-weight':'700', 'background-color': clr});
  jQuery('#table5').css({'font-family':'Arial', 'width':'500px'})
  jQuery('#table5 th, td').css({'padding':'15px'})
  jQuery('#table3').hide();
  jQuery('#table2').hide();
  
  jQuery('#idHeader').hide();
                jQuery('#TopLinks').hide();
                jQuery('.SearchButton').hide();
       
                break;
    
            case 'orderpreferences' :
                jQuery('legend').css({'font-family':'Arial'});
                jQuery('#_Layout6SearchButton1_btnAdvSearch').hide();
                jQuery('#TopLinks').hide();
		    jQuery('#lblShipDate').text('Delivery by Date');
                break;
    
            case 'inventoryinfo':
            
                //alert("Gaurav");
                
                jQuery('#_Layout6SearchButton1_btnAdvSearch').hide();
                jQuery('#TopLinks').hide();
                jQuery('#txtItemID').hide();
                jQuery('#lblItemId').hide();
                jQuery('#lblInventoryListingMessage').css({'font-family':'arial'});
                jQuery('#lblFedexText').css({'font-family':'arial'});
                jQuery('#LinkCartItems').css({'font-family':'arial'});
                jQuery('#InventoryInfoGrid').css({'font-family':'arial'});
                jQuery('fieldset').before('<fieldset id="fs_searchfieldset"><legend><b>Search Options</b></legend><div id="fs_searchbox">test</div></fieldset');
                jQuery('#fs_searchfieldset').css({
                    'font-family':'arial',
                    'position':'relative',
                    'overflow':'visible',
                    'height':'160px',
                    'margin-bottom':'20px'
                });
                
                jQuery('#lblInventoryListingMessage, #lblFedexText').css({'font-size':'12px','font-weight':'bold','color':'olive'});
                jQuery('#LinkCartItems').css({'padding-left':'10px'});
                
                var fs_searchtable = '<table id="fs_searchtable"><tr><td><div class="label">Flower Name</div><div id="r1c1"></div></td><td><div class="label">Color</div><div id="r1c2"></div></td><td><div class="label">Variety</div><div id="r1c3"></div></td></tr><tr><td><div class="label">Grade</div><div id="r2c1"></div></td><td><div class="label">Country</div><div id="r2c2"></div></td><td><div class="label"></div><div id="r2c3"></div></td></tr><tr><td colspan="3" id="fs_btn"></td></tr></tr></table>';
                
                jQuery('#fs_searchbox')
                    .html(fs_searchtable)
                    .css({'position':'relative', 'overflow':'visible'});
                jQuery('#fs_searchtable').css({
                    'margin':'0 auto',
                    'font-family':'arial',
                    'overflow':'visible',
                    'top':'15px',
                    'bottom':'150px'
                });
                jQuery('#fs_searchtable .label').css({'font-size':'12px'})

                jQuery('#InventoryInfoGrid').parent().append('<div id="pager"></div>');
                var pager = jQuery('.grid-pager td:first-child').html();
                jQuery(pager).appendTo(jQuery('#pager'));
                
                jQuery('#txtFlowerName').appendTo('#r1c1');
                jQuery('#txtColor').appendTo('#r1c2').css({'width':'200'});
                jQuery('#txtVariety').appendTo('#r1c3');
                jQuery('#txtGrade').appendTo('#r2c1');
                //jQuery('#txtFobLocation').appendTo('#r2c2');
                jQuery('#txtCountry').appendTo('#r2c2');
                jQuery('#btnSearch').appendTo('#fs_btn');
                jQuery('<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>').appendTo('#fs_btn');
                jQuery('#btnReset').appendTo('#fs_btn');
                jQuery('#fs_btn').css({'text-align':'center', 'padding-top':'20px'});
                jQuery('fieldset:eq(1)').hide()
                jQuery('#fs_searchtable input[type=text]').css({'width':'160'});
                jQuery('#InventoryInfoGrid').css({'width':'100%', 'margin-top':'25px'});
                jQuery('#InventoryInfoGrid td:first-child, th:first-child').hide();
                jQuery('#InventoryInfoGrid td:nth-child(4), th:nth-child(4)').hide();
                jQuery('#InventoryInfoGrid td:nth-child(5), th:nth-child(5)').hide();
                jQuery('#InventoryInfoGrid td:nth-child(6), th:nth-child(6)').hide();
                jQuery('#InventoryInfoGrid td:nth-child(7), th:nth-child(7)').hide();
                jQuery('#InventoryInfoGrid td:nth-child(9), th:nth-child(9)').hide();
                jQuery('#InventoryInfoGrid td:nth-child(11)').css({'text-align':'right'});
                jQuery('#InventoryInfoGrid td:nth-child(15)').css({'text-align':'center'});
                jQuery('#InventoryInfoGrid td:nth-child(15) a').html('buy now');
                jQuery('#InventoryInfoGrid th:nth-child(15)').html('');
                jQuery('#InventoryInfoGrid th:nth-child(14)').html('Available');
                //jQuery('#InventoryInfoGrid th:nth-child(4)').html('Supplier');        
                jQuery('#InventoryInfoGrid th, td').css({'border-style':'hidden', 'padding':'5px'});
                jQuery('#InventoryInfoGrid th').css({'vertical-align':'top'});
    
                //jQuery('#InventoryInfoGrid').parent().append('<div id="pager"></div>');
//                jQuery('.grid-pager td').appendTo(jQuery('#pager'));
                
    
                break;
    
            case 'itemdetails':
            
                jQuery('#_Layout6SearchButton1_btnAdvSearch').hide();
                jQuery('#TopLinks').hide();
                jQuery('#sideBox').hide();
                jQuery('#layer1').hide();
            
                var table = '<table id="fs_ItemsDetailTable">';
                table += '<tr><td id="r1c1" class="" colspan="3" >Purchase this Item</td></td</tr>';
                table += '<tr><td id="r2c1" class="fs_header" colspan=2 ></td><td id="imgCont" rowspan="8"></tr>';
                table += '<tr><td id="r3c1" class="fs_header" colspan=2 >Supplier: </td></tr>';
                table += '<tr><td id="r4c1" class="fs_c1">Price per Unit</td><td id="r4c2"></td></tr>';
                table += '<tr><td id="r5c1" class="fs_c1">Units per Box</td><td id="r5c2"></td></tr>';
                table += '<tr><td id="r6c1" class="fs_c1">Price per Box</td><td id="r6c2"></td></tr>';
                table += '<tr><td id="r7c1" class="fs_c1">Available Boxes</td><td id="r7c2"></td></tr>';
                table += '<tr><td id="r8c1" class="fs_c1">Select Box Qty</td><td id="r8c2"></td></tr>';
                table += '<tr><td id="r9c1" class="fs_c1">Total Cost</td><td id="r9c2"></td></tr>';
                table += '<tr><td id="r10c1" colspan="3"></td></tr>';
                table += '</table>';
                
                jQuery('#table1')
                    .before('<div id="fs_newcontainer"></div>')
                    .hide();
        
                jQuery('#fs_newcontainer').append(table);
        
                if(jQuery('#_ItemDetails1_imgItem').attr('src') != 'no_image.gif') {
                    jQuery('#imgCont').append(jQuery('#_ItemDetails1_imgItem'));
                    jQuery(jQuery('#_ItemDetails1_imgItem').css({'float':'left', 'margin-left':'20px', 'border':'1px solid grey'}))
                }
        
                jQuery('#r2c1').text(jQuery('#_ItemDetails1_lblItemName').text());
                jQuery('#r3c1').text('Supplier: '+jQuery('#_ItemDetails1_lblGrower').text());
                jQuery('#r4c2').text(jQuery('#_ItemDetails1_lblPricePerStem').text());
                jQuery('#r5c2').text(jQuery('#_ItemDetails1_lblStemsPerBox').text());
                jQuery('#r6c2').text(jQuery('#_ItemDetails1_lblPricePerBox').text());
                jQuery('#r7c2').text(jQuery('#_ItemDetails1_lblAvailableStems').text());
                jQuery('#_ItemDetails1_txtQty2').appendTo(jQuery('#r8c2'));
                jQuery('#r9c2').text(jQuery('#_ItemDetails1_lblTotalCost').text());
                
                jQuery('#fs_ItemsDetailTable').css({
                    'margin':'0 auto',
                    'font-family':'arial',
                    'border':'1px solid grey',
                    'border-collapse':'collapse'
                });
                
                jQuery('#fs_ItemsDetailTable td').css({
                    'padding':'5px'
                });
                
                jQuery('#r4c2, #r5c2, #r6c2, #r7c2, #r8c2, #r9c2').css({
                    'text-align':'right'
                });
                
                jQuery('.fs_header').css({
                    'font-weight':'bold'
                });
                jQuery('.fs_c1').css({
                    'text-align':'left',    
                    'font-size':'14px',
                    'color':'grey'
                });
                
                jQuery('#r1c1').css({
                    'background-color':'grey',
                    'color':'white',
                    'text-align':'center',
                    'padding':'10px',
                    'font-weight':'bold'
                });
                
                jQuery('#_ItemDetails1_btnAddtocart').appendTo(jQuery('#r10c1'));
                jQuery('<span>&nbsp;</span>').appendTo(jQuery('#r10c1'));
                jQuery('#_ItemDetails1_btnCancel')
                    .appendTo(jQuery('#r10c1'))
                    .val('CANCEL');
            
                break;
    
            case 'cartform':
                jQuery.each(jQuery('table'), function () 
                    { 
                        if (this.id == 'itemContent') 
                        jQuery(this).addClass('itemContent'); 
                    }); 
                jQuery('.itemContent td:nth-child(2), th:nth-child(2)').hide();
                
                jQuery('#_Layout6SearchButton1_btnAdvSearch').hide();
                jQuery('#TopLinks').hide();
                //jQuery('#itemContent td:nth-child(2), th:nth-child(2)').hide();
                jQuery('#table2 td:nth-child(2), th:nth-child(2)').hide();
                jQuery('img').each(function(i) {
                    var x = this.src.indexOf("no_image.gif");
                    if(x > -1) this.src = '';
                });
               
                // center buttons 
                var newdiv = '<div id="buttonContainer" style="text-align: center"></div>' 
                var deltable = jQuery('#btnContinue').closest('table'); 
                deltable.before(newdiv) 
                jQuery('#btnCheckout').appendTo('#buttonContainer').css({'margin-right':'5px'}) 
                jQuery('#btnContinue').appendTo('#buttonContainer')
                break;            
                
            case 'paymentinfo':
                jQuery.each(jQuery('table'), function () 
                    { 
                        if (this.id == 'itemContent') 
                        jQuery(this).addClass('itemContent'); 
                    }); 
                jQuery('.itemContent td:nth-child(2), th:nth-child(2)').hide();                   
                
                jQuery('#_Layout6SearchButton1_btnAdvSearch').val('Continue Shopping');
                jQuery('#idHeader').hide();
                jQuery('#TopLinks').hide();
			jQuery('#table7').hide();
                jQuery('#drpAboutUs').closest('tr').hide();
                //jQuery('#itemContent td:nth-child(2), th:nth-child(2)').hide();
                jQuery('#table2 td:nth-child(2), th:nth-child(2)').hide();
                jQuery('img').each(function(i) {
                    var x = this.src.indexOf("no_image.gif");
                    if(x > -1) this.src = '';
                });
                break;
    
            case 'deliveryinformation':
                
                jQuery('#_Layout6SearchButton1_btnAdvSearch').val('Continue Shopping');
                jQuery('#idHeader').hide();
                jQuery('#TopLinks').hide();
                break;
            
            case 'reviewpage':
                jQuery('#_Layout6SearchButton1_btnAdvSearch').val('Continue Shopping');
                jQuery('#idHeader').hide();
                jQuery('#TopLinks').hide();
                jQuery('#itemContent td:nth-child(2), th:nth-child(2)').hide();
                jQuery('#table2 td:nth-child(2), th:nth-child(2)').hide();
                    break;
            default:
                //console.log('default');
                //break;
        } // end switch
    
        //jQuery('#bodyMain').fadeIn(2000)
        jQuery('#bodyMain').show()
    //} // end if
});









