<!-- Hide script from old browsers

/**
 * Selects all input content
 */
function selectText(textbox)
{
	jQuery("#"+textbox).select();
}

/**
 * Sets video player volume in COOKIE
 */
function setPlayerVolume(volume)
{
	createCookie("playerVolume",volume,1);
}

/**
 * Displays send message panel.
 */
function showSendMessagePanel(userId, errorMsg)
{
	if (userId != '')
		jQuery('#send-message-panel').show('fast');
	else
		showUserRegisteredError(errorMsg, 'message');	
}

/**
 * Selects video search option for search input box.
 */
function searchOptionVideosCheck()
{
	jQuery('#search-videos').attr('className', 'search-option-videos-sel');
	jQuery('#search-users').attr('className', 'search-option-users');
	jQuery('#search-option-field').val('1');
}

/**
 * Selects users search option for search input box.
 */
function searchOptionUsersCheck()
{
	jQuery('#search-videos').attr('className', 'search-option-videos');
	jQuery('#search-users').attr('className', 'search-option-users-sel');
	jQuery('#search-option-field').val('2');
}
 

/**
 * JavaScript validation for terms checkbox in user registration page.
 */
function termsClientValidate(sender, parameter)
{
	if (!parameter)
		return false;
	else
		return true;
}

/**
 * JavaScript validation for gender radio buttons.
 */
function genderClientValidate(sender, parameter)
{
	male = document.getElementById('ctl0_Content_Male');
	female = document.getElementById('ctl0_Content_Female');
	error = document.getElementById('ctl0_Content_ErrorGender');

	if (!male.checked && !female.checked)
	{
		error.style.display = '';
		return false;
	}
	else 
	{
		error.style.display = 'none';
		return true;
	}
}

/**
 * JavaScript validation for birthdate list boxes.
 */
function birthdateClientValidate(sender, parameter)
{
	birthday = document.getElementById('ctl0_Content_BirthDay');
	birthmonth = document.getElementById('ctl0_Content_BirthMonth');
	birthyear = document.getElementById('ctl0_Content_BirthYear');
	error = document.getElementById('ctl0_Content_ErrorBirthDate');
	
	if (birthday.value == '-' || birthmonth.value == '-' || birthyear.value == '-')
	{
		error.style.display = '';
		return false;
	}
	else
	{ 
		error.style.display = 'none';
		return true;
	}
}

/**
 * JavaScript validation for category drop down list.
 */
function categoryClientValidate(sender, parameter)
{
	if (parameter == '-')
		return false;
	else
		return true;
}


/**
 * Called when Thumbnails view button is clicked.
 * Thumbnails button is selected. Normal view button becomes normal
 */
function btnView1Click()
{
	document.getElementById('btn-v1').className = 'btn-view1-sel';
	document.getElementById('btn-v2').className = 'btn-view2';
}

/**
 * Called when Thumbnails view button is clicked.
 * Thumbnails button becomes norlam. Normal view button becomes selected
 */
function btnView2Click()
{
	document.getElementById('btn-v2').className = 'btn-view2-sel';
	document.getElementById('btn-v1').className = 'btn-view1';
}

current_clip_info_id = 'clips-editor-info';

/**
 * Displays selected video highlight list
 */
loadingClipList = false;
function show_current_clip_info(clip_info_id)
{
	if (!loadingClipList)
	{
		if (clip_info_id != current_clip_info_id)
		{
			//showPane(clip_info_id);
			//hidePane(current_clip_info_id);
			jQuery('#'+clip_info_id).show();
			jQuery('#'+current_clip_info_id).hide();
			current_clip_info_id = clip_info_id;
		}
	
		switch (clip_info_id)
		{
			case 'clips-editor-info': type = 1; break;
			case 'clips-recent-info': type = 2; break;
			case 'clips-popular-info': type = 3; break;
			case 'clips-rated-info': type = 4; break;						
		}
		
		loadingClipList = true;
		jQuery('#header-clips-holder').load('http://www.maxtv.bg/modules/ajax_videos_highlight_list.php', {type: type}, function() {
			loadingClipList = false;
		});
	}
}

