// JavaScript Document
/*function joinRateCaptcha()
{
	document.getElementById("ratingJoinNow").value="";
	alert('joinNow'+document.getElementById("ratingJoinNow").value );
	joinRateNow();
}*/

function clearJoinRate()
{
	//alert('clearJoinRate');
	document.getElementById('txtJoinRateEmail').value="";
	document.getElementById('txtJoinRateUserName').value="";
	document.getElementById('txtJoinRatePwd').value="";
	document.getElementById('txtJoinRateConfirmPwd').value="";
	document.getElementById('txtJoinRateFirstName').value="";
	document.getElementById('txtJoinRateLastName').value="";
	document.getElementById('txtJoinRateBday').value="MM-DD-YYYY";
	//document.getElementById('rdJoinRateGender').value="";
	
	document.getElementById("errorEmail").innerHTML="";
	document.getElementById("errorEmail").style.display="none";
	document.getElementById("errorUserName").innerHTML="";
	document.getElementById("errorUserName").style.display="none";
	document.getElementById("errorPwd").innerHTML="";
	document.getElementById("errorPwd").style.display="none";
	document.getElementById("errorConfirmPwd").innerHTML="";
	document.getElementById("errorConfirmPwd").style.display="none";
	document.getElementById("errorFirstName").innerHTML="";
	document.getElementById("errorFirstName").style.display="none";
	document.getElementById("errorLastName").innerHTML="";
	document.getElementById("errorLastName").style.display="none";
	document.getElementById("errorBirthday").innerHTML="";
	document.getElementById("errorBirthday").style.display="none";
	document.getElementById("errorGender").innerHTML="";
	document.getElementById("errorGender").style.display="none";
	document.getElementById("errorCaptcha").innerHTML="";
	document.getElementById("errorCaptcha").style.display="none";
}


function joinNow()
{
	close_order();
	getContent(3);	
}

function insideJoinNow()
{
	close_order();
	getContent_inside(3);
}

function joinRateCaptcha()
{
	//alert('joinNow'+document.getElementById("ratingJoinNow").value );
	//alert('joinRateCaptcha');
	
	
	
	var ratingJoinNowOption="";
	if( document.getElementById("ratingJoinNow").value=="Y" )
	{
		ratingJoinNowOption= document.getElementById("ratingJoinNow").value;
		var ratingJoinVideoId= document.getElementById("ratingJNVideoId").value;
		var ratingJoinVideoType= document.getElementById("ratingJNVideoType").value;
	}
	
	var JSONObject = new Object;
	JSONObject.action ='frtJoinRateVideosRegister';
	JSONObject.parameters=new Object;
		JSONObject.parameters.emailId = document.getElementById('txtJoinRateEmail').value;
		JSONObject.parameters.userName =document.getElementById('txtJoinRateUserName').value;
		JSONObject.parameters.pwd =document.getElementById('txtJoinRatePwd').value;
		JSONObject.parameters.confirmPwd =document.getElementById('txtJoinRateConfirmPwd').value;
		JSONObject.parameters.firstName =document.getElementById('txtJoinRateFirstName').value;
		JSONObject.parameters.lastName =document.getElementById('txtJoinRateLastName').value;
		JSONObject.parameters.birthday = document.getElementById('txtJoinRateBday').value;
		JSONObject.parameters.gender = document.getElementById('rdJoinRateGender').value;
		JSONObject.parameters.recaptcha_challenge_field = document.getElementById("recaptcha_challenge_field").value;
		JSONObject.parameters.recaptcha_respone_field = document.getElementById("recaptcha_response_field").value;
		JSONObject.parameters.sessionId= document.getElementById('sessionId').value;
		JSONObject.parameters.schoolId= document.getElementById('schoolId').value;
	JSONstring = JSON.stringify(JSONObject);
	//alert('JSONstring'+JSONstring);
	
	var siteURL=document.getElementById("siteURL").value;
	
	//alert('site url'+siteURL);
	$.post('/frtLogin', { data: JSONstring }, 
			  function(data){
				  //alert('result:'+data);
				  
					var JSONtext = data;
					// convert received string to JavaScript object
					var JSONobject = JSON.parse(JSONtext);
					var Msg= JSONobject.frtEndJoinRateVideos['Msg'];
					var emailError= JSONobject.frtEndJoinRateVideos['emailError'];
					var userNameError= JSONobject.frtEndJoinRateVideos['userNameError'];
					var pwdError= JSONobject.frtEndJoinRateVideos['pwdError'];
					var confirmPwdError= JSONobject.frtEndJoinRateVideos['confirmPwdError'];
					var firstNameError= JSONobject.frtEndJoinRateVideos['firstNameError'];
					var lastNameError= JSONobject.frtEndJoinRateVideos['lastNameError'];
					var birthdayError= JSONobject.frtEndJoinRateVideos['birthdayError'];
					var genderError= JSONobject.frtEndJoinRateVideos['genderError'];
					var captchaError= JSONobject.frtEndJoinRateVideos['captchaError'];
					var profileUN= JSONobject.frtEndJoinRateVideos['profileUserName'];
					var profilePwd= JSONobject.frtEndJoinRateVideos['profilePassword'];
					var session= JSONobject.frtEndJoinRateVideos['session'];
					//var redirection= JSONobject.frtEndJoinRateVideos['redirection'];
					//alert('email error'+emailError);
					//alert('msg'+Msg);
					if( Msg!="Your profile details have been created.")
					{
						errorShow('errorEmail',emailError,'emailError');
						errorShow('errorUserName',userNameError,'userNameError');
						errorShow('errorPwd',pwdError,'pwdError');
						errorShow('errorConfirmPwd',confirmPwdError,'confirmPwdError');
						errorShow('errorFirstName',firstNameError,'firstNameError');
						errorShow('errorLastName',lastNameError,'lastNameError');
						errorShow('errorBirthday',birthdayError,'birthdayError');
						errorShow('errorGender',genderError,'genderError');
						errorShow('errorCaptcha',captchaError,'captchaError');
					}
					else
					{
						//alert('success');
						$("#joinResult").html( document.getElementById('txtJoinRateUserName').value+" profile details have been created.");
						$("#joinResult").fadeIn(500);
						
						if( ratingJoinNowOption=="Y" )
						{
							//alert('profile UserName'+profileUN);
							//alert('profile Password'+profilePwd);
							//alert('joinNow option'+ratingJoinNowOption );
							//alert('joinNow videoId'+ratingJoinVideoId );
							//alert('joinNow videoType'+ratingJoinVideoType );
							//alert('session'+session);
							
							$("#joinData").fadeOut(500);
							
							tb_show('&nbsp;', siteURL+'html/frtEndRatingVideo.php?height=200&width=500&videoId='+ratingJoinVideoId+"&sessionId="+session+"&vt="+ratingJoinVideoType, false);
						}
						else
						{
							window.location.replace('home/'+session+'.html');	
						}
						
					}
					
			  });
}

