function initialize(){
    var feed1 = new google.feeds.Feed("http://www.kankuso.com/wordpress/?feed=rss2");
    feed1.setNumEntries(5);
    var feed2 = new google.feeds.Feed("http://hohoemizakura.blog25.fc2.com/?xml");
    feed2.setNumEntries(5);
    
    
    feed1.load(function(result){
    
        if (!result.error) {
            var container = document.getElementById("borablog");
            for (var i = 0; i < result.feed.entries.length; i++) {
                var entry = result.feed.entries[i];
                container.innerHTML += "<strong><a href='" + entry.link + "'>" + entry.title + "</a></strong><br />" + createDateString(entry.publishedDate) + "<br><hr />";
            }
            
        }
        
    });
    feed2.load(function(result){
    
        if (!result.error) {
            var container = document.getElementById("sakurabiyori");
            for (var i = 0; i < result.feed.entries.length; i++) {
                var entry = result.feed.entries[i];
                container.innerHTML += "<strong><a href='" + entry.link + "'>" + entry.title + "</a></strong><br />" + createDateString(entry.publishedDate) + "<br><hr />";
                
            }
            
        }
        
    });
    
}

// google.setOnLoadCallback(initialize);
function createDateString(publishedDate){
    var pdate = new Date(publishedDate);
    
    var pday = pdate.getDate();
    var pmonth = pdate.getMonth() + 1;
    var pyear = pdate.getFullYear();
    var phour = pdate.getHours();
    var pminute = pdate.getMinutes();
    var psecond = pdate.getSeconds();
    var strdate = pyear + "年" + pmonth + "月" + pday + "日" +
    phour +
    "時" +
    pminute +
    "分" +
    psecond +
    "秒";
    
    return strdate;
}

function resizeImg(aTag, imgTag, flg){

    $(aTag).click(function(){
        if (!flg) {
            $(imgTag).effect("scale", {
                percent: 400
            }, 800, function(){
                //alert("call1");
                flg = true;
                //alert("call2" + flg);
            });
            
        }
        else {
            $(imgTag).css({
                width: 100,
                height: 66
            });
            flg = false;
        }
        
        //return true;
    });
    
}

function resizeImg2(aList){
    var flg = false;
    var nowID;
    for (i = 0; i < aList.length; i++) {
    
        $(aList[i]).click(function(){
            var targetId = "i" + this.id;
            if (targetId != nowID) {
                $("#" + nowID).css({
                    width: 100,
                    height: 66
                });
                $("#" + targetId).effect("scale", {
                    percent: 400
                }, 800, function(){
                    //alert("call1");
                    flg = true;
                    nowID = this.id;
                    //alert("call2" + flg);
                });
                
            }
            else if (targetId == nowID && flg == true) {
                $("#" + targetId).css({
                    width: 100,
                    height: 66
                });
                flg = false;
                
            }
            else {
                $("#" + targetId).css({
                    width: 100,
                    height: 66
                });
                flg = false;
            }
            
            //return true;
        });
    }
    
    
    
    
}



$(function(){
    $('#rotate > ul').tabs({
        fx: {
            opacity: 'toggle'
        }
    });
    //                $("#maintab").click(function(){
    //                    initialize();
    //                });
    $('.ui-tabs-nav').bind('tabsshow', function(event, ui){
        if (ui.index == 0) {
            initialize();
            
        }
        if (ui.index == 2) {
        
            $('#accordion').accordion({
                header: ".ui-accordion-header",
                clearStyle: true
            });
        }
        if (ui.index == 3) {
            carclick("hummer", 1150);
            carclick("durango", 1150);
            carclick("daicap", 1150);
            carclick("ractis", 1150);
            carclick("variant", 500);
            carclick("crown1", 1150);
            carclick("crown2", 1150);
            
        }
        if (ui.index == 4) {
            $("#dialog").hide();
            $("#883").bind('click', function(){
                $("#dialog").load("./ss/ss.html", function(text, status){
                    $("#883").effect("bounce", {
                        direction: "down"
                    }, 100, function(){
                        cardlgctrl(1100);
                        
                    });
                    
                    
                });
                
            });
            
            carclick("x4", 2200);
            carclick("royal", 1100);
            carclick("majesty", 1100);
            carclick("fusion", 1100);
            carclick("majesty", 1100);
            carclick("tw", 1100);
            carclick("flhs", 1100);
            carclick("vespa", 1100);
            carclick("tl", 1100);
            
        }
        
        if (ui.index == 5) {
            carclick("cycle1", 1150);
            carclick("cycle2", 1150);
            
        }
        
    });
    
});
function carclick(carname, hgt){
    $("#" + carname).bind('click', function(){
        $("#dialog").load(carname + ".html", function(text, status){
            $("#" + carname).effect("bounce", {
                direction: "down"
            }, 100, function(){
                cardlgctrl(hgt);
                
            });
            
        });
        
    });
    
}

function cardlgctrl(hgt){
    if (!$("#cardialog").dialog("isOpen")) {
        $("#cardialog").dialog({
        
            modal: true,
            width: 850,
            height: hgt,
            close: destoryDlg,
            overlay: {
                opacity: 0.5,
                background: "black"
            }
        });
        $("#cardialog").dialog("open");
        $('.pics').cycle({
            fx: 'scrollDown',
            timeout: 2000
        });
    }
    
    
}

function dlg2ctrl(){
    if (!$("#dlg2").dialog("isOpen")) {
        $("#dlg2").dialog({
        
            modal: true,
            width: 850,
            height: 1150,
            close: destoryDlg2,
            overlay: {
                opacity: 0.5,
                background: "black"
            }
        });
        $("#dlg2").dialog("open");
    }
    
    
}

function destoryDlg(){
    //alert("aaa");
    $("#cardialog").destloy();
}

function destoryDlg2(){
    //alert("aaa");
    $("#dlg2").destloy();
}