/**
 * Displays selected video highlight
 */
loadingClip = false;
function select_clip(clip_holder_id, id, type)
{
	if (!loadingClip)
	{
		clip_holder = document.getElementById(clip_holder_id);
	
		switch (current_clip_info_id)
		{
			case 'clips-editor-info' :
				clip_holder.className = 'clip-item-sel-editor';
				break;
			case 'clips-recent-info' :
				clip_holder.className = 'clip-item-sel-recent';
				break;
			case 'clips-popular-info' :
				clip_holder.className = 'clip-item-sel-popular';
				break;
			case 'clips-rated-info' :
				clip_holder.className = 'clip-item-sel-rated';
				break;			
		}
	
		for (i=1; i<=4; i++)
		{
			obj = document.getElementById("clip-item-holder"+i);
			if (obj != clip_holder)
			{
				obj.className = 'clip-item-holder';
			}
		}
		
		loadingClip = true;
		jQuery.ajax({
			type:'POST', 
			url:'http://www.maxtv.bg/modules/ajax_videos_highlight.php', 
			data:'id='+id+'&type='+type, 
			success:function(data) {
				loadingClip = false;
				jQuery('#header-main-clip').html(data);				
			}
		});
	}
}

/**
 * Shows panel specified by id
 */
function showPane(id)
{
	var obj;
	if(obj = document.getElementById(id)) obj.style.display='';
}

/**
 * Hides panel specified by id
 */
function hidePane(id)
{
	var obj;
	if(obj = document.getElementById(id)) obj.style.display='none';
}

/**
 * Toggle between different view modes.
 * if mode = 2 switches to thumbnails view mode.
 * if mode = 1 switches to norlma view mode.
 */
function changeClipView(mode){
	var el1 = document.getElementById("btn-v2");
	var el2 = document.getElementById("btn-v1");
	
	//Normal view mode
	if(mode==1){
		//We show normal-view div and hide thumbnail-view div
		showPane('normal-view'); 
		hidePane('thumbnail-view');
		el1.className = "btn-view1-sel";
		el2.className = "btn-view2";
		defaultClipView = 1;
		
		//We save the view mode
		createCookie('videosDefaultView', 1, 1)
	} 
	else if(mode == 2) {
		//Now we hide normal-view div and show thumbnail-view div
		hidePane('normal-view'); 
		showPane('thumbnail-view');
		
		el1.className = "btn-view1";
		el2.className = "btn-view2-sel";	
		defaultClipView = 2;
		
		//We save the view mode
		createCookie('videosDefaultView', 2, 1)
	}
}

/**
 * If videosDefaultView cookie is set, we read it and switch to the a 
 * viewing mode depending on cookie value. Alternatively we set the cookie with view mode 1 - normal view
 */
function toggleClipView(){
	var mode = readCookie('videosDefaultView');
	if(mode == null) createCookie('videosDefaultView', 1, 1);
	else changeClipView(mode);
}

/**
 * function that creates cookie 
 * first parameter sets cookie name
 * second sets cookie value
 * last parameter sets cookie expiration time
 */
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}


/**
 * Reads cookie value for cookie name specified by name
 */
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

/**
 * erase cookie
 */
function eraseCookie(name) {
	createCookie(name,"",-1);
}

/**
 * Hides/shows response videos divs depending on rcont value.
 * Decrements rcont.
 */
var rcont = 1;
function scrollLeftResponse(){
	if(document.getElementById('response-container-'+(rcont-1)) && rcont>1){
		rcont--; 
		hidePane('response-container-'+(rcont+1)); 
		showPane('response-container-'+rcont);
	}
}

/**
 * Hides/shows response videos divs depending on rcont value.
 * Increments rcont.
 */
function scrollRightResponse(){
	if(document.getElementById('response-container-'+(rcont+1)) && rcont<3){
		rcont++;
		hidePane('response-container-'+(rcont-1)); 
		showPane('response-container-'+rcont);
	}
}

/**
 * Ajax script. Loads subvideos into related-videos div
 */
