function GenerateBookmarkIcons()
{
	var title = document.title;
	var href = window.location.href;
	href = href.split("?")[0];	
	GetBookMarkHtml(title,href);
}

function GetBookMarkHtml(title,href)
{
    var string = "<a class='BookmarkIcon' href='http://www.myspace.com/Modules/PostTo/Pages/?u="+href+"&c=Experience Infotainment&t="+title+"' target='_blank' ><img src='http://e-infotainment.com/files/images/Myspace.png' width='25px' height='25px'/></a>"+
	            "<a class='BookmarkIcon' href='http://twitter.com/home?status="+title+" - "+href+"' target='_blank' ><img src='http://e-infotainment.com/files/images/Twitter.png' width='25px' height='25px' /></a>" +
	            "<a class='BookmarkIcon' href='http://delicious.com/post?url="+href+"' target='_blank' ><img src='http://e-infotainment.com/files/images/Delicious.png'  width='25px' height='25px' /></a>" +
	            "<a class='BookmarkIcon' href='http://www.stumbleupon.com/submit?url="+href+"' target='_blank' ><img src='http://e-infotainment.com/files/images/StumbleUpon.png' width='25px' height='25px' /></a>" +
	            "<a class='BookmarkIcon' href='http://www.facebook.com/share.php?u="+href+"' target='_blank' ><img src='http://e-infotainment.com/files/images/Facebook.png' width='25px' height='25px' /></a>" +
	            "<a class='BookmarkIcon' href='http://buzz.yahoo.com/buzz?guid="+href+"' target='_blank' ><img src='http://e-infotainment.com/files/images/YahooBuzz.png' width='25px' height='25px' /></a>";	          
	            
    document.write("<div id='Bookmarks' style='text-align:center'><div style='margin:0px auto;'>"+string+"</div></div>"); 	           
}

$(document).ready(function () {

    $('#MenuWrapper').accordion({
        defaultState: "collapsed",
        mode: "multi",
        duration: 350
    });

    $(".EINavigation").treeview({
        defaultState: "collapsed"

    });

    $(".EITabs").tabs({
        orientation: "VerticalRight",
        tabstrip: ">div:eq(1)",
        multiview: ">div:eq(0)"
    });

    if ($(".CommentBox").length > 0) {
        //Get the data from all the fields
        var name = $('input[name=CB_Name]').restrictText({ filter: /^[A-Za-z\ .]+$/ }),
        email = $('input[name=CB_Email]').restrictText({ filter: /^[A-Za-z\ .-_@]+$/ }),
        website = $('input[name=CB_Website]').restrictText({ filter: /^[\w\d:#@%\/;$()~_?\+-=\\\.&]+$/ }),
        comment = $('textarea[name=CB_Comment]').restrictText({ filter: /^[A-Za-z\s.-]+$/ }),
        curPageId = pageId || 0;

        //if submit button is clicked
        $('.CB_Submit').click(function () {
            var nameVal = $.trim(name.val()),
            emailVal = $.trim(email.val()),
            websiteVal = $.trim(website.val()),
            commentVal = $.trim(comment.val());

            //Simple validation to make sure user entered something
            //If error found, add hightlight class to the text field
            if (nameVal == '') {
                name.addClass('CB_Highlight');
                return false;
            } else name.removeClass('CB_Highlight');

            if (emailVal == '') {
                email.addClass('CB_Highlight');
                return false;
            } else email.removeClass('CB_Highlight');

            if (commentVal == '') {
                comment.addClass('CB_Highlight');
                return false;
            } else comment.removeClass('CB_Highlight');

            //organize the data properly
            var data = 'PageId=' + curPageId + '&CB_Name=' + nameVal + '&CB_Email=' + emailVal + '&CB_Website='
        + websiteVal + '&CB_Comment=' + encodeURIComponent(commentVal);

            $('.CommentBox form').hide();

            //show the loading sign
            $('.CB_Loading').show();

            //start the ajax
            $.ajax({
                url: "http://e-infotainment.com/addcomment.php",

                type: "POST",

                data: data,

                cache: false,

                success: function (html) {
                    $('.CB_Loading').hide();
                    if (html == 1)
                        $('.CB_SuccessMsg').show();
                    else if (html == 2) {
                        alert(html);
                        $('.CB_RequiredMissing').show();
                    }
                    else {
                        alert(html);
                        $('.CB_FailureMsg').show();
                    }

                }
            });

            //cancel the submit button default behaviours
            return false;
        });
    }
}); 
