// JavaScript Document
function CategorySearch(CategoryId , VFrom, VTo , Schoolid)
{
	//alert('mahesh');
	//alert(CategoryId);
	
	var JSONObject = new Object;
	
	JSONObject.action ='CategorySearch';
	JSONObject.parameters=new Object;
	JSONObject.parameters.CategoryId = CategoryId;
	JSONObject.parameters.VFrom = VFrom;	
	JSONObject.parameters.VTo = VTo;
	JSONObject.parameters.Schoolid = Schoolid;
	JSONstring = JSON.stringify(JSONObject);
	//alert('JSONstring'+JSONstring);
	
	var siteURL=document.getElementById("siteURL").value;
	
	//alert('site url'+siteURL);
	$.post('/search', { data: JSONstring }, 
			  function(data){
			 //alert('result:'+data);
			
			  	var JSONtext = data;
				var JSONobject = JSON.parse(JSONtext);
				var Content = JSONobject.View['Videos'];
				var Content1 = JSONobject.View['TITLE'];
				
				 //alert('Content'+Content);
				 //alert('div style'+document.getElementById("centerpanelone").style.display );
				$('#welcometxt').hide();
				$('#title').html(Content1);
				$('#title').show(); 
				$('#centerpanel').hide();
				$('#centerpanelone').hide();
				$('#bottomcenter').hide();
				$('#centerpanelone').html(Content);
				$('#centerpanelone').show();
				});
}
function searchKeyword( Kfrom )
{
	var keyword=document.getElementById("KeywordSearch").value;
	//alert("Keyword"+keyword);
	keyword = keyword.replace(/^[\s]+/,'').replace(/[\s]+$/,'').replace(/[\s]{2,}/,' ');
	if(keyword == "Keyword Search" || keyword == "" )
	{
		return false;
	}
	var JSONObject = new Object;
	JSONObject.action ='KeywordSearch';
	JSONObject.parameters = new Object;
    JSONObject.parameters.KFrom = Kfrom ;	
	JSONObject.parameters.keyword = keyword;	
	JSONstring = JSON.stringify(JSONObject);
	//alert('JSONstring'+JSONstring);
	var siteURL=document.getElementById("siteURL").value;
	
	//alert('site url'+siteURL);
	$.post('/search', { data: JSONstring }, 
			  function(data){
			 //alert('result:'+data);
			  	var JSONtext = data;
				var JSONobject = JSON.parse(JSONtext);
				var Content = JSONobject.View['Videos'];
				var Content1 = JSONobject.View['TITLE'];
				$('#welcometxt').hide();
				$('#title').html(Content1);
				$('#title').show(); 
				$('#centerpanel').hide();
				$('#centerpanelone').hide();
				$('#bottomcenter').hide();
				$('#centerpanelone').html(Content);
				$('#centerpanelone').show();
				});
	
	//JSONObject.parameters.VTo = VTo;
	
}
function nodcasterSearch( Kfrom )
{
	var keyword=document.getElementById("nodcasterSearch").value;
	//alert("Keyword"+keyword);
	keyword = keyword.replace(/^[\s]+/,'').replace(/[\s]+$/,'').replace(/[\s]{2,}/,' ');
	if(keyword == "Nodcaster Search" || keyword == "")
	{
		return false;
	}
	var JSONObject = new Object;
	JSONObject.action ='nodcasterSearch';
	JSONObject.parameters = new Object;
    JSONObject.parameters.KFrom = Kfrom ;	
	JSONObject.parameters.keyword = keyword;	
	JSONstring = JSON.stringify(JSONObject);
	//alert('JSONstring'+JSONstring);
	var siteURL=document.getElementById("siteURL").value;
	
	//alert('site url'+siteURL);
	$.post('/search', { data: JSONstring }, 
			  function(data){
			    //alert('result:'+data);
			  	var JSONtext = data;
				var JSONobject = JSON.parse(JSONtext);
				var Content = JSONobject.View['Videos'];
				var Content1 = JSONobject.View['TITLE'];
				$('#welcometxt').hide();
				$('#title').html(Content1);
				$('#title').show(); 
				$('#centerpanel').hide();
				$('#centerpanelone').hide();
				$('#bottomcenter').hide();
				$('#centerpanelone').html(Content);
				$('#centerpanelone').show();
				});
}
function nodcasterDisplay( Nid )
{
	//var keyword=document.getElementById("nodcasterSearch").value;
	//alert("Keyword"+keyword);
	//alert(Nid);
	var JSONObject = new Object;
	JSONObject.action ='nodcasterDisplay';
	JSONObject.parameters = new Object;
    JSONObject.parameters.Nid= Nid ;	
	//JSONObject.parameters.keyword = keyword;	
	JSONstring = JSON.stringify(JSONObject);
	//alert('JSONstring'+JSONstring);
	var siteURL=document.getElementById("siteURL").value;
	$.post('/search', { data: JSONstring }, 
			  function(data){
			 //alert('result:'+data);
			  	var JSONtext = data;
				var JSONobject = JSON.parse(JSONtext);
				var Content = JSONobject.View['Videos'];
				var Content1 = JSONobject.View['TITLE'];
				$('#welcometxt').hide();
				$('#title').html(Content1);
				$('#title').show(); 
				$('#centerpanel').hide();
				$('#centerpanelone').hide();
				$('#bottomcenter').hide();
				$('#centerpanelone').html(Content);
				$('#centerpanelone').show();
				});
}
function NodcasterVideos(Nid,VFrom)
{				
	
	//alert(Nid);
	//alert(VFrom);
	var JSONObject = new Object;
	JSONObject.action ='nodcasterVideos';
	JSONObject.parameters = new Object;
    JSONObject.parameters.Nid= Nid ;	
	JSONObject.parameters.VFrom = VFrom;	
	JSONstring = JSON.stringify(JSONObject);
	//alert('JSONstring'+JSONstring);
	var siteURL=document.getElementById("siteURL").value;
	$.post('/search', { data: JSONstring }, 
			  function(data){
		//	 alert('result:'+data);
			  	var JSONtext = data;
				var JSONobject = JSON.parse(JSONtext);
				var Content = JSONobject.View['Videos'];
				//var Content1 = JSONobject.View['TITLE'];
				$('#searchvideos').hide();
				$('#searchvideos').html(Content);
				$('#searchvideos').show();
				});
}
function NodcasterArticles(Nid,AFrom)
{				
	//alert(Nid);
	//alert(AFrom);
	var JSONObject = new Object;
	JSONObject.action ='nodcasterArticle';
	JSONObject.parameters = new Object;
    JSONObject.parameters.Nid= Nid ;	
	JSONObject.parameters.AFrom = AFrom;	
	JSONstring = JSON.stringify(JSONObject);
	//alert('JSONstring'+JSONstring);
	var siteURL=document.getElementById("siteURL").value;
	$.post('/search', { data: JSONstring }, 
			  function(data){
		//	 alert('result:'+data);
			  	var JSONtext = data;
				var JSONobject = JSON.parse(JSONtext);
				var Content = JSONobject.View['Videos'];
				
				$('#searcharticles').hide();
				$('#searcharticles').html(Content);
				$('#searcharticles').show();
				});
}

