jQuery.noConflict();
jQuery(document).ready(function () {
    var menu_collapsed = true;
    var feeds_open = false;

    var overlay = jQuery('<div id="overlay"> </div>');
    overlay.appendTo(document.body);

    /********************************************************************************************************
    VIDEO Functions
    ********************************************************************************************************/
    var video_source = "http://www.youtube.com/embed/utDJJSsqmJ8?html5=1&feature=channel_video_title&enablejsapi=1&origin=" + window.location.host;
    jQuery("#btn-video").click(function () {
        var h = jQuery('#uws-single-content').height() - 3 + 'px';
        var w = jQuery('#uws-single-content').width() - 0 + 'px';
        jQuery('#uws-video-frame').height(h).width(w).attr('src', video_source).show();
        jQuery("#uws-security").dialog("close");
        overlay.hide();
        overlay.css({ "z-index": "9999" });
        jQuery("#uws-login").css({ 'width': '100px' });
        jQuery("#uws-login a").children("h4").html("Back To Log In");
        Cufon.replace('#uws-login a h4');
        return false;
    });

    /********************************************************************************************************
    GENERIC Functions
    ********************************************************************************************************/
    jQuery("a").each(function () {
        jQuery(this).attr("hideFocus", "true").css("outline", "none");
    });

    jQuery(".uws-blog-post a, .uws-blog-post h2").each(function () {
        jQuery(this).css({ "cursor": "pointer" });
        //jQuery(this).bind("click", function () { location.href = 'blog.htm'; return false; });
    });
    /********************************************************************************************************
    HEADER Functions
    ********************************************************************************************************/
    // Custom: Append login dialog to form, for postbacks
    //jQuery("#uws-security").dialog({
    var dlg = jQuery("#uws-security").dialog({
        autoOpen: false,
        position: 'center',
        height: 'auto',
        width: 400,
        zIndex: 9999999,
        title: '<h3>Welcome to Pango</h3>',
        draggable: false,
        resizable: false,
        modal: false,
        close: function () {
            overlay.hide();
            overlay.css({ "z-index": "9999" });
        }
    });
    dlg.parent().appendTo(jQuery("form:first"));
    jQuery(window).resize(function () { jQuery("#uws-security").dialog("option", "position", 'center') });
    jQuery("#uws-login a").click(function () {
        var loginUrl = '/templates/landing.aspx';
        if (window.location.pathname.substring(0, 23).toLowerCase() != loginUrl) {
            location.href = loginUrl + '?login=true';
            return false;
        } else {
            jQuery('#uws-video-frame').attr('src', '');
            jQuery("#uws-login a").children("h4").html("Log In");
            jQuery("#uws-login").css({ 'width': '80px' });
            Cufon.replace('#uws-login a h4');
            overlay.css({ "z-index": "9999998" });
            overlay.show();
            jQuery("#uws-security").dialog("open");
        }
    });

    // Custom location redirect
    jQuery("#uws-logout").click(function () {
        //location.href = 'index.htm';
        location.href = '?logout=true';
        return false;
    });

    /********************************************************************************************************
    LEFT PANEL Functions
    ********************************************************************************************************/
    //My Profile - Menu
    jQuery("#uws-my-profile-header").click(function () {
        if (menu_collapsed == true) {
            jQuery("#uws-main-content-inner").stop(true, true).animate({ marginLeft: 200 }, 100);
            jQuery("#uws-sidebar-left").stop(true, true).animate({ marginLeft: 0 }, 100);
            jQuery("#uws-my-profile-header a").removeClass("icon-right").addClass("icon-left");
            jQuery("#uws-edit-my-profile").css({ "visibility": "visible" });
            jQuery("#uws-edit-my-status").css({ "visibility": "visible" });
            jQuery("#uws-top-friends-list").css({ "visibility": "visible" });
            menu_collapsed = false;
        } else {
            jQuery("#uws-sidebar-left").stop(true, true).animate({ marginLeft: -200 }, 100);
            jQuery("#uws-main-content-inner").stop(true, true).animate({ marginLeft: 0 }, 100);
            jQuery("#uws-my-profile-header a").removeClass("icon-left").addClass("icon-right");
            jQuery("#uws-edit-my-profile").css({ "visibility": "hidden" });
            jQuery("#uws-edit-my-status").css({ "visibility": "hidden" });
            jQuery("#uws-top-friends-list").css({ "visibility": "hidden" });
            jQuery("#uws-sidebar-feeds").css({ "visibility": "hidden" });
            jQuery("#uws-sidebar-feeds-list").css({ "visibility": "hidden" });
            jQuery("#uws-my-feeds-header").removeClass("active");
            overlay.hide();
            jQuery("#uws-my-profile-header").css({ "width": "247px" });
            jQuery("#uws-my-profile-header").stop(true, true).animate({ marginLeft: 0 }, 100);
            jQuery("#uws-my-profile-header").children("h1").html("My Profile");
            menu_collapsed = true;
            feeds_open = false;
        }
        return false;
    });

    jQuery(".uws-status").click(function () { jQuery(this).val(''); return false; });


    //My Homepage
    jQuery("#uws-my-home-page-header").hover(
		function () { if (menu_collapsed == true) { jQuery("#uws-my-home-page").stop(true, true).animate({ marginLeft: 200 }, 200); } },
		function () { jQuery("#uws-my-home-page").stop(true, true).animate({ marginLeft: 0 }, 200); }
	);
    //jQuery("#uws-my-home-page-header").click(function () { location.href = 'home.htm'; return false; });
    jQuery("#uws-my-home-page-header").click(function () { location.href = '/'; return false; });

    //My Friends
    jQuery("#uws-my-friends-header").hover(
		function () { if (menu_collapsed == true) { jQuery("#uws-my-friends").stop().animate({ marginLeft: 200 }, 200); } },
		function () { jQuery("#uws-my-friends").stop().animate({ marginLeft: 0 }, 200); }
	);
    //jQuery("#uws-my-friends-header").click(function () { location.href = 'friends.htm'; return false; });

    //My Groups
    jQuery("#uws-my-groups-header").hover(
		function () { if (menu_collapsed == true) { jQuery("#uws-my-groups").stop().animate({ marginLeft: 200 }, 200); } },
		function () { jQuery("#uws-my-groups").stop().animate({ marginLeft: 0 }, 200); }
	);
    //jQuery("#uws-my-groups-header").click(function () { location.href = 'groups.htm'; return false; });
    jQuery("#uws-my-groups-header").click(function () { location.href = '/Groups'; return false; });

    //My Discussions
    jQuery("#uws-my-discussions-header").hover(
		function () { if (menu_collapsed == true) { jQuery("#uws-my-discussions").stop().animate({ marginLeft: 200 }, 200); } },
		function () { jQuery("#uws-my-discussions").stop().animate({ marginLeft: 0 }, 200); }
	);
    //jQuery("#uws-my-discussions-header").click(function () { location.href = 'discussions.htm'; return false; });

    //My Feeds
    jQuery("#uws-my-feeds").hover(
		function () { if (menu_collapsed == true) { jQuery("#uws-my-feeds").stop().animate({ marginLeft: 200 }, 200); } },
		function () { jQuery("#uws-my-feeds").stop().animate({ marginLeft: 0 }, 200); }
	);
    jQuery("#uws-my-feeds-header").click(function () {
        //		overlay.show();
        jQuery("#uws-my-feeds").stop().animate({ marginLeft: 0 }, 200);
        if (menu_collapsed == true) {
            jQuery("#uws-my-profile-header").css({ "width": "267px", "background": "url(/images/bg-dark-stripe.gif) repeat-x" });
            jQuery("#uws-my-profile-header").stop(true, true).animate({ marginLeft: 200 }, 200);
        } else {
            if (feeds_open == false) { jQuery("#uws-my-profile-header").css({ "width": "467px", "background": "url(/images/bg-dark-stripe.gif) repeat-x" }); }
        }
        jQuery("#uws-my-profile-header a").removeClass("icon-right").addClass("icon-left");
        jQuery("#uws-sidebar-feeds-list").css({ "visibility": "visible" });
        jQuery("#uws-my-profile-header").children("h1").html("Back To Profile");
        jQuery("#uws-my-feeds-header").addClass("active");
        menu_collapsed = false;
        feeds_open = true;
        return false;
    });


    //Top Friends
    jQuery("#uws-top-friends").hover(
		function () {
		    if (menu_collapsed == true) {
		        jQuery("#uws-top-friends").stop().animate({ marginLeft: 200 }, 200);
		        jQuery("#uws-top-friends-list").css({ "visibility": "visible" });
		    }
		}, function () {
		    if (menu_collapsed == true) { jQuery("#uws-top-friends-list").css({ "visibility": "hidden" }); }
		    jQuery("#uws-top-friends").stop().animate({ marginLeft: 0 }, 200);
		}
	);

    jQuery("#uws-sidebar-feeds-close").click(function () {
        jQuery("#uws-sidebar-feeds").css({ "visibility": "hidden" });
    });

    jQuery(".uws-top-friends-list img").each(function () {
        var html = '';
        html += '<div id="uws-top-friend-popup">';
        html += '	<div id="uws-top-friend-popup-thumbnail"><img src="images/sample-top-friend-popup.jpg" alt="" /></div>';
        html += '	<div id="uws-top-friend-popup-info">';
        html += '		<p class="uws-top-friend-popup-name">Jane Citizen</p>';
        html += '		<p class="uws-top-friend-popup-course">Penrith Selective HS</p>';
        html += '	</div>';
        html += '	<div id="uws-top-friend-popup-status"><p><i>"Can\'t wait for the school formal with my besties!"</i></p></div>';
        html += '</div>';

        jQuery(this).attr('cursor', 'pointer');


        jQuery(this).qtip({
            content: { text: html },
            position: { target: 'mouse', corner: 'bottomLeft' },
            style: {
                width: 345,
                padding: 0,
                textAlign: 'left',
                border: { width: 0, radius: 0 },
                tip: { corner: 'bottomLeft', color: '#499424' },
                name: 'green'
            }
        })
    });


    /********************************************************************************************************
    LOGIN / SIGNUP Functions
    ********************************************************************************************************/
    jQuery("#btn-sign-up").click(function () {
        jQuery("#uws-sign-up-box").show();
        jQuery("#uws-login-box").hide();
        return false;
    });

    jQuery("#btn-cancel").click(function () {
        jQuery("#uws-login-box").show();
        jQuery("#uws-sign-up-box").hide();
        return false;
    });

    //jQuery("#btn-login, #btn-register").click(function () { location.href = 'home.htm'; return false; });

    /********************************************************************************************************
    CONTENT Functions
    ********************************************************************************************************/
//    jQuery("#uws-main-content").click(function () {
//        if (feeds_open == true) {
//            jQuery("#uws-my-profile-header").trigger("click");
//        }
//        return false;
//    });

    jQuery("#btn-notifications").click(function () {
        jQuery("#uws-list-notifications").html('<li>No new notifications</li>');
        jQuery("#btn-notifications").hide();
    });

    jQuery("#btn-all-updates, #btn-questions, #btn-answers").click(function () {
        LoadUpdates(this.rel);
        jQuery(".uws-my-updates-tabs").children("li").removeClass("active");
        jQuery(this).parent("li").addClass("active");

    });

    /********************************************************************************************************
    RIGHT PANEL Functions
    ********************************************************************************************************/
//    jQuery("#uws-sidebar-accordion").accordion({ header: "> section > header", active: false, autoHeight: false, collapsible: true });

//    jQuery("#uws-sidebar-accordion header").click(function () {
//        if (jQuery(this).hasClass("uws-dark-panel")) {
//            jQuery(this).removeClass("uws-dark-panel").addClass("uws-light-panel");
//            jQuery(this).children("a").removeClass("icon-up").addClass("icon-down-inactive");
//        } else {
//            jQuery("#uws-sidebar-accordion header").removeClass("uws-dark-panel").addClass("uws-light-panel");
//            jQuery("#uws-sidebar-accordion a").removeClass("icon-up").addClass("icon-down-inactive");
//            jQuery(this).removeClass("uws-light-panel").addClass("uws-dark-panel");
//            jQuery(this).children("a").removeClass("icon-down-inactive").addClass("icon-up");
//        }
//        Cufon.replace('.uws-dark-panel h1');
//        Cufon.replace('.uws-light-panel h1');
//        return false;
//    });

    //	jQuery("#btn-login, #btn-register").click(function(){location.href = 'home.htm';return false;});

    /********************************************************************************************************
    FOOTER Functions
    ********************************************************************************************************/
    // Custom: Show dynamic content not static html
    jQuery("#uws-footer-high-school,#uws-footer-uni,#uws-footer-career,#uws-footer-life").click(function (e) {
        var detailId = this.id.replace('footer', 'footer-detail');

        e.preventDefault();
        if (jQuery(this).parent().hasClass("active")) {
            if (jQuery("#" + detailId).is(':hidden')) {
                jQuery("#" + detailId).show();
                return false;
            } else {
                jQuery("#" + detailId).hide(100, function () {
                    overlay.hide();
                    return false;
                });
                jQuery("#" + detailId).hide();
                jQuery(this).parent().toggleClass("active");
                return false;
            }
        } else {
            jQuery(".footer-menu").children("li").removeClass("active");
            jQuery(this).parent().toggleClass("active");

            jQuery("#uws-footer-detail-high-school").hide();
            jQuery("#uws-footer-detail-uni").hide();
            jQuery("#uws-footer-detail-career").hide();
            jQuery("#uws-footer-detail-life").hide();

            if (jQuery("#" + detailId).is(':hidden')) {
                jQuery("#" + detailId).show();
                return false;
            }
        }
    });

    jQuery("#btn-notifications").val("Clear All " + LoadNotifications());
    LoadUpdates(0);
    LoadFeeds(1);

    if (LoadFriends(1)) { jQuery("#uws-sidebar-accordion .uws-green-panel").trigger("click"); }
    if (LoadGroups(1)) { jQuery("#uws-sidebar-accordion .uws-purple-panel").trigger("click"); }
    if (LoadDiscussions(1)) { jQuery("#uws-sidebar-accordion .uws-red-panel").trigger("click"); }

    // Custom: these statements fail when sidebar is hidden (say in Landing.aspx), stopping javascript
    // Not Working in IE 7/8
    try {
        jQuery('#uws-main-content-inner').jScrollPane({ autoReinitialise: true, showArrows: false, horizontalGutter: 0, verticalGutter: 20 });
        jQuery("#uws-sidebar-feeds-list").jScrollPane({ autoReinitialise: true, showArrows: false, horizontalGutter: 0, verticalGutter: 0 });
        jQuery('#uws-sidebar-feeds-list-details-wrapper').jScrollPane({ autoReinitialise: true, showArrows: false, horizontalGutter: 0, verticalGutter: 0 });
        //jQuery('#uws-sidebar-right').jScrollPane({ autoReinitialise: true, showArrows: false, horizontalGutter: 0, verticalGutter: 20 });
    }
    catch (err) { }
});

