function SiteSeal(img,type){
if(window.location.protocol.toLowerCase()=="https:"){var mode="https:";} else {var mode="http:";}
var host=location.host;
var baseURL=mode+"//seals.networksolutions.com/siteseal_seek/siteseal?v_shortname="+type+"&v_querytype=W&v_search="+host+"&x=5&y=5";
document.write('<a href="#" onClick=\'window.open("'+baseURL+'","'+type+'","width=450,height=500,toolbar=no,location=no,directories=no,\
status=no,menubar=no,scrollbars=no,copyhistory=no,resizable=no");return false;\'>\
<img src="'+img+'" style="border:none;" oncontextmenu="alert(\'This SiteSeal is protected\');return false;"></a>');}



function Translate(lan)
{
window.open('http://www.windowslivetranslator.com/BV.aspx?ref=AddIn&lp='+lan+'&a='+encodeURIComponent(location.href) );  
 
}

function BookMark()
{
window.open('http://www.addthis.com/bookmark.php?wt=nw&pub=mercola&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title), 'addthis', 'scrollbars=yes,menubar=no,width=620,height=520,resizable=yes,toolbar=no,location=no,status=no,screenX=200,screenY=100,left=200,top=100');
                                                
}

function NotAuthorized()
{
     alert('You are not authorized to vote on this post.');
}

function AuthorOfPost(votingAuthor)
{
   alert('You can not vote on your own post.');
}

//For Checking of duplicates Articles being saved
function CheckDuplicate()
{
var txt = document.getElementById('messagetext');
txt.innerHTML = "Article Already saved in your Favorite List";
var divContentMsg = document.getElementById("ShareFavoritesSaveMessage").innerHTML;
Shadowbox.open({
        player:     'html',
        content:    divContentMsg,
        height:     158,
        width:      600,
        flashBgColor: '', 
        title: ''
    });  
return false;
}
// END


//Function to Email a Friend
function EmailToFriend()
{
   parent.location = 'mailto:?Subject=Healthy News Article from Mercola.com&body=A friend of yours highly recommends you read this health article: ' + self.location ;
}

//to show login div for anonymous user

var lastDivId = "";
var lastDiv = "";
var commonDiv = 0;

function ShowTopLoginDiv()
{

    document.getElementById('LoginDivTop').style.display = 'none';

    var logindiv = document.getElementById('LoginDivTop');   

    if(logindiv != "")
    {
       logindiv.style.display = "block";
    	commonDiv = 0;
    } 
   
     
    return true;

}

function ShowDiv(currentDivId)
{     
    //document.getElementById('LoginDivTop').style.display = 'none';
    //document.getElementById('PostDiv0').style.display = 'none';
    if(lastDivId != "")
    {
        var LastDiv;
        LastDiv = document.getElementById('PostDiv' + lastDivId);
	if(LastDiv != null)
        {
		LastDiv.innerHTML = '';
        	LastDiv.style.display = 'none';
	}
    }    
    lastDivId = currentDivId;
    var CurrentDiv;
    CurrentDiv = document.getElementById('PostDiv' + currentDivId);
    CurrentDiv.style.display = 'block';
    CurrentDiv.innerHTML = document.getElementById('Login').innerHTML;

    if(commonDiv == 1)
    {
        var logindiv = document.getElementById('LoginDiv');
        logindiv.style.display = "none";
        commonDiv = 0;
    }    
}


function ShowHideLoginDiv(IsBannedUser)
{
   //document.getElementById('LoginDivTop').style.display = 'none';
  //document.getElementById('PostDiv0').style.display = 'none';
   var logindiv = document.getElementById('LoginDiv');
   
   if(IsBannedUser==1)
   {
      alert("Sorry! your account is banned. You can not post comment now. Please contact the administrator.");  
      Set_Cookie( 'FocusCookie', 'true', 365, '/', '', '' ); 
      return false;
   }
   else
   {
        if(lastDivId != "")
        {
            var LastDiv;
            LastDiv = document.getElementById('PostDiv' + lastDivId);
            LastDiv.innerHTML = '';
            LastDiv.style.display = 'none';
        }
        logindiv.style.display = "block";
        commonDiv = 1;
        return true;

    }         
    Set_Cookie( 'FocusCookie', 'true', 365, '/', '', '' ); 
}

function ShowSpammingDiv(currentDivId,userID,hiddenControlUserID,hiddenSelectPostID)
{
  //document.getElementById('PostDiv0').style.display = 'none';
    if(lastDivId != "")
    {
        var LastDiv;
        LastDiv = document.getElementById('PostDiv' + lastDivId);
         if(LastDiv!=null)
        {
        	LastDiv.innerHTML ="";
        	LastDiv.style.display = 'none';
        }
    }    
    lastDivId = currentDivId;
    var CurrentDiv;
    var postid;
    CurrentDiv = document.getElementById('PostDiv' + currentDivId);   
    CurrentDiv.style.display = 'block';
    CurrentDiv.innerHTML = document.getElementById('divSpam').innerHTML;
    var hdnControl = document.getElementById(hiddenControlUserID);
    if(hdnControl != null)
    {
        hdnControl.value = userID;
    }
    var hdnPostID = document.getElementById(hiddenSelectPostID);  
    if(hdnPostID != null)
    {
        hdnPostID.value = currentDivId;
    }
}

function CharacterLimitOLD(multilineTextBox)
{          
    var txtobj = document.getElementById(multilineTextBox);
    if (txtobj.value.length==2000*1) 
        return true;
    CharacterCount(multilineTextBox);
}

/*function CharacterCount(multilineTextBox) 
{    
  var taObj=document.getElementById(multilineTextBox);
  if (taObj.value.length > 2000*1)
  {
    taObj.value = taObj.value.substring(0,2000*1);
  }      
   var countingMessage1 = document.getElementById('countingMessage1');
   var countingMessage2 = document.getElementById('countingMessage2');
   countingMessage1.innerHTML = 2000-taObj.value.length; 
   countingMessage2.innerHTML = 2000-taObj.value.length;  
}*/

function ShowBanningMsg(Action)
{
  if(Action=='Vote')
  {
      alert('Sorry! your account is banned. You can not vote on this post. Please contact the administrator.');
  }
  else if(Action=='Spam')
  {
    alert('You can not spam on this post.');
  }
  else if(Action=='Edit')
  {
    alert('Sorry! your account is banned. You can not edit this post. Please contact the administrator.');
  }
  else if(Action=='AddFriend')
  {
    alert('Sorry! your account is banned. You can not add this user as friend. Please contact the administrator.');
  }
  else if(Action=='SendEmail')
  {
    alert('Sorry! your account is banned. You can not send mail to the user. Please contact the administrator.');
  }
  else if(Action=='Reply')
  {
    alert('Sorry! your account is banned. You can not reply yo this comment. Please contact the administrator.');
  }
  
    
}

var persistclose=0 //set to 0 or 1. 1 means once the bar is manually closed, it will remain closed for browser session
var startX = 750 //set x offset of bar in pixels
var startY = 300 //set y offset of bar in pixels
var verticalpos="fromtop" //enter "fromtop" or "frombottom"

function iecompattest()
{
    return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function get_cookie(Name) 
{
    var search = Name + "="
    var returnvalue = "";

    if (document.cookie.length > 0) 
    {
        offset = document.cookie.indexOf(search)
        if (offset != -1) 
        {
            offset += search.length
            end = document.cookie.indexOf(";", offset);
            if (end == -1) end = document.cookie.length;
                returnvalue=unescape(document.cookie.substring(offset, end))
        }
    }
    return returnvalue;
}

function Show_SubCommentDiv(currentDivId, hiddenSelectedPostId)
{         
    //document.getElementById('LoginDivTop').style.display = 'none';
    if(lastDivId != "")
    {
        var LastDiv;
        LastDiv = document.getElementById('PostDiv' + lastDivId);
        if(LastDiv != null)
        {
            LastDiv.innerHTML ="";
            LastDiv.style.display = 'none';
        }
    }    
    lastDivId = currentDivId;
    var CurrentDiv;
    CurrentDiv = document.getElementById('PostDiv' + currentDivId);
    CurrentDiv.style.display = 'block';
    CurrentDiv.innerHTML = document.getElementById('divPostSubcomment').innerHTML;

    if(commonDiv == 1)
    {
        //var logindiv = document.getElementById('LoginDiv');
        //logindiv.style.display = "none";
        commonDiv = 0;
    }
    
     var selectedPostId = document.getElementById(hiddenSelectedPostId);
     selectedPostId.value=currentDivId;    
     
     var countingMessage1 = document.getElementById('countingMessagePostSubComment');    
     countingMessage1.innerHTML = countingMessage1.innerHTML + 2000;  
} 

function SetPostIDToHiddenField(postid,hiddenSelectedPostId)
{                 
     var selectedPostId = document.getElementById(hiddenSelectedPostId);
     selectedPostId.value = postid;     
} 

function Show_EditCommentDiv(currentDivId, lblComment, txtEditComment, hiddenSelectedPostId)
{     
    //document.getElementById('LoginDivTop').style.display = 'none';            

    if(lastDivId != "")
    {
        var LastDiv;
        LastDiv = document.getElementById('PostDiv' + lastDivId);
        if(LastDiv != null)
	{
	LastDiv.innerHTML = '';
        LastDiv.style.display = 'none';
	}
    }    
    lastDivId = currentDivId;
    var CurrentDiv;
    CurrentDiv = document.getElementById('PostDiv' + currentDivId);
    CurrentDiv.style.display = 'block';
    CurrentDiv.innerHTML = document.getElementById('divEditcomment').innerHTML;

    if(commonDiv == 1)
    {
        //var logindiv = document.getElementById('LoginDiv');
        //logindiv.style.display = "none";
        commonDiv = 0;
    }    
    
    var selectedPostId = document.getElementById(hiddenSelectedPostId);
    selectedPostId.value=currentDivId;  
    
    var labelComment = document.getElementById(lblComment);
    var textComment = document.getElementById(txtEditComment);
    if(navigator.appName == "Netscape")
    {   
        textComment.value = labelComment.textContent;        
    }
    else
    {   
        textComment.value = labelComment.innerText;	
    }    
    //textComment.value = labelComment.innerHTML;
     var countingMessage2 = document.getElementById('countingMessageEditComment');
     countingMessage2.innerHTML = 'Characters Remaining : ' + (2000-textComment.value.length); 
}

function ShowEditReplySuccessDiv()
{    
    var LastDiv = document.getElementById('PostDiv' + lastDivId);
    LastDiv.innerHTML = document.getElementById('divCommentEditReplySuccess').innerHTML;
}

function hideSelecteddiv()
{ 
    var LastDiv = document.getElementById('PostDiv' + lastDivId);
    LastDiv.innerHTML = '';
}

//--------------------------------CreateUser.aspx starts-------------------------------------
function FieldsRequired()
{ 
    var email = document.getElementById("txtEmail");
    var emailDiv = document.getElementById("emailDiv");
    if(email.value == '')
    {
        emailDiv.innerHTML = "<img src='../themes/default/images/error_x.jpg'  hspace='3' align='left'><span style=\"color:Red;\">Email is required.</span>";
        emailDiv.style.display = "block";
        return false;
    }
    emailDiv.style.display = "none";    
    
    if(checkEmailSyntax(email.value) == false)
    {
        emailDiv.innerHTML = "<img src='../themes/default/images/error_x.jpg'  hspace='3' align='left'><span style=\"color:Red;\">Invalid Email address.</span>";
        emailDiv.style.display = "block";
        return false;
    }
    
    var password = document.getElementById("txtPassword");
    var passwordDiv = document.getElementById("passwordDiv");  
    if(password.value == '')
    {
        passwordDiv.innerHTML = "<img src='../themes/default/images/error_x.jpg'  hspace='3' align='left'><span style=\"color:Red;\">Password is required.</span>";
        passwordDiv.style.display = "block";
        return false;
    }      
    passwordDiv.style.display = "none";       
       
    if(password.value.length < 6)
    {
        passwordDiv.innerHTML = "<img src='../themes/default/images/error_x.jpg'  hspace='3' align='left'><span style=\"color:Red;\">Password must have atleast 6 characters.</span>";
        passwordDiv.style.display = "block";
        return false;
    }
    passwordDiv.style.display = "none";         
   
    var confirmPassword = document.getElementById("txtConfirmPassword");
    var confirmPasswordDiv = document.getElementById("confirmPasswordDiv");    
    if(confirmPassword.value == '')
    { 
        confirmPasswordDiv.innerHTML = "<img src='../themes/default/images/error_x.jpg'  hspace='3' align='left'><span style=\"color:Red;\">Confirm Password is required.</span>";
        confirmPasswordDiv.style.display = "block";
        return false;
    }
    confirmPasswordDiv.style.display = "none";
    
    if(confirmPassword.value != password.value)
    {
        confirmPasswordDiv.innerHTML = "<img src='../themes/default/images/error_x.jpg'  hspace='3' align='left'><span style=\"color:Red;\">Confirm Password does not match.</span>";
        confirmPasswordDiv.style.display = "block";
        return false;
    }
    confirmPasswordDiv.style.display = "none";
    
    var securityQue = document.getElementById("ddlSecurityQuestion");
    var securityAns = document.getElementById("txtSecurityAnswer");
    var securityQuestionDiv = document.getElementById("securityQuestionDiv");
    var securityAnswerDiv = document.getElementById("securityAnswerDiv");    
   
    if(securityQue.value == 'Security Question')                   
    {             
       securityQuestionDiv.innerHTML = "<img src='../themes/default/images/error_x.jpg'  hspace='3' align='left'><span style=\"color:Red;\">Security Question is required</span>";
       securityQuestionDiv.style.display = 'block';
       return false;
    }
    securityQuestionDiv.style.display = 'none'; 
    
    if(securityAns.value == '')
    {             
        securityAnswerDiv.innerHTML = "<img src='../themes/default/images/error_x.jpg'  hspace='3' align='left'><span style=\"color:Red;\">Security Answer is required.</span>";
        securityAnswerDiv.style.display = 'block';
        return false; 
    }   
    securityAnswerDiv.style.display = 'none';          
      
    var txtdisplayname = document.getElementById("txtdisplayname");
    var displayNameDiv = document.getElementById("displayNameDiv");
    if(txtdisplayname.value == '')
    {            
        displayNameDiv.innerHTML = "<img src='../themes/default/images/error_x.jpg'  hspace='3' align='left'><span style=\"color:Red;\">Display name is required.</span>";
        displayNameDiv.style.display = "block";
        return false;
    }
    displayNameDiv.style.display = "none";    
    
    var txtFirstName = document.getElementById("txtFirstName");
    var firstNameDiv = document.getElementById("firstNameDiv");
    if(txtFirstName.value == '')
    {            
        firstNameDiv.innerHTML = "<img src='../themes/default/images/error_x.jpg'  hspace='3' align='left'><span style=\"color:Red;\">First name is required.</span>";
        firstNameDiv.style.display = "block";
        return false;
    }
    firstNameDiv.style.display = "none";     
    
    var txtLastName = document.getElementById("txtLastName");
    var lastNameDiv = document.getElementById("lastNameDiv");
    if(txtLastName.value == '')
    {            
        lastNameDiv.innerHTML = "<img src='../themes/default/images/error_x.jpg'  hspace='3' align='left'><span style=\"color:Red;\">Last name is required.</span>";
        lastNameDiv.style.display = "block";
        return false;
    }
    lastNameDiv.style.display = "none";       
     
    var txtCity = document.getElementById("txtCity");
    var cityDiv = document.getElementById("cityDiv");
    if(txtCity.value == '')
    {
        cityDiv.innerHTML = "<img src='../themes/default/images/error_x.jpg'  hspace='3' align='left'><span style=\"color:Red;\">City name is required.</span>";
        cityDiv.style.display = "block";
        return false;
    }
    cityDiv.style.display = "none";
    
    var ctry = document.getElementById("ddlcountries");
    var pin = document.getElementById("txtPin");
    var pinDiv = document.getElementById("pinDiv");
    if(isNaN(pin.value))
    {
        pinDiv.innerHTML = "<img src='../themes/default/images/error_x.jpg'  hspace='3' align='left'><span style=\"color:Red;\">Zip code must be numeric.</span>";
        pinDiv.style.display = "block";
        return false;
    } 
    
    if(ctry.value == "1" || ctry.value == "5")
    {
        if(pin.value == '')
        {
            pinDiv.innerHTML = "<img src='../themes/default/images/error_x.jpg'  hspace='3' align='left'><span style=\"color:Red;\">Zip code is required.</span>";
            pinDiv.style.display = "block";
            return false;
        }   
        pinDiv.style.display = "none";
        
        if(pin.value.length < 5 && ctry.value == "1")
        {
            pinDiv.innerHTML = "<img src='../themes/default/images/error_x.jpg'  hspace='3' align='left'><span style=\"color:Red;\">Please enter 5 digits zip code for US.</span>";
            pinDiv.style.display = "block";
            return false;
        }   
        pinDiv.style.display = "none"; 
        if(pin.value.indexOf(' ') != -1)
        {
            pinDiv.innerHTML = "<img src='../themes/default/images/error_x.jpg'  hspace='3' align='left'><span style=\"color:Red;\">Spaces are not allowed</span>";                    
            pinDiv.style.display = "block";
            return false;
        }
        pinDiv.style.display = "none";                
       
    }
    pinDiv.style.display = "none";     
      
    var date = document.getElementById("ddlDate");
    var month = document.getElementById("ddlMonth");
    var year = document.getElementById("ddlYear");
    var divDOB = document.getElementById("divDOB");
            
    if(date.value =='Day' || month.value == 0 || year.value == 'Year')
    {
        divDOB.innerHTML = "<img src='../themes/default/images/error_x.jpg' hspace='3' align='left'><span style=\"color:Red;\">Date of Birth is required.</span>";
        divDOB.style.display = 'block';
        return false;
    }
    else
    {
        switch (month.value)
        {
            case "2":
                    if((year.value % 4) == 0)
                    {
                        if(date.value > 29)
                        {
                            divDOB.innerHTML = "<img src='../themes/default/images/error_x.jpg' hspace='3' align='left'><span style=\"color:Red;\">Enter valid date.</span>";
                            divDOB.style.display = 'block';
                            return false;
                        }   
                  
                    }
                    else
                    {
                        if(date.value > 28)
                        {
                            divDOB.innerHTML = "<img src='../themes/default/images/error_x.jpg' hspace='3' align='left'><span style=\"color:Red;\">Enter valid date.</span>";
                            divDOB.style.display = 'block';
                            return false;
                        }  
                    }
                    break;
             
             case "4": 
             case "6":
             case "9":
             case "11":
                    if(date.value > 30)
                        {
                            divDOB.innerHTML = "<img src='../themes/default/images/error_x.jpg' hspace='3' align='left'><span style=\"color:Red;\">Enter valid date.</span>";
                            divDOB.style.display = 'block';
                            return false;
                        }   
                    break;
        }
        divDOB.style.display = "none";
    }            
        
    var yearsOfPractise=document.getElementById("txtYearsInPractice");
    var divYearsOfPractise=document.getElementById("divYearsInPractice");
    if(isNaN(yearsOfPractise.value))
    {
        divYearsOfPractise.style.display = "block";
        divYearsOfPractise.innerHTML = "<img src='../themes/default/images/error_x.jpg' hspace='3' align='left'><span style=\"color:Red;\">Years must be numeric value.</span>";
        return false;
    }
    divYearsOfPractise.style.display = "none";    
      
    var chkAggreement = document.getElementById("chkAgreement");
    var divAggreement  = document.getElementById("divCheckAggreement");  
    if(chkAggreement.checked == "false")
    {
        divAggreement.style.display = "block";
        divAggreement.innerHTML = "<img src='../themes/default/images/error_x.jpg' hspace='3' align='left'><span style=\"color:Red;\">You must accept the site terms and service agreement.</span>";
        return false;
    }
    divAggreement.style.display = "none";
    
    
    return true;         
 }

        
function checkEmailSyntax(str)
{
    var at="@";
    var dot=".";
    var lat=str.indexOf(at);
    var lstr=str.length;
    var ldot=str.indexOf(dot);
    if (str.indexOf(at)==-1){               
       return false
    }

    if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
       return false;
    }

    if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
        return false;
    }

     if (str.indexOf(at,(lat+1))!=-1)
     {
        return false;
     }

     if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
        return false;
     }

     if (str.indexOf(dot,(lat+2))==-1){
        return false;
     }

     if (str.indexOf(" ")!=-1){
        return false;
     }
     return true ;                             
}

