/*!
 * MOBILE MELODY v1.0
 * Developed by: phpSugar (www.phpsugar.com) / support@phpsugar.com
 * Copyright: (c) 2004-2012 PhpSugar.com. All rights reserved.
 */
addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false);
function hideURLbar(){
window.scrollTo(0,1);
}

$(document).ready(function(){
	$("#c_submit").live("click",function(){
		//	hide the button
		//$(this).hide();
		
		//	display the 'loading' gif;
		$("#mycommentspan").html('<div align="center" id="loader"><img src="'+JS_MOBI_URL+'/images/moreajax.gif" /></div>').show();

		//	get the info
		var userId = $("#c_user_id").val();
		var videoId	= $("#c_vid").val();
		var commentTxt = $("#c_comment_txt").val();
		var uName = $("#c_username").val();
		// user comment
		$.post( JS_MOBI_URL+"/comment.php", { vid: videoId, user_id: userId, comment_txt: commentTxt },
				function(data){
					if(data.cond == true)
					{
						$("#myform").slideUp("normal", function() {  
							$("#mycommentspan").html(data.msg).show();
							
							//	preview comment
							if(data.preview == true)
							{
								$("#be_the_first").hide();										
							}
						});
						
					}
					else if(data.cond == false)
					{
						$("#c_submit").show();
						$("#mycommentspan").html(data.msg).show();
					}
					
				},"json"
			 );
      return false;

	});	
	/* CLICKABLE AREAS */	
	$('#featured li').click(function(){ 
		location.href = $(this).find("a").attr("href");
	});
	$('#video_listing li').click(function(){ 
		location.href = $(this).find("a").attr("href");
	});
	$('#subcategory_listing li').click(function(){ 
		location.href = $(this).find("a").attr("href");
	});
	$('#show_search').click(function() {
	  $('#search_form').toggle();
	});
	$('.maximizer').click(function(){
		$(this).parents("li").children('#subcategory_listing').slideToggle('fast');
		return false; //ensures no anchor jump
	});
	$('#slider li').click(function(){ 
		location.href = $(this).find("a").attr("href");
	});
	$("#show_menu").click(function()
	{ 
		$("#quick_menu").toggle();
	});

	/*SHOW MORE VIDEOS*/
	$('.more').live("click",function() {
	var ID = $(this).attr("id");
	var CASE = $(".case").attr("id");
	var EXTRADATA = $(".extra_data").attr("id");
	if(ID) {
		$("#more"+ID).find("#loader").css('display', 'block');
		$.ajax({
		type: "POST",
		url: JS_MOBI_URL+"/ajax.php",
		data: "lastpos=" + ID +"&case=" + CASE + "&extradata=" + EXTRADATA,
		cache: false,
		success: function(html){
		$("#video_listing").append(html);
		$("#art_listing").append(html);
		$("#more"+ID).remove(); // removing old more button
		}
	});
	} else {
	$(".morebox").html('');// no results
	}
	return false;
	});
	});
	
	$(function() {
	$('.morec').live("click",function() {
	var ID = $(this).attr("id");
	var CASE = $('.morecbox').children(".case").attr("id");
	var EXTRADATA = $('.morecbox').children(".extra_data").attr("id");
	if(ID) {
		$("#morec"+ID).find("#loader").css('display', 'block');
		$.ajax({
		type: "POST",
		url: JS_MOBI_URL+"/ajax.php",
		data: "lastpos=" + ID +"&case=" + CASE + "&extradata=" + EXTRADATA,
		cache: false,
		success: function(html){
		$("#video_comments").append(html);
		$("#morec"+ID).remove(); // removing old more button
		}
	});
	} else {
	$(".morecbox").html('');// no results
	}
	return false;
	});	
	
});