var currentView = "normal";
var lastId;
var subVideosType;
function loadSubVideos(id, type, view, author_id, label){
	jQuery('#related-title').html(label);
	if(currentView != view || subVideosType != type){
		lastId = id;
		subVideosType = type;		
		jQuery('#related-videos').load('http://www.maxtv.bg/modules/ajax_get_subvideos.php', {vid: id, type: type, view: view, author_id: author_id});		
	}	
}

/**
 * Called when thumbnails or normal view button is clicked in related videos panel 
 * in Video preview page. 
 */
function changeSubVideos(view, author_id){
	if(currentView != view){
		loadSubVideos(lastId, subVideosType, view, author_id);
		currentView = view;
	}
}

/**
 * Ajax script. Loads video comments into comments panel in Video preview page
 */
var currentCommentsPage;
function loadComments(id, page, type){
	jQuery('#comments-holder').load('http://www.maxtv.bg/modules/ajax_get_comments.php', {id: id, page: page, type:type});
	currentCommentsPage = page;
}

/**
 * Shows add comment panel in Video Preview page
 */
function showAddCommentPanel(){
	jQuery('#add-comment-panel').show('slow');
	jQuery('#comment-result').hide('fast');
}

/**
 * Called when add comment button is clicked in Video preview page.
 * First parameter specifies video id.
 * Second specifies the current language.
 * Third parameter specifies the user id.
 * if parent_id = 0 then the comment is nota a response to another comment
 * Alternatively the comment is a response to a comment with id = parent_id 
 */
function addComment(id, parent_id, pid, type){
	if(parent_id == 0){
		var title = jQuery("#comment-title").val();
		var text = jQuery("#comment-text").val();	
	} else {
		var title = jQuery('#comment-title-reply-'+pid).val();
		var text = jQuery('#comment-text-reply-'+pid).val();
	}

	if(title.length == 0) alert('Enter comment title!');
	else if(title.length > 50) alert('Title length must shorter than 50 characters!');
	else if(text.length == 0) alert('Enter comment!');
	else if(text.length > 500) alert('Comment length must shorter than 500 characters!');
	else {
		if(parent_id == 0){
			jQuery("#comment-text").val('');
			jQuery("#comment-title").val('');
		} else {
			jQuery('#comment-title-reply-'+pid).val('');
			jQuery('#comment-text-reply-'+pid).val('');
		}
		jQuery('#comment-result').load('http://www.maxtv.bg/modules/ajax_add_comment.php', {id: id, title: title, text: text, parent_id: parent_id, type: type});
		jQuery("#comment-text").val('');
		jQuery("#comment-title").attr('disabled');
		jQuery("#remaining-symbols").text("500");
	}
}

//Function sets languale constants for reply-form in Video preview page
var labelTitle;
var labelComment;
var labelReply;
var labelCancel;
var labelRemainigChars;
function setReplyFormText(ttitle, tcomment, treply, tcancel, tremain){
	labelTitle = ttitle;
	labelComment = tcomment;
	labelReply = treply;
	labelCancel = tcancel;
	labelRemainigChars = tremain;
}
/**
 * Called when reply link on a comment is clicked 
 */
function replyComment(id, pid, vid, title, type){
	jQuery('#comment-reply-'+id).html(getReplyFormHtml(id, vid, title, pid, type));
	jQuery('#comment-reply-'+id).show();
}

/**
 * Displays reply form
 */