function ShowPractitioner()
{
  var rblHealth = document.getElementById("rblHealth");  
  var divPractitioner = document.getElementById('divPractitioner');
  for (var i=0; i<rblHealth.rows.length; i++) 
        {  
            for (var j=0; j<rblHealth.rows[i].cells.length; j++) 
            {
                var list1 = rblHealth.rows[i].cells[j].childNodes[0]; 
                if(list1.checked) 
                {
                    if(list1.value == 'Y')
                    {
                        divPractitioner.style.display = 'block';
                    }
                    else
                    {   
                        divPractitioner.style.display = 'none';
                    }
                }
            }
         }
}

/* // Following code might be required if "What is your speciality" need to asked
// //CBLTypeOfPracticing1.Attributes.Add("onclick", "ShowSpeciality('CBLTypeOfPracticing1',new Array(0,1,2,3))");
var specialCheck = false;
function ShowSpeciality(checkBoxListId, chkArray)
{  
    if(specialCheck == false)
    {
        var dvspeciality=document.getElementById('dvspeciality');
        for(i = 0; i<chkArray.length; i++)
        {
	        objItem = document.getElementById(checkBoxListId + '_' + chkArray[i]);
	        if(objItem == null)
	        {
		        continue;
	        }
	        if(objItem.checked==true)
	        {
	            specialCheck=true;
	             dvspeciality.style.display = "block";
	             return;
	        }
        }
        dvspeciality.style.display = "none";
        specialCheck = false;
    }
}
*/