/****************************************************************
General Functions
****************************************************************/

/****************************************************************
Ajax Functions
****************************************************************/

// Custom: Don't load static html
////Load Footer Information
//function LoadFooterData(section){
//	jQuery(".uws-footer-image").html('<img src="images/map.jpg" />');
//	jQuery(".uws-footer-overview").html('<h2>' + section + ' Overview</h2><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vel aliquam magna. Nunc nibh ante, vestibulum eu dictum quis,commodo eu enim. Sed ornare, velit vel commodo sagittis, mi dui gravida dui, eu viverra sapien arcu non arcu. Morbi turpis dis parturient montes, nascetur ridiculus mus. Suspendisse sit amet orci sit amet ligula congue accumsan. </p>');
//	jQuery(".uws-footer-interact").html('<h2>Interact with ' + section + '</h2><ul class="uws-footer-info"><li>Groups</li><li>Discussions</li><li>Blogs</li><li>Resources</li></ul>');
//	jQuery(".uws-footer-knowledge").html('<h2>Knowledge Bank</h2><ul class="uws-footer-info-gray"><li class="active"><a href="#">The Path To ' + section + '</a></li><li><a href="#">Scholarships</a></li><li><a href="#">Once I\'m at ' + section + '</a></li><li><a href="#">Surviving ' + section + '</a></li><li><a href="#">Making ' + section + ' work for You</a></li><li><a href="#">Overseas and ' + section + '</a></li></ul>');
//	jQuery(".uws-footer-path").html('<h2>The Path To ' + section + '</h2><p><a href="#">Third Level Nav 1</a><br /><a href="#">Third Level Nav 2</a><br /><a href="#">Third Level Nav 3</a><br /><a href="#">Third Level Nav 4</a></p>');
//	jQuery(".uws-footer-path a").each(function() {
//		jQuery(this).bind("click",function(){location.href = 'content.htm';return false;});
//	});
//}

