﻿// JScript File
var subpriceOrder = 0;
var subpriceOrder2 = 0;
$(document).ready(function()   
{  
setCurrentNav("nav1");

setTimeout(function(){loadAdv();},2000);

//setWelcome();

setSupportMore();

$(".cmdorder").mouseover(function()
{
    $(this).attr('src','/images/btDatHang2.gif')
 
});

$(".cmdorder").mouseout(function()
{
      $(this).attr('src','/images/btDatHang.gif')
});

$(".cmdorder").click(function()
{
      doOrder();
});



if($("#cmName").length >0 || $("#cmEmail").length>0)
    {
        $("#cmdCommend").click(function(){
             if($("#cmName").val()=="")
            {
                alert("Ghi chú: Bạn hãy cho biết tên của mình nhé !");
                $("#cmName").focus();
                return false;
            }
            var name = $.trim($("#cmName").val());
            if(name.length < 2)
            {
                alert("Ghi chú: Tên của bạn qua ngắn rồi, bạn vui lòng cung cấp chính xác !");
                $("#cmName").focus();
                return false;
            }
             if(!isValidEmailAddress($("#cmEmail").val()))
            {
                alert("Ghi chú: Email của bạn không chính xác !");
                $("#cmEmail").focus();
                return false;
            }
            var detail = $.trim($("#ctl00_ContentRight_txtcommend").val());
            if(detail.length < 2)
            {
                 alert("Ghi chú: Nội dung của bạn quá ngắn !");
                $("#ctl00_ContentRight_txtcommend").focus();
                 return false;
            }
            
            doCommend();
            return false;
        });
        
    }
    else
    {
        $("#cmdCommend").click(function(){
        
            var detail = $.trim($("#ctl00_ContentRight_txtcommend").val());
            if(detail.length < 2)
            {
                 alert("Ghi chú: Nội dung của bạn quá ngắn !");
                $("#ctl00_ContentRight_txtcommend").focus();
                 return false;
            }
            doCommend();
            return false;
        });
    } 

    setTopBanner();
    setTimeout(function(){getImage();},1000);
    setSubDetail();
    connect1();
    
});

function connect1()
{
     var content = $(".my-tool").html();
     //content = '<iframe src="http://www.facebook.com/plugins/like.php?href=" + url + "&amp;layout=standard&amp;show_faces=false&amp;width=130&amp;action=like&amp;font=arial&amp;colorscheme=light&amp;height=58" frameBorder=0 allowTransparency scrolling=no height=24 width=54  align="middle"></iframe> <img src="/images/page/facebook-icon.gif"  align="middle"><b>Like</b> sản phẩm này trên <b>Facebook</b>, chia sẻ cùng bạn bè ! <br>'  + content;
     content = '<iframe id="facebookf" src="http://www.facebook.com/plugins/like.php?href=http://hula.vn' + window.location.pathname +  '&amp;layout=standard&amp;show_faces=false&amp;width=130&amp;action=like&amp;font=arial&amp;colorscheme=light&amp;height=58" frameBorder=0 allowTransparency scrolling=no height=24 align="middle" ></iframe> ' + '<a title="Chia sẻ lên Facebook" href="http://www.facebook.com/sharer.php?u=http://hula.vn' + window.location.pathname +  '" target=_blank> <img alt="Chia sẻ lên Facebook" src="/images/page/facebook-icon.gif" align="middle" border="0"> </a> <br>'  + content;
     $(".my-tool").html(content);
     $("#facebookf").hide();
     $("#facebookf").load(function () {              
     $(this).fadeIn(1500);    })        
     .error(function () {      
         
      })           
}

function showtip(text)  
{
  if (document.all&&document.readyState=="complete") 
  {
  
  document.all.tooltip.innerHTML="<table cellpadding='0' cellspacing='0' width='200'><tr><td  style='width: 7px'></td><td  style='height: 10px'></td><td  style='width: 7px'></td></tr><tr><td  rowspan='3' style='height: 35px'></td><td rowspan='3' class='normal' style='height: 200px; vertical-align:top;background-color:#ffffff'>"+text+"</td><td  rowspan='3' style='height: 35px'></td></tr><tr></tr><tr></tr><tr><td  style='height: 10px; width: 5px;'></td><td >  </td><td style='width: 5px; height: 10px;'></td></tr></table>";
  
  document.all.tooltip.style.pixelLeft=event.clientX+document.body.scrollLeft;
  document.all.tooltip.style.pixelTop=event.clientY+document.body.scrollTop+document.documentElement.scrollTop-70;
  document.all.tooltip.style.visibility="visible";
  }
}