function CheckDisplayName()
{
    var dname = document.getElementById("<%= txtdisplayname.ClientID %>").value;    
    var message = document.getElementById("<%= firstNameDiv.ClientID %>");  
    if(dname !='')
    {      
        CreateUser.CheckDisplayname(dname,CheckDisplayName_CallBack);
    }
    else
    {
       message.style.display = 'block';
       message.innerHTML = 'Display Name is required.';	
    }
}
//--------------------------------CreateUser.aspx ends-------------------------------------
x = screen.width;
y = screen.height;
function setVisible(obj)
{

        obj = document.getElementById(obj);
        obj.style.display = "block";
}
 function placeIt(obj) {
        obj = document.getElementById(obj);     
        obj.style.left = x + 'px' ;
        obj.style.top = y + 'px' ;
}
//added for submenu
function toggle(theDiv) {
    var elem = document.getElementById(theDiv);
    elem.style.display = (elem.style.display == "none")?"":"none";
}

function openwindow(value)
{
      window.open(value,"mywindow","menubar=1,resizable=1,toolbar=no,scrollbars=yes,width=650,height=580,left=250,top=200");
}

function OpenNewWindow(sURL)
{
    
	var left = parseInt((screen.availWidth/2) - (300/2));
    var top = parseInt((screen.availHeight/2) - (200/2));

    var features="toolbar=0,scrollbars=0,resizable=0,location=no,status=0,menubar=0,titlebar=0,width=360,height=280,left="+left+",top="+top
	oMyWin=window.open(sURL,"Confirm",features)
	//return false;
}


