$(document).ready(function(){
				/**** Footer background extension *****/
				setBackground();
				$(window).resize(function() {
				setBackground();
				});
				/**** End of footer background extension *****/
 				if(screen.width < 1441){
				$(window).load(function(){	
				var pageWidth=null;
				var view = getSiteView(document.URL);
				pageWidth=screen.width-22;
				if(!($.browser.msie)){				 
				pageWidth=screen.width-17;          
				}
				if(jQuery.browser.msie && jQuery.browser.version < 7)
				{
				pageWidth=screen.width-27;
				}
				if(jQuery.browser.msie){/*** Restricted to perform zoom out effect n IE8 ***/
					if(jQuery.browser.version != 8){
						$("body").css("width",pageWidth+"px");}
				}
				else{
					//$("body").css("width",pageWidth+"px");
					}
			});
		}
	
	var j;    
	var view = getSiteView(document.URL);	
	var num = show_survey_message - 1; // Show the Survey Pop Up after n number of visits.		
	if(notify_survey == 1){			
		var prev_url;
		var curr_url = window.location; 
		var nfy_block_url=String(curr_url);      
		if(get_cookie('showexternal_popup') == num && get_cookie('prev_url_cookie')!=curr_url && get_cookie('remove_survey_popup') != 'no'
		   && (nfy_block_url.indexOf('schedule/demo/saved')==-1) && (nfy_block_url.indexOf('user/register')==-1)){ /*** Removing override survey popup against loaded default popup ***/
			j = 0;	
			set_cookie('showexternal_popup',j, view);			
			tb_show('', baseurl + 'survey/popup?viewmode=popup&width=400&height=150&modal=true&view='+view);
		   	return false;		
		} else if(get_cookie('showexternal_popup') < num) {		
			var temp = num-1;			
				if(get_cookie('showexternal_popup') == temp){
					var prev_url = window.location;
					set_cookie('prev_url_cookie',prev_url, view);
				} 
			j = parseInt(get_cookie('showexternal_popup'));
			j+=1;
			set_cookie('showexternal_popup',j, view);
		} else {		
			j = 0;
			prev_url = '';
			set_cookie('showexternal_popup',j, view);
			set_cookie('prev_url_cookie',prev_url, view);
		}
	}
	
	
});

/**** Footer background extension *****/
function setBackground(){
	var widowHeight=screen.height;
	var pageHeight=$(document).height();
	var background_color=$('body div.footertop_pat').css('background-color')!=null? $('body div.footertop_pat').css('background-color'):$('body div.footertop').css('background-color');
	if(widowHeight > pageHeight){	
	$('body').css('height',widowHeight);
	$('body').css('background-color',background_color);
	}
}
/**** End of footer background extension *****/


	  function set_cookie ( name, value, view)
	    {
			var cookie_string = name + "=" + escape ( value )+ "; path=/";
	        
                document.cookie = cookie_string;
					/*$.ajax({
					type: "POST",
					data: "name= "+name+"&value= "+value+"&view= "+view,
					url: baseurl+"remove_survey_popup",
					cache:false,
					success:function(msg){
					    //alert(msg)
						//$('#set_remove_survey').trigger('click');
						$.ajax({
							type: "POST",
							data: "name= "+name+"&value= "+value+"&view= "+view,
							url: baseurl+"remove_survey_popup",
							cache:false,
							success:function(msg){
								//alert(msg)
								//$('#set_remove_survey').trigger('click');
								
					}
					});
					}
					});*/
	              
	    }

	    function get_cookie ( cookie_name )
	    {
	            var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
	            if ( results )
	              return ( unescape ( results[2] ) );
	            else
	              return null;
	    }

	  function set_surveypopup_cookie ( name, value)
	    {
		var exdate=new Date();
		var exdays=30;
		exdate.setDate(exdate.getDate()+exdays);
		var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
		var cookie_string = name + "=" + escape ( value )+ "; path=/;"+c_value;	        
                document.cookie = cookie_string;					
	    }	    
function remove_survey_popup()
{
  var view = getSiteView(document.URL);	
  set_surveypopup_cookie('remove_survey_popup','no');  
  tb_remove();
}
/*function showSurveyPopup(){
	
	
}*/

function swapImage(hoverObj,imgpath){
   
       hoverObj.style.background = 'url('+themeurl+'/images/'+imgpath+') top right no-repeat #fff';

}
function downloadSlideShow(slideId){
   window.open(baseurl + 'slideshow/download?slideId='+slideId);
}

function gettip(txt,elmId) {
  var pixIs=txt.length;
  if(pixIs >50){
    pixIs=txt.length*7+'px';
  }
  else{
    pixIs=txt.length*8+'px';
  }

  $("#"+elmId).css("width",pixIs);
  document.getElementById(elmId).innerHTML=txt;
}

function reset(elmId) {
  $("#"+elmId).css("width","0px");
  document.getElementById(elmId).innerHTML="";
}

function searchbuttonhome(obj){	
	 if($("#input_head").val() != ''){
		s = obj.src;		  
		 if(s.match(/btn_search\.gif/)){
		    obj.src = themeurl+'/images/redarrow231.png';
		  } else {
		    obj.src = themeurl+'/images/btn_search.gif';
		  }
	 }		  
}