function errorShow(divName, msg, fieldName)
{
	$("#"+divName).fadeOut(500, function(){
		$("#"+divName).html( msg );
		$("#"+divName).fadeIn(500);
	  });
}


function onOpenLoginBox_order() {	
	//alert('openLoginBox');
	tb_remove();
	var overlayDiv = document.getElementById('lb_overlay');
	var boxDiv = document.getElementById('order_lb_box');
	overlayDiv.style.display = 'block';
	overlayDiv.style.backgroundColor = '#000';
	//overlyaDiv.style.backgroundColor ='#000';
	boxDiv.style.display = 'block';
	//boxDiv.style.backgroundColor='#000';
	//alert('overlayDiv'+overlayDiv);
	//alert('boxDiv'+boxDiv);
	//alert('boxdiv value'+document.getElementById('lb_overlay').value );
	center2(boxDiv);
}

function center2(element) {
  var my_width  = 0;
   var my_height = 0;
   var divWidth = 514;
   var divHeight = 314;
   

   if ( typeof( window.innerWidth ) == 'number' ){
      my_width  = window.innerWidth;
      my_height = window.innerHeight;
   }else if ( document.documentElement &&
   ( document.documentElement.clientWidth ||
   document.documentElement.clientHeight ) ){
      my_width  = document.documentElement.clientWidth;
      //my_height = document.documentElement.clientHeight+400;
	  my_height = document.documentElement.clientHeight;
   }
   else if ( document.body &&
   ( document.body.clientWidth || document.body.clientHeight ) ){
      my_width  = document.body.clientWidth;
      //my_height = document.body.clientHeight+400;
	  my_height = document.body.clientHeight;
   }

   element.style.position = 'absolute';
   element.style.zIndex   = 99;

   var scrollY = 0;

   if ( document.documentElement && document.documentElement.scrollTop ){
      scrollY = document.documentElement.scrollTop;
   }else if ( document.body && document.body.scrollTop ){
      scrollY = document.body.scrollTop;
   }else if ( window.pageYOffset ){
      scrollY = window.pageYOffset;
   }else if ( window.scrollY ){
      scrollY = window.scrollY;
   }


   var setX = ( my_width  - divWidth  ) / 2;
   var setY = ( my_height - divHeight ) / 2 + scrollY;

   setX = ( setX < 0 ) ? 0 : setX;
   setY = ( setY < 0 ) ? 0 : setY;

	//alert('setY'+setY);
	//alert('scrollY'+scrollY);
	
	//setY= setY-200;
	//alert('setX'+setX);
	setX=setX-205;
	setY=setY-150;
   element.style.left = setX + "px";
   element.style.top  = setY + "px";
   element.style.display  = 'block';
   var overlayDiv = document.getElementById('lb_overlay');
   overlayDiv.style.width = my_width + "px";
   //alert('my width'+my_width);
   //alert('my height'+my_height);
   scrollY=2;
   overlayDiv.style.height = my_height + "px";
   overlayDiv.style.top = scrollY + "px";
   overlayDiv.style.left = "0px";
   document.getElementById("order_lb_box").style.display='none';
   
   //document.getElementBYId("joinResult").style.display='none';
   //document.getElementById("lb_overlay").style.display='block';
  // alert('order_lb_box style:'+document.getElementById("lb_overlay").style.display);
  	clearJoinRate();
  
   $("#order_lb_box").fadeIn(1000);
}