function openSpamWindow()
{
  
   if(confirm('Are you sure you want to Mark this post as spam?'))
   {
   
        return true; 
        }
   else
   {
   
   var LastDiv = document.getElementById('divSpam');
   LastDiv.style.display = 'none'; 
         return false; 
         }

}

function openWindow(postID,authorID,banUser)
{
    
    var strUrl = 'SpamingMessages.aspx?PostID=' + postID + '&PostAuthorId=' + authorID
    var left = parseInt((screen.availWidth/2) - 400);
    var top = parseInt((screen.availHeight/2) - 350);

    if(banUser == 'false')
    {
      
        if(confirm('Are you sure you want to delete this comment?'))
        {
            strUrl=strUrl+'&From=1&Ban=0'
           win=window.open(strUrl,"Confirm", "toolbar=no,scrollbars=yes,resizable=yes,width=800,height=690,left="+left+",top="+top);
         }
    }
    else
    {
    
        if(confirm('Are you sure you want to delete this comment and ban the author?'))
        {
            strUrl=strUrl+'&From=1&Ban=1'
           win=window.open(strUrl,"Confirm", "toolbar=no,scrollbars=yes,resizable=yes,width=800,height=690,left="+left+",top="+top);

        }
    }
}


//Added for Edit profile page.
function EditProfileEnableSave()
{
    var save = document.getElementById("ctl00_bcr_EditUserForm1_ctl02_UpdateButtonBottom");
    var saveChanges = document.getElementById("ctl00_bcr_EditUserForm1_ctl02_btnSave");
    
    save.className="EditProfileSaveButtonNone";
    saveChanges.className="EditProfileSaveButtonBlock";    
    
    return true;
}
function EditProfileDisableSave()
{
    var save = document.getElementById("ctl00_bcr_EditUserForm1_ctl02_UpdateButtonBottom");
    var saveChanges = document.getElementById("ctl00_bcr_EditUserForm1_ctl02_btnSave");

    save.className="EditProfileSaveButtonBlock";
    saveChanges.className="EditProfileSaveButtonNone";    
    
    return true;
}