function search_buttonhome(obj){	
	 if($("#input_head").val() != ''){
		s = obj.src;		  
		 if(s.match(/btn_search\.gif/)){
		    obj.src = themeurl+'/images/redarrow231.png';
		  } else {
		    obj.src = themeurl+'/images/btn_search.gif';
		  }
	 }	
}
	 
$(function() {
	 $('#input_head').keydown(function(e){
		 var sear = document.getElementById('input_head').value;		 
		 if(sear == '' || sear == 'Search'){
	        if (e.keyCode == 13) {
	        	return fn_sear();
	        }
		  }
		  
	    });
	 
	 $('#input_corp_head').keydown(function(e){
		 var sear = document.getElementById('input_corp_head').value;		 
		 if(sear == '' || sear == 'Search'){
	        if (e.keyCode == 13) {
	        	return corporate_fn_sear();
	        }
		  }
		  
	    });
	 
  // set opacity to nill on page load
  // on mouse over
  $("#meetHarmonic").hover(function () {
    // animate opacity to full
    $("#meetHarmonic").css("opacity","0");			
    $("#meetHarmonic").stop().animate({
      opacity: 1
    }, "slow");
  },
  // on mouse out
  function () {
    // animate opacity to nill
  });
		
  $("#meetHarmonic3").hover(function () {
    // animate opacity to full
    $("#meetHarmonic3").css("opacity","0");	
    $("#meetHarmonic3").stop().animate({	
      opacity: 1
    }, "slow");
  },
  // on mouse out
  function () {
    // animate opacity to nill
  });
		
  $("#meetHarmonic1").hover(function () {
    // animate opacity to full
    $("#meetHarmonic1").css("opacity","0");
    $("#meetHarmonic1").stop().animate({
      opacity: 1
    }, "slow");
  },
  // on mouse out
  function () {
    // animate opacity to nill
  });
		
  $("#meetHarmonic2").hover(function () {
    // animate opacity to full
    $("#meetHarmonic2").css("opacity","0");
    $("#meetHarmonic2").stop().animate({
      opacity: 1
    }, "slow");
  },
  // on mouse out
  function () {
    // animate opacity to nill
  });
});


function fnDisableButton(obj,imagepath){
	
	 if(imagepath.match(/btn_search\.gif/)){
		 
		 if($("#input_head").val() == ''){
			 document.getElementById(obj).src = themeurl+'/images/redarrow231_disable.png';			 
		  }else{
			  document.getElementById(obj).src = themeurl+'/images/btn_search.gif';
		  }
     }
}

/******** Set the video from the search results ************************************************************/

var today = new Date();
var expiry = new Date(today.getTime() + 365 * 24 * 60 * 60 * 1000);



function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1) { endstr = document.cookie.length; }
  return unescape(document.cookie.substring(offset, endstr));
  }

function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
	  //alert(alen);
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg) {
      return getCookieVal (j);
      }
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; 
    }
  return null;  
  }

function DeleteCookie (name,path) {
  if (GetCookie(name)) {
    document.cookie = name + "=" +
    ((path) ? "; path=" + path : "path=/") +    
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
  }

function SetCookieVideo (name,value,expires,path) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "path=/");
  }


function getVideoIdCookie(videoId){
	/*if(GetCookie ("VideoId") != null){
		DeleteCookie("VideoId","/");
	} else {*/
		SetCookieVideo("VideoId", videoId, expiry,"/");
	/*}*/
}
/******** End of setting the video as cookie from the search results ************************************************************/
/* Function to get the current site url */

function getSiteView(url){
	var view;
	  if(url.match('/providers') || url.match('/provider')  || url.match('/promyees') || url.match('/healthcaremanager') || url.match('/Healthcaremanagers') || url.match('/provider_ees_og')){
		view = 'healthcaremanagers';

	} else if(url.match('/payors') || url.match('/payor') || url.match('/payormyees') || url.match('/payor_ees_og')) {
		view = 'payors';
	} else if(url.match('/patients') || url.match('/patient')) {
		view = 'patient';
	} else if(url.match('/Clinicians') || url.match('/answercenter') || url.match('/myees') || url.match('/clinicians') || url.match('/ees_og') ){
		view = 'clinicians';
	} 
	return view;
}
function getGroupView(view){
    var pageview;
    if(view == 'healthcaremanagers')
    pageview = 'healthcaremanager_';
  else if(view == 'payors')
    pageview = 'payor_';
  else if(view == 'patient')
    pageview = 'patient_';	
  else
    pageview = '';
return pageview;
}

function fn_sear() {	
    var view = getSiteView(document.URL);
var pageview = getGroupView(view);
  var sear = document.getElementById('input_head').value; 
  if(document.getElementById('prodsear').name == 'prodsear'){
	  if(sear == '' || sear == 'Search') { 
	   $("#input_head").focus();		
	   $("#input_head").select();	
	  tb_show('', baseurl +pageview +'ees_og/popup?viewmode=popup&width=400&height=150&modal=true&msgtype=search-popup');
      return false;			  
	  } else {
      document.prodsear.submit();
      }
  }  
   return true; 
}