function hidetip()  
{
  var tooltop =  document.getElementById("tooltip");
  tooltop.style.display="none";
}

function showtip2()  
{
  var img= document.getElementById("imageproduct");
  var src = img.src;
  src = src.replace("/large","/normal");
  var text = "<img width='0' id='bigimage' alt='" + img.alt + "'  src='" + src + "'>";
  var tooltop =  document.getElementById("tooltip");
  tooltop.innerHTML="<table onclick='hidetip();' cellpadding='0' cellspacing='0' width='300'><tr><td class='normal' style='height: 200px; vertical-align:top;background-color:#ffffff;border:solid 3px #f3fcee'>" + text + "<br>Nhấn vào hình để đóng lại</td></tr></table>";
  tooltop.style.display="block";
  imggrowth();
  tooltop.style.left = ((screen.width/2) - (img.width)) + "px" ;
  tooltop.style.top= (screen.height - img.height)/4 + "px";
}

function loadpic(pic)  
{
  var img = document.getElementById(pic);
  var src = img.src;
  src = src.replace("/large","/normal");
  var text = "<img onclick='hidetip();' src='" + src + "'>";
  if (document.all&&document.readyState=="complete") 
  {
  var tooltop =  document.getElementById("tooltip");
  tooltop.innerHTML="<div>" + text + "<br>Nhấn vào hình để đóng lại</div>";
  
  tooltop.style.pixelLeft=event.clientX+document.body.scrollLeft ;
  tooltop.style.pixelTop= event.clientY+document.body.scrollTop+document.documentElement.scrollTop - 400;
  tooltop.style.display="block";
  }
}


function restorepic(pic)
{
    var image = document.getElementById("imageproduct");
    image.src=pic;
    var src = image.src;
    src = src.replace("/large","/normal");
    $('#imageproduct').attr('data-zoomsrc', src);
    MojoZoom.init();
}
        
function zin()
{

var image = document.getElementById("imageproduct");
if( image.width<320)
 {
 image.width += 10;
 setTimeout("zin();",10);
 }
 }
       
function zout()
{ 
var image = document.getElementById("imageproduct");
if ( image.width>160)
{
image.width -= 10;
 setTimeout("zout();",10);
}
}

 function imggrowth()
  {
   img = document.getElementById('bigimage');
   if (img.width < 300)
   {
   img.width += 20;
   setTimeout("imggrowth();",5);
   }
   else if(img.width < 350)
   {
      img.width += 2;
   setTimeout("imggrowth();",40);
   }
   else if(img.width < 401)
   { 
   img.width += 20;
   setTimeout("imggrowth();",5);
   }
  }
  
 function doOrder()
 {
    if($('#subprice').length == 0)
    { 
        if($('#subprice2').length == 0)
        { 
            $('#myAction').val('doOrder');
            $('#myAction2').val(0);
            $("#aspnetForm").submit();
        }
        else
        {
             if(subpriceOrder2>0)
            {
                $('#myAction').val('doOrder');
                $('#myAction2').val(subpriceOrder2);
                $("#aspnetForm").submit();
            }
            else
            {
                alert("Xin hãy chọn thông tin về sản phẩm bạn nhé !");
            }
        }
    }
    else
    {
        if(subpriceOrder>0)
        {
                if($('#subprice2').length == 0)
                { 
                    $('#myAction').val('doOrder');
                    $('#myAction2').val(subpriceOrder);
                    $("#aspnetForm").submit();
                }
                else
                {
                    if(subpriceOrder2>0)
                    {
                          $('#myAction').val('doOrder');
                          $('#myAction2').val(subpriceOrder + "-" + subpriceOrder2);
                          $("#aspnetForm").submit();
                    }
                    else
                    {
                        alert("Xin hãy chọn đủ thông tin về sản phẩm bạn nhé !");
                    }
            
                }
              
        }
        else
        {
            alert("Xin hãy chọn thông tin về sản phẩm bạn nhé !");
        }
    }
    return false;
 }
 
 function setsubprice(value)
 {
    subpriceOrder = value;
 }
 
 function setsubprice2(value)
 {
    subpriceOrder2 = value;
 }
 
 function doCommend()
 {
    var value = $("#ctl00_ContentRight_txtcommend").val();
    if(value.lenght < 2)
    {
        alert("Nhận xét của bạn quá ngắn !");
        return false;
    }
    alert('Xin cảm ơn nhận xét của bạn !');
    $('#myAction').val('doCommend');
    $("#aspnetForm").submit();
    return false;
    
 }