//Load Notification Section
function LoadNotifications() {
    var count = 4;
    var items = '';
    items += '<li><a class="icon-comments-gray fltlft" href="#"></a><a class="icon-close-gray fltrt" href="#"></a><a href="#">Jane Citizen</a> commented on your <a href="#">question</a></li>';
    items += '<li><a class="icon-user-gray fltlft" href="#"></a><input type="submit" class="uws-gray-close fltrt" name="cancel" value="Ignore" /><input type="submit" class="uws-blue-accept fltrt" name="cancel" value="Accept" /><a href="#">John Appleseed</a> wants to be your friend</li>';
    items += '<li><a class="icon-comments-gray fltlft" href="#"></a><a class="icon-close-gray fltrt" href="#"></a><a href="#">John Appleseed</a> commented on your <a href="#">question</a></li>';
    items += '<li><a class="icon-like-gray fltlft" href="#"></a><a class="icon-close-gray fltrt" href="#"></a><a href="#">Jane Citizen</a> likes your <a href="#">post</a></li>';
    jQuery("#uws-list-notifications").html(items);
    return count;
}

//Load Updates Section
function LoadUpdates(view) {
    view = typeof (view) != 'undefined' ? view : 0;
    var items = '';
    var indent = view == 0 ? ' class="uws-my-updates-photo-indented"' : "";

    if (view == 0 || view == 1) {
        items += '<article><div class="uws-my-updates-photo"><img  src="images/sample-jane.jpg" alt="" /></div><div class="uws-my-updates-comments"><p><b><a href="#">Jane Citizen</a> at 4.36 pm</b><br />Can anyone give me some pointers for how to get started in Physics? I' + "'" + 'm in Year 10 but find this stuff to be tough, tough, tough....</p><footer><div class="uws-my-updates-total-likes fltlft"><span href="#" class="icon-like-left"></span>28 people like this</div><div class="uws-my-updates-like fltrt"><a href="#"><span href="#" class="icon-like-white-right"></span>Like</a></div><div class="fltrt uws-my-updates-comment"><a href="#">Comment</a></div></footer></div>';
    }
    if (view == 0 || view == 2) {
        items += '<article' + indent + '><div class="uws-my-updates-photo"><img  src="images/sample-john.jpg" alt="" /></div><div class="uws-my-updates-comments"><p><b><a href="#">John Appleseed</a> at 4.36 pm</b><br />Best you join a study group, get a tutor, check out the library, or find a friend who can help you! That' + "'" + 's what I did and it helped me no end!</p><footer><div class="uws-my-updates-total-likes fltlft"><span href="#" class="icon-like-left"></span>You and 8 people like this</div><div class="uws-my-updates-comment fltrt"><a href="#">Unlike</a></div></footer></div></article>';
    }
    if (view == 0 || view == 1) { items += '</article>'; }
    items += '<br clear="left" /><br />';
    if (view == 0 || view == 1) {
        items += '<article><div class="uws-my-updates-photo"><img  src="images/sample-jane.jpg" alt="" /></div><div class="uws-my-updates-comments"><p><b><a href="#">Jane Citizen</a> at 4.36 pm</b><br />I' + "'" + 'm planning to get my P' + "'" + 's next year and my first car. How do I get started?</p><footer><div class="uws-my-updates-total-likes fltlft"><span href="#" class="icon-like-left"></span>28 people like this</div><div class="uws-my-updates-like fltrt"><a href="#"><span href="#" class="icon-like-white-right"></span>Like</a></div><div class="fltrt uws-my-updates-comment"><a href="#">Comment</a></div></footer></div>';
    }
    if (view == 0 || view == 2) {
        items += '<article' + indent + '><div class="uws-my-updates-photo"><img  src="images/sample-john.jpg" alt="" /></div><div class="uws-my-updates-comments"><p><b><a href="#">John Appleseed</a> at 4.36 pm</b><br />You' + "'" + 'll need driving lessons from an instructor so check with your parents and friends who can help you or who they recommend. Don' + "'" + 't get your parents or friends to teach you though as you' + "'" + 'll pickup all their bad habits</p><footer><div class="uws-my-updates-total-likes fltlft"><span href="#" class="icon-like-left"></span>You and 8 people like this</div><div class="uws-my-updates-comment fltrt"><a href="#">Unlike</a></div></footer></div></article>';
    }
    if (view == 0 || view == 1) { items += '</article>'; }
    items += '<br clear="left" /><br />';

    jQuery("#uws-list-updates").html(items);

}