function getReplyFormHtml(id, vid, title, pid, type){
	if(type=="videos") width = 460;
	else width = 290;
	var rForm = '<div id="reply-comment-panel">'	+	
				'<div class="bold">'+ labelTitle +':</div><div class="spacer">' +
				'<input type="text" id="comment-title-reply-'+ id +'" Style="width: '+ width +'px;" class="text-box" value="'+ title +'" />'+
				'</div><div class="bold" style="padding-top: 10px;">'+ labelComment +':</div><div class="spacer">' +
				'<textarea id="comment-text-reply-'+ id +'" rows="5" style="width: '+ width +'px;" class="text-box" onkeyup="textKeyPress(\'comment-text-reply-'+ id +'\', \'remaining-symbols-'+ id +'\')" ></textarea>' +
				'</div><div style="height: 25px; margin: 10px 0px 20px 0px;"><div class="btn-submit-left"></div>' +
				'<a href="javascript: void(0);" class="btn-add-comment" style="width: 50px;"' +
				'onClick="addComment(\''+ vid +'\', '+ pid +', '+ id +', \''+ type +'\');">'+ labelReply +'</a>'+
				'<div class="btn-submit-right"></div><div style="float: left; width: 10px; height: 15px;">&nbsp;</div><div class="btn-submit-left"></div>'+
				'<a href="javascript: void(0);" class="btn-cancel-comment" '+
				'onClick="jQuery(\'#comment-reply-'+ id +'\').hide()">' + labelCancel + '</a>' +	
				'<div class="btn-submit-right"></div>' +
				'<div id="remaining-symbols-'+ id +'" style="float: right; font-weight: bold; padding-top: 4px;">500</div>' +
				'<div class="remaining-symbols-text">' + labelRemainigChars + ':</div>' +
				'</div></div>';
	return rForm;	
}

/**
 * Called on onkeyup event in 'add' or 'reply comment' form in Video Preview page
 */
function textKeyPress(fld, tpanel){
	var text = jQuery("#"+fld).val();

	var remainingSymbols=(500-text.length);
	jQuery("#"+tpanel).text(remainingSymbols);
}

/*
 * RATING FUNCTIONS
 */
 
var starGraySrc = 'themes/Main/star-gray.gif';
var starRedSrc = 'themes/Main/star-red.gif';
var starHalfSrc = 'themes/Main/star-half.gif';
var starYellowSrc = 'themes/Main/star-yellow.gif';
var srcArray = new Array;
/**
 * Shows gif stars according to value
 */
function showRating(value, pointer)
{
	var src;
	var starId = '';
	var valueStr = ''+value+'';
	
	var v1 = Math.floor(value);
	var v2 = valueStr.charAt(2);
	
	for (i=1; i<=5; i++)
	{
		src = starGraySrc;
		if (i <= v1) src = starRedSrc;
		if (i == v1+1 && v2 >= 5) src = starHalfSrc;
		srcArray[i-1] = src;
		starId = document.getElementById('star'+i);
		starId.src = src;
		if (pointer) starId.style.cursor = 'pointer';
	}

}

/**
 * Called on mouse hover over rating star
 */
function ratingOver(id)
{
	var index = id.charAt(4);
	for (i=1; i<=index; i++)
		document.getElementById('star'+i).src = starYellowSrc;
}

/**
 * Called on mouse out over rating star
 */
function ratingOut(id)
{
	var index = id.charAt(4);
	for (i=1; i<=index; i++)
		document.getElementById('star'+i).src = srcArray[i-1];
}

/**
 * Called when users clicks on Favourites button in Video preview page
 * Ajax call to a script that processes information and the result is displayed in action-result div
 */
var addToFavoutites;
function addToFavourites(video_id){
	if(!addToFavoutites){
		jQuery("#action-result").load('http://www.maxtv.bg/modules/ajax_add_favourites.php', {video_id: video_id}, function(){
			resultPanelShow();
		});
		addToFavoutites = true;
	}
}

/**
 * called on onClick event on a rating star
 */
function rate(id, fieldId, userId, lang)
{
	var index = fieldId.charAt(4);
	jQuery("#rating-stars").load('http://www.maxtv.bg/modules/ajax_rate.php', {video_id: id, user: userId, lang: lang, rating: index}, function(){
		jQuery("#panel-voted").load('http://www.maxtv.bg/modules/ajax_showrating.php', {id: id, lang: lang});
	});
}
 
var secs;
var timerID = null;
var timerRunning = false;
var delay = 1000;

/**
 * Shows action-result div for a several seconds
 */
function resultPanelShow()
{
    // Set the length of the timer, in seconds
    secs = 5;
    StopTheClock();
    StartTheTimer();
    jQuery("#action-result").show('fast');
}

/**
 * Stops timer
 */
function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false
}

/**
 * Starts timer
 */