// Newsletter

var subid;
var msgBoard;
var wheelobj;        
var textbox;

function showprogress(Loding,wheel,Subscribe,EmailAddress)  
{                
        textbox = document.getElementById(EmailAddress);
        if (emailCheck(textbox.value))
        {
            subid = document.getElementById(Subscribe);
            msgBoard=document.getElementById(Loding);
            wheelobj=document.getElementById(wheel);  
            msgBoard.style.display="block";
            wheelobj.style.display="block";
            subid.style.display="none";  	
            setTimeout("hideprogress()",10000);
            return true;   	    	
        }
        else
        {
            return false;
        }
}

function hideprogress()
{
    msgBoard.style.display="none";
    wheelobj.style.display="none";
    subid.style.display="block";
}

function ContinueSubscription(e, buttonid,EmailAddress)
{
    textbox = document.getElementById(EmailAddress);
    var bt = document.getElementById(buttonid); 
    if (typeof bt == 'object')
    { 
        bt.disabled = false;
        if(navigator.appName.indexOf("Netscape")>(-1))
        { 
            if (e.keyCode == 13)
            { 
               if (emailCheck(textbox.value))
               {       
                    bt.click(); 
               }
               return false; 
            } 
        } 
        if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1))
        { 
            if (event.keyCode == 13)
            { 
               if (emailCheck(textbox.value))
               {       
                    bt.click(); 
               } 
               return false; 
            } 
        } 
     }
}


