﻿$(document).ready(function() {
    StartTwitter();
    
    
    var flashvars = {};
        var params = {
            menu: "false",
            wmode: "transparent",
            quality: "high",
            bgcolor: "#ffffff",
            menu: "true",
		    allowFullScreen: "false",
		    allowScriptAccess: "sameDomain"
        };
        
    var attributes = {};
    
    swfobject.embedSWF("home-rotator.swf", "divFlashHome", "784", "430", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
    
    swfobject.embedSWF("footer-anim-splash.swf", "divFlashFooter1", "320", "120", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
    swfobject.embedSWF("footer-anim-healthpro.swf", "divFlashFooter2", "320", "120", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
    swfobject.embedSWF("footer-anim-makingstrides.swf", "divFlashFooter3", "320", "120", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
        
});
function StartTwitter(){    
    $.getJSON("ajax/getTwitter.ashx?page=1&fromindex=1",
            function(data){                                                                                      
                $("#spntwitter").setTemplateURL("templates/twitterindex.htm");
                $("#spntwitter").processTemplate(data);
            });
    $('#bookmark').hide();
    $('#bookmark').mouseover(function(){
        blnCanHideBookmark = false;
        $('#bookmark').unbind("mouseleave");
        $('#bookmark').mouseleave(function(){
            blnCanHideBookmark = true;
        });    
    });
    timerid = setInterval("HideBookmarks()",2000);
}

var blnCanHideBookmark = false;
var timerid = 0;

var currentpediapage = "";
function BookmarkingPedia(type){
    var pag = currentpediapage;    
    if (type == 1){
        //delicious
        window.open("http://delicious.com/save?jump=yes&url=" + encodeURIComponent(pag) + "&title=via%20Nutralenda","_blank");
    }if(type == 2){
        //myspace
        window.open("http://www.myspace.com/Modules/PostTo/Pages/?u="  + encodeURIComponent(pag)+ "&t=via%20Nutralenda","_blank");
    }if(type == 3){
        //facebook
        window.open("http://www.facebook.com/sharer.php?u=" + encodeURIComponent(pag) + "&t=via%20Nutralenda","_blank");
    }if(type == 4){
        //digg
        window.open("http://digg.com/submit/?phase=2&url=" + encodeURIComponent(pag) + "&title=via%2520Nutralenda","_blank");
    }if(type == 5 ){
        //twitter
        window.open("http://twitter.com/home?status=" + encodeURIComponent(pag) + " via%20Nutralenda","_blank");
    }
    return false;
}
function ShowBookmarking(currurl,obj,id, fixpos, fixposy){
    var numfixpos = 0;
    var numfixposy = 0;
    if (fixpos > 0){
        numfixpos = fixpos;
    }
    if (fixposy > 0){
        numfixposy = fixposy;
    }
    var winheight = $(obj).position();
    var aux1 = winheight.left- 55;

    
    currentpediapage = currurl;
     var aux = $("#twitttime" + id);   
     //$(aux).hide();     
     blnCanHideBookmark = false;
     $('#bookmark').bookmark('change',{url: [currurl]});     
     var pos = aux.offset();
     //alert(pos.top)
     var width = aux.width();
     //$('#bookmark').css({"left": (pos.left -40 + fixposy) + "px","top":(pos.top - 125 - numfixpos) + "px"});
     $('#bookmark').css({"left":aux1,"top":(pos.top - 125 + 5)});
     $('#bookmark').show(500);
     //setTimeout('OutBookmarking()',4000)
}
function OutBookmarking(){
   //$("#divtest").append(1);
   blnCanHideBookmark = true;
   //setTimeout("HideBookmarks()",1500);    
    
}
function HideBookmarks(){
    if (blnCanHideBookmark == true){ 
        //$("#divtest").append("*");     
        $('#bookmark').hide();
        blnCanHideBookmark  = false;
        clearInterval(timerid);
        timerid = setInterval("HideBookmarks()",2000);
    }
}