function StartTheTimer()
{
    if (secs==0)
    {
        StopTheClock()
        // Here's where you put something useful that's
        // supposed to happen after the allotted time.
        // For example, you could display a message:
       	jQuery("#action-result").hide('fast');
    }
    else
    {
        self.status = secs;
        secs = secs - 1;
        timerRunning = true;
        timerID = self.setTimeout("StartTheTimer()", delay);
    }
}

/**
 * Called on user click on send button in send message panel in Video preview page
 * Ajax call to a script that processes the data and returns the result in action-result div 
 */
sendButtonDisabled = false;
processingAjax = false;
function sendMessage(video_id, user_id, lang){
	var message_to = jQuery("#message-to").val();
	var message_text = jQuery("#message-text").val();
	
	if(message_to.length == 0) alert('Please enter valid e-mail or MaxTV username.');
	else if(message_text.length == 0) alert('Please enter your message');
	else if(processingAjax == false) {
		processingAjax = true;
		jQuery("#send-button").attr('disabled', 'disabled');	
		jQuery("#action-result").load('http://www.maxtv.bg/modules/ajax_send_message.php', {video_id: video_id, user_id: user_id, lang: lang, to: message_to, text: message_text}, function(){
			processingAjax = false;
			resultPanelShow();
		});
	}
}

/**
 * Called on user click over Inappropriate button in Video preview page
 */
var markedAsInappropriate;
function markAsInappropriate(video_id){
	if(!markedAsInappropriate)
	{
		jQuery("#action-result").load('http://www.maxtv.bg/modules/ajax_add_inappropriate.php', {video_id: video_id}, function(){
			resultPanelShow();
		});	
		markedAsInappropriate = true;
	}
}

/**
 * Called when Add Video repsonse link clicked in Video Preview page
 * or add video clip as a response cliced
 * In the first case displays user videos for selecting a video as a video response.
 * In the second case processes user video selection, 
 * makes ajax script and loads the result in action-result div
 */
var responsePanelLoaded = false;
function addResponse(video_id, show_form){
	if(show_form==1){
		if(!responsePanelLoaded){
			jQuery("#response-panel").load('http://www.maxtv.bg/modules/ajax_add_response.php', {video_id: video_id, show_form: show_form}, function(){
				jQuery("#response-panel").show('fast');
				responsePanelLoaded = true;
			});			
		}	
	} else {
		jQuery("#response-panel").hide();
		var sel = document.getElementById("user-videos");
		if(sel) sel_index = sel.options[sel.selectedIndex].value;	
		jQuery("#action-result").load('http://www.maxtv.bg/modules/ajax_add_response.php', {video_id: video_id, show_form: show_form, sel_index: sel_index}, function(){
			responsePanelLoaded = false;
			window.location.reload();
		});
	}
}

/**
 * Called on user click on subscribe to user in Video preview page or user profile page
 */
var subscribed = false;
function subscribe(user_id, profile_id, lang, panel){
	if(!subscribed && user_id != profile_id){
		jQuery("#"+panel).load('http://www.maxtv.bg/modules/ajax_subscribe.php', {user_id: user_id, profile_id: profile_id, lang: lang});
	}
}

/**
 * Called onClick event on Inappropriate button in Group preview page 
 */
function markAsUnappropriateGroup(group_id, lang)
{	
	jQuery("#markGroup").hide();
	jQuery("#action-result").load('http://www.maxtv.bg/modules/ajax_add_inappropriate_group.php', {group_id: group_id, lang: lang}, function(){
		jQuery("#action-result").show();
	});
}

/*
 * 
 */
targetFavourites = false;
targetSendMessage = false
function showUserRegisteredError(error, target){
	if(target == "message"){
		if(targetSendMessage) return false;
		targetSendMessage = true;
	}
	else if(target == "favourites"){
		if(targetFavourites) return false;
		targetFavourites = true;
	}
	
	jQuery("#action-result").html(error);
	resultPanelShow();
}

requestInProgress = false;
function markCommentAsSpam(id, type, target_id){
	if(!requestInProgress){
		requestInProgress = true;
		jQuery("#comment-result").load('http://www.maxtv.bg/modules/ajax_mark_spam.php', {id: id, type: type, target_id: target_id}, function(){
			loadComments(target_id, currentCommentsPage, type);
			requestInProgress = false;
			
		});	
	}
}