//Load Feeds Section
function LoadFeeds(view) {
    view = typeof (view) != 'undefined' ? view : 0;  //0 = All Feeds, 1 = My Feeds 
    var items = '';
    var detail = '';

    for (var i = 1; i < 11; i++) {
        if (view == 1 && i == 4) { break; }
        items += '<li><h2 id="' + i + '">Feed Title ' + i + '</h2>';
        items += '<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non adipiscing eros. </p></li>';
    }

    detail += '<article>';
    detail += '<p><img src="images/sample-feed-image.gif" alt="" /></p>';
    detail += '<h3>Feed Article Title</h3>';
    detail += '<h4>24TH September, 2011  |  Tags:  Tag title 1</h4>';
    detail += '<p>Donec lectus lorem, laoreet vel, venenatis id, pellentesque eget, leo. Sed tortor purus, consequat';
    detail += 'id, placerat id, lacinia id, purus. Ut mi. Fusce quis sapien. Duis congue elementum tellus. Nam nec urna.';
    detail += 'Vestibulum dolor erat, dignissim quis, rhoncus et, accumsan non, felis. Donec ultrices odio sed magna. </p>';
    detail += '<p>Nunc dui urna, faucibus vitae, vulputate ac, cursus vel, sem. Sed ligula mauris, mattis eget, rhoncus ut, ';
    detail += 'aliquet sit amet, magna. Vestibulum ornare sapien in dui.</p>';
    detail += '</article>';


    items += '<br clear="left" /><br /><br /><br />';
    jQuery(".uws-sidebar-feeds-list").html(items);

    jQuery(".uws-sidebar-feeds-list li").click(function () {
        var id = jQuery(this).children("h2").attr("id");
        var title = "Feed Title " + id;
        var articles = '';
        jQuery("#uws-sidebar-feeds-title").html(title);
        Cufon.replace('#uws-sidebar-feeds h1');
        for (i = 0; i < id; i++) { articles += detail; }
        articles += '<br clear="left" /><br /><br /><br />';
        jQuery("#uws-sidebar-feeds-list-details").html(articles);
        jQuery("#uws-sidebar-feeds").css({ "visibility": "visible" });
        return false;
    });
    jQuery("#btn-all-feeds, #btn-my-feeds").click(function () {
        LoadFeeds(this.rel);
        Cufon.replace('#uws-sidebar-feeds-list h2');
        jQuery(".uws-all-feeds").children("li").removeClass("active");
        jQuery(this).parent("li").addClass("active");
        return false;
    });

}

