function change_video_paging(current_page,total_loop,total_page) {
		var show_div = 3*current_page - 3 ;
		var end_div = show_div + 3 ;
		for(i=0 ; i< total_loop ; i++) {
			if( i >= show_div && i < end_div)
				document.getElementById('video_thumb_'+i).style.display = "";
			else
				document.getElementById('video_thumb_'+i).style.display = "none";
		}
		var page_string = '' ;
		for(j=1 ; j <= total_page ; j++) {
			if( j == current_page)
				page_string = page_string + '<span class="color1_dark">'+j+'</span>&nbsp' ;
			else
				page_string = page_string + '<a href="javascript: void(0);" onclick="javascript: change_video_paging(\''+j+'\',\''+total_loop+'\',\''+total_page+'\');" >'+j+'</a>&nbsp' ;
		}
		document.getElementById('paging_list').innerHTML = page_string ;
		
	}

function change_article_paging(current_page,total_page) {
	
		/*var show_div = 3*current_page - 3 ;
		var end_div = show_div + 3 ;
		for(i=0 ; i< total_loop ; i++) {
			if( i >= show_div && i < end_div)
				document.getElementById('text_'+i).style.display = "";
			else
				document.getElementById('text_'+i).style.display = "none";
		}*/
		var page_string = '' ;

		if(current_page > 1){
			
			j=current_page-1;
				page_string = page_string + '<a href="javascript: void(0);" onclick="javascript: change_article_paging(\''+j+'\',\''+total_page+'\');" >Prev</a>&nbsp' ;
				//alert(j);
		}
		
		for(j=1 ; j <= total_page ; j++) {
			
			
			if( j == current_page) {
				page_string = page_string + '<span class="color1_dark">'+j+'</span>&nbsp' ;
				document.getElementById('fullstory_'+(j-1)).style.display = "";
			}
			else {
				page_string = page_string + '<a href="javascript: void(0);" onclick="javascript: change_article_paging(\''+j+'\',\''+total_page+'\');" >'+j+'</a>&nbsp' ;
				document.getElementById('fullstory_'+(j-1)).style.display = "none";
			}			
			
		}		
		if (current_page <= (total_page-1)) {
			
			j=parseInt(current_page)+1;
			page_string = page_string + '<a href="javascript: void(0);" onclick="javascript: change_article_paging(\''+j+'\',\''+total_page+'\');" >Next</a>&nbsp' ;
		}
		
		document.getElementById('article_paging_list').innerHTML = page_string ;
		
	}

function recipeunit(searchin) {
	var split_array = searchin.split("#");
	document.getElementById('hiddenrecipeunit'+split_array[0]).value = split_array[1] ;
	return false ;
}


function isEmpty( str ){
  var strRE = /^[\s ]*$/gi;
  return strRE.test( str );
}

function check_recipe_search() {

	var frmObj	= document.form_recipe_search ;	
	var re = /^\s{1,}$/g; //match any white space including space, tab, form-feed, etc. 
	
	if((frmObj.recipesearchfield.value == "Type keyword here") || isEmpty(frmObj.recipesearchfield.value) || (frmObj.recipesearchfield.value.length==0) || (frmObj.recipesearchfield.value==null)|| ((frmObj.recipesearchfield.value.search(re)) > -1)) {
		alert("Please Enter Search Keyword");
		frmObj.recipesearchfield.focus() ;
		return false;
	}	
	
	return true ;
}

function video_section(sectionid) {
	
	go_page('1',sectionid,'/app/get_videoajax_data.php') ;

}
function news_section(sectionid) {
	go_page('1',sectionid,'/app/get_newsajax_data.php') ;

}
function show_list(filter_id) {

	go_page('1','filter_shows', filter_id,'/ajaxrequest/get_ajax_data.php') ;
	//go_page('1','filter_shows', filter_id,'/app/hdontv.php') ;

}
function reply(sectionid){}
function recipesearchin(sectionid){}
function showname(sectionid){}
function department(sectionid){}
function state(sectionid){}
function topic(sectionid){}
function month(sectionid){}
function m(sectionid){}
function year(sectionid){}
function y(sectionid){}
function video_select(sectionid){}
function news_select(sectionid){}
function experts(sectionid){}
function expertid(sectionid){}
function eid(sectionid){}
function qa_month(sectionid){}
function qa_year(sectionid){}
function show_cat_id(filter_id){}