function setTopBanner()
{
    $("#header-right").html('<img src="http://hula.vn/images/advs/banner-660x60-mua-sam-hula.gif" alt="Mua sắm tại Hula" title="Thêm tiện nghi cùng Hula nhé !!"/>');
}

function setSubDetail()
{
    $("#sub-detail").html('<center><a href=\"http://hula.vn/tin_hula/noi_dung/21.html\"><img src="http://lh4.ggpht.com/_RKfs3StpCs8/S_oyjOylBPI/AAAAAAAAGz4/kveRjfDmajk/s800/hula_qui-trinh-ban-hang.jpg" alt="Mua sắm tại Hula" title="Thêm tiện nghi cùng Hula nhé !!"/></a><br><br><br><b>Vị trí Hula trên bản đồ Tp. Hồ Chí Minh: </b>(tại ngôi sao)<br><IFRAME id=hula_com height=700 src="http://hula.vn/sites/hula-map.html" frameBorder=0 width=630 scrolling=no></IFRAME></center><br><br>');
}

function setSupportMore()
{
    $("#supportMore").html('<br>* Lời nhắn từ Hula: <p>- Bán và chuyển hàng đi toàn quốc. Các bạn nhấn vào nút Mua ngay, cung cấp đầy đủ thông tin, chọn hình thức thanh toán thích hợp chúng tôi sẽ chuyển hàng đến cho các bạn.</p><p>- Các bạn ở gần có thể đến mua hàng trực tiếp (trừ các mặt hàng chỉ bán qua mạng <a href="http://hula.vn/huong_dan/hula-chi-ban-hang-qua-mang-la-gi/4.html" target="_blank"><img border="0" src="http://hula.vn/images/icoHelp.gif" /></a>), ngoài ra các bạn nên liên hệ trước để biết mặt hàng mình mua có còn hàng hay không nhé.</p><p>- Đây là nơi các bạn nhận xét cho ý kiến của mình về sản phẩm, chúng tôi sẽ không trả lời các bạn nhiều tại đây, mọi thắc mắc bạn có thể tham khảo phần Faq, chi tiết sản phẩm hay liên hệ bộ phận hỗ trợ trực tuyến để có câu trả lời chính xác nhất nhé <IMG src="http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/1.gif"></p>');
}

function getImage()
{
    var i =0;
    if(arrContent.length > 0)
    {    
        $("[name=\"image-detail\"]").each(function() {
         $(this).load(function () {              
         $(this).fadeIn(1500);    })        
         .error(function () {      
             
          })           
         $(this).attr('src', arrContent[i]);
        i++;
        
        });
        
        
    }
}


function setWelcome()
{

      $('#right-content').prepend('<div class="h-message"><h3>Thông báo nghỉ tết</h3>Hula xin thông báo:<br> <ul><li>Các đơn hàng đặt nhẫn đôi sẽ tạm dừng xử lý từ Thứ Hai ngày <b>08/02/2010</b><li> Các đơn hàng đi tỉnh sẽ tạm dừng vào Thứ Hai ngày <b>08/02/2010</b>.<li> Các đơn hàng giao tại nội thành TP. Hồ Chí Minh sẽ tạm dừng vào ngày  <b>12/02/2010</b>. <li> Mua hàng trực tiếp tại Hula đến hết ngày 30 tết tức <b>13/02/2010</b>.</ul> Các đơn hàng chưa xử lý trong thời gian tết sẽ được tiếp tục được xử lý từ mồng 4 tết tức ngày <b>17/02/2010</b>. Hula xin chân thành cảm ơn sự ủng hộ của quý khách hàng. </div>'); 

}