// --------------------------------------------------
// USER PROFILE FUNCTIONS
// --------------------------------------------------

// Shows file upload input
function showUserImageUploadForm()
{
	if (!uploadingImage)
		showPane('user-img-holder');
}

// Hides file upload input
function hideUserImageUploadForm()
{
	hidePane('user-img-holder');
}

// Indicates if file upload is completed
var uploadingImage = false;

// Ajax file upload function
function ajaxFileUpload(userId, userImageDir)
{
	if (jQuery('#fileToUpload').val() != '')
	{
		hideUserImageUploadForm();
		uploadingImage = true;
		
		jQuery("#user-profile-image").html('<img src="themes/Main/loading.gif" border="0" style="margin: 38px 0px 0px 48px;" />');
			
		jQuery.ajaxFileUpload
		(
			{
				url:'http://www.maxtv.bg/modules/ajax_user_image_upload.php?uid='+userId,
				secureuri:false,
				fileElementId:'fileToUpload',
				dataType: 'json',
				success: function (data, status)
				{
					jQuery('#fileToUpload').val('');
					uploadingImage = false;
					
					if(typeof(data.error) != 'undefined')
					{
						if(data.error == '')						
						{
							var date = new Date();
							jQuery("#user-profile-image").html('<img src="'+userImageDir+userId+"3.jpg?"+date.getTime()+'" border="0" />');							
						}
					}
				},
				error: function (data, status, e)
				{
					jQuery('#fileToUpload').val('');
					uploadingImage = false;					
				}
			}
		)	
	}
}

// Shows user quote input
function showUserQuoteUpdateForm()
{
	if (!updatingQuote)
	{
		showPane('edit-quote-form'); 
		hidePane('edit-quote');
	}
}

// Hides user quote input
function hideUserQuoteUpdateForm()
{
	showPane('edit-quote'); 
	hidePane('edit-quote-form');
}

// Indicates if update quote request is completed
var updatingQuote = false;

// Updates user quote
function updateUserQuote(uid, div_id, label_update)
{
	updatingQuote = true;
	jQuery('#quote-text').html(label_update);
	hideUserQuoteUpdateForm();
	quote = jQuery('#'+div_id).val();
	jQuery('#quote-text').load('http://www.maxtv.bg/modules/ajax_update_user_quote.php', {uid: uid, quote:quote}, function() {
		//jQuery('#'+div_id).val(jQuery('#quote-text').html());
		updatingQuote = false;
	});
}

// Shows user info input
function showUserInfoUpdateForm()
{
	if (!updatingInfo)
	{
		showPane('edit-info-form'); 
		hidePane('edit-info');
	}
}

// Hides user info input
function hideUserInfoUpdateForm()
{
	showPane('edit-info'); 
	hidePane('edit-info-form');
}

// Indicates if update info request is completed
var updatingInfo = false;

// Updates user info
function updateUserInfo(uid, div_id, label_update)
{
	updatingInfo = true;
	jQuery('#info-text').html(label_update);
	hideUserInfoUpdateForm();
	info = jQuery('#'+div_id).val();
	jQuery('#info-text').load('http://www.maxtv.bg/modules/ajax_update_user_info.php', {uid: uid, info:info}, function() {
		//jQuery('#'+div_id).val(jQuery('#info-text').html());
		updatingInfo = false;
	});
}

function cbCheck(check)
{
	var parent = document.getElementById("checkAll");
	var radio;
	var i = 1;
		
	parent.checked = check;
	
	arr = document.getElementById("user-content").getElementsByTagName('input');		
	for(i=0; i<arr.length; i++) 
	{		
		arr[i].checked = check;				
	}
}