//Load Friends Section
function LoadFriends(view) {
    view = typeof (view) != 'undefined' ? view : 0;  //0 = All Friends, 1 = My Friends 
    var detail = '';
    if (jQuery("#uws-list-friends").length > 0) {
        for (var i = 1; i < 10; i++) {
            if (view == 1 && i == 5) { break; }
            detail += '<article>';
            detail += '<div class="uws-friends-photo"><img src="images/sample-friend.jpg" alt="" /></div>';
            detail += '<div class="uws-friends-comments">';
            detail += '<h3>Jane Citizen</h3>';
            detail += '<p>School<br />';
            detail += '<i>"Nulla facilisi. Sed non metus eget leo condimentum facilisis quis quis sem."</i></p>';
            detail += '<span class="uws-friends-add"><a href="#" >Add Friend</a></span><span class="uws-friends-remove"><a href="#" >Remove Friend</a></span>';
            detail += '</div>';
            detail += '</article>';
        }

        jQuery("#uws-list-friends").html(detail);
        jQuery("#btn-everyone, #btn-my-friends").click(function () {
            LoadFriends(this.rel);
            jQuery(".uws-friends-tabs").children("li").removeClass("active");
            jQuery(this).parent("li").addClass("active");
            return false;
        });
        Cufon.replace('#uws-list-friends h3');
        jQuery("#uws-list-friends h3").each(function () {
            jQuery(this).css({ "cursor": "pointer" });
            //jQuery(this).bind("click",function(){location.href = 'friends-detail.htm';return false;});
        });
        return true;
    }
}