function corporate_fn_sear() {	
    var view = getSiteView(document.URL);
    var pageview = getGroupView(view);
	  var sear = document.getElementById('input_corp_head').value;
	  if(document.getElementById('prod_sear_corp').name == 'prod_sear_corp'){ 
		  if(sear == '' || sear == 'Search') {      
		  	tb_show('', baseurl +pageview +'ees_og/popup?viewmode=popup&width=400&height=150&modal=true&msgtype=search-popup');
			return false;
		  } else {
		    document.prod_sear_corp.submit();
		  }
	  }	  
	  return true;
	}

function password(){	
  var pass_div = document.getElementById("caphead");
  if(pass_div != null){
    var padding=parseInt($(".caphead").css("padding-top").replace('px', ''))+parseInt($(".homebottom").css("padding-top").replace('px', ''));
		
    if($(".footerhome").css("padding-top") != null){
      padding=+parseInt($(".footerhome").css("padding-top").replace('px', ''));
    }
  }
  var pageSize=getPageSize();
  document.getElementById('show_id').style.display     = "block";
  document.getElementById('show_id').style.height = pageSize[1]-padding+21+'px';
  document.getElementById('video_login').style.display = 'none';
  document.getElementById('video_confirm_list').style.display = 'none';
  document.getElementById('video_load').style.display = 'none';
 
  document.getElementById('popup_div').style.display   = "none";
}


function close_box(forgot_path){ 
  var destination = forgot_path;  
  
  if(destination != null){	
    window.location.href = baseurl+destination;
  }else{
    document.getElementById('show_id').style.display = 'none';   
    document.getElementById('video_login').style.display = 'none';
    document.getElementById('video_confirm_list').style.display = 'none';
    document.getElementById('video_load').style.display = 'none';
  }
}


function close_box_reg(forgot_path,arg1,arg2){ 
  var destination = forgot_path;  
  var arg1 = arg1;  
  var arg2 = arg2;  
  
  if(arg2 != null){	
    window.location.href = baseurl+arg1+'/'+arg2;
  }
  else{
    document.getElementById('show_id').style.display = 'none';
    document.getElementById('video_login').style.display = 'none';
    document.getElementById('video_confirm_list').style.display = 'none';
    document.getElementById('video_load').style.display = 'none';
  }
}

function close_box_new(){ 
  document.getElementById('show_id').style.display = 'none';
}

function getPageSize(){
  var xScroll, yScroll;
		
  if (window.innerHeight && window.scrollMaxY) {
    xScroll = window.innerWidth + window.scrollMaxX;
    yScroll = window.innerHeight + window.scrollMaxY;
  } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
    xScroll = document.body.scrollWidth;
    yScroll = document.body.scrollHeight;
  } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
    xScroll = document.body.offsetWidth;
    yScroll = document.body.offsetHeight;
  }
		
  var windowWidth, windowHeight;
		
  if (self.innerHeight) {	// all except Explorer
    if(document.documentElement.clientWidth){
      windowWidth = document.documentElement.clientWidth;
    } else {
      windowWidth = self.innerWidth;
    }
    windowHeight = self.innerHeight;
  } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
    windowWidth = document.documentElement.clientWidth;
    windowHeight = document.documentElement.clientHeight;
  } else if (document.body) { // other Explorers
    windowWidth = document.body.clientWidth;
    windowHeight = document.body.clientHeight;
  }
		
  // for small pages with total height less then height of the viewport
  if(yScroll < windowHeight){
    pageHeight = windowHeight;
  } else {
    pageHeight = yScroll;
  }
	
  // for small pages with total width less then width of the viewport
  if(xScroll < windowWidth){
    pageWidth = xScroll;
  } else {
    pageWidth = windowWidth;
  }
        
  return [pageWidth,pageHeight];
}

function bluerem(){
  document.getElementById('edit-name-2').value = "";
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr;
  for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages () { //v3.0
  var d=document;
  if(d.images){
    if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments;
    for(i=0; i<a.length; i++)
      if (a[i].indexOf("#")!=0){
        d.MM_p[j]=new Image;
        d.MM_p[j++].src=a[i];
      }
  }
}

function MenuloadImages () {
	var image1 = new Image;
	var image2 = new Image;
	var image3 = new Image;
	var image4 = new Image;
	var image5 = new Image;
	var image6 = new Image;
    var image7 = new Image;
    var image8 = new Image;
    var image9 = new Image;
	image1.src = themeurl+'/images/topnavsubbg_pro.gif';			
	image2.src = themeurl+'/images/topnavsubbg_spl.gif';			
	image3.src = themeurl+'/images/topnavsubbg_suprt.gif';			
	image4.src = themeurl+'/images/topnavsubbg_edu.gif';			
	image5.src = themeurl+'/images/topnavsubbg_info.gif';			
	image6.src = themeurl+'/images/topnavsubbg_ees-adv.gif';
    image7.src = themeurl+'/images/go_arrow_over.gif';
    image8.src = themeurl+'/images/Find_group_over_L.gif';
    image9.src = themeurl+'/images/Create_group_over_L.gif';
}

function MM_findObj (n, d) { //v4.01
  var p,i,x;
  if(!d) d=document;
  if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document;
    n=n.substring(0,p);
  }
  if(!(x=d[n])&&d.all) x=d.all[n];
  for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n);
  return x;
}