function emailCheck (emailStr) {

/* The following variable tells the rest of the function whether or not
to verify that the address ends in a two-letter country or well-known
TLD.  1 means check it, 0 means don't. */

var checkTLD=1;

/* The following is the list of known TLDs that an e-mail address must end with. */

var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

/* The following pattern is used to check if the entered e-mail address
fits the user@domain format.  It also is used to separate the username
from the domain. */

var emailPat=/^(.+)@(.+)$/;

/* The following string represents the pattern for matching all special
characters.  We don't want to allow special characters in the address. 
These characters include ( ) < > @ , ; : \ " . [ ] */

var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

/* The following string represents the range of characters allowed in a 
username or domainname.  It really states which chars aren't allowed.*/

var validChars="\[^\\s" + specialChars + "\]";

/* The following pattern applies if the "user" is a quoted string (in
which case, there are no rules about which characters are allowed
and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
is a legal e-mail address. */

var quotedUser="(\"[^\"]*\")";

/* The following pattern applies for domains that are IP addresses,
rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
e-mail address. NOTE: The square brackets are required. */

var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

/* The following string represents an atom (basically a series of non-special characters.) */

var atom=validChars + '+';

/* The following string represents one word in the typical username.
For example, in john.doe@somewhere.com, john and doe are words.
Basically, a word is either an atom or quoted string. */

var word="(" + atom + "|" + quotedUser + ")";

// The following pattern describes the structure of the user

var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

/* The following pattern describes the structure of a normal symbolic
domain, as opposed to ipDomainPat, shown above. */

var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

/* Finally, let's start trying to figure out if the supplied address is valid. */

/* Begin with the coarse pattern to simply break up user@domain into
different pieces that are easy to analyze. */

var matchArray=emailStr.match(emailPat);

if (matchArray==null) {

/* Too many/few @'s or something; basically, this address doesn't
even fit the general mould of a valid e-mail address. */

alert("Please Enter Valid Email address!!");
return false;
}
var user=matchArray[1];
var domain=matchArray[2];

// Start by checking that only basic ASCII characters are in the strings (0-127).

for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert("Ths username contains invalid characters. Please Enter Valid Email address!!");
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert("Ths domain name contains invalid characters. Please Enter Valid Email address!!");
return false;
   }
}

// See if "user" is valid 

if (user.match(userPat)==null) {

// user is not valid

alert("The username doesn't seem to be valid. Please Enter valid Email address!!");
return false;
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
host name) make sure the IP address is valid. */

var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {

// this is an IP address

for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("Destination IP address is invalid! Please Enter valid Email address!!");
return false;
   }
}
return true;
}

// Domain is symbolic name.  Check if it's valid.
 
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
alert("The domain name does not seem to be valid. Please Enter valid Email address!!");
return false;
   }
}

/* domain name seems valid, but now make sure that it ends in a
known top-level domain (like com, edu, gov) or a two-letter word,
representing country (uk, nl), and that there's a hostname preceding 
the domain or country. */

if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(knownDomsPat)==-1) {
alert("The address must end in a well-known domain. Please Enter valid Email address!!");
return false;
}

// Make sure there's a host name preceding the domain.

if (len<2) {
alert("This address is missing a hostname! Please Enter valid Email address!!");
return false;
}

// If we've gotten this far, everything's valid!
return true;
}

//  End -->

function AllowReply()
{
	var txt = document.getElementsByTagName('textarea');
	var errorMsg = document.getElementById('subCommentRequiredMessage');	
	for(i=0;i<txt.length;i++)
	{
		if(txt[i].id.indexOf('txtSubComment') > -1)
		{		
                       
			if(txt[i].value.trim().length == 0)
			{
				
				errorMsg.style.display = "block";
				return false;
				break;
			}
			else if(txt[i].value.trim().length > 2000)
			{
			    alert('Please enter less than 2000 characters.');
				return false;
				break;
			}
			errorMsg.style.display = "none";
			break;			
		}	
	}	
	errorMsg.style.display = "none";
	return true;
     
}

