pbbgM        = new Image(118,4); 
pbbgM.src    = "http://img.clipta.com/search/btn_pmbg.gif"; 
pbbgCTLI     = new Image(240,7); 
pbbgCTLI.src = "http://img.clipta.com/search/btn_pctlibg.gif"; 
pbbgCTRI     = new Image(240,7); 
pbbgCTRI.src = "http://img.clipta.com/search/btn_pctribg.gif"; 
pbbgCB       = new Image(240,7); 
pbbgCB.src   = "http://img.clipta.com/search/btn_pcbbg.gif"; 
icoLoad      = new Image(16,16); 
icoLoad.src  = "http://img.clipta.com/search/ico_bfwbload.gif"; 

function switchLangSel () {
	$("div.lang-sel").slideToggle("fast");
}
function view_more () {

	$("div.more").slideToggle("fast");

}
function view_more2 () {

	$("div.more2").slideToggle("fast");

}

function closePromoDetails ( sBn ) {
	$("#cont_" + sBn).slideUp("normal", function() {
		$("#btnb_" + sBn).removeClass("pbbg-m");
	});
}

function switchPromoDetails ( sBn ) {
	switch ( sBn ) {
		case 'vc':
			closePromoDetails("ca");
		break
		case 'ca':
			closePromoDetails("vc");
		break
	}
	if ( !$("#btnb_" + sBn).hasClass("pbbg-m") ) {
		$("#btnb_" + sBn).toggleClass("pbbg-m");
	}
	$("#cont_" + sBn).slideToggle("normal", function() {
		if ( $("#cont_" + sBn).css("display") == "none" ) {
			$("#btnb_" + sBn).removeClass("pbbg-m");
		}
	});
}

function submitForm ( sFrm ) {
	$("#" + sFrm).submit();
}

function submitSearchQuery () {
	
	url="/search/"+encodeURIComponent($('#q').val());
	url=url.replace("%2F","%252F");
	document.location=url;
	return false;
}

function switchNewsPanel ( sExpandedText, sCollapsedText ) {
	if ( $("#news_panel").css("display") == "none" ) {
		$("#news_res0").css({'border-bottom' : '1px solid #e7e7e8', 'padding-bottom' : '10px', 'margin-bottom' : '10px'});
		$("#news_panel_label").html(sCollapsedText);
	}
	else {
		$("#news_res0").css({'border-bottom' : '0px', 'padding-bottom' : '0px', 'margin-bottom' : '0px'});
		$("#news_panel_label").html(sExpandedText);
	}
	$("#news_panel").toggle();
}

function rateVideo ( iVideoId, sLoaderText ) {

	$("#opt_panel").html('<img src="http://img.clipta.com/search/ico_bfwbload.gif" />&nbsp;&nbsp;&nbsp;' + sLoaderText + '...');
	$("#opt_panel").show();
	
	$("#opt_panel").load("jax/rate_video_new.jax.php", { vid : iVideoId });
}

function rateVideoNews ( iVideoId, sLoaderText ) {

	$("#opt_panel").html('<img src="http://img.clipta.com/search/ico_bfwbload.gif" />&nbsp;&nbsp;&nbsp;' + sLoaderText + '...');
	$("#opt_panel").show();
	
	$("#opt_panel").load("jax/rate_video.jax.php", { vid : iVideoId, type : 'news' });
}

function addFavoriteVideo ( iVideoId, iUserId, sLoaderText ) {

	$("#opt_panel").html('<img src="http://img.clipta.com/search/ico_bfwbload.gif" />&nbsp;&nbsp;&nbsp;' + sLoaderText + '...');
	$("#opt_panel").show();
	
	$("#opt_panel").load("jax/add_favorite_video_new.jax.php", { vid : iVideoId, uid : iUserId });
}

function saveSocialNetworkRate ( iVideoId ) {
	$.ajax({
	   type: "POST",
	   url: "jax/save_social_network_rate.php",
	   data: "video_id="+iVideoId,
	   success: function(msg){
	   }
	});
}

function showPublicDescriptionForm ( iVideoId ) {
	$("#opt_panel").load("jax/process_public_description.jax.php", { action : 'show', vid: iVideoId }, function () {
		$("#opt_panel").slideDown();
	});
}

function submitPublicDescription ( sDescription, iVideoId, sLoaderText ) {
	$("#pub_desc_loader").html('<img src="http://img.clipta.com/search/ico_bfwbload.gif" />&nbsp;&nbsp;&nbsp;' + sLoaderText + '...');
	$("#opt_panel").load("jax/process_public_description_new.jax.php", { action : 'submit', vid: iVideoId, description : sDescription });
}

function showVideoFlagOptions ( iVideoId ) {
	$("#opt_panel").show();
	$("#opt_panel").load("jax/process_flag_video_new.jax.php", { action : 'show', vid: iVideoId });
}

function submitVideoFlag ( iVideoId, iFlagType, sLoaderText ) {
	$("#opt_panel").html('<img src="http://img.clipta.com/search/ico_bfwbload.gif" />&nbsp;&nbsp;&nbsp;' + sLoaderText + '...');
	$("#opt_panel").load("jax/process_flag_video_new.jax.php", { action : 'submit', vid: iVideoId, type : iFlagType });
}

function hideOptionsPanel () {
	$("#opt_panel").slideUp();
}

function showPostCommentForm () {
	$("#post_comment_form").slideDown();
}

function hidePostCommentForm () {
	$("#post_comment_form").slideUp();
}

function postComment ( sMessage ) {
	iVideoId = $('#comment_vid').val();
	sCommentText = $('#comment_text').val();
	if ( typeof(sCommentText) != 'undefined' && sCommentText != '' && sCommentText != ' ' ) {
		$("#comment_list").load("jax/post_comment_new.jax.php", { vid: iVideoId, text : sCommentText });
	}
	else {
		$('#post_comment_message').html(sMessage);
	}
	return false;
}
