var tt;
function loadPic(ele, type) {
    $(ele + " a").each(function() {
        var a = $(this); 
        var id = a.attr("href").split("-")[4].split(".")[0];
        setPic(id, a, type);
    });
}

function setPic(i, a, t) {
    $.ajax({
        url:"GetPic.aspx",
        type:"post",
        data:"id=" + i + "&type=" + t,
        timeout:3000,
        error:function() {
            a[0].id = i;
            a.parent().html("load image error,<br /><a href='javascript:' onclick='' id='" + a[0].id + "'>Reload</a>");
            reloadPic(a[0].id, t)
        },
        success:function(data) {
            data = data.split("|");
            if(data[1] == "0") {
                a.parent().attr("style", "background:url('http://www.lrwatch.com/" + data[0] + "') no-repeat center top");
            } else {
                a.html($("<img src='http://www.lrwatch.com/" + data[0] + "' width='180' height='136' border='1' class='pr_img_border' />"));
            }
        }
    });
}

function reloadPic(id, t) {
    $.ajax({
        url:"GetPic.aspx",
        type:"post",
        data:"id=" + id + "&type=" + t,
        timeout: 3000,
        error:function() {
            $("#" + id).parent().html("load image error,<br /><a href='javascript:' onclick='reloadPic(\"" + id + "\", \"" + t + "\")' id='" + id + "'>Reload again</a>");
            //reloadPic(id, t)
        },
        success:function(data) {
            $("#" + id).parent().html("<a href='Product-" + id + ".html' target='_blank'><img src='http://www.lrwatch.com/" + data.split("|")[0] + "' border='1' class='pr_img_border' width='180' height='136' /></a>");
        }
    });
}

function loadPhoto(id) {
    var photo;
    $.ajax({
        url:"GetPic.aspx",
        type:"post",
        data:"id=" + id + "&type=photo",
        timeout:3000,
        error:function() {
            loadPhoto(id);
        },
        success:function(data) {
            photo = data;
        }
    });
    photo = photo.split(",");
    alert(photo);
    $("#photoList div").each(function() {
        var i = $("#photoList div").index($(this)[0]);
        $(this).parent().attr("style", "background:url(http://www.lrwatch.com/" + photo[i] + ") no-repeat");
    });
}

$(document).ready(function () {
    //$(".slideshow").cycle();
    //$("#oTransContainer").cycle();
    $( '#divMenu' ).scrollFollow( {
     speed: 1000,
     offset: 50
    } );
    $("#tracqfloater").scrollFollow( {
     speed: 1000,
     offset: 100
    });
    $("#ctl00_top_tbxSearch,#ctl00_top_ddlCat").keyup(function(e) {
        if(e.keyCode == 13)
            turnSearch("ctl00_top_tbxSearch","ctl00_top_ddlCat");
    });
});

  
Ext.onReady(function () {
    var body = Ext.getBody();
    //body.insertFirst({tag: 'div', html: '\
    //      <div id="2008TopBar" style="clear:both;width:950px;height:38px;margin:0 auto;padding:0;background:url(images/2009/9/60_zty_950x38.jpg) no-repeat;overflow:hidden;position:relative;">\
    //        <a href="javascript:" style="position:absolute;left:0;top:0;height:38px;padding:0;margin:0;cursor:pointer;width:950px;z-index:1;"></a>\
    //        <div id="60Btncls" style="width:40px;height:18px;padding:0;margin:0;position:absolute;right:0;bottom:0;cursor:pointer;display:block;background:url(images/2009/9/60_zty_cls1.jpg) no-repeat;z-index:2;" title="Close"></div>\
    //      </div>\
    //      <div id="2008TopBlank" style="clear:both;height:5px;line-height:0;font-size:0;overflow:hidden;display:none;"></div>\
    //    '});
    //Ext.fly('60Btncls').on('click', function() { body.setStyle({ background: 'url(images/pr-sbg.jpg) #010101 repeat-x 50% top' }); Ext.fly('2008TopBar').setStyle({ display: 'none' }); });
    //body.setStyle({ background: 'url(images/2009/10/091016.jpg) repeat-x 50% top #fb8b1b' });
});