//Last edited by tommy.wu@nbcuni.com 12/27
// Intial Behaviors

jqN(function() {
	if(jqN('body.search-results')!=0){
		disableSort();
			jqN('.search-results #search-button').hide();
			jqN('.search-results #search-button').after('<img src="/assets/images/scet/video4/x-close.gif" alt="clear" id="close-x" />');
			jqN('#close-x').click(function() {
				jqN('.search-results #search-field').attr('value','');
			});
	}	
})

function disableSort(){
	jqN('.search-results #scet-view-by a').removeClass('active');
	jqN('.search-results #scet-view-by').append('<div id="disableBTN" style="height:24px; position:absolute; width:290px; background:#fff;"></div>');
	jqN('#disableBTN').css('opacity','.4');	
}

function _initBrowse(){ 
try {
sortObjTotal = sortObj.length;
debug("DEBUG sortObjTotal "+sortObjTotal);
//sortBuildPaginator();
} catch(err) {}
}

/* Legacy permalinks */
hashString = document.location.hash.substring(1);
meaStart = hashString.indexOf("mea=");
vidStart = hashString.indexOf("vid=");
if (hashString.indexOf("vid=") >= 0) window.location = "/app/video/redirect_by_video_id.php?videoId=" + hashString.substring(vidStart+4);
if (hashString.indexOf("mea=") >= 0) window.location = "/app/video/redirect_by_video_id.php?videoId=" + hashString.substring(meaStart+4);


/* dichirico (6/7/2011) -- commenting this out because we have new Collarity code to be placed directly in template
jqN(document).ready(function() {
	// Contextual Ads
	nbcu.util.common.getScript('/assets/nbcu/classes/CollarityContent.js', function (data, status) {
		if (status == 'success') {
			collarity_kw = "";
			try {
				jqN.getScript(collarity_ads.requestURI(siteName, "video"));
			} catch(err) {}
		}
	});
});
*/

function changeViewMode(mode) {
	 if (typeof mode !== undefined) {
	    eraseCookie('__vscetBmode');
	    createCookie('__vscetBmode',mode);
	 }
	 window.location.reload();
}

function changeViewMode(mode) {
    var destination = location.href.replace(/[?&]view\=([a-zA-Z]+)/g, '');
	if (destination.indexOf('?') > 0) {
	   var seperator = '&';
	} else {
	   var seperator = '?';
	}	    
	destination = location.href.replace(/[?&]view\=([a-zA-Z]+)/g, '') + seperator + 'view='+mode;
	
	window.location = destination;
}