function TrapEnterKeyForSearch(evt,sourceTextBoxName)
{
 var txtValue;
      if(evt && evt.target)
      {
          if (evt.keyCode == 13)
          { 
	    txtValue = document.getElementById(sourceTextBoxName).value;		
            RedirectToSearchURL(txtValue,'0');
            return false;
        }
      }
      else if(window.event)
      {
            if (event.keyCode == 13)
        {              
            txtValue = document.getElementById(sourceTextBoxName).value;	
            RedirectToSearchURL(txtValue,'0');
            return false;
        }
      }
}
function RedirectToSearchURL(sourceName) 
{ 
var searchURL; 
	var txtboxValue;
	txtboxValue = document.getElementById(sourceName).value;     
    searchURL = "http://search.mercola.com/Results.aspx?k=" + txtboxValue ;
    location.href = searchURL ;
}



function popup(url) 
{
 params  = 'width='+screen.width;
 params += ', height='+screen.height;
 params += ', top=0, left=0'
 params += ', fullscreen=no';
 params += ', directories=no';
 params += ', location=no';
 params += ', menubar=yes';
 params += ', resizable=no';
 params += ', scrollbars=yes';
 params += ', status=yes';
 params += ', toolbar=yes';
 newwin=window.open(url,'windowname5', params);
 if (window.focus) {newwin.focus()}
 return false;
}

 function Validate()
{
  var txtEmail = document.getElementById('textBoxEmailAddress');		    
  if(txtEmail.value == '' || txtEmail.value ==null )
  {
  alert("Please Enter Email Address.");
  return false;
  }
  if(checkEmailSyntax(txtEmail.value) == false)
  {
	alert("Invalid Email address.");
        return false;
  }
    return true; 
		          
}


function CheckValidation(msg)
{
  if(msg==2)
  {
  alert("Email Address is not valid ");
  return false;
  }
  else if(msg==3)
  {
  alert('Sorry! We are not able to connect to validation server. Please try again.');
  return false;
  }
  else if(msg==4)
  {
  alert('Please enter email address.');
  return false;
  }
  
}


function CommunitiesTrapEnterKeyForSearch(evt,sourceTextBoxName)
{
    var txtValue;
    if(evt && evt.target)
	    {
		    if (evt.keyCode == 13)
			    { 
			        txtValue = document.getElementById(sourceTextBoxName).value;
                    CommunitiesRedirectToSearchURL(txtValue,'0');
                    return false;
                }
	    }
    else if(window.event)
        {
            if (event.keyCode == 13)
		        { 
                    txtValue = document.getElementById(sourceTextBoxName).value;
                    CommunitiesRedirectToSearchURL(txtValue,'0');
                    return false;
                }
	    }
}

function CommunitiesRedirectToSearchURL(sourceName,option) 
{ 

    var searchURL,txtboxValue;
    if (option == '1')
    {
        txtboxValue = document.getElementById(sourceName).value;
    }
    else
    {
        txtboxValue = sourceName;
    }
    searchURL = "/search/SearchResults.aspx?k=" + txtboxValue ;
	location.href = searchURL ;
}

window.onload = function(){


}
function PopUpPage(){

Shadowbox.init();
    Shadowbox.open({
        player:     'iframe',
        content:    '/Themes/Blogs/mercolaArticle/RegistrationPopUp.aspx',
        height:     466,
        width:      664,
		title: ''
    });
}


function CharacterLimitMainComment()
{

    var txt = document.getElementsByTagName('textarea');
    
	for(i=0;i<txt.length;i++)
	{
		if(txt[i].id.indexOf('tbComment') > -1)
		{
		   
		    if (txt[i].value.length > 2000)
		    {
		        alert('Please enter 2000 characters only');
                        return false;  
		    }
		}
	}
    return true;
}

/*

function CharacterCount() 
{ 
  var taObj=document.getElementById('ctl00_ctl00_ctl00_bcr_bcr_bcr_WeblogPostCommentForm1_ctl01_tbComment');
  if (taObj.value.length > 2000*1)
  {
    taObj.value = taObj.value.substring(0,2000*1);
  }       
}
*/

function GetTextArea(controlName)
{
    var txt = document.getElementsByTagName('textarea');
	for(i=0;i<txt.length;i++)
	{
		if(txt[i].id.indexOf(controlName) > -1)
		{
		    return txt[i];		    
		}
	}
    return null;  
}

function CharacterCount(controlName,messageLabelID) 
{ 

  var taObj=GetTextArea(controlName);

  if(taObj != null)
  {      
      if (taObj.value.length > 2000)
      {
        taObj.value = taObj.value.substring(0,2000);
      }     

      var lbl = document.getElementById(messageLabelID);

      lbl.innerHTML =  'Characters remaining : ' + (2000-(taObj.value.length));
   }   
}

function CharacterLimit()
{

    var txt = document.getElementsByTagName('textarea');
	for(i=0;i<txt.length;i++)
	{
		if(txt[i].id.indexOf('tbComment') > -1)
		{
		    if (txt[i].value.trim().length > 2000)
		    {
		        alert('Please enter 2000 characters only');
                        return false;  
		    }
	   	    else if (txt[i].value.trim().length == 0)
		    {
		        if(txt[i].value.length == 0)
			{
				alert('Please enter your comment');
			}
                        return false;  
		    }
		}
	}
    return true;   
}