//Load Groups Section
function LoadGroups(view) {
    view = typeof (view) != 'undefined' ? view : 0;  //0 = All Groups, 1 = My Groups 
    var detail = '';
    if (jQuery("#uws-list-groups").length > 0) {
        for (var i = 1; i < 5; i++) {
            if (view == 1 && i == 3) { break; }
            detail += '<article>';
            detail += '<div class="uws-groups-photo"><img src="images/sample-groups.jpg" alt="" /></div>';
            detail += '<div class="uws-groups-comments">';
            detail += '<h3>Year 10 Science Students</h3>';
            detail += '<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non adipiscing eros. Pellentesque vitae';
            detail += 'nulla vel ipsum tincidunt ultrices in id nulla...</p>';
            detail += '</div>';
            detail += '<div class="uws-groups-summary">';
            detail += '<p><label>Members</label>165</p>';
            detail += '<p><label>Age Group</label>15-16 years</p>';
            detail += '<p><label>Category</label>High School</p>';
            detail += '</div>';
            detail += '</article>';
            detail += '<article>';
            detail += '<div class="uws-groups-photo"><img src="images/sample-groups.jpg" alt="" /></div>';
            detail += '<div class="uws-groups-comments">';
            detail += '<h3>Year 11 Science Students</h3>';
            detail += '<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non adipiscing eros. Pellentesque vitae';
            detail += 'nulla vel ipsum tincidunt ultrices in id nulla...</p>';
            detail += '</div>';
            detail += '<div class="uws-groups-summary">';
            detail += '<p><label>Members</label>165</p>';
            detail += '<p><label>Age Group</label>15-16 years</p>';
            detail += '<p><label>Category</label>High School</p>';
            detail += '</div>';
            detail += '</article>';
        }

        jQuery("#uws-list-groups").html(detail);
        jQuery("#btn-all-groups, #btn-my-groups").click(function () {
            LoadGroups(this.rel);
            jQuery(".uws-groups-tabs").children("li").removeClass("active");
            jQuery(this).parent("li").addClass("active");
            return false;
        });
        Cufon.replace('#uws-list-groups h3');
        jQuery("#uws-list-groups h3").each(function () {
            jQuery(this).css({ "cursor": "pointer" });
            //jQuery(this).bind("click",function(){location.href = 'groups-detail.htm';return false;});
        });
        return true;
    }
}