function close_order()
{
	var overlayDiv = document.getElementById('lb_overlay');
	//var boxDiv = document.getElementById('order_lb_box');
	overlayDiv.style.display = 'none';
	//boxDiv.style.display = 'none';
	$("#joinResult").fadeOut(500);
	$("#order_lb_box").fadeOut(500);
}

<!-- userLogin Function -->
function userLogin()
{
	//alert('userlogin');
	var JSONObject = new Object;
	JSONObject.action ='frtLoginValidate';
	JSONObject.parameters=new Object;
		JSONObject.parameters.userName =document.getElementById('txtLoginName').value;
		JSONObject.parameters.pwd =document.getElementById('txtLoginPwd').value;
		JSONObject.parameters.session= document.getElementById('sessionId').value;
		JSONObject.parameters.schoolId= document.getElementById('schoolId').value;
	JSONstring = JSON.stringify(JSONObject);
	var siteURL=document.getElementById("siteURL").value;
	
	//alert('sampleText'+document.getElementById("txtSample").value );
	//alert('siteURL'+siteURL);
	//alert('jsonString'+JSONstring);
	
	$.post('/frtLoginValidate', { data: JSONstring }, 
			  function(data){
				  //alert('result:'+data);
				  
					var JSONtext = data;
					// convert received string to JavaScript object
					var JSONobject = JSON.parse(JSONtext);
					var Msg= JSONobject.frtEndLogin['Msg'];
					var session= JSONobject.frtEndLogin['session'];
					var url= JSONobject.frtEndLogin['redirectionURL'];
					if( Msg>0)
					{
						tb_remove();
						$("#rightpanel").hide(500);
						$("#bottomcenter").hide(500);
						
						//alert('url'+url);
						window.location.replace(url);
						
					}
					else
					{
						$("#loginErrorMessage").html(Msg);
						
						$("#loginErrorMessage").hide(500, function(){
							$("#loginErrorMessage").show(500);
	 					   });
					}
			  });
}

function saveRateVideo()
{
	//alert('Rate Now');
	//alert('rating sessionId'+document.getElementById("ratingSessionId").value );
	//alert('rating videoId'+document.getElementById("ratingVideoId").value );
	//alert('rating VideoType'+document.getElementById("RatingVideoType").value );
	//alert('radio length'+document.frmRatingVideo.rdoRating.length );
	var rdoRatingValue='';
	
	for (var i=0; i<document.frmRatingVideo.rdoRating.length; i++)  { 
		if (document.frmRatingVideo.rdoRating[i].checked)  {
			rdoRatingValue = document.frmRatingVideo.rdoRating[i].value
		} 
	} 

	//alert('found value'+rdoRatingValue );
	var site=document.getElementById("siteURL").value;
	var JSONObject = new Object;
	JSONObject.action ='frtVideoRatings';
		JSONObject.parameters=new Object;
		JSONObject.parameters.sessionId= document.getElementById("ratingSessionId").value;
		JSONObject.parameters.schoolId= document.getElementById("schoolId").value;
		JSONObject.parameters.videoId= document.getElementById("ratingVideoId").value;
		JSONObject.parameters.videoType= document.getElementById("RatingVideoType").value;
		JSONObject.parameters.videoRating= rdoRatingValue;

		JSONstring = JSON.stringify(JSONObject);
		//alert( 'JSONstring'+JSONstring );
		//alert('site'+site);
		
		$.post(site+"ajax/frtVideoRatings.php", { data: JSONstring }, 
			  function(data){
				  //alert('result:'+data);
				  
					var JSONtext = data;
					// convert received string to JavaScript object
					var JSONobject = JSON.parse(JSONtext);
					var Msg= JSONobject.frtEndVideoRatings['loginMessage'];
					var ratingHTML = JSONobject.frtEndVideoRatings['ratingHTML'];
					var ratingURL = JSONobject.frtEndVideoRatings['ratingURL'];
					
					if( ratingHTML !=1 )
						alert(ratingHTML );
					
					//if( ratingHTML ==1 )
						window.location.replace( ratingURL );
					//else
						//$("#RatingVideoMsg").html( ratingHTML );
			  });
		
}