function MM_swapImage () { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments;
  document.MM_sr=new Array;
  for(i=0;i<(a.length-2);i+=3)
    if ((x=MM_findObj(a[i]))!=null){
      document.MM_sr[j++]=x;
      if(!x.oSrc) x.oSrc=x.src;
      x.src=a[i+2];
    }
}

/**
 * function to redirect the page based on the selected menu
 */
function selectMainMenu (id, url) {
  window.location.href = baseurl + url + '/' + id;
}

/**
 * Function to redirect the page
 */
function redirectPage (url, page) {
    if(page == "")
      window.location.href = baseurl + url;
	if(page == 1)  
	  window.location.href = '/'+ url ;
    else 
      window.location.href = '/'+page+'/'+ url ;     
}

function edit_user_profile(viewcheck,getview){
    
    if(viewcheck == getview || (viewcheck == "providers" && getview == "clinicians") || (viewcheck == "clinicians" && getview == "healthcaremanagers") || (viewcheck == "providers" && getview == "healthcaremanagers")){
         window.location.href = "myprofile/edit?view=" + getview;
    }    
    else{
        $.ajax({
        type: "POST",
        url: baseurl+"edit_profile_view",
        cache:false,
        success:function(msg){
            $(".edit_message").css("display","block");
        }

        });
     }
}

/**
 *Function to redirect the page in clinician's education block
 */
function redirectEducationPage(url)
{
    window.location.href=url;
}
/**
 * Function to aler the user to confirm redirection
 */
function confirmredirect(){
  $("#popup_div").show();
  $("#confirm_redirect_div").show();
  $("#orderprint").show();
}
 
/**
  * Functioin to close the order print window
  */
function closeorderprint(){
  $("#popup_div").hide();
  $("#confirm_redirect_div").hide();
  $("#orderprint").hide();
}

/**
 * Function to redirect the page
 */
function redirect(){
  closeorderprint();
  location.redirect = "http://www.jnjgateway.com";
}

function scheduledemo(){
  window.location.href = absurl +'/schedule/demo';
}

function replaceText () {
 /* if ($("#edit-pass").val() == "") {
    $("#password-text").show();
    $("#password-password").hide();
  }*/
}

function clearText(){	
  if ($("#forgot-pass-name").val() == "Email Address") {
    $("#forgot-pass-name").val('');
	document.getElementById("forgot-pass-name").value == "";
  }
}



function close_new(){
  var temp = document.getElementById('path').value;
  var path = document.getElementById('basepath').value;

  var loc = window.location;
  var url = loc.protocol+'//'+loc.host;
  // document.location.href= url +path +temp;
  document.location.href= baseurl + temp;
}

function bluerem(){
  document.getElementById('edit-name').value = "";
}

/**
 * Function to close the thickbox
 */
function close_thickbox () {
  tb_remove();
  $('body').css('overflow','auto');
}

function SetCookie(cookieName,cookieValue,nDays,path) {
  var today = new Date();
  var expire = new Date();
  if (nDays==null || nDays==0) nDays=1;
  expire.setTime(today.getTime() + 3600000*24*nDays);
  document.cookie = cookieName+"="+escape(cookieValue)+ ";expires="+expire.toGMTString()+";path="+path;
}

function DeleteCookie(name) {
  document.cookie = name +'=; expires=Thu, 01-Jan-70 00:00:01 GMT;';
}

