var mode_s = "o";
$(document).ready(function()
			{
				/*alert($("#f_cat_id").val());
				$("#loader").show();		
					$.post("video_ajax_cat.php",{
					 cat_id:$("#f_cat_id").val()				
					},function(res)
					{
						addResponse(res);	
					});
					function addResponse(res)
			{				
				//$("#loader").hide();				
				$("#Secton_Box_Container").empty();
				$("#Secton_Box_Container").append(res);
			}
			//alert($("#f_cat_id").val())*/
			load_cat($("#f_cat_id").val());
			


});
function load_cat(cat_id){
	$("#Secton_Box_Container").empty();
	$("#Secton_Box_Container").append("<div style=\"padding: 200px 200px\" ><img src=\"images/ajax-loader.gif\" ></div>");
	$("#loader").show();		
					$.post("video_ajax_cat.php",{
					 cat_id:cat_id				
					},function(res)
					{
						add_cat(res);	
					});			
			
}
function add_cat(res){
	//$("#loader").hide();	
	$("#Secton_Box_Container").empty();
	$("#Secton_Box_Container").append(res);
	load_vids($("#f_sub_id").val(),1)
}
function load_svids(keyword,ival){
	$("#video-player").empty();
	$("#playerlist-box").empty();
	$("#video-player").append("<div style=\"padding: 200px 200px\" ><img src=\"images/ajax-loader.gif\" ></div>");
	$("#playerlist-box").append("<div style=\"padding: 50px 150px\" ><img src=\"images/ajax-loader.gif\" ></div>");
	$("#loader").show();		
					$.post("vlist.php",{
					 keyword:keyword,
					 i:ival,
					 site:document.getElementById("ATK_dd1_Val").firstChild.nodeValue
					},function(res)
					{
						add_svids(res);	
					});
}
function add_svids(res){
	//$("#loader").hide();	
	$("#playerlist-box").empty();
	$("#playerlist-box").append(res);
	getPlayer1(channel_i,url_i,0);
}
var i_val = 1;
var g_keyword = "";
function search_vids(){
	clearAllTabs();
	mode_s = "s";
	load_vids($("#query").val(),1);
}
function load_vids(keyword,ival){	
	$("#video-player").empty();
	$("#dynamic-photos-div").empty();
	$("#playerlist-box").empty();
	$("#video-player").append("<div style=\"padding: 200px 200px\" ><img src=\"images/ajax-loader.gif\" ></div>");
	$("#dynamic-photos-div").append("<div style=\"padding: 200px 200px\" ><img src=\"images/ajax-loader.gif\" ></div>");
	$("#playerlist-box").append("<div style=\"padding: 50px 150px\" ><img src=\"images/ajax-loader.gif\" ></div>");
	if(mode_s == "s"){
		$("#Secton_Box_Container").empty();
		$("#Secton_Box_Container").append("<div style=\"padding: 200px 200px\" ><img src=\"images/ajax-loader.gif\" ></div>");
	}
	i_val = ival;
	g_keyword = keyword;
	$("#loader").show();		
					$.post("list.php",{
					 keyword:keyword,
					 i:ival,
					 site:document.getElementById("ATK_dd1_Val").firstChild.nodeValue
					},function(res)
					{
						add_vids(res);	
					});
}
function add_vids(res){
	//$("#loader").hide();	
	
	if(mode_s == "o"){		
		$("#dynamic-photos-div").empty();		
		try{
		$("#dynamic-photos-div").append(res);
		}
		catch(e){}
	}
	else{
		$("#Secton_Box_Container").empty();
		try{
		$("#Secton_Box_Container").append(res);
		}
		catch(e){}
	}	
	load_svids(g_keyword,i_val);
}
function getPlayer(page_count,url,count){
	load_svids(g_keyword,parseInt(page_count)+parseInt(count));
	/*alert(parseInt(page_count)+parseInt(count));
	//$("#Lloader").show();
	//$("#loader").show();
	$("#title_div").html(title_arr[count]);
	$("#summ_div").html(summary_arr[count]);
	$("#sour_div").html("<img src=\""+source_arr[count]+"\" >");
	$("#dt_div").html(date_arr[count]);
	$.post("getVideo.php",{
	url:url,
	vtype:player
	},function(response)
	{
		//$("#Lloader").hide();
		//$("#loader").hide();
		updateResponse(response);
	});
	return false;*/
}

function getPlayer1(player,url,count){
	
	//alert(url);
	//$("#Lloader").show();
	//$("#loader").show();
	//$("#title_div").html(title_arr1[count]);
	$("#title_div").html($("#title_arr1"+count).val());
	//$("#summ_div").html(summary_arr1[count]);
	$("#summ_div").html($("#summary_arr1"+count).val());
	//$("#sour_div").html("<img src=\""+source_arr1[count]+"\" >");
	$("#sour_div").html("<img src=\""+$("#source_arr1"+count).val()+"\" >");
	//$("#dt_div").html(date_arr1[count]);
	$("#dt_div").html($("#date_arr1"+count).val());
	$.post("getVideo.php",{
	url:url,
	vtype:player
	},function(response)
	{
		//$("#Lloader").hide();
		//$("#loader").hide();
		updateResponse(response);
	});
	return false;
}
function updateResponse(resp)
{				
	try{
	changeScript();
	}catch(e){}
	$("#video-player").empty();
	$("#video-player").append(resp);
}

function clearAllTabs(){
	try{
		firstTime = true;
		for(var i = 0 ;i<20;i++){
			document.getElementById("nav"+i).className = "cnnNav_Button_ext_med"
		}
	}
	catch(e){}
}
function PM(msg){
	if(ip == "59.99.4.112"){
		alert(msg);
	}
}