<!-- This function is to link article to dashboard article page -->
function articleDashboardRedirect(articleId,schoolId)
{
	//alert('articleId'+articleId);
	var session= document.getElementById("sessionId").value;
	var siteURL=document.getElementById("siteURL").value;
	
	//alert('siteURL'+siteURL);
	if( session=='' )
	{
		var JSONObject = new Object;
		JSONObject.action ='frtEndCreateVisitor';
			JSONObject.parameters=new Object;
			JSONObject.parameters.schoolId =schoolId;
			
		JSONstring = JSON.stringify(JSONObject);
		var siteURL=document.getElementById("siteURL").value;
		
		JSONstring = JSON.stringify(JSONObject);
		//alert('jsonString'+JSONstring);
		
		$.post('/createVisitor', { data: JSONstring }, 
				  function(data){
					  //alert('result:'+data);
					  
					  var JSONtext = data;
						// convert received string to JavaScript object
						var JSONobject = JSON.parse(JSONtext);
						var sessionId= JSONobject.frtEndCreateVisitor['sessionId'];
						var schoolName= JSONobject.frtEndCreateVisitor['schoolName'];
						//alert('new visitor session'+sessionId);
						
						//alert('schoolName'+schoolName);
						
						//window.location.replace(siteURL+'_id_'+sessionId+'_val_'+schoolId+'_vid_1'+'_a_'+articleId+'.html');
						window.location.replace(siteURL+'dashboardArticle/'+sessionId+'/'+schoolId+'/1/'+schoolName+'/'+articleId+'.html');
					});
	}
	else
	{
		//alert('already existing session'+session );
		var JSONObject = new Object;
			JSONObject.action ='frtGetSchool';
			JSONObject.parameters=new Object;
			JSONObject.parameters.schoolId =schoolId;
			
			JSONstring = JSON.stringify(JSONObject);
			
			//alert('jsonString'+JSONstring);
			$.post('/frtGetSchool', { data: JSONstring }, 
			  function(data){
				  //alert('result:'+data);
				  
				  var JSONtext = data;
				  var JSONobject = JSON.parse(JSONtext);
				  var school= JSONobject.frtGetSchool["schoolName"];
				  //alert('school'+school);
				  
				  //alert('schoolName'+school);
				  window.location.replace(siteURL+'dashboardArticle/'+session+'/'+schoolId+'/'+school+'/'+articleId+'.html');
			 });
		
		//window.location.replace(siteURL+'article/'+session+'/'+schoolId+'/'+articleId+'.zip');
	}
}