function submit_rating(rate_type,rate_id,rating) {
	
	/*document.getElementById('page_loading').style.display = 'inline';
	document.getElementById('page_loading').innerHTML = '<img src="/loading.gif">';*/

	createRequest();
	var contentType = "application/x-www-form-urlencoded; charset=UTF-8";
	var url= "/app/ajax_submitrating.php?rate_id="+rate_id+"&rate_type="+rate_type+"&rating="+rating;

	request.open("GET",url,true);
	request.setRequestHeader("Content-Type", contentType);
	request.onreadystatechange = ratingSubmit;
	request.send(null);	
	return false;
}

function ratingSubmit(){	
	if(request.readyState==4){			
		/*document.getElementById('pagination_data').style.display='inline';
		document.getElementById('body_load_data').style.display = 'none';
		document.getElementById('page_loading').style.display = 'none';	*/	
		document.getElementById('stars_rating').innerHTML = request.responseText;
		document.getElementById('rate_txt_id').innerHTML = 'Average Rating';
	}
}

var parentdivid ;
function toggle_video(divid,sectionid,toggle) {
	parentdivid = divid ;
	document.getElementById('page_loading').style.display = 'inline';
	//document.getElementById(parentdivid).innerHTML = '<img src="/loading.gif">';
	//document.getElementById(parentdivid).style.opacity = '0.4' ;
	//document.getElementById(parentdivid).style.filter = 'alpha(opacity=10)' ;
	
	
	createRequest();
	var contentType = "application/x-www-form-urlencoded; charset=UTF-8";
	var url= "/app/ajax_videotoggle.php?sectionid="+sectionid+"&toggle="+toggle+"&parentdivid="+parentdivid;

	request.open("GET",url,true);
	request.setRequestHeader("Content-Type", contentType);
	request.onreadystatechange = showVideo;
	request.send(null);	
	return false;
}

function showVideo(){	
	if(request.readyState==4){			
		/*document.getElementById('pagination_data').style.display='inline';
		document.getElementById('body_load_data').style.display = 'none';*/
		document.getElementById(parentdivid).innerHTML = request.responseText;		
	}
}

function uncheck_other(id)
{

	if(id==1)
	{
		document.getElementById('ans_2').className = '';
		document.getElementById('ans_3').className = '';
	}else if(id==2)
	{
		document.getElementById('ans_1').className = '';
		document.getElementById('ans_3').className = '';
	}else if(id==3)
	{
		document.getElementById('ans_1').className = '';
		document.getElementById('ans_2').className = '';
	}
}

function zipcode() {
	var frmObj	= document.frmZipcode;
	if(frmObj.input_zip.value == "") {
		alert("Please Enter Zip Code");
		return false;
	}
	//window.location.href = 'zip_code.html?<?=encode_substring_url('zip_code=1')?>';
}


function check_search() {

	var frmObj	= document.search_form ;	
	var re = /^\s{1,}$/g; //match any white space including space, tab, form-feed, etc. 
	
	if((frmObj.searchfield.value == "SEARCH") || isEmpty(frmObj.searchfield.value) || (frmObj.searchfield.value.length==0) || (frmObj.searchfield.value==null)|| ((frmObj.searchfield.value.search(re)) > -1)) {
		$("#globel_searcherror").show('slow');
		$("#globel_searcherror").fadeTo(200,0.1,function() {
			$(this).html('Please enter the search keyword').addClass('messageboxerror').fadeTo(900,1);
			return false;
		});
		return false ;
	}	
	
	return true ;
}
function check_search_doctor() {
	
	var frmObj	= document.search_form_doctor ;	
	var re = /^\s{1,}$/g; //match any white space including space, tab, form-feed, etc. 
	
	if(isEmpty(frmObj.searchfield.value) || (frmObj.searchfield.value.length==0) || (frmObj.searchfield.value==null)|| ((frmObj.searchfield.value.search(re)) > -1)) {
		alert("Please Enter Search Keyword");
		frmObj.searchfield.focus() ;
		return false;
	}	
	
	return true ;
}