var remove_tool_tip=false; /** Global variable to hide Web services tool-tip **/
function redirectShareURL (n)
{
   remove_tool_tip=true;
  var selectedtabname = $(".TabbedPanels li.TabbedPanelsTabSelected").html();
	var url = '';
	var share_url   = $("#favorite_page_url").val();
  share_url=share_url.replace("/About", "");
  share_url=share_url.replace("/Compare", "");
  share_url=share_url.replace("/Overview", "");
  share_url=share_url.replace("/interactive", "");
  share_url=share_url.replace("/surgical", "");
  share_url=share_url.replace("/training", "");
  share_url=share_url.replace("/acc-education", "");
  share_url=share_url.replace("/videos-downloads", "");
  share_url=share_url.replace("/videos", "");
  share_url=share_url.replace("/science-technology", "");
  share_url=share_url.replace("/how-to-use", "");
  share_url=share_url.replace("/description-specs", "");
  share_url=share_url.replace(/&/g, "%26");
  
  tabname = change_Tabname(selectedtabname);
   var view = getSiteView(document.URL);
  if(tabname) {
    if (view == 'patient'){
      if(navigator.userAgent.search('MSIE 6.0') != '-1'){
        if(share_url.search('#') !='-1'){
          var the_length=share_url.length;
          if(share_url.charAt(the_length-1)== '#'){
            share_url=share_url+tabname;
          }
        }else{
          share_url=share_url+"#"+tabname;
        }
     }
     else{
        share_url=share_url+"#"+tabname;
     }
    }
    else
        share_url=share_url+"/"+tabname;
}
  share_url=share_url.replace(/#/g, "%23");
	var share_title = $("#current_page_name").val();
 	switch(n)
	{
		case 1:
      share_url=share_url.replace(/%26/g, escape("%26"));
      url = 'http://twitter.com/home?status='+share_url;
		  break;
		case 2:
		  url = 'http://del.icio.us/post?url=' + share_url + '&title=' + share_title;
		  break;
		case 3:
		  url = 'http://reddit.com/submit?url=' + share_url + '&title=' + share_title;
		  break;
		case 4:
		  url = 'http://www.stumbleupon.com/submit?url=' + share_url + '&title=' + share_title;
		  break;
		case 5:
		  url = 'http://www.livejournal.com/update.bml?subject=' + share_title + '&event=' + share_url;
		  break;
		case 6:
		  url = 'http://api.addthis.com/oexchange/0.8/forward/wordpress/offer?url=' + share_url + '&title=' + share_title;
		  break;
		case 7:
		  url = 'http://digg.com/submit?phase=2&url=' + share_url + '&title=' + share_title;
		  break;
		case 8:
		  url = 'http://www.google.com/reader/link?url=' + share_url + '&title=' + share_title;
		  break;
		case 9:
		  url = 'http://www.linkedin.com/shareArticle?mini=true&url=' + share_url + '&title=' + share_title + '&summary=' + '&source';
		  break;
		case 10:
                   var myspace_share_url;
                   
                   $.ajax({
                        type: "POST",
                        url:  baseurl+"patient/myspace/shortenurl",
                        data: "longurl=" + share_url,
                        async: false,
                        success: function(shorten_url)
                        {
                            myspace_share_url = shorten_url;
                        }
                   });

		  var L = 1000;
                  //url = 'http://www.myspace.com/share?' + 't=' + encodeURIComponent(share_title)+ '&u=' + encodeURIComponent(myspace_share_url) + '&l=' + L;
                  url = 'http://www.myspace.com/index.cfm?fuseaction=postto&' + 't=' + encodeURIComponent(share_title)+ '&u=' + encodeURIComponent(myspace_share_url) + '&l=' + L;
		  break;
		case 11:
		  url = 'http://www.blogger.com/blog_this.pyra?t&u=' + share_url + '&n=' + share_title;
		  break;
		case 12:
		  url = 'http://www.google.com/bookmarks/mark?op=add&bkmk=' + share_url + '&title=' + share_title;
		  break;
		case 13:
		  url = 'http://www.newsvine.com/_tools/seed&save?u=' + share_url + '&h=' + share_title;
		  break;
		case 14:
		  url = 'http://www.netvibes.com/share?url=' + share_url + '&title=' + share_title;
		  break;
		case 15:
		  url = 'http://myweb2.search.yahoo.com/myresults/bookmarklet?u=' + share_url + '&t=' + share_title;
		  break;
		default:
		  url = '';
	}
	
	closeLayer('service_tool_tip');
	
	tb_show('', baseurl + 'exit/popup?viewmode=popup&width=400&height=300&modal=true');
	$("#redirecturl").val(url);
	
	return false;
}

function redirectEventRegister(url)
{	
	closeEventPopup('details_popup');
	tb_show('', baseurl + 'exit/popup?viewmode=popup&width=400&height=300&modal=true');
	$("#redirecturl").val(url);
	
	return false;
}



function ans_cancel_question_login_frm(userid){

	if(userid == 0){
	 $('#edit-ans-user-name').val('');
	 $('#edit-email').val('');
	}

	$('#edit-submit-question').val('');
}

function submitquestion_popup() {
	  tb_show('', baseurl + 'submitquestion/popup?viewmode=popup&width=400&height=150&modal=true');
}
function pro_submitquestion_popup() {
	  tb_show('', baseurl + 'pro_submitquestion/popup?viewmode=popup&width=400&height=150&modal=true');
}

function copySearckKeyword (text) {
  $("#advanceinput").val(text);
  $("#keyword-specialty").val(text);
  $("#keyword-media").val(text);
}

function ans_form_validate(user_id) {
var error = '';

	 if (user_id  !=  '' && user_id > 0 ) {

	 }
	 else if (!$('#edit-agree').attr("checked")) {
	  	return false;
	 }
	 if ($('#edit-ans-user-name').val() == ''){
   		$('#edit-ans-user-name-error').empty().append('Please enter your name');
   		error = '#edit-ans-user-name';
	 }
         else if(!isAlphanumeric_name($.trim($('#edit-ans-user-name').val()))){
         $('#edit-ans-user-name-error').empty().append('Please enter your valid name');
         error = '#edit-ans-user-name';
         }
          else {
   		$('#edit-ans-user-name-error').empty().append('&nbsp;');
	 }

	 if ($('#edit-email').val() == '') {
   		$('#edit-email-error').empty().append('Please enter email address');
   		error ='#edit-email-error';
	 }
   else if(!validateEmail($.trim($("#edit-email").val()))){
   		$('#edit-email-error').empty().append('Please enter valid email address');
   		error ='#edit-email-error';
   }
	 else {
	 		$('#edit-email-error').empty().append('&nbsp;');
	 }

	 if ($('#edit-submit-question').val()=='') {
   		$('#edit-submit-question-error').empty().append('Please enter your question');
	    error = '#edit-submit-question' ;
	 }
         else if(!isAlphanumeric($("#edit-submit-question").val())){
   		$('#edit-submit-question-error').empty().append('Please enter valid question');
   		error ='#edit-submit-question';
   }
       else {
   		$('#edit-submit-question-error').empty().append('&nbsp;');
	 }
	 if (error != '') {
	 	return false;
	 }
	 return true;

}
function isAlphanumeric(elem){

	var flag = 0;
	var iChars = "*|,-._!^\":<>[]{}`\';()@&$#%0123456789";
	for (var i = 0; i < elem.length; i++) {
		if (iChars.indexOf(elem.charAt(i)) != -1){
			flag++;
		}
	}
	var alphaExp = /^[a-zA-Z][a-zA-Z0-9_\-\.]+$/;

	if(IsNumeric(elem)){
		return false;
	}

	if(elem.match(alphaExp)){
		return true;
	}else if(elem.length != flag){
		return true;
	}else{
		return false;
	}

}

function isAlphanumeric_name(elem)
{
       //var alphaExp = /^[a-zA-Z ]+[\S]$/;
       var alphaExp = /^[a-z\sA-Z0-9]+$/;
         if(elem.match(alphaExp)){
            
		return true;
	}else{
		return false;
	}

}
function IsNumeric(zipText) {
  var validChars = "0123456789";
  var isNumber = true;
  var Char;
  for (i = 0; i < zipText.length && isNumber == true; i++) {
    Char = zipText.charAt(i);
    if (validChars.indexOf(Char) == -1) {
      isNumber = false;
    }
  }
  return isNumber;
}

function clear_field(obj) {
var fieldId = obj.id;
var fieldVal = obj.value;
if (fieldId == 'validateFormUserName' && fieldVal == 'Example: Jack') {
  obj.value = '';
}

if (fieldId == 'validateFormUserEmail' && fieldVal == 'Example: jackwhite@gmail.com') {
  obj.value = '';
}

if (fieldId == 'validateFormPagePhone' && fieldVal == 'Example: 080-123-3023') {
  obj.value = '';
}

if (fieldId == 'notloggedHospitalPractice' && fieldVal == 'Example: Northridge Hospital Medical Center') {
  obj.value = '';
}


}
function validateEmail(emailaddress) {
  var isEmailAddress = false;
  var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Z\sa-z]{2,4})+$/;
  if (reg.test(emailaddress)) {
	 $.ajax({
            type: "POST",
            url:  baseurl+"anscenter/validate/email",
            data: "from_email=" + emailaddress,
            async: false,
            success: function(e)
            {
                if(e == "1")
                    isEmailAddress = true;
            }
    });
  }
  return isEmailAddress;
}

