/*
Company: Sapient
Date: 14/01/2011
Project: Share Happy
*/
function CheckDownLoadLink(prmUrl) {
    var url = prmUrl.toLowerCase();
    if (url.indexOf('pdf') > 0) {
        //alert('true')
        window.open(url, 'Download');
    }

}
function GetDefaultPage()
{
var hostName=location.pathname.split("/");
var loc = location.toString();
var pname = location.pathname.toString();
if(loc.search("shpreview")==-1)
{
	if(hostName[1].toString().search("_")==-1)
	{
    var finalURL=location.protocol+"//"+location.host+"/default.aspx";
	}
	else
	{
	 var finalURL=location.protocol+"//"+location.host+"/"+hostName[1]+"/default.aspx";
   	}
}
else 
{
	if((pname.search("be_")==-1) && (pname.search("ch_")==-1))
	{
	var finalURL=location.protocol+"//"+location.host+"/"+hostName[1]+"/default.aspx";
	}
	else
	{
	var finalURL=location.protocol+"//"+location.host+"/"+hostName[1]+"/"+hostName[2]+"/default.aspx"; 	
	}	
}
	window.location= finalURL;
}
function HtmlEncode(s) {
    var el = document.createElement("div");
    el.innerHTML = s;
    if (el.textContent) {
        s = el.textContent; // for ff
    }
    else {
        s = el.innerText; // for ie
    }
    delete el;
    return s;
}
var YouTubeChannelObj = new YouTubeChannel();
var FaceBookObj = new FaceBook();
var isTwitter = true;
function ShowVideo(channelname, iD) {
    YouTubeChannelObj.objName = 'YouTubeChannelObj';
    YouTubeChannelObj.channelName = channelname;
    YouTubeChannelObj.videoHeight = '410';
    YouTubeChannelObj.videoWidth = '685';
    if (iD != null) {
        YouTubeChannelObj.videoID = iD;
    }

    YouTubeChannelObj.__GetChannelVideo();

}

function ShowVideo(channelname, iD, width, height) {
    YouTubeChannelObj.objName = 'YouTubeChannelObj';
    YouTubeChannelObj.channelName = channelname;
    if (width && height) {
        YouTubeChannelObj.videoWidth = width;
        YouTubeChannelObj.videoHeight = height;
    }
    else {
        YouTubeChannelObj.videoHeight = '410';
        YouTubeChannelObj.videoWidth = '685';
    }
    if (iD != null) {
        YouTubeChannelObj.videoID = iD;
    }
    YouTubeChannelObj.__GetChannelVideo();

}

function GetBubbleText(BubbleTextLink) {

    var FaceBookOrTwitter = BubbleTextLink.toLowerCase();
    var username = "";
    if (FaceBookOrTwitter.indexOf('?') > 0) {
        FaceBookOrTwitter = FaceBookOrTwitter.substring(0, FaceBookOrTwitter.indexOf('?'));
    }
    if (FaceBookOrTwitter.indexOf('facebook') > 0) {
        isTwitter = false;
        username = FaceBookOrTwitter.substring(FaceBookOrTwitter.lastIndexOf("/") + 1);
    }
    else if (FaceBookOrTwitter.indexOf('twitter') > 0) {
        isTwitter = true;
        username = FaceBookOrTwitter.substring(FaceBookOrTwitter.lastIndexOf("/") + 1);
    }

    if (isTwitter) {
        jQuery(document).ready(function ($) {
            $("#twitter-text").tweet({
                avatar_size: 32,
                count: 1,
                username: [username],
                loading_text: "searching twitter...",
                refresh_interval: 0,
                maxLength: 115


            });

        })
    }
    else {

        FaceBookObj.objName = 'FaceBookObj';
        FaceBookObj.maxNo = 1;
        FaceBookObj.url = BubbleTextLink;
        FaceBookObj.profileName = username;
        FaceBookObj.albumName = 'Wall Photossss';
        FaceBookObj.divName = 'twitter-text';
        FaceBookObj.accessToken = '124888097576569|60ccb6efe7b0d37fcb2cb6ef-100002082667164|vf3cWtF7I0BM16-mDnxe_7toq5M';
        FaceBookObj.__GetFeed();

        //printFBPosts("twitter-text",FaceBookObj);
    }



}
function ShowBubbleText() {
    if (FaceBookObj != null && FaceBookObj.wallPosts.length > 0)
        document.writeln(FaceBookObj.wallPosts[0].formatedMsg);
}




function getFBPics(profileName, albumName, maxCount) {
    var tmpProfName = profileName;
    if (tmpProfName.indexOf('?') > 0) {
        tmpProfName = tmpProfName.substring(0, tmpProfName.indexOf('?'));
    }
    if (tmpProfName.indexOf('facebook') > 0) {
        tmpProfName = tmpProfName.substring(tmpProfName.lastIndexOf("/") + 1);
    }
    FaceBookObj.objName = 'FaceBookObj';
    FaceBookObj.profileName = tmpProfName;
    FaceBookObj.albumName = albumName;
    FaceBookObj.maxNo = maxCount;
    FaceBookObj.accessToken = '124888097576569|60ccb6efe7b0d37fcb2cb6ef-100002082667164|vf3cWtF7I0BM16-mDnxe_7toq5M';
    FaceBookObj.__GetAlbumID();
}
function printPics() {
    var imgString = "";
    imgString += '<ul id="mycarousel">';
    for (var pics in FaceBookObj.albumPics) {
        imgString += '<li><img src=\"' + FaceBookObj.albumPics[pics].bigPic.src + '\"width=\"270\"height=\"240\"alt=\"DefaultThumbnail\"/></li>';
    }
    imgString += '</ul>';
    document.writeln(imgString);

}

$(document).ready(function () {

    // expandable content area
    $('.point-main a.point-closed').click(function () {
        $(this).toggleClass('point-open').next().slideToggle('slow');
        return false;
    });

    // second level navigation styling on
    $('.subNavigation').hover(function () {
        $(this).addClass('active-nav');
        $(this).children("ul").show();
        $(".navigationBottomCurve").show();
    }, function () {
        $('.subNavigation').children("ul").hide();
        $(this).removeClass('active-nav');
    });

    $('.facebook-closed').css({ 'height': (likeBoxHeight - 199) + "px" });
    if ($.browser.msie && (parseFloat($.browser.version) < 7)) {
        $('.social-panel-m').css({ 'height': (likeBoxHeight - 198) + "px" });
        $('.social-panel-closed').css({ 'height': (likeBoxHeight - 197) + "px" });
    }
    //facebook mouse over
    $('.facebook-closed').hover(function () {
        $(this).animate({

            height: likeBoxHeight + "px"
        }, { queue: false });
    }, function () {
        $(this).animate({
            height: (likeBoxHeight - 199) + "px"
        }, { queue: false });
    });
    //add CSS Class in Video Link
    $(".article-split-two a").addClass("r")


    //Article page apply block css
    $(".articleBlockContainer").parents("#wrapper").removeClass("stripe")
    $(".articleBlockContainer").parents("#wrapper").addClass("block")

});