function toggle_login() {
	if($('#login-form').css('display')=='none')
   {
   		//clear previously entered data
		document.getElementById('msgbox').innerHTML = '';
		document.getElementById('loginid').value = '';
		document.getElementById('loginpass').value = '';

		$('#forgot-passward').css('display','none');   		
		$('#msgboxfp').css('display','none');
		$('#login-form').fadeIn(function(){$('#loginid').focus();});
   }else{
	   $('#login-form').fadeOut();
	   document.getElementById('loginid').value = '';
	   document.getElementById('loginpass').value = '';
	   
	   /*$('#login-form').css('position','absolute');
	   $('#login-form').css('top','108px');
	   $('#login-form').css('left','740px');*/

   }
   return false;
}

function toggle_recipe_login() {
	if($('#login-recipe').css('display')=='none')
   {
   		//clear previously entered data
		document.getElementById('msgbox').innerHTML = '';
		document.getElementById('loginid').value = '';
		document.getElementById('loginpass').value = '';

		$('#forgot-passward').css('display','none');   		
		$('#msgboxfp').css('display','none');
		$('#login-recipe').fadeIn(function(){$('#loginid').focus();});
   }else{
	   
	   $('#login-recipe').fadeOut();
	   document.getElementById('loginid').value = '';
	   document.getElementById('loginpass').value = '';
	   
	   /*$('#login-form').css('position','absolute');
	   $('#login-form').css('top','108px');
	   $('#login-form').css('left','740px');*/

   }
   return false;
}


function toggle_seclogin() {
	if($('#login-form').css('display')=='none')
	 {
		document.getElementById('login-form').style.display = '';
		document.getElementById('login-form').style.position = 'absolute';
		document.getElementById('login-form').style.top = '500px';
		document.getElementById('login-form').style.left = '470px';
		document.getElementById('loginid').value = '';
		document.getElementById('loginpass').value = '';
	 }else{
		 $('#login-form').fadeOut();
	   document.getElementById('loginid').value = '';
	   document.getElementById('loginpass').value = '';
	 
	 }
   return false;
}

function toggleForgotPassward()
  {	
   if($('#login-form').css('display')=='none')
   {
	document.getElementById('user_email').value = '';
    $('#forgot-passward').css('display','none');
	$('#msgboxfp').css('display','none');
	$('#login-form').fadeIn(function(){$('#user_email').focus();});

	//clear previously entered data
	document.getElementById('msgbox').innerHTML = '';
	document.getElementById('loginid').value = '';
	document.getElementById('loginpass').value = '';

   }
   else
   {
	document.getElementById('user_email').value = '';
    $('#login-form').fadeOut(function(){$('#forgot-passward').css('display','block');});
	}
return false;}

function login_fade_favourite(fav_id,fav_type,page_url) {

	createRequest();
	var contentType = "application/x-www-form-urlencoded; charset=UTF-8";
	var url= page_url+'check_fav_session.html'+"?fav_id="+fav_id+"&fav_type="+fav_type;		
		
	request.open("GET",url,true);
	request.setRequestHeader("Content-Type", contentType);
	request.onreadystatechange = fav_session_result;
	request.send(null);		
}

function fav_session_result() {
	if(request.readyState==4) {					
		
		var str = request.responseText;		
		var patt = new RegExp("session_empty");

		if (patt.test(str) == true) {
			fade_favourite();
		  }
		 else {		
			//document.getElementById('favourite').style.display = 'none';		
			document.getElementById('favourite_result').innerHTML = request.responseText;
			add_favourite_success();
		 }			
	}
}

function fade_comment_login(){
	if($('#comment-login-form').css('display')=='none'){
		$('#comment-login-form').fadeIn();
	}else{
		$('#comment-login-form').fadeOut();
	}

}

function sortDiscussion(id){
	document.getElementById("sort_discussion").value = id;
	document.getElementById("sortdis").submit();
}