function validateEmail_duplicate(emailaddress, page_details) {
  var isEmailAddress = false;
 $.ajax({
        type: "POST",
        url:  baseurl+"anscenter/validate/reg_email",
        data: "from_email=" + emailaddress,
        async: false,
        success: function(e)
        {
            if(e == 1)
                isEmailAddress = true;
            else if(e == 2 && page_details == "register")
                isEmailAddress = true;

        }
});		 
  return isEmailAddress;
}

function createGroup (dest) {
    var view = getSiteView(document.URL);
var pageview = getGroupView(view);
	window.location.href = baseurl + pageview +"ees_og/cg?destination=" + dest;
}
function groupactive(grouplist, view, num)
{  var group;
  if(grouplist == '')grouplist ='Overview';
  if(view == 'clinicians')group = 'groups';else group = 'group';
	$.ajax({
        type: "POST",
        url:  group,
        data: "grptype=" + grouplist + "&num=" + num,
        async: false,
        success: function(e)
        {
            var strval = document.getElementById("grpcrt_left");
            var grphead = document.getElementById("group_type_list_name");            
            strval.innerHTML = e;
            $(document).ready(function () {
                if(grouplist == 'Overview'){
                    $("#group_type_list_name").html("<h4 class='toppad botpad'>Featured Groups</h4>");
                } else {
                    if(grouplist == "Speciality")$("#group_type_list_name").html("<h4 class='toppad botpad'>Specialty Groups</h4>");
                    else $("#group_type_list_name").html("<h4 class='toppad botpad'>"+grouplist+" Groups</h4>");
                }
                switch(grouplist){
                  case 'Overview':
                      $("#Overview").attr('class', 'grplan_tableft');
                      $("#Overview").removeClass("grplan_tabcenter_left");
                      $('#Speciality').attr('class', 'grplan_tabcenter');
                      $("#Speciality").removeClass("grplan_tableft_center");
                      $("#Product").attr('class', 'grplan_tabcenter');
                      $("#Product").removeClass("grplan_tableft_center");
                      $("#Special_Interest").attr('class', 'grplan_tabright');
                      $("#Special_Interest").removeClass("grplan_tableft_right");
                    break;
                  case 'Speciality':
                      $("#Overview").attr('class',"grplan_tabcenter_left");
                      $("#Overview").removeClass("grplan_tableft");
                      $('#Speciality').attr('class', 'grplan_tableft_center');
                      $("#Speciality").removeClass("grplan_tabcenter");
                      $("#Product").attr('class', 'grplan_tabcenter');
                      $("#Product").removeClass("grplan_tableft_center");
                      $("#Special_Interest").attr('class', 'grplan_tabright');
                      $("#Special_Interest").removeClass("grplan_tableft_right");
                    break;
                  case 'Product':
                    $("#Overview").attr('class',"grplan_tabcenter_left");
                      $("#Overview").removeClass("grplan_tableft");
                      $("#Product").attr('class', 'grplan_tableft_center');
                        $("#Product").removeClass("grplan_tabcenter");
                        $('#Speciality').attr('class', 'grplan_tabcenter');
                      $("#Speciality").removeClass("grplan_tableft_center");
                      $("#Special_Interest").attr('class', 'grplan_tabright');
                      $("#Special_Interest").removeClass("grplan_tableft_right");
                    break;
                  case 'Special Interest':
                    $("#Overview").attr('class',"grplan_tabcenter_left");
                      $("#Overview").removeClass("grplan_tableft");
                      $("#Product").attr('class', 'grplan_tabcenter');
                      $("#Product").removeClass("grplan_tableft_center");
                      $("#Special_Interest").attr('class', 'grplan_tableft_right');
                      $("#Special_Interest").removeClass("grplan_tabright");
                      $('#Speciality').attr('class', 'grplan_tabcenter');
                      $("#Speciality").removeClass("grplan_tableft_center");
                    break;
                }
            });
        }
});
  
}
function group_load(grouplist){
   if(grouplist == 'Overview'){
                    $("#group_type_list_name").html("<h4 class='toppad botpad'>Featured Groups</h4>");
                } else {
                    if(grouplist == "Speciality")$("#group_type_list_name").html("<h4 class='toppad botpad'>Specialty Groups</h4>");
                    else $("#group_type_list_name").html("<h4 class='toppad botpad'>"+grouplist+" Groups</h4>");
                }
                switch(grouplist){
                  case 'Overview':
                      $("#Overview").attr('class', 'grplan_tableft');
                      $("#Overview").removeClass("grplan_tabcenter_left");
                      $('#Speciality').attr('class', 'grplan_tabcenter');
                      $("#Speciality").removeClass("grplan_tableft_center");
                      $("#Product").attr('class', 'grplan_tabcenter');
                      $("#Product").removeClass("grplan_tableft_center");
                      $("#Special_Interest").attr('class', 'grplan_tabright');
                      $("#Special_Interest").removeClass("grplan_tableft_right");
                    break;
                  case 'Speciality':
                      
                      $("#Overview").attr('class',"grplan_tabcenter_left");
                      $("#Overview").removeClass("grplan_tableft");
                      $('#Speciality').attr('class', 'grplan_tableft_center');
                      $("#Speciality").removeClass("grplan_tabcenter");
                      $("#Product").attr('class', 'grplan_tabcenter');
                      $("#Product").removeClass("grplan_tableft_center");
                      $("#Special_Interest").attr('class', 'grplan_tabright');
                      $("#Special_Interest").removeClass("grplan_tableft_right");
                    break;
                  case 'Product':
                    $("#Overview").attr('class',"grplan_tabcenter_left");
                      $("#Overview").removeClass("grplan_tableft");
                      $("#Product").attr('class', 'grplan_tableft_center');
                        $("#Product").removeClass("grplan_tabcenter");
                        $('#Speciality').attr('class', 'grplan_tabcenter');
                      $("#Speciality").removeClass("grplan_tableft_center");
                      $("#Special_Interest").attr('class', 'grplan_tabright');
                      $("#Special_Interest").removeClass("grplan_tableft_right");
                    break;
                  case 'Special Interest':
                    $("#Overview").attr('class',"grplan_tabcenter_left");
                      $("#Overview").removeClass("grplan_tableft");
                      $("#Product").attr('class', 'grplan_tabcenter');
                      $("#Product").removeClass("grplan_tableft_center");
                      $("#Special_Interest").attr('class', 'grplan_tableft_right');
                      $("#Special_Interest").removeClass("grplan_tabright");
                      $('#Speciality').attr('class', 'grplan_tabcenter');
                      $("#Speciality").removeClass("grplan_tableft_center");
                    break;
                    
                }
}
function group_active(grouplist, input_d, sort, num)
{ 
	$.ajax({
        type: "POST",
        url:  "discussion_group",
        data: "grptype=" + grouplist + "&input_d=" + input_d + "&sort=" + sort + "&num=" + num,
        async: false,
        success: function(e)
        {
            var strval = document.getElementById("grpcrt_left");
            var grphead = document.getElementById("group_type_list_name");
            strval.innerHTML = e;
            $(document).ready(function () {
                if(grouplist == 'Overview'){
                    $("#group_type_list_name").html("<h4 class='toppad botpad'>Featured Groups</h4>");
                } else {
                    if(grouplist == "Speciality")$("#group_type_list_name").html("<h4 class='toppad botpad'>Specialty Groups</h4>");
                    else $("#group_type_list_name").html("<h4 class='toppad botpad'>"+grouplist+" Groups</h4>");
                }
                switch(grouplist){
                  case 'Overview':
                      $("#Overview").attr('class', 'grplan_tableft');
                      $("#Overview").removeClass("grplan_tabcenter_left");
                      $('#Speciality').attr('class', 'grplan_tabcenter');
                      $("#Speciality").removeClass("grplan_tableft_center");
                      $("#Product").attr('class', 'grplan_tabcenter');
                      $("#Product").removeClass("grplan_tableft_center");
                      $("#Special_Interest").attr('class', 'grplan_tabright');
                      $("#Special_Interest").removeClass("grplan_tableft_right");
                    break;
                  case 'Speciality': 
                      $("#Overview").attr('class',"grplan_tabcenter_left");
                      $("#Overview").removeClass("grplan_tableft");
                      $('#Speciality').attr('class', 'grplan_tableft_center');
                      $("#Speciality").removeClass("grplan_tabcenter");
                      $("#Product").attr('class', 'grplan_tabcenter');
                      $("#Product").removeClass("grplan_tableft_center");
                      $("#Special_Interest").attr('class', 'grplan_tabright');
                      $("#Special_Interest").removeClass("grplan_tableft_right");
                    break;
                  case 'Product': 
                    $("#Overview").attr('class',"grplan_tabcenter_left");
                      $("#Overview").removeClass("grplan_tableft");
                      $("#Product").attr('class', 'grplan_tableft_center');
                        $("#Product").removeClass("grplan_tabcenter");
                        $('#Speciality').attr('class', 'grplan_tabcenter');
                      $("#Speciality").removeClass("grplan_tableft_center");
                      $("#Special_Interest").attr('class', 'grplan_tabright');
                      $("#Special_Interest").removeClass("grplan_tableft_right");
                    break;
                  case 'Special Interest':
                    $("#Overview").attr('class',"grplan_tabcenter_left");
                      $("#Overview").removeClass("grplan_tableft");
                      $("#Product").attr('class', 'grplan_tabcenter');
                      $("#Product").removeClass("grplan_tableft_center");
                      $("#Special_Interest").attr('class', 'grplan_tableft_right');
                      $("#Special_Interest").removeClass("grplan_tabright");
                      $('#Speciality').attr('class', 'grplan_tabcenter');
                      $("#Speciality").removeClass("grplan_tableft_center");
                    break;
                }
            });
        }
});

}