function globalSearchInside()
{
	//alert('globalSearch Inside');	
	var Keyword=document.getElementById("globalKeyword").value;
	//alert('globalSearch Inside'+Keyword);	
	
	var siteURL=document.getElementById("siteURL").value;
	var session= document.getElementById("sessionId").value;
	var verification=  document.getElementById("verification").value;
	
	if( verification !='')
		window.location.href= siteURL+'/index.php?search='+Keyword;
	else
		window.location.href= siteURL+'/index.php?id='+session+'&search='+Keyword;
}

function globalSearch()
{				
	//alert("Mahesh");
	var Keyword=document.getElementById("globalKeyword").value;
	//alert(Keyword);
	var JSONObject = new Object;
	JSONObject.action ='globalSearch';
	JSONObject.parameters = new Object;
    JSONObject.parameters.Keyword= Keyword ;	
	//JSONObject.parameters.AFrom = AFrom;	
	JSONstring = JSON.stringify(JSONObject);
	//alert('JSONstring'+JSONstring);
	var siteURL=document.getElementById("siteURL").value;
	$.post('/search', { data: JSONstring }, 
			  function(data){
			 //alert('result:'+data);
			  	var JSONtext = data;
				var JSONobject = JSON.parse(JSONtext);
				var Content = JSONobject.View['Videos'];
				var Content1 = JSONobject.View['TITLE'];
				$('#welcometxt').hide();
				$('#title').html(Content1);
				$('#title').show(); 
				$('#centerpanel').hide();
				$('#centerpanelone').hide();
				$('#bottomcenter').hide();
				$('#centerpanelone').html(Content);
				$('#centerpanelone').show();
				});
}
function GlobalVideoSearch(VFrom)
{				
	//alert("Mahesh");
	var Keyword=document.getElementById("globalKeyword").value;
	//alert(Keyword);
	var JSONObject = new Object;
	JSONObject.action ='GlobalVideoSearch';
	JSONObject.parameters = new Object;
    JSONObject.parameters.Keyword= Keyword ;	
	//JSONObject.parameters.AFrom = AFrom;	
	JSONObject.parameters.VFrom = VFrom;
	JSONstring = JSON.stringify(JSONObject);
	//alert('JSONstring'+JSONstring);
	var siteURL=document.getElementById("siteURL").value;
	$.post('/search', { data: JSONstring }, 
			  function(data){
			 //alert('result:'+data);
			  	var JSONtext = data;
				var JSONobject = JSON.parse(JSONtext);
				var Content = JSONobject.View['Videos'];
				//var Content1 = JSONobject.View['TITLE'];
				$('#searchvideos').hide();
				$('#searchvideos').html(Content);
				$('#searchvideos').show();
				});
}
function GlobalNodcasterSearch(VFrom)
{				
	//alert("Mahesh");
	var Keyword=document.getElementById("globalKeyword").value;
	//alert(Keyword);
	var JSONObject = new Object;
	JSONObject.action ='GlobalNodcasterSearch';
	JSONObject.parameters = new Object;
    JSONObject.parameters.Keyword= Keyword ;	
	JSONObject.parameters.VFrom = VFrom;
	JSONstring = JSON.stringify(JSONObject);
	//alert('JSONstring'+JSONstring);
	var siteURL=document.getElementById("siteURL").value;
	$.post('/search', { data: JSONstring }, 
			  function(data){
			 //alert('result:'+data);
			  	var JSONtext = data;
				var JSONobject = JSON.parse(JSONtext);
				var Content = JSONobject.View['Videos'];
				//var Content1 = JSONobject.View['TITLE'];
				$('#searchnodcasters').hide();
				$('#searchnodcasters').html(Content);
				$('#searchnodcasters').show();
				});
}
function GlobalArticleSearch(VFrom)
{				
	//alert("Mahesh");
	var Keyword=document.getElementById("globalKeyword").value;
	//alert(Keyword);
	var JSONObject = new Object;
	JSONObject.action ='GlobalArticleSearch';
	JSONObject.parameters = new Object;
    JSONObject.parameters.Keyword= Keyword ;	
	//JSONObject.parameters.AFrom = AFrom;	
	JSONObject.parameters.VFrom = VFrom;
	JSONstring = JSON.stringify(JSONObject);
	//alert('JSONstring'+JSONstring);
	var siteURL=document.getElementById("siteURL").value;
	$.post('/search', { data: JSONstring }, 
			  function(data){
			 //alert('result:'+data);
			  	var JSONtext = data;
				var JSONobject = JSON.parse(JSONtext);
				var Content = JSONobject.View['Videos'];
				//var Content1 = JSONobject.View['TITLE'];
				$('#searcharticles').hide();
				$('#searcharticles').html(Content);
				$('#searcharticles').show();
				});
}