var AllowCheckOtherOption=true;
function SetParam(sender,index)
{		
	var numSelected = 0;
		
	arr = document.getElementById("allItems").getElementsByTagName('input');		
	for(i=0; i<arr.length; i++) 
		if (arr[i].checked) numSelected=numSelected+1;	
			
	if (sender.selectedIndex==index) 
	{
		AllowCheckOtherOption=false;
		if (numSelected>1)
		{
			arr = document.getElementById("allItems").getElementsByTagName('input');		
			for(i=0; i<arr.length; i++) 
				arr[i].checked = false;
		}
	}
	else
	{
		AllowCheckOtherOption=true;		
	}	
	
				
		arr = document.getElementById("allItems").getElementsByTagName('select');	
			for(i=0; i<arr.length; i++) 			
			arr[i].selectedIndex = sender.selectedIndex;
		
}	

function SetMultyParam(sender, index1, index2)
{	
	if (sender.selectedIndex==index1 ) 
	{
		SetParam(sender,index1);
	}
	if (sender.selectedIndex==index2 ) 
	{
		SetParam(sender,index2);
	}
	
}

function checkBoxControl(ob)
{	
	var numSelected = 0;
		
	if (!AllowCheckOtherOption)
	{
		arr = document.getElementById("allItems").getElementsByTagName('input');	
		for(i=0; i<arr.length; i++) 
			if (arr[i].checked) numSelected=numSelected+1;
			
		if (numSelected>1)	
		{
			for(i=0; i<arr.length; i++)
				arr[i].checked = false;				
			
		current = document.getElementById(ob);		
		current.checked = true; 
		}
	}	
}

var AllowCheckPrivateCategories = false;
function synchronizePrivateCategories(sender, index)
{
	var numSelected = 0;
		
	arr = document.getElementById("allItems").getElementsByTagName('input');		
	for(i=0; i<arr.length; i++) 
		if (arr[i].checked) numSelected=numSelected+1;	
			
	if (sender.selectedIndex==0 || sender.selectedIndex==2) 
	{
		AllowCheckPrivateCategories=false;
		if (numSelected>1)
		{
			arr = document.getElementById("allItems").getElementsByTagName('input');		
			for(i=0; i<arr.length; i++) 
				arr[i].checked = false;
		}
	}
	else AllowCheckPrivateCategories=true;	
				
	arr = document.getElementById(index);
	arr.selectedIndex = sender.selectedIndex;
}

function checkPrivateCategories(ob)
{
	var numSelected = 0;
		
	if (!AllowCheckPrivateCategories)
	{
		arr = document.getElementById("allItems").getElementsByTagName('input');	
		for(i=0; i<arr.length; i++) 
			if (arr[i].checked) numSelected=numSelected+1;
			
		if (numSelected>1)	
		{
			for(i=0; i<arr.length; i++)
				arr[i].checked = false;				
			
		current = document.getElementById(ob);		
		current.checked = true; 
		}
	}	
}

function showConfirmGroup(ob, message1, message2)
{	
	var numSelected=0;
	var message ="";
	
	arr = document.getElementById("allItems").getElementsByTagName('input');		
	for(i=0; i<arr.length; i++) 
		if (arr[i].checked) numSelected=numSelected+1;
	
	if (!numSelected) return false;
	else
	{
		var select = document.getElementById(ob).selectedIndex;
		
		if (select == 0) 
			message = message1; 
		else
			message = message2; 
			
		if(!confirm(message)) 
			return false;
		else 
			return true;
	}
} 

function showConfirmVideoInInapp(ob, message1, message2)
{	
	var numSelected=0;
	var arr;
	var message='';
	arr = document.getElementById("allItems").getElementsByTagName('input');		
	for(i=0; i<arr.length; i++) 
		if (arr[i].checked) numSelected=numSelected+1;
	
	if (!numSelected) return false;
	else
	{
		var select = document.getElementById(ob).selectedIndex;	
		if (select == 0) 
			message = message1; 
		else
			message = message2; 
			
		if(!confirm(message)) 
			return false;
		else 
			return true;
	}
	
} 

function confirmSpamCommentsAction(ob, message1, message2)
{	
	var numSelected=0;
	var arr;
	
	arr = document.getElementById("allItems").getElementsByTagName('input');	
	for(i=0; i<arr.length; i++) {
		if (arr[i].checked) numSelected=numSelected+1;
		
	}
		
	if (!numSelected) return false;
	else
	{
		var select = document.getElementById(ob).selectedIndex;	
		if (select == 0) 
			message = message1; 
		else
			message = message2; 
			
		if(!confirm(message)) 
			return false;
		else 
			return true;
	}
}