function saveDiscussion(stype){
	document.getElementById("stype").value = stype;
	document.discussionFrm.submit();
}

function isValidEmailAddress(emailAddress) {
	var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
	return pattern.test(emailAddress);
	}

function filterBlogList(archives,type){
	document.getElementById('type').value = type;
	document.getElementById('filter').value = archives;
	document.getElementById('blog_filter').submit();
}

function twodigithex(num) {
  return (Math.floor(num / 16).toString(16) + (num % 16).toString(16)).toUpperCase();
}

function changeuploadimage(url,imgsrc){
	document.getElementById('userprofileavt').src = url+imgsrc;
	document.getElementById('user_avatar').value = imgsrc;
	document.getElementById('uimage').value = '';
}
function userdefaultimage(url,imgsrc){
	document.getElementById('userprofileavt').src = url+imgsrc;
	document.getElementById('user_avatar').value = '';
}

function share_recipe_login(){

	

}

$("#newsletter_home").click(function() {
		var email = jQuery.trim($("#newsletteremail").val());
		var zipcode = jQuery.trim($("#newsletterzip").val());
		
		$("#msgboxnewsletter").removeClass().addClass('messagebox').text('Validating....').fadeIn(1000);
		
				
		if(email=="" || email == 'E-MAIL'){
			
			$("#msgboxnewsletter").fadeTo(200,0.1,function() {
					  $(this).html('Enter Email ID').addClass('messageboxerror').fadeTo(900,1);
					  return false;
			});
		}
		else if(!isValidEmailAddress(email)){
	 
			$("#msgboxnewsletter").fadeTo(200,0.1,function() {
					  $(this).html('Invalid Email ID').addClass('messageboxerror').fadeTo(900,1);
					  return false;
			});	
			
		}
		else if(zipcode == '' || zipcode == 'ZIPCODE'){
			$("#msgboxnewsletter").fadeTo(200,0.1,function() {
					 $(this).html('Enter Zip Code').addClass('messageboxerror').fadeTo(900,1);
					  return false;
			});
		}else if(zipcode!=''){
			if (!zipcode.toString().match(/^[-]?\d*\.?\d*$/)){
				$("#msgboxnewsletter").fadeTo(200,0.1,function() {
					$("#msgboxnewsletter").show();		
					  $(this).html('Enter valid zip code').addClass('messageboxerror').fadeTo(900,1);
					  return false;
				});
				return false;
			}else{
				$("#msgboxnewsletter").removeClass().addClass('messagebox').text('Submitting....').fadeIn(1000);
				$.post($('#ajaxurl').val()+"newslettersignup.html",{ newsemail:jQuery.trim($("#newsletteremail").val()),newszip:jQuery.trim($("#newsletterzip").val()),provider_id:jQuery.trim($("#provider_id").val()),user_name:jQuery.trim($("#user_name").val()),dob_month:jQuery.trim($("#dob_month").val()),dob_date:jQuery.trim($("#dob_date").val()),dob_year:jQuery.trim($("#dob_year").val())} ,function(data)
				{
				  if(data=='true') {
					  $("#msgboxnewsletter").removeClass().addClass('messagebox').text('').fadeIn(1000);
					//document.location=jQuery.trim($('siteurl').val())+'newsletter-signup-confirmation.html';
					var newURL = $('#ajaxurl').val()+"newsletter-signup-confirmation.html?height=600&width=800&inlineId=hiddenModalContentID";

						TB_show("", newURL,'newsletter'); 
						return false;
				  } 
				  if(data=='emailerror') {				  
					$("#msgboxnewsletter").fadeTo(200,0.1,function() {
					  $(this).html('Email already exist').addClass('messageboxerror').fadeTo(900,1);
					});		
				  }
				  if(data=='ziperror') {				  
					$("#msgboxnewsletter").fadeTo(200,0.1,function() {
					  $(this).html('Enter valid zip code').addClass('messageboxerror').fadeTo(900,1);
					});	
					 
				  }
				});
				return false;
			}
  
		}
		return false;
	});