// isCommTab

jqN(function() {
// Default State of the Comments

// commentHash = window.location.toString().split('#')[1];
// if (commentHash == "comment") {
// 		setCommentPost();	
// } else{
// 		setCommentView();
// };
		setCommentView();
// The changing state of the comments.
	jqN('.user_comm, .post_comm').css('cursor', 'pointer');
	jqN('.user_comm').click(function() {
		setCommentView();
	});
	jqN('.post_comm').click(function() {
		setCommentPost();		
	});
	
	jqN('.shareThisPost').click(function() {
		if (jqN(this).parent().next('.jf_sharebx').css("display") == "none") {
				jqN(this).parent().next('.jf_sharebx').slideDown('fast');
		} else{
			jqN(this).parent().next('.jf_sharebx').slideToggle('fast');
		}
		jqN(this).toggleClass("makeOpc")
		return false;
	})
	jqN('.linkValueTXT input').click(function() {
		this.select()
	})
	
	/*var ea = [];
	
	jqN('.showFlash embed').each(function(i,value){
		ea.push(jqN(this).attr('id'));
	})
	
	jqN('#jf_navbar ul').hover(function(){
		//hidemeplease(ea);														
		//jqN('.showFlash').hide();
	},
	function(){
		//showmenow(ea);
		//jqN('.showFlash').show();
	});*/
});


/*function hidemeplease(what){
	if(what){
		var hd = what.split(",");
		for(var i=0;i<hd.length;i++){
			embeddedPlayerManager.getPlayer(hd[i]).hidePlayer();
		}
	}
}
function showmenow(what){
	if(what){
		var hd = what.split(",");
		for(var i=0;i<hd.length;i++){
			embeddedPlayerManager.getPlayer(hd[i]).unHidePlayer();
		}
	}	
}*/

function embedVideo(video,wap){
	document.write("<div class=\"flashWrap\"><div id=\"vid_"+video+"\" class=\"showFlash\"></div></div>");
	if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)))
	{
		if(wap!=null ){
			jqN("#vid_"+video).load("/assets/mobile/includes/video/jim/"+wap+".html");
		}
	}
	else
	{
		nbcu.util.common.loadClass("Nbcu.Sn.ViewCount");
		var so = new SWFObject("/swf/nbcclips_2.swf","Flash Promote","511","290","9","#000000"); 
		so.addParam("allowfullscreen", "true");
		so.addVariable("clipId", video);
		so.addVariable("showId", showId);
		so.addVariable("vidTitle", "<$mt:EntryTitle$>");
		so.addVariable("vidDesc", "");
		so.addVariable("vidUrl", "<$mt:EntryPermalink$>");
		so.addVariable("incrementCount", "nbcu.sn.viewCount.setViewCount('void(0)', null, null, 'VIDEO-"+video+"', 'SS_VIDEO')");
		so.write("vid_"+video+"");
	}
}

function send2FriendWebEx(obj)
{
    var arr_parts   = obj.id.split('_');
    var elem_num    = arr_parts[1];
    var prefix      = arr_parts[0];
    if (prefix.indexOf('MostPopular') != -1) {
        var appendThis = 'MostPopular';
    } else {
        var appendThis = '';
    }
    var email       = encodeURI(document.getElementById('email'+appendThis+'_'+elem_num).value); // get the senders email
    var friendemail = encodeURI(document.getElementById('friendemail'+appendThis+'_'+elem_num).value); // get the friends email
    var subject     = encodeURI(document.getElementById('subject'+appendThis+'_'+elem_num).value); // get the subject
    var message     = "Your friend knew you'd be dying to check out this latest info from NBC.com...\n";
    message         += document.getElementById('message'+appendThis+'_'+elem_num).value; // get the message
    var message     = escape(message); // get the message
    var url         = escape(document.getElementById('url'+appendThis+'_'+elem_num).value); // get the url
    var mediaName   = encodeURI(document.getElementById('mediaName'+appendThis+'_'+elem_num).value); // get the media name
    var mediaDesc   = encodeURI(document.getElementById('mediaDesc'+appendThis+'_'+elem_num).value); // get the media desc 
    var bool_email       = validateEmailLocal(email);
    var bool_friendemail = validateEmailLocal(friendemail);
    if (!bool_email) {
        // alert('Please enter a valid e-mail address for yourself.');
jqN('.socialNetworkLinks').after('<p class="email_alert">Please enter a valid e-mail address for yourself.</p>')
        document.getElementById('email'+appendThis+'_'+elem_num).focus();
setTimeout('jqN(".email_alert").fadeOut("slow",function() {jqN(this).remove()})', 3000);
        return false;
    }
    if (!bool_friendemail) {
        // alert("Please enter a valid friend's e-mail address.");
		jqN('.socialNetworkLinks').after("<p class=\"email_alert\">Please enter a valid friend's e-mail address.</p>")
		setTimeout('jqN(".email_alert").fadeOut("slow",function() {jqN(this).remove()})', 3000);

        document.getElementById('friendemail'+appendThis+'_'+elem_num).focus();
        return false;
    }

    // the 'mediaName' and 'mediaDesc' form the HTML form have the same values already
    // assigned to the 'message' variable, so go ahead and set 'mediaDesc' and 'mediaName'
    // to empty string as a workaround:
    mediaName = '';
    mediaDesc = '';
    jqN.get("/app/form_mail/send2friend.scet.php?email="+email+"&friendemail="+friendemail+"&subject="+subject+"&message="+message+"&url="+url+"&mediaName="+mediaName+"&mediaDesc="+mediaDesc, function(data) {
            confirmItLocal(elem_num,appendThis);
                  });
}

function confirmItLocal(iteration,appendThis)
{
    //
    document.getElementById('friendemail'+appendThis+'_'+iteration).value = '';
    jqN('.scet_send_confirmation'+appendThis+'_'+iteration).html("<h5>Your email was sent. Enter another email address to send again.</h5>");
setTimeout("jqN('.shareBox h6').remove().fadeOut('slow');", 3000);
}

function validateEmailLocal(value)
{
    var good = /^([\w\d\.\-_]+)@([\w\d\.\-]+)$/i;
    var evil =  /[^a-z0-9\@_\-\.]+/i;
        
    if (good.test(value) && !evil.test(value)) {
        return true;
    } else {
        return false;
    }
}

// jqN('#A-searchform input').hint();

function setCommentView (){
	jqN('.sn_comment_form_div').hide();
	jqN('.sn_comment_div').show();
	jqN('.post_comm').removeClass('isCommTab');
	jqN('.user_comm').addClass('isCommTab');
	jqN('.sn_comment_pager_div').show();
}
function setCommentPost (){
	jqN('.sn_comment_div').hide();
	jqN('.sn_comment_form_div').show();
	jqN('.user_comm').removeClass('isCommTab');
	jqN('.post_comm').addClass('isCommTab');
	jqN('.sn_comment_pager_div').hide();
}