function showConfirmGroupDelete(ob, message1, message2)
{
	var select = document.getElementById(ob).selectedIndex;
	
	var numSelected = 0;
		
	arr = document.getElementById("allItems").getElementsByTagName('input');		
	for(i=0; i<arr.length; i++) 
		if (arr[i].checked) numSelected=numSelected+1;
	
	if (!numSelected) return false;
	else
	{	
		if (select == 0)
		{ 
		    arr = document.getElementById("allItems").getElementsByTagName('select');		
			numSelected = arr[0].length;
		    if(numSelected==1)
		     message = message1; 
		    else
		     message = message2; 
			if(!confirm(message)) 
				return false;
			else 
				return true;
		}
		else return true;
	}
}

function showConfirmVideoInUserSettings(ob, message)
{	
	var select = document.getElementById(ob).selectedIndex;
	
	var numSelected = 0;
		
	arr = document.getElementById("allItems").getElementsByTagName('input');		
	for(i=0; i<arr.length; i++) 
		if (arr[i].checked) numSelected=numSelected+1;
	
	if (!numSelected) return false;
	else
	{	
		if (select == 0)
		{	
			if(!confirm(message)) 
				return false;
			else 
				return true;
		}
		else return true;
	}
} 

function showConfirmVideoInResponse(ob, message)
{
	var select = document.getElementById(ob).selectedIndex;
	
	var numSelected = 0;
		
	arr = document.getElementById("allItemsR").getElementsByTagName('input');		
	for(i=0; i<arr.length; i++) 
		if (arr[i].checked) numSelected=numSelected+1;
	
	if (!numSelected) return false;
	else
	{	
		if (select == 0)
		{	
			if(!confirm(message)) 
				return false;
			else 
				return true;
		}
		else return true;
	}
}

function showConfirmCategoriesDelete(ob, message)
{
	var select = document.getElementById(ob).selectedIndex;
	
	var numSelected = 0;
	
	arr = document.getElementById("allItems").getElementsByTagName('input');		
	for(i=0; i<arr.length; i++) 
		if (arr[i].checked) numSelected=numSelected+1;
	
	if (!numSelected) return false;
	else
	{	
		if (select == 1)
		{	
			if(!confirm(message)) 
				return false;
			else 
				return true;
		}
		else return true;
	}	
}

function showIfHasChecked()
{	
	var arr = document.getElementById("allItems").getElementsByTagName('input');
	var	numSelected=0;
		
	for(i=0; i<arr.length; i++) 
		if (arr[i].checked) numSelected=numSelected+1;
	
	if (numSelected) return true;
	else return false; 
}
function confirmVideosInGroupPreview(ob, message)
{
	var numSelected = 0;
	var select = document.getElementById(ob).selectedIndex;
		
	arr = document.getElementById("allItems").getElementsByTagName('input');		
	for(i=0; i<arr.length; i++) 
		if (arr[i].checked) numSelected=numSelected+1;	
		
	if (!numSelected) return false;
	else
	{	
		if (select == 1)
		{ 			    
			if(!confirm(message)) 
				return false;
			else 
				return true;
		}
		else return true;
	}	
}

function confirmUsersInGroupPreview(ob, message)
{
	var numSelected = 0;
	var select = document.getElementById(ob).selectedIndex;
		
	arr = document.getElementById("allItems").getElementsByTagName('input');		
	for(i=0; i<arr.length; i++) 
		if (arr[i].checked) numSelected=numSelected+1;	
		
	if (!numSelected) return false;
	else
	{	
		if (select == 0)
		{ 			    
			if(!confirm(message)) 
				return false;
			else 
				return true;
		}
		else return true;
	}	
}

function confirmMessage(message){
	if(!confirm(message)) 
		return false;
	else 
		return true;
}

function checkIfIsString(sender)
{		
	var obj = document.getElementById(sender)
	var v = obj.value;
	if (v.length) return true;
	else return false;
}
// End hidding script from old browsers -->