/*****Payors Media Downloads and Videos******/

/**
 * Function to downloads video
 */
function payors_downloadableResults(type,keyword){

      keyword = "'"+keyword+"'";

      $('#video').html('<a href="javascript:payors_medialist(\'all\','+keyword+')">Video</a>');
	
	  $('#featured_result').html("Loading Please wait");   
      $('#downloads').html('Downloads');
	  
	  $.ajax({
		type: "POST",
		url: baseurl+"payor/downloadable",
		data: "type=" + type +"&input="+keyword,
		success: function(msg){
          //alert(msg.length);
		  if(msg.length <15){
			if(type == 'all'){
			  msg = 'No items  Exists';
			}
			else{
			  msg = 'No items of '+type+' Exists';
			}
		  }
		  $('#featured_result').html(msg);
		}
	  });  
}
/**
 * Function to play video
 */

function payors_medialist(type,keyword){

  keyword = "'"+keyword.replace(/\'/g,"\\\'")+"'";
  
   $('#video').html('<a href="javascript:payors_medialist(\'all\','+keyword+')">Video</a>');
  $('#downloads').html('<a href="javascript:payors_downloadableResults(\'all\','+keyword+')">Downloads</a>');
  $('#video').html("Video");
  $('#featured_result').html("Loading Please wait");
  $.ajax({
    'type': "POST",
	'data': 'input=' + keyword,
    'url': baseurl+"payor/medialist/ajax",
    'success': function(msg){
           $('#featured_result').html(msg);
    }
  });
}

/*****End of Payors Media Downloads and Videos******/

/*****Patient Media Downloads and Videos******/

/**
 * Function to downloads video
 */

function patient_downloadableResults(type,keyword){

      keyword = "'"+keyword+"'";

      $('#video').html('<a href="javascript:patient_medialist(\'all\','+keyword+')">Video</a>');

	  $('#featured_result').html("Loading Please wait");
      $('#downloads').html('Downloads');

	  $.ajax({
		type: "POST",
		url: baseurl+"patient/downloadable",
		data: "type=" + type +"&input="+keyword,
		success: function(msg){
          //alert(msg.length);
		  if(msg.length <15){
			if(type == 'all'){
			  msg = 'No items  Exists';
			}
			else{
			  msg = 'No items of '+type+' Exists';
			}
		  }
		  $('#featured_result').html(msg);
		}
	  });
}

/*****Patient Media Downloads and Videos******/

/**
 * Function to downloads video
 */

function patient_medialist(type,keyword){

  keyword = "'"+keyword.replace(/\'/g,"\\\'")+"'";

   $('#video').html('<a href="javascript:patient_medialist(\'all\','+keyword+')">Video</a>');
  $('#downloads').html('<a href="javascript:patient_downloadableResults(\'all\','+keyword+')">Downloads</a>');
  $('#video').html("Video");
  $('#featured_result').html("Loading Please wait");
  $.ajax({
    'type': "POST",
	'data': 'input=' + keyword,
    'url': baseurl+"patient/medialist/ajax",
    'success': function(msg){
           $('#featured_result').html(msg);
    }
  });
}

/*****End of Patient Media Downloads and Videos******/

