﻿var pageID

$(document).ready(function() {

    pageID = $("#tabID").text();
    
    if(pageID==902)
    {
       $(".centercolumn .green").css("margin","0 auto");
       $(".centercolumn .green").css("margin-top","95px");
       $(".centercolumn .green").css("margin-bottom","94px");
    }
     if(pageID==519)
    {
       $(".footerpane").css("margin-top","84px");
    }
     if(pageID==1602)
     {
        $('.centercolumn').css('direction','ltr');
     }
    /* change page title */
    var pTitle;
     if(pageID==558)
    {
       pTitle = $('.StoreDetailContainer .StoreDetailContainer-Title .StoreProductModelName').text();
       document.title = pTitle;  
    }
   

    $(".StoreCategoryProductItem .info a").attr("rel", "nofollow");
    
    
    /*  product alt and title */
    
    var productTitle;
    $('.StoreCategoryProductList TD, .StoreFeaturedProductList TD').each(function() {

       productTitle = $('.title span.StoreProductModelName', this).text();
         
       $('a.StoreProductLinkImage', this).attr("title",productTitle);
       $('.info a img', this).attr("alt",productTitle); 

    });

   
    
    if ($(".StoreMiniCartQuantityFooter").length !=0){
  
    	var n=$(".StoreMiniCartQuantityFooter SPAN").text()
	if (n=="1")
    		$(".cartCount").parent().text("יש לך מוצר 1 בסל");
	else
		$(".cartCount").text(n);
    	}
    else{
    	$(".cartCount").parent().text("אין לך מוצרים בסל");
	}
    
    //עמוד קטגוריה
    if ($(".pagenum").attr("text") == 589) {
        $(".centercolumn UL.level-0").addClass("CategoryPage");
        $(".centercolumn UL.CategoryPage LI IMG").each(function() {
            x = $(this).attr("src");
            $(this).attr("src", x.replace(".jpg", "_c.jpg"));
        })


    }
    // 
    var innerText = $("#dnn_ctr1199_dnnTITLE_lblTitle").text();
    $("#dnn_ctr1199_dnnTITLE_lblTitle").html('<a class="squareA" href="/content/החנות.aspx">' + innerText + '</a>');
    var innerText = $("#dnn_ctr1200_dnnTITLE_lblTitle").text();
    $("#dnn_ctr1200_dnnTITLE_lblTitle").html('<a class="squareA" href="/סלים/tabid/557/CategoryID/13/Default.aspx">' + innerText + '</a>');
    


    
   
    
    // add classes in order to view scrolling items
    $(".leftcolumn .StoreCatalogWrapper .StoreListContainer-Content").addClass("listItemWrapper");
    $(".leftcolumn .StoreCatalogWrapper .StoreListContainer-Content table").addClass("listItems");
    $(".leftcolumn .StoreCatalogWrapper .StoreListContainer-Content table tr").addClass("listItem");
    $('.listItem td').each(function(index) {
    if($(this).html()=="")
    {
       $(this).remove();   
    }
    
    //if the user after registretion page is showing - put it in center div and fit the editor to the page
    if($("#dnn_ctr1134_Login_pnlProfile").html() != null)
    {
    	var tempHolder = $("#dnn_ctr1134_Login_pnlProfile");
	$("#dnn_ctr1134_Login_pnlProfile").remove();
	$(".centercolumn").html(tempHolder);
	$(".RadEditor").css("width", "400px").css("min-width", "400px");
    }
    
    
  });
  
  
  
  
  
   var message=$(".StoreCategoryMessage").text();
   $(".CatalogMessage").text(message);

  
$("DIV.StoreAccountCustomerCart").wrap("<div class='StoreAccountCustomerCartWrap' />");
$("DIV.StoreAccountAddressesWrapper").wrap("<div class='StoreAccountAddressesWrapperWrap' />");
    //login
    //styling has to be here & not in css because it has to be an element style to remove the previous element style
    $("#dnn_ctr1134_Login_cmdRegister").addClass("pushButton");
    $("#dnn_ctl00_UR_btnSubmit").addClass("regButton");
    $(".StandardButton").addClass("pushButton");
    $("#dnn_ctr1134_Login_Login_DNN_cmdLogin").val("היכנס");
    $(".AuthenticationContent .LoginPanel LABEL").addClass("ALabels")
    $(".AuthenticationContent .LoginPanel #dnn_ctr1134_Login_Login_DNN_plUsername_lblLabel").text("שם משתמש");
    $(".AuthenticationContent .LoginPanel #dnn_ctr1134_Login_Login_DNN_plPassword_lblLabel").text("סיסמא");
    $(".AuthenticationContent #dnn_ctr1134_Login_cmdPassword").text("שכחת סיסמא?");
    //$(".AuthenticationContent TABLE TR").eq(6).css("display", "none");
    $(".AuthenticationContent TABLE:eq(0) tr:eq(6) td").attr("align", "right")
    $(".AuthenticationContent .pushButton:last").css({ "right": "80px", "line-height": "31px" });
    $(".AuthenticationContent .pushButton:first").css({ "right": "8px", "padding": "7px 0" });
    $(".AuthenticationContent .pushButton:last").text("הירשם");
    
    $(".AuthenticationContent .CommandButton:last").addClass("retreive");
    $(".AuthenticationContent .LoginPanel TABLE").css("width", "152px");
    $(".AuthenticationContent .LoginPanel TABLE .NormalTextBox").css("width", "136px");
    $(".AuthenticationContent .LoginPanel TABLE .NormalTextBox").parent().css("text-align", "center");

    //homepage
    $(".square:first").css("margin-left", "27px");
    $(".square UL LI:last").css("border-left", "none");

    // עמוד סלים 
    $(".StoreCategoryProductList TD.StoreCategoryProductAlternatingItem").addClass("StoreCategoryProductItem").removeClass("StoreCategoryProductAlternatingItem")

    $("a#dnn_ctr1138_Account_ctl00_ctl00_lnkEditBillingAddress").attr("href", "/דףהרשמה/tabid/852/Default.aspx?returnurl=http%3a%2f%2fdev6.mezoo.co.il%2fHome.aspx");
    $("table.StoreAccountCheckoutSelectBillingAddress tr:eq(0)").hide();
    $(".StoreAccountCheckoutTotal table:eq(1)").hide();
    
    
    $(".StorePageNav a").each( function(){
    	if ($(this).attr("href").indexOf("/tabid/") > 0)
	{		
		var tabid = (window.location + "").substr((window.location + "").indexOf("/tabid/") + 7, 3);
		var wrongTabid = $(this).attr("href").substr($(this).attr("href").indexOf("/tabid/") + 7, 3);
		$(this).attr("href", $(this).attr("href").replace(wrongTabid, tabid));
	}
    });
    if ($("div.CategoryListContainer-Navigation").html() != null && $("div.CategoryListContainer-Navigation").html() != "")
    {
    	$("div.CategoryListContainer-Content").before("<div class='CategoryListContainer-Navigation' style='margin-top: 30px;'>" + $("div.CategoryListContainer-Navigation").html() + "</div>");
    }
    if ($("a.StoreAccountCheckoutButton span span span").html() == "הירשם")
    {
    	$(".StoreAccountCheckoutButton").attr("href", "/דףהרשמה/tabid/852/Default.aspx?returnurl=http%3a%2f%2fdev6.mezoo.co.il%2fAccount.aspx");
    }
    
    // english articles
    if($(".English").length != 0)
    {
       //$(".English .DNNArticleContent a.CommandButton").text('return »');
    
       $(".English .CategoryArticleListContent  a.CommandButton").remove();
      
       if(pageID==1652)
       {
           $(".English .DNNArticleContent a.CommandButton").text('return »');
       }
       if(pageID==1650)
       {
           $("#dnn_ContentPane div:first").css('float','left').css('width','321px');
       }
       
    }
}); 