function rating()
{
	//alert('rating');
	tb_remove();
	//alert('video Type'+ document.getElementById("RatingVideoType").value );
	window.location.replace('_id_'+document.getElementById("ratingSessionId").value+'_v_'+document.getElementById("RatingVideoType").value+'.html');
}

<!-- Rating videos based on videoId -->
function rateVideo(videoId)
{
	//alert('rating video concept');
	//alert('videoId: '+videoId);
	var sessionId= document.getElementById("sessionId").value;
	var videoType= document.getElementById("ViewVideoType").value ;
	var siteURL= document.getElementById("siteURL").value;
	
	//alert('videoType'+videoType);
	//if( document.getElementById("verification").value!='' )
		//var verification= document.getElementById("verification").value;
	
	
	//tb_show('<strong>LOGIN</strong>', 'html/frtEndLoginRatng.php?height=330&width=450&videoId='+videoId+"&vt=School Events", false);
	if( document.getElementById("sessionId").value =="")
	{
		tb_show('&nbsp;', siteURL+'html/frtEndLoginRatng.php?height=330&width=450&videoId='+videoId+"&vt="+videoType, false);
	}
	else if( document.getElementById("sessionId").value!="" && document.getElementById("verification").value==1)
	{
		tb_show('&nbsp;', siteURL+'html/frtEndLoginRatng.php?height=330&width=450&videoId='+videoId+"&vt="+videoType, false);
	}
	else
	{
		//alert('videoType'+videoType);
		//alert('sessionId'+sessionId);
		tb_show('&nbsp;', siteURL+'/html/frtEndRatingVideo.php?height=200&width=500&videoId='+videoId+"&vt="+videoType+"&sessionId="+sessionId, false);
	}
	
}


function userLoginRating()
{
	//alert('userlogin rating');
	var videoId= document.getElementById('RatingvideoId').value;
	//alert('videoId'+videoId );
	var JSONObject = new Object;
	JSONObject.action ='frtLoginValidate';
	JSONObject.parameters=new Object;
		JSONObject.parameters.userName =document.getElementById('txtRatingLoginName').value;
		JSONObject.parameters.pwd =document.getElementById('txtRatingLoginPwd').value;
		JSONObject.parameters.session= document.getElementById('sessionId').value;
		
	JSONstring = JSON.stringify(JSONObject);
	
	
	//alert('JSONString'+JSONstring);
	var siteURL=document.getElementById("siteURL").value;
	
	$.post('/frtLoginValidate', { data: JSONstring }, 
			  function(data){
				  //alert('result:'+data);
				  
					var JSONtext = data;
					// convert received string to JavaScript object
					var JSONobject = JSON.parse(JSONtext);
					var Msg= JSONobject.frtEndLogin['Msg'];
					var session= JSONobject.frtEndLogin['session'];
					
					if( Msg>0)
					{
						//alert('user exists');
						//tb_remove();
						//alert('session'+session);
						var videoType= document.getElementById("ViewVideoType").value ;
						//alert('view video Type'+videoType );
						tb_show('&nbsp;', siteURL+'html/frtEndRatingVideo.php?height=200&width=500&videoId='+videoId+"&sessionId="+session+"&vt="+videoType, false);
						//window.location.replace(siteURL+'_id_'+session+'.html');
						
					}
					else
					{
						$("#loginErrorMessage").html(Msg);
						
						$("#loginErrorMessage").hide(500, function(){
							$("#loginErrorMessage").show(500);
	 					   });
					}
			  });
}

function ratingJoinNow(videoId,videoType)
{
	//alert('rating JoinNow');	
	document.getElementById("ratingJoinNow").value="Y";
	document.getElementById("ratingJNVideoId").value= videoId;
	document.getElementById("ratingJNVideoType").value= videoType;
	tb_remove();
	onOpenLoginBox_order();
}

function test()
{
	tb_show('&nbsp;', 'html/frtEndRatingVideo.php?height=330&width=450&videoId=1&vt=MostViewed', false);
}