function CloseSpamOptionDiv()
{
var div = document.getElementById('layer1');
div.style.display = "none";
return false;
}

function OpenLogin()
{
Shadowbox.init();
var divContent = document.getElementById('LoginDivShadowBox').innerHTML;
Shadowbox.open({
        player:     'html',
        content:    divContent,
        height:     158,
        width:      620,
        flashBgColor: '',
		title: ''
    });
    
    
}
function ConfirmPromote()
{
return confirm('Are you sure you want to promote this subcomment to comment?');
}

function AuthorforSpam()
{
   alert('You can not spam your own post.');
}

function AllowEdit()
{

	var txt = document.getElementsByTagName('textarea');
var errorMsg = document.getElementById('editCommentRequiredMessage');
	for(i=0;i<txt.length;i++)
	{
		if(txt[i].id.indexOf('txtEditComment') > -1)
		{		
			if(txt[i].value.trim().length == 0)
			{				
				errorMsg.style.display = "block";
				//alert('Please enter the comment');
				return false;
				break;
			}
			else if(txt[i].value.trim().length > 2000)
			{
			    	alert('Please enter less than 2000 characters.');
				return false;
				break;
			}
			errorMsg.style.display = "none";
			break;			
		}	
	}
	errorMsg.style.display = "none";
	return true;
     
}


function OpenShareFavorites()
{

var divContent = document.getElementById("ShareFavorites").innerHTML;
Shadowbox.init();
Shadowbox.open({
        player:     'html',
        content:    divContent,
        height:     250,
        width:      600,
        flashBgColor: '', 
        title: ''
    });
}

function OpenContactImporter(addressBook)
{
if(addressBook=='web')
{var divContent = document.getElementById("ContactImporterWeb").innerHTML;}
else if (addressBook=='local')
{var divContent = document.getElementById("ContactImporterLocal").innerHTML;}
else if (addressBook=='ETAF')
{var divContent = document.getElementById("emailToFriend").innerHTML;}
Shadowbox.open({
        player:     'html',
        content:    divContent,
        height:     480,
        width:      850,
        flashBgColor: '', 
        title: ''
    });
}

function OpenProfileCompleteness()
{
var divContent = document.getElementById("ProfileCompleteness").innerHTML;
Shadowbox.open({
        player:     'html',
        content:    divContent,
        height:     500,
        width:      600,
        flashBgColor: '', 
        title: ''
    });
}

function SaveSharedFavoriteValue()
{
var inputs = document.getElementsByTagName('input');
var i;
var hdnShare;
var hdnVarFound = false;
var radioButtonChecked = false;

for(i=0;i<inputs.length;i++)
{
    if(!hdnVarFound && inputs[i].id.indexOf('hdnShare')> 0)
    {
        hdnShare = inputs[i];
        hdnVarFound = true;
    }
    
    if(inputs[i].id.indexOf('SaveArticle')> 0)
    {        
        if(inputs[i].checked)
        {
            radioButtonChecked = true;
            if(hdnShare != null)
            {
                hdnShare.value = inputs[i].id.charAt(inputs[i].id.length-1);                
            }            
        }        
    }
}
if(!radioButtonChecked)
{
  alert('Please select option');
}
return radioButtonChecked;
}


function AddFriendRequest(userid)
{
 Shadowbox.init();
    Shadowbox.open({
        player:     'html',
       content:    '<div style="width:550px;height:300px;"><div style="border:1 px solid red;float:right;"><a href="javascript:Shadowbox.close();"><img src="/Themes/mercolaArticle/images/FR_modalSubscriptionCloseBtn.png" alt="" border="0" /></a></div><div style="width:550px;height: 360px;"><iframe src="/Themes/mercolaArticle/user/RequestFriend.aspx?UserId='+userid+'&ConversationID=00000000-0000-0000-0000-000000000000" width="550" height="300" frameborder="0"></iframe></div></div>',
        height:     466,
        width:      664,       
		title: ''
    });  
}


function CheckUserFriendList(username,userid,check)
{
var txt = document.getElementById('divFriendMsg');
if(check==1)
{
 txt.innerHTML = "<b>"+username+" has chosen to receive messages from approved friends only.<br/> You are not yet "+username+"'s friend or your friend request has not been approved. Please <a onclick='javascript:AddFriendRequest("+userid+");'>Click here</a> to add "+username+" as friend.";
 
}
else
{
 txt.innerHTML = "<b>"+username+" has chosen not to receive private messages from other members";
}
var divContentMsg = document.getElementById("SendmsgDiv").innerHTML;

Shadowbox.open({
        player:     'html',
        content:    divContentMsg,
        height:     158,
        width:      600,
        flashBgColor: '', 
        title: ''
    });
}

function RedirectToSearchURL(sourceName,option) 
{ 	
    var searchURL,txtboxValue;

    if (option == '1')//button click
    {
        txtboxValue = document.getElementById(sourceName).value;
    }
    else if(option == '0')//enter key
    {
        txtboxValue = sourceName;
    }
    else
    {		
	if(sourceName == 'qmaster')
	{
		txtboxValue = document.getElementById(sourceName).value;
	}
	else
	{
		txtboxValue = sourceName;
	}
    }
    
    
    searchURL = "http://search.mercola.com/Results.aspx?k=" + txtboxValue   ;
	location.href = searchURL ;
}