//Load Discussions Section
function LoadDiscussions(view) {
    view = typeof (view) != 'undefined' ? view : 0;  //0 = All Discussions, 1 = My Discussions, 2 = My Comments 
    var detail = '';
    var item = '';
    if (jQuery("#uws-list-discussions").length > 0) {
        for (var i = 1; i < 10; i++) {
            if ((view == 1 || view == 2) && i == 5) { break; }
            item = (view == 2) ? 'My Comment' : 'Discussion Title';
            item += ' ' + i;
            detail += '<article>';
            detail += '<div class="uws-discussions-comments"><h3>' + item + '</h3>';
            detail += '<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non adipiscing eros. Pellentesque vitae';
            detail += 'nulla vel ipsum tincidunt ultrices in id nulla...</p>';
            detail += '</div>';
            detail += '<div class="uws-discussions-summary">';
            detail += '<p><label>Members</label>165</p>';
            detail += '<p><label>Age Group</label>15-16 years</p>';
            detail += '<p><label>Category</label>High School</p>';
            detail += '</div>';
            detail += '</article>';
        }

        jQuery("#uws-list-discussions").html(detail);
        jQuery("#btn-all-discussions, #btn-my-discussions, #btn-my-comments").click(function () {
            LoadDiscussions(this.rel);
            jQuery(".uws-discussions-tabs").children("li").removeClass("active");
            jQuery(this).parent("li").addClass("active");
            return false;
        });
        Cufon.replace('.uws-list-discussions h3');
        jQuery("#uws-list-discussions h3").each(function () {
            jQuery(this).css({ "cursor": "pointer" });
            //jQuery(this).bind("click",function(){location.href = 'discussions-detail.htm';return false;});
        });

        return true;
    }
}

