﻿// JScript File
function DisplayMessage(status)
{       
//        var newsletterErrorsDiv = document.getElementById("errorDivAddNewsletter");
//        if(newsletterErrorsDiv!=null && newsletterErrorsDiv != "")
//        {
//             
//            newsletterErrorsDiv.style.display = "block";
            
            var msg ="";
            if(status == "1")
            {
              msg = "Congratulations! Your blog post has been created successfully.";
               ShowMessageBox(msg);
              self.location.href = "ViewBlogs.aspx";
              return true;
            }
            else if(status=="0")
            {  
              msg = "Error occured while processing the submission. Please try again.";
              alert(msg);
              return false;
            }
          
            //newsletterErrorsDiv.innerHTML = msg;   
     // }
    //window.scrollTo(0,0);
         
}
function DisplayUpdateMessage(status)
{       
       // var newsletterErrorsDiv = document.getElementById("errorDivAddNewsletter");
        //if(newsletterErrorsDiv!=null && newsletterErrorsDiv != "")
       // {
             
          //  newsletterErrorsDiv.style.display = "block";
            
            var msg ="";
            if(status == "1")
            {
              msg = "Congratulations, your blog post has been updated successfully.";
              ShowMessageBox(msg);
              self.location.href = "ViewBlogs.aspx";
              return true;  
            }
            else if(status=="0")
            {
              msg = "Error occurred while processing the updation. Please try again.";  
              alert(msg);
              return false;  
            }
          
            //newsletterErrorsDiv.innerHTML = msg;   
     // }
      //window.scrollTo(0,0);
}

function DisplayDispatchMessage(status)
{       
//        var newsletterErrorsDiv = document.getElementById("errorDivAddNewsletter");
//        if(newsletterErrorsDiv!=null && newsletterErrorsDiv != "")
//        {
//             
//            newsletterErrorsDiv.style.display = "block";
            
            var msg ="";
            if(status == "1")
            {
                msg = "Congratulations, Blogs is dispatched successfully.";
                ShowMessageBox(msg);
            }
            else if(status=="0")
            {
                msg = "Error occured while dispatching, Please try again.";  
                alert(msg);
            }
            
          
            //newsletterErrorsDiv.innerHTML = msg;   
     // }
      window.scrollTo(0,0);
    return true;     
        
    
}

function DisplayDuplicateNameMessage()
{       
        var newsletterErrorsDiv = document.getElementById("WarningMsgs_RegistrationErrors");
        if(newsletterErrorsDiv!=null && newsletterErrorsDiv != "")
        {
             
            newsletterErrorsDiv.style.display = "block";
             document.getElementById("WarningMsgs_divWarningInfo").style.display = "block";

            
            var msg ="";
          
              msg = "Duplicate title of blog. Use another name.";
                      
            newsletterErrorsDiv.innerHTML = msg;   
      }
      window.scrollTo(0,0);
    return true;     
        
    
}

function DeleteBlogConfirmation(BlogId,btnId)
{
    document.getElementById("confirmBox_hidButtonId").value=btnId;
    document.getElementById("hidRecordId").value=BlogId;
    
    ShowConfirmBox('Would you like to delete this blog? It will also delete blog post and comments.');
    return false;
}

function DeleteBlogPostConfirmation(BlogId,btnId)
{
    document.getElementById("confirmBox_hidButtonId").value=btnId;
    document.getElementById("hidRecordId").value=BlogId;
    
    ShowConfirmBox('Would you like to delete this blog post? It will also delete blog post comments.');
    return false;
}

function OffensiveBlogConfirmation(BlogId,btnId)
{
    document.getElementById("confirmBox_hidButtonId").value=btnId;
    document.getElementById("hidRecordId").value=BlogId;
    ShowConfirmBox('Would you like to report this blog as offensive?');
    return false;
}
function OffensiveBlogPostConfirmation(BlogId,btnId)
{
    //return confirm('Would you like to report this post of blog as offensive?');
    
    document.getElementById("confirmBox_hidButtonId").value=btnId;
    document.getElementById("hidRecordId").value=BlogId;
    ShowConfirmBox('Would you like to report this blog post as offensive?');
    return false;
}
function OffensiveBlogCommentConfirmation(BlogId,btnId)
{
    //return confirm('Would you like to report this comment on blog post as offensive?');
    
    document.getElementById("confirmBox_hidButtonId").value=btnId;
    document.getElementById("hidRecordId").value=BlogId;
    ShowConfirmBox('Would you like to report this blog post comment as offensive?');
    return false;
}
function DisplayCannotDispatchMessage()
{       
        var newsletterErrorsDiv = document.getElementById("WarningMsgs_RegistrationErrors");
        if(newsletterErrorsDiv!=null && newsletterErrorsDiv != "")
        {
             
            newsletterErrorsDiv.style.display = "block";
              document.getElementById("WarningMsgs_divWarningInfo").style.display = "block";
            var msg ="";
            
            
              msg = "Blog cannot dispatch because of creation date.";  
            
          
            newsletterErrorsDiv.innerHTML = msg;   
      }
      window.scrollTo(0,0);
    return true;     
        
    
}
function DispatchConfirmation()
{ 
    var flag=document.getElementById("hiddenFlag").value;
    
    if(flag =="0")
    {
        return confirm('Do you want to dispatch blog?');
    }
    if(flag =="1")
    {
        return confirm('The Blog is dispatched already. Do you want it dispatch again?');
    }
   
}

function DeleteBlogCommentConfirmation(RecordId,btnId)
{
   // return confirm('Would you like to delete this comment?');
    document.getElementById("confirmBox_hidButtonId").value=btnId;
    document.getElementById("hidRecordId").value=RecordId;
    
    ShowConfirmBox('Would you like to delete this comment?');
    return false;
}

function AcceptBlogCommentConfirmation(RecordId,btnId)
{
   // return confirm('Would you like to accept this comment?');
    
    document.getElementById("confirmBox_hidButtonId").value=btnId;
    document.getElementById("hidRecordId").value=RecordId;
    
    ShowConfirmBox('Would you like to accept this comment?');
    return false;
}

function AddComments()
{
    var hidAddCommentsEnable = document.getElementById("hidAddCommentsEnable").value;
    if(hidAddCommentsEnable == "true")
    {
        return ShowModalPopup('pnlComment','Add Comments','m');
    }
    else
    {
        ShowInformationMessageBox("Please login to add comments.");
        return false;
    }
    
}
function createBlogTop()
{
    var hidUserId=document.getElementById("hidUserId").value;
    if(hidUserId == "0")
    {
        ShowInformationMessageBox("You need to login for adding blog.");
        return false;
    }
    return true;
}

function btnAddBlogCommentCancel()
{
    document.getElementById("txtCommentDescription").value="";
    document.getElementById("WarningMsgs_RegistrationErrors").innerHTML = "";
    document.getElementById("WarningMsgs_RegistrationErrors").style.display = "none";
    document.getElementById("WarningMsgs_divWarningInfo").style.display = "none";
   return closepopup('pnlComment');
}

//function ValidateAddNewBlog()
//{   
//    errors="";
//     var status = true;
//     mandatoryFieldsErrorFlag = false;
//     var varTemp;
//     var alertName;
//     var isMandatory;
//          
//       	//Date Validation		
//	 alertName="Posted Date";		
//     var currentdate=new Date();
//     var varselectedday = document.getElementById("ddlDayOfMonth").value; 
//     var varselectedMonth = document.getElementById("ddlMonth").value -1;
//     var varselectedYear = document.getElementById("ddlBirthYear").value;
//     var selecteddate=new Date(varselectedYear,varselectedMonth,varselectedday);
//     // Check for leap year
//    if (varselectedMonth == 1) 
//    {
//		if ( ( (varselectedYear%4 == 0)&&( varselectedYear%100 != 0) ) || (varselectedYear%400 == 0) ) 
//		{ 
//			if (varselectedday > 29)
//			{ 
//			 errors += alertName + " Month ends  at 29." +'<br/>'; 
//             status= false;
//             return false;
//            
//            }
//            else
//            {
//		    status= true; 
//		    }
//		}
//		else
//		 { 
//		   if (varselectedday > 28)
//		    { 
//		       errors += alertName + "   Month  ends  at 28." +'<br/>'; 
//               status= false; 
//             return false;
//		    } 
//		    else
//		    {
//		    status= true; 
//		    }
//		}
//	 }
//    else if ((varselectedMonth == 3) ||(varselectedMonth == 5)||(varselectedMonth == 8)||(varselectedMonth == 10))
//     {
//		if (varselectedday > 30)
//		 { 
//		   errors += alertName + "  Month  ends  at 30." +'<br/>'; 
//           status= false;
//          return false;
//		 }
//		 else
//		 {
//		   status= true;
//		   }
//	}
//    else
//    {
//         if( (currentdate.getDate() == selecteddate.getDate())&& (currentdate.getMonth() == selecteddate.getMonth()) && (currentdate.getFullYear() == selecteddate.getFullYear()))
//           {
//              status= true;
//            
//           }
//         else
//            {
//                    if(selecteddate > currentdate == true)
//                       {
//                           errors += alertName + " can not be greater than current date." +'<br/>'; 
//                           status= false;
//	                        return false;
//                       }
//                    else
//                    {
//                      status= true;
//                      }
//            }
//    }

//       
//       
//       //Title Validation
//      varTemp = document.getElementById("txtBlogTitle");  
//      alertName = "Blog Header ";
//      isMandatory = 'True';
//     if(bValidate(varTemp, "General" ,isMandatory , alertName) != true)
//     {
//         //errors += alertName + " should not be empty."; 
//         status = false; 
//         return false;
//      }
//      else
//      {
//            if(varTemp.value.length > 200 )
//             {
//                        errors += alertName + " should not contain more than 200 characters ." +'<br/>'; 
//						varTemp.focus();
//						status=false;
//						return false;
//						
//			}
//      }   
//     
//        alertName="Blog Content";
//        varTemp = document.getElementById("ta"); // Rich TinyMCE html textarea
//        var MessageTextValue =varTemp.value;
//	    MessageTextValue = tinyMCE.getInstanceById("ta").getHTML();
//	    if (MessageTextValue=="")
//	    {
//	      if(mandatoryFieldsErrorFlag == false) 
//	      {
//			    mandatoryFieldsErrorFlag = true;
//	      }
//    	  errors += alertName + " can not be blank."; 				
//	      status=false;
//	      return false;
//	    }
//	


// return true;
//}

function ValidateAddNewBlog()
{ 
    errors="";
     var status = true;
     mandatoryFieldsErrorFlag = false;
     var varTemp;
     var alertName;
     var isMandatory;
          
       	//Date Validation		
	 alertName="Posted Date";		
     var currentdate=new Date();
     //var varselectedday = document.getElementById("ddlDayOfMonth").value; 
     //var varselectedMonth = document.getElementById("ddlMonth").value -1;
     //var varselectedYear = document.getElementById("ddlBirthYear").value;
     //var selecteddate=new Date(varselectedYear,varselectedMonth,varselectedday);
     // Check for leap year
//    if (varselectedMonth == 1) 
//    {
//		if ( ( (varselectedYear%4 == 0)&&( varselectedYear%100 != 0) ) || (varselectedYear%400 == 0) ) 
//		{ 
//			if (varselectedday > 29)
//			{ 
//			 errors += alertName + " Month ends  at 29." +'<br/>'; 
//             status= false;
//             return false;
//            
//            }
//            else
//            {
//		    status= true; 
//		    }
//		}
//		else
//		 { 
//		   if (varselectedday > 28)
//		    { 
//		       errors += alertName + "   Month  ends  at 28." +'<br/>'; 
//               status= false; 
//             return false;
//		    } 
//		    else
//		    {
//		    status= true; 
//		    }
//		}
//	 }
//    else if ((varselectedMonth == 3) ||(varselectedMonth == 5)||(varselectedMonth == 8)||(varselectedMonth == 10))
//     {
//		if (varselectedday > 30)
//		 { 
//		   errors += alertName + "  Month  ends  at 30." +'<br/>'; 
//           status= false;
//          return false;
//		 }
//		 else
//		 {
//		   status= true;
//		   }
//	}
//    else
//    {
//         if( (currentdate.getDate() == selecteddate.getDate())&& (currentdate.getMonth() == selecteddate.getMonth()) && (currentdate.getFullYear() == selecteddate.getFullYear()))
//           {
//              status= true;
//            
//           }
//         else
//            {
//                    if(selecteddate > currentdate == true)
//                       {
//                           errors += alertName + " can not be greater than current date." +'<br/>'; 
//                           status= false;
//	                        return false;
//                       }
//                    else
//                    {
//                      status= true;
//                      }
//            }
//    }

       
       
       //Title Validation
      varTemp = document.getElementById("txtBlogTitle");  
      alertName = "Blog Header ";
      isMandatory = 'True';
     if(bValidate(varTemp, "General" ,isMandatory , alertName) != true)
     {
         //errors += alertName + " should not be empty."; 
         status = false; 
         return false;
      }
      else
      {
            if(varTemp.value.length > 200 )
             {
                        errors += "Blog header"+ " should not contain more than 200 characters ." +'<br/>'; 
                        varTemp.value = varTemp.value.substring(0,199);
						varTemp.focus();
						status=false;
						return false;
						
			}
      }   
     
        alertName="Blog Content";
        varTemp = document.getElementById("ta"); // Rich TinyMCE html textarea
        var MessageTextValue =varTemp.value;
	    MessageTextValue = tinyMCE.getInstanceById("ta").getHTML();
	    if (MessageTextValue=="")
	    {
	      if(mandatoryFieldsErrorFlag == false) 
	      {
			    mandatoryFieldsErrorFlag = true;
	      }
    	  errors += "Blog content can not be blank."; 				
	      status=false;
	      return false;
	    }
	


 return true;
}

//function ValidateAddNewBlogStatus()
//{
//     if(ValidateAddNewBlog()==true)
//     {
//     
//       return true;
//     }
//     else
//     {
//    
//         var registrationErrorsDiv = document.getElementById("WarningMsgs_RegistrationErrors");
//        registrationErrorsDiv.style.display = "block";
//        document.getElementById("WarningMsgs_divWarningInfo").style.display = "block";
//        registrationErrorsDiv.innerHTML = "";
//        registrationErrorsDiv.innerHTML = errors; 
//        window.scrollTo(0,0);
//       return false;
//     }
//}
function ValidateAddNewBlogStatus()
{
     if(ValidateAddNewBlog()==true)
     {
        var DummyArea = document.getElementById("ta");
        if(DummyArea != null)
        {
             DummyArea.value = tinyMCE.getInstanceById('ta').getHTML();
        }
        return true;
     }
     else
     {
    
        var registrationErrorsDiv = document.getElementById("WarningMsgsAddPost_RegistrationErrors");
        registrationErrorsDiv.style.display = "block";
        document.getElementById("WarningMsgsAddPost_divWarningInfo").style.display = "block";
        registrationErrorsDiv.innerHTML = "";
        registrationErrorsDiv.innerHTML = errors; 
        window.scrollTo(0,0);
       return false;
     }
}
function ValidateComments()
{
    errors="";
    var status = true;
    mandatoryFieldsErrorFlag = false;
    var alertName="Comment Description ";
    var varTemp;
    
      // Comment Description
     varTemp = document.getElementById("txtCommentDescription");
     var len = trim(varTemp.value).length;//varTemp.value.length;
     varTemp.value=trim(varTemp.value);
     if(len > 1024)
     {
         errors = alertName + sDescription_Message +'<br/>'; 
         status = false;  
     } 
     if(len == 0)
     {
         errors = alertName + sDescription_MessageBlank +'<br/>'; 
          document.getElementById("txtCommentDescription").value="";
          document.getElementById("txtCommentDescription").focus();
	     status = false;  
     } 
      
            if(status == false)
            { 
               var registrationErrorsDiv = document.getElementById("WarningMsgs_RegistrationErrors");
                
                registrationErrorsDiv.style.display = "block";
                document.getElementById("WarningMsgs_divWarningInfo").style.display = "block";
                registrationErrorsDiv.innerHTML = "";
                registrationErrorsDiv.innerHTML = errors; 
                return false;
            }
            else
            {
                errors ='';
                status = CheckBanWord(document.getElementById("txtCommentDescription"),document.getElementById("txtCommentDescription"),document.getElementById("WarningMsgs_RegistrationErrors"));
                if(status==false)
                {
                    errors ='' + document.getElementById("WarningMsgs_RegistrationErrors").innerHTML;
                }
            }  
            return status;
}


function ValidateCreateBlog()
{
    errors = "";
    mandatoryFieldsErrorFlag = false;
    var status = ValidateCreateBlogRoutines();
    if(status == false)
    { 
        var registrationErrorsDiv = document.getElementById("WarningMsgs_RegistrationErrors");
        registrationErrorsDiv.style.display = "block";
        document.getElementById("WarningMsgs_divWarningInfo").style.display = "block";
        registrationErrorsDiv.innerHTML = "";
        registrationErrorsDiv.innerHTML = errors; 
        return false;
    }
    else
    {
       errors ='';
       status = CheckBanWord(document.getElementById("txtTitle"),document.getElementById("txtDescription"),document.getElementById("WarningMsgs_RegistrationErrors"));
       if(status==false)
       {
             errors ='' + document.getElementById("WarningMsgs_RegistrationErrors").innerHTML;
       }
    }  
}

function ValidateCreateBlogRoutines()
{
    var status = true;
     mandatoryFieldsErrorFlag = false;
     var varTemp = document.getElementById("txtTitle");  
     var alertName = "Blog Title";
     var isMandatory = 'True';
     errors = "";
     if(bValidate(varTemp, "General" ,isMandatory , alertName) != true)
     {   
          varTemp.focus();
			  status = false;
			  return false; 
     } 
      else
      {
      
            if(varTemp.value.length > 256 )
             {
                errors = alertName + " should not contain more than 256 characters." +'<br/>'; 
				varTemp.focus();
			    status = false;
			    return false; 
			}
      }   
   
     alertName="Description";
    
      // Blog Description
     varTemp = document.getElementById("txtDescription");  
    
     var len = varTemp.value.length;
     if(len > 1024)
     {
         errors =''+ alertName + sDescription_Message +'<br/>'; 
	     varTemp.focus();
		 status = false;
		 return false; 
     } 
    return status;
}

   function OpenPage()
            { 
                var sFeatures = 'dialogHeight:100px,dialogWidth:400px,center:yes';
                var taObj = document.getElementById("hidPostContent")
                var html = ""; //  = new System.Text.StringBuilder();
              //  html = html + "<body background='" + backImageFileName  + "'>";
              if(document.all)
              {
                  html = html + taObj.value;
                  //document.getElementById('element').innerText = "my text";
              } 
              else
              {
                 html = html + taObj.value;
                 // document.getElementById('element').textContent = "my text";
              }
                html = html + "</body>";
               if(document.all)
               {
                  var windowObj = window.open("",null,'height=500px,width=800px,left=150,top=150');
               }
               else
               {
                   var windowObj = window.open("",null,'height=500px,width=800px,left=150,top=150');
               }
                windowObj.document.write(html);
                
                
            //                    document.getElementById("divButtons").style.display="none";
            //                    document.getElementById("divNewsletterContents").style.display="none";
            //                    
            //                    document.getElementById("rowBackToAdd").style.display="block";
            //                    document.getElementById("lnkBack").style.display="block";
            //                    document.getElementById("ifrmShowHtml").style.display="block";
                
//                var backImageUploadObj = document.getElementById("hiddenImageFileName");
//                var backImageFileName = backImageUploadObj.value;
                //var htmlFileName = "/NewsLetters/TempHtml.htm";
               // var hiddenHtmlFileName.Value = "TempHtml.htm";
             
            }		  
            
            


 function HandleException()
 {
      if (!document.all)
       {
            window.onbeforeunload = function()
             {
               Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequest);
              }
      }
  }

  function endRequest(sender, e)
  {
       var err = e.get_error();
        if (err)
        {
              if (err.name == "Sys.WebForms.PageRequestManagerServerErrorException") 
              {
                e.set_errorHandled(true);
              }
              if (err.name == "Sys.WebForms.PageRequestManagerParserErrorException") 
              {
                e.set_errorHandled(true);
              }
        }
  }

function ShowCreateBlogPopup(isLogin)
{
   if(isLogin =="True")
   {
    var PicId=0;
    var date;      
    document.getElementById("divCreateBlog").style.display="block";
    document.getElementById("ddlBlogCategory").style.display="block";
    
    document.getElementById("txtBlogName").value="";
    document.getElementById("txtDescription").value="";
     document.getElementById("ddlBlogCategory").value="1";
    
    ShowModalPopup('divCreateBlog','Create your Blog');
       document.getElementById("ddlBlogCategory").style.display="block";
     return false;    
    }
    else
    {
         ShowInformationMessageBox("You need to login first to create a blog."); 
        return false;
    }
}
function CloseCreateBlogPopup()
{
 
closepopup('divCreateBlog');
return false;
}

function CreateBlogRequestHandler()
{
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    prm.add_endRequest(CreateBlogEndRequestHandler);   
}
function CreateBlogEndRequestHandler(sender, args) 
{  
     var UserMessage = null;
    UserMessage = document.getElementById("hidUserMessage"); 
    if(UserMessage != null && UserMessage != "")
    {
       var UserMessageVal = UserMessage.value;
    }
    switch(UserMessageVal)
    {
      case "BlogsAddDone" :
         UserMessage.value = "";
         closepopup('divCreateBlog');
         var msg = "Congratulations! Your blog has been created successfully.";
         ShowMessageBox(msg);
         break;
      case "SetPreviewValuesDone":
           UserMessage.value = "";  
            showPreview();
            break;
    }
}

function ValidateCreateNewBlog()
{
    errors = "";
    mandatoryFieldsErrorFlag = false;
    var status = ValidateCreateNewBlogRoutines();
    if(status == false)
    { 
        var registrationErrorsDiv = document.getElementById("WarningMsgs_RegistrationErrors");
        registrationErrorsDiv.style.display = "block";
        document.getElementById("WarningMsgs_divWarningInfo").style.display = "block";
        registrationErrorsDiv.innerHTML = "";
        registrationErrorsDiv.innerHTML = errors; 
        return false;
    }
    else
    {
       errors ='';
//       status = CheckBanWord(document.getElementById("txtTitle"),document.getElementById("txtDescription"),document.getElementById("WarningMsgs_RegistrationErrors"));
//       if(status==false)
//       {
//             errors ='' + document.getElementById("WarningMsgs_RegistrationErrors").innerHTML;
//       }
    }  
}

function ValidateCreateNewBlogRoutines()
{
    var status = true;
     mandatoryFieldsErrorFlag = false;
     var varTemp = document.getElementById("txtBlogName");  
     var alertName = "Blog Name";
     var isMandatory = 'True';
     errors = "";
     if(bValidate(varTemp, "General" ,isMandatory , alertName) != true)
     {   
          varTemp.focus();
			  status = false;
			  return false; 
     } 
      else
      {
      
            if(varTemp.value.length > 256 )
             {
                errors = alertName + " should not contain more than 256 characters." +'<br/>'; 
				varTemp.focus();
			    status = false;
			    return false; 
			}
      }   
   
    
      // Blog Description
     alertName="Description";
     varTemp = document.getElementById("txtDescription");  
     var len = varTemp.value.length;
     if(len > 1024)
     {
         errors =''+ alertName + sDescription_Message +'<br/>'; 
	     varTemp.focus();
		 status = false;
		 return false; 
     } 
      //contact email    
      alertName="Contact email";
      varTemp = document.getElementById("txtContactEmail");  
      isMandatory = "true";
      if(bValidate(varTemp, "Email" ,isMandatory , alertName) != true)
      {   
         varTemp.focus();
	     status = false;
	     return false; 
      }
      
       var tmpDescription = document.getElementById("txtDescription");  
        var countIframes = countInstances(tmpDescription.value,"<iframe");
        if(countIframes >= 2)
        {
           var cntWorkoutWidget =  countInstances(tmpDescription.value,"WorkoutWidget.aspx");
           var cntRaceScheduleWidget =  countInstances(tmpDescription.value,"MyRaceScheduleWidget.aspx");
           var cntGoaltWidget =  countInstances(tmpDescription.value,"GoalsWidget.aspx");
           var cntChallengeWidget =  countInstances(tmpDescription.value,"ChallengesWidget.aspx");
           
           if((cntWorkoutWidget >= 2 )|| (cntRaceScheduleWidget >= 2) || (cntGoaltWidget >= 2) || (cntChallengeWidget >= 2)  )
           {
             errors ='Every widget can be inserted only once.'; 
	         tmpDescription.focus();
		     status = false;
		     return false; 
           }
        }
     
    return status;
}



function ResetCreateBlogPopup()
{
      
//        var tmpDescription = document.getElementById("txtDescription");  
//        var countIframes = countInstances(tmpDescription.value,"<iframe");
//        if(countIframes >= 2)
//        {
//           var cntWorkoutWidget =  countInstances(tmpDescription.value,"WorkoutWidget.aspx");
//           var cntRaceScheduleWidget =  countInstances(tmpDescription.value,"MyRaceScheduleWidget.aspx");
//           var cntGoaltWidget =  countInstances(tmpDescription.value,"GoalsWidget.aspx");
//           var cntChallengeWidget =  countInstances(tmpDescription.value,"ChallengesWidget.aspx");
//           
//           if((cntWorkoutWidget >= 2 )|| (cntRaceScheduleWidget >= 2) || (cntGoaltWidget >= 2) || (cntChallengeWidget >= 2)  )
//           {
//            alert("in if == error");
//           }
//        }
      
      var messageErrorsDiv = document.getElementById("WarningMsgs_RegistrationErrors");
      messageErrorsDiv.innerHTML = "";
      messageErrorsDiv.style.display = "none";
      document.getElementById("WarningMsgs_divWarningInfo").style.display = "none";
      document.getElementById("txtBlogName").value = "";
      document.getElementById("txtDescription").value = "";
      document.getElementById("txtContactEmail").value = "";
      document.getElementById("ddlBlogCategory").value = 1;
      document.getElementById("txtBlogName").focus();
}


function getPreview(print_area)
		{

			CallButtonClick("hidbtnShowPreviewDetails");
			return false;
			
	}
	function showPreview()
	{
	    var print_area="divPagePreview";
			//setTimeout('10000');
			 var varTemp = document.getElementById("txtBlogName");  
             var alertName = "Blog Name";
             var isMandatory = 'True';
             errors = "";
             if(bValidate(varTemp, "General" ,isMandatory , alertName) != true)
             {   
                varTemp.focus();
                var registrationErrorsDiv = document.getElementById("WarningMsgs_RegistrationErrors");
                registrationErrorsDiv.style.display = "block";
                document.getElementById("WarningMsgs_divWarningInfo").style.display = "block";
                registrationErrorsDiv.innerHTML = "";
                registrationErrorsDiv.innerHTML = errors; 
			          status = false;
			          return false; 
             } 
              else
              {
              
                    if(varTemp.value.length > 256 )
                     {
                        errors = alertName + " should not contain more than 256 characters." +'<br/>'; 
				        varTemp.focus();
			            status = false;
			            return false; 
			        }
             }   
   		     var Title =  document.getElementById("txtBlogName").value;	
		     if(Title.length > 28)
		     {
		        Title = Title.substring(0, 30) + "..";
		     }
			 var Description  = document.getElementById("txtDescription").value;
		     var len = Description.length;
             if(len > 1024)
             {
                 errors = alertName + " should not contain more than 1024 characters." +'<br/>'; 
				        document.getElementById("txtDescription").focus();
			            status = false;
			            return false; 
             }
		    
		     if(Description .length > 98)
		     {
		     
		     Description = Description.substring(0, 100) + "..";
			 }
			 document.getElementById("lblPreviewBlogName").innerHTML = Title;//document.getElementById("txtBlogName").value;
	         document.getElementById("lblShortDescription").innerHTML =Description; //document.getElementById("txtDescription").value;
	         document.getElementById("lblCreatorName").innerHTML = document.getElementById("hidUserName").value;
	         
	         //change BG according to theme
	         var ddlCategory = document.getElementById("ddlBlogCategory").value;
	         if(ddlCategory == 4)
	         {
                 document.getElementById("tblPreviewTopBG").className = "clsPagePreviewTopBGCycling";
	             document.getElementById("tdPreviewRight").style.display = "block";
	             document.getElementById("tdPreviewLeft").style.display = "block";
	             document.getElementById("tblPreviewMiddle").style.width = "951px";

//                document.getElementById("tblPreviewTopBG").style.background = "url('../../Images/backgroundImages/Blogs/blue_box_top_center.png')"; 
//                 document.getElementById("tblPreviewTopBG").style.backgroundRepeat = "no-repeat";
                 
	         }
	         else
	         {
	            document.getElementById("tblPreviewTopBG").className = "clsPagePreviewTopBGPlain";
	            document.getElementById("tdPreviewLeft").style.display = "none";
	             document.getElementById("tdPreviewRight").style.display = "none";
	             document.getElementById("tblPreviewMiddle").style.width = "967px";
	            
	         }
	   
	
			//Creating new page
			var pp = window.open();
			//Adding HTML opening tag with <HEAD> … </HEAD> portion 
			pp.document.writeln('<HTML><HEAD><title>Blog Preview</title><LINK href=../../CustomizedCSS/BlogHomePage.css  type="text/css" rel="stylesheet">')
			pp.document.writeln('<HTML><HEAD><title>Blog Preview</title><LINK href=../../Css/TopFrame.css  type="text/css" rel="stylesheet">')
			pp.document.writeln('<HTML><HEAD><title>Blog Preview</title><LINK href=../../CustomizedCSS/Buttons.css  type="text/css" rel="stylesheet">')
			
			pp.document.writeln('<base target="_self"></HEAD>')
			//Adding Body Tag
			pp.document.writeln('<body MS_POSITIONING="GridLayout" bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0">');
			//Adding form Tag
			pp.document.writeln('<form  method="post">');
			pp.document.writeln(document.getElementById(print_area).innerHTML);
			pp.document.writeln('</form></body></HTML>');		
			
	   		return true;
		}		
	
		
		
		
function ValidateAddNewComments(isLogin)
{
   
     if(isLogin == "false")
    {
         ShowInformationMessageBox("You need to login first to add a comment."); 
        return false;
    }
    else
    {
        errors="";
        var status = true;
        mandatoryFieldsErrorFlag = false;
        var alertName="Comment Description ";
        var varTemp;
        
          // Comment Description
         varTemp = document.getElementById("txtCommentDescription");
         var len = trim(varTemp.value).length;//varTemp.value.length;
         varTemp.value=trim(varTemp.value);
         if(len > 1024)
         {
             errors = alertName + sDescription_Message +'<br/>'; 
             status = false;  
         } 
         if(len == 0)
         {
             errors = alertName + sDescription_MessageBlank +'<br/>'; 
              document.getElementById("txtCommentDescription").value="";
              document.getElementById("txtCommentDescription").focus();
	         status = false;  
         } 
          
                if(status == false)
                { 
                   var registrationErrorsDiv = document.getElementById("WarningMsgs_RegistrationErrors");
                    
                    registrationErrorsDiv.style.display = "block";
                    document.getElementById("WarningMsgs_divWarningInfo").style.display = "block";
                    registrationErrorsDiv.innerHTML = "";
                    registrationErrorsDiv.innerHTML = errors; 
                    return false;
                }
                else
                {
                    errors ='';
                    status = CheckBanWord(document.getElementById("txtCommentDescription"),document.getElementById("txtCommentDescription"),document.getElementById("WarningMsgs_RegistrationErrors"));
                    if(status==false)
                    {
                        errors ='' + document.getElementById("WarningMsgs_RegistrationErrors").innerHTML;
                    }
                }  
                return status;
    }
}
function resetComment()
{
    document.getElementById("txtCommentDescription").innerHTML = "";
     HideRegistrationError("WarningMsgs_divWarningInfo");
     document.getElementById("txtCommentDescription").focus();
    return false;
}
function EditComment(CommentId,CommentText)
{
 //   HideRegistrationError("WarningMsgs_divWarningInfo");
    document.getElementById("txtCommentDescription").value=CommentText;//.replaceAll("&#8203;", "");
    document.getElementById("hidCommentId").value= CommentId;
    document.getElementById("txtCommentDescription").focus();
   
    return false;

}


function PostDetailsRequestHandler()
{
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    prm.add_endRequest(PostDetailsEndRequestHandler);   
}
function PostDetailsEndRequestHandler(sender, args) 
{   
    
    var UserMessage = null;
     
    UserMessage = document.getElementById("hidUserMessage"); 
       
    if(UserMessage != null && UserMessage != "")
    {
       var UserMessageVal = UserMessage.value;
    }
    //alert('hello');
    //By Ritesh to set scroll top
    //CheckForMessageWin();
    switch(UserMessageVal)
    {
         case "AddBlogCommentsSuccessful":
            UserMessage.value = "";
            var AcceptanceStaus = null;
            AcceptanceStaus = document.getElementById("hidCommentAcceptanceStatus"); 
            if(AcceptanceStaus != null && AcceptanceStaus != "")
            {
                var UserAcceptanceStaus = AcceptanceStaus.value;
            }                
            if(UserAcceptanceStaus == 0)
            {
                //alert("Comment on blog is added successfully.\nIt will be visible after approval of blog creator.");
                var msg="Congratulations! Comment has been added successfully.\nIt will be visible after approval of blog creator.";
                ShowMessageBox(msg);
             }
             else
             {
                var msg="Congratulations! Comment has been added successfully.";
                ShowMessageBox(msg);
             }
             AcceptanceStaus.value=""; 
               UserMessage.value = "";         
             break;  
             
         case "EditBlogCommentsSuccessful":
            UserMessage.value = "";
            var AcceptanceStaus = null;
            AcceptanceStaus = document.getElementById("hidCommentAcceptanceStatus"); 
            if(AcceptanceStaus != null && AcceptanceStaus != "")
            {
                var UserAcceptanceStaus = AcceptanceStaus.value;
            }                
            if(UserAcceptanceStaus == 0)
            {
                //alert("Comment on blog is added successfully.\nIt will be visible after approval of blog creator.");
                var msg="Congratulations! Comment has been updated successfully.\nIt will be visible after approval of blog creator.";
                ShowMessageBox(msg);
             }
             else
             {
                var msg="Congratulations! Comment has been updated successfully.";
                ShowMessageBox(msg);
             }
             AcceptanceStaus.value=""; 
               UserMessage.value = "";         
             break;   
             
//            case "DeleteBlogCommentsSuccessful":
//                alert("DeleteBlogCommentsSuccessful");
//                UserMessage.value = "";
//                var AcceptanceStaus = null;
//                var msg="Congratulations! Comment has been deleted successfully.";
//                ShowMessageBox(msg);
//                       
//                 break;   
         case "ReportCommentOffensive":
         
            UserMessage.value = "";  
            var msg="Congratulations! Comment is reported as offensive.";     
            ShowMessageBox(msg); 
            break;   
            
            
           
            
            
        case "PollVoteSuccess":
            UserMessage.value = "";  
           var msg="Congratulations! Vote saved successfully."; 
            ViewPollResult();   
            ShowMessageBox(msg); 
            break;  
            
        case "NotLoggedInUser":
                    document.getElementById("divTwitterLoading").style.display="none";
                    ShowInformationMessageBox("Please login to access this feature.");
                    UserMessage.value = "";  
                    break; 
        case "UserNotHavingTwitterAccount":
            document.getElementById("divTwitterLoading").style.display="none";
//            if(document.getElementById("hidViewedUserDisplayName")!=null && document.getElementById("hidViewedUserDisplayName").value!="")
//            {
//                var DisplayName=document.getElementById("hidViewedUserDisplayName").value;
//                ShowInformationMessageBox(DisplayName+" is not having an account with twitter.");
//               // ShowMessageBox("User is not having an account with twitter.");
//             } 
//             else
//             {
               ShowInformationMessageBox("User is not having an account with twitter.");
             //}  
            UserMessage.value = "";  
            break; 
      case "LoginUserNotHavingTwitterAccount":
                document.getElementById("divTwitterLoading").style.display="none";
                ShowConfimMessage('JSOperation','RedirectToTwitterPage');
                UserMessage.value = "";  
                break; 
      case "SelfCantFollow":
            document.getElementById("divTwitterLoading").style.display="none";
            ShowInformationMessageBox("Twitter doesn't allow users to follow themselves.");
            UserMessage.value = "";  
            break; 
        case "FollowsSuccess":
                document.getElementById("divTwitterLoading").style.display="none";
                ShowMessageBox("You are now following this user.");
                UserMessage.value = "";  
                break; 
             
             
    }
    
}
function CommentRemovedSuccessfullMsg()
{
    
    var AcceptanceStaus = null;
    var msg="Congratulations! Comment has been deleted successfully.";
    ShowMessageBox(msg);
 
}

function DeleteCommentRecordConfirmation(RecordId,btnId)
{

    document.getElementById("confirmBox_hidButtonId").value=btnId;
    document.getElementById("hidRecordId").value=RecordId;
    ShowConfirmBox('Are you sure you want to delete the selected comment?');
    return false;
}

function OffensiveChallengeCommentConfirmation(RecordId,btnId)
{
    document.getElementById("confirmBox_hidButtonId").value=btnId;
    document.getElementById("hidRecordId").value=RecordId;
    ShowConfirmBox('Would you like to report this comment as offensive?');
    return false;
}


        function ShowGetContacts(IsLogin, PostId)
        {
             if(IsLogin=="True")
             {
                ShowModalPopup('divpnlGetContacts','Get Contacts');
                document.getElementById("rdbGmail").checked=true;
                document.getElementById("txtContactEmailId").value="";
                document.getElementById("txtPassword").value="";
                //document.getElementById("ddlProvider").style.display="block";
                HideRegistrationError("WarningMsg3");
                document.getElementById("hidBlogPostId").value = PostId;
             }
             else
             {  
                ShowInformationMessageBox("You need to login first to access this feature."); 
             }
             return false;
        }
        
        function GetContacts()
        {
            xmlHttpObject=null;
            xmlHttpObject=GetXmlHttpObject();
            if (xmlHttpObject==null)
            {
                alert("Browser does not support HTTP Request");
                return;
            } 
            var varTemp = document.getElementById("txtContactEmailId");
            var emailId = document.getElementById("txtContactEmailId").value;
            var pwd = document.getElementById("txtPassword").value;
            
            if(bValidate(varTemp, "Email" ,'false' , 'Email id') != true)
            {
                var errors  = "Please enter valid email id."; 
                ShowRegistrationError("WarningMsg3", errors);
                varTemp.focus();
                return false;   
            }
            if(emailId =="")
            {
                var errors="Email id is missing";
                ShowRegistrationError("WarningMsg3", errors);
                  varTemp.focus();
                return false;
            }
            
            if(pwd =="")
            {
                var errors="Password is missing";
                ShowRegistrationError("WarningMsg3", errors);
                document.getElementById("txtPassword").focus();
                return false;
            }
            
           HideRegistrationError("WarningMsg3");

            
            //var provider = document.getElementById("ddlProvider").value;
            var IsGMail = document.getElementById("rdbGmail").checked;
            var IsYahoo = document.getElementById("rdbYahoo").checked;
            var IsHotmail = document.getElementById("rdbHotmail").checked;
            
            if(IsGMail==true)
            {
                provider = "GMail";
            }
            else if(IsYahoo==true)
            {
                provider = "Yahoo"; 
            }
            else 
            {
                provider = "Hotmail"; 
            }
            

           //alert("provider="+provider);
            var url="../../OpenInviter/example.php";               
            var parameters="email_box="+emailId+"&password_box="+pwd+"&provider_box="+provider; 
            //var parameters="email_box=rsthakur27@yahoo.com&password_box=bcsmcanilu&provider_box=Yahoo"; 
            //var parameters="email_box=rsthakur7@hotmail.com&password_box=bcsmca12$&provider_box=Hotmail";
             
            xmlHttpObject.open("POST",url,true);
            xmlHttpObject.onreadystatechange=stateChangedForContacts;
            xmlHttpObject.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            xmlHttpObject.setRequestHeader("Content-length", parameters.length);
            xmlHttpObject.setRequestHeader("Connection", "close");
            xmlHttpObject.send(parameters);
            document.getElementById("divLoading").style.display="block";
            return false;
        }
        
      
        function stateChangedForContacts() 
        { 
            if (xmlHttpObject.readyState==4 )
            { 
               var response = xmlHttpObject.responseText;
               document.getElementById("hidResponse").value=response;
              // alert(response);
               //alert("response="+document.getElementById("hidResponse").value);
             //  document.getElementById("hidResponse").value="<html><head><script type='text/javascript'>function submitPage(){document.openinviter.submit();}</script></head><body onload='submitPage()'>GMail!~!@@@sreejithpune@gmail.com###Sreejith Krishnankutty@@@ritesh_thakur23@rediffmail.com###ritesh_thakur23@rediffmail.com@@@vsthakur007@yahoo.com###vsthakur007@yahoo.com@@@vssthakur@gmail.com###vikas thakur@@@chaudhary.khalid@gmail.com###Khalid chaudhary@@@arvindsingh5182@gmail.com###Arvind kumar singh@@@diyu_javameet@yahoo.com###Ajay Patel@@@amit.j.27@gmail.com###Amit Kumar Jha@@@mgpatil31@gmail.com###Milind Patil@@@anandks16@sify.com###Anand singh@@@amol_pingale@rediffmail.com###Amol Pingale@@@eclatsatya@gmail.com###Satyaprakash Jha@@@amolam@techmahindra.com###Amol Manchekar@@@mukesh_pandit_mca@yahoo.co.in###Mukesh Pandit@@@starparag@gmail.com###Parag Patil@@@yasmeen.sayyed@gmail.com###Yasmeen Sayyed@@@swaroopa.waghmare@rediffmail.com###Swaroopa Waghmare@@@kailas_mhase@persistent.co.in###Kailash Mhase@@@adevbrat@gmail.com###Ashutosh Devbrat@@@sagargandhi2006@gmail.com###Sagar Gandhi@@@nandu.karlekar@gmail.com###Nandkumar Karlekar@@@rsthakur7@gmail.com###rsthakur7@gmail.com@@@ritesht@harbinger-systems.com###Ritesht@@@pramodjagdale25@gmail.com###pramodjagdale25@gmail.com@@@rsthakur27@yahoo.com###rsthakur27@yahoo.com@@@anitthakur@gmail.com###anitthakur@gmail.com@@@siddhartha@harbinger-systems.com###siddhartha@harbinger-systems.com@@@Onboarding@infosys.com###Onboarding@infosys.com@@@archanaj@harbingergroup.com###Archana@@@arjun@harbingergroup.com###arjun@harbingergroup.com@@@madan.singh@icicibank.com###madan.singh@@@Sameera_226110@infosys.com###Sameera Saman@@@madanmsingh@gmail.com###madan singh@@@varun@harbingergroup.com###varun@harbingergroup.com@@@CnBOffers@infosys.com###CnBOffers@infosys.com@@@nitin.rns@gmail.com###nitin.rns@gmail.com@@@careers.pune@honeywell.com###careers.pune@honeywell.com@@@ashishthakur05@gmail.com###ashishthakur05@gmail.com@@@careers_hrd@infosys.com###careers_hrd@infosys.com@@@purnimabettu@rediffmail.com###purnimabettu@rediffmail.com@@@amit_kumar_jha_1984@yahoo.com###amit_kumar_jha_1984@yahoo.com@@@Nikhil_Dhawan@infosys.com###Nikhil_Dhawan@infosys.com@@@amit_adkar08@yahoo.com###amit_adkar08@yahoo.com@@@arcjagdale@gmail.com###arcjagdale@gmail.com@@@manchekar_amol@rediffmail.com###manchekar_amol@rediffmail.com@@@ritesht@harbingergroup.com###ritesht@harbingergroup.com@@@swaroopaw@gmail.com###swaroopaw@gmail.com@@@amit_adkar08@yahoo.co.in###amit_adkar08@yahoo.co.in!~!</body></html>";
               closepopup('divpnlGetContacts');
               document.getElementById("divLoading").style.display="none";
               ShowModalPopup('divContactsList','Contact List');
               CallButtonClick("btnhidShowContacts");
               return false;
            }
        }
        
        function CallButtonClick(btnId)
        {
         
       
             var btnObj = document.getElementById(btnId);
                if (btnObj != null)
                 { 
                    if ((document.all)||(is_Safari > 0))
                    { 
                        btnObj.click();
                    }
                    else
                    {   
                        var e = document.createEvent("MouseEvents");
                        e.initEvent("click", true, true);
                        btnObj.dispatchEvent(e);
                    }
                 } 
             // setTimeout("this.delayed = false;", 5000);
                 //wait(5000);
                 //alert("end CallButtonClick");
        }
        
        
         function ShowRegistrationError(RegistrationErrorId, Message)
        {
           var registrationErrorsDiv = document.getElementById(RegistrationErrorId +"_RegistrationErrors");            
           registrationErrorsDiv.style.display = "block";
           registrationErrorsDiv.innerHTML = Message;
           document.getElementById(RegistrationErrorId + "_divWarningInfo").style.display = "block";
        }

        function HideRegistrationError(RegistrationErrorId)
        {
            var registrationErrorsDiv = document.getElementById(RegistrationErrorId + "_RegistrationErrors");        
            registrationErrorsDiv.innerHTML = "";
            registrationErrorsDiv.style.display = "none";  
            document.getElementById(RegistrationErrorId + "_divWarningInfo").style.display = "none";
        }
        
        

function ValidateAddNewBlog()
{ 
    errors="";
     var status = true;
     mandatoryFieldsErrorFlag = false;
     var varTemp;
     var alertName;
     var isMandatory;
          
       	//Date Validation		
	 alertName="Posted Date";		
     var currentdate=new Date();
     //var varselectedday = document.getElementById("ddlDayOfMonth").value; 
     //var varselectedMonth = document.getElementById("ddlMonth").value -1;
     //var varselectedYear = document.getElementById("ddlBirthYear").value;
     //var selecteddate=new Date(varselectedYear,varselectedMonth,varselectedday);
     // Check for leap year
//    if (varselectedMonth == 1) 
//    {
//		if ( ( (varselectedYear%4 == 0)&&( varselectedYear%100 != 0) ) || (varselectedYear%400 == 0) ) 
//		{ 
//			if (varselectedday > 29)
//			{ 
//			 errors += alertName + " Month ends  at 29." +'<br/>'; 
//             status= false;
//             return false;
//            
//            }
//            else
//            {
//		    status= true; 
//		    }
//		}
//		else
//		 { 
//		   if (varselectedday > 28)
//		    { 
//		       errors += alertName + "   Month  ends  at 28." +'<br/>'; 
//               status= false; 
//             return false;
//		    } 
//		    else
//		    {
//		    status= true; 
//		    }
//		}
//	 }
//    else if ((varselectedMonth == 3) ||(varselectedMonth == 5)||(varselectedMonth == 8)||(varselectedMonth == 10))
//     {
//		if (varselectedday > 30)
//		 { 
//		   errors += alertName + "  Month  ends  at 30." +'<br/>'; 
//           status= false;
//          return false;
//		 }
//		 else
//		 {
//		   status= true;
//		   }
//	}//    else
//    {
//         if( (currentdate.getDate() == selecteddate.getDate())&& (currentdate.getMonth() == selecteddate.getMonth()) && (currentdate.getFullYear() == selecteddate.getFullYear()))
//           {
//              status= true;
//            
//           }
//         else
//            {
//                    if(selecteddate > currentdate == true)
//                       {
//                           errors += alertName + " can not be greater than current date." +'<br/>'; 
//                           status= false;
//	                        return false;
//                       }
//                    else
//                    {
//                      status= true;
//                      }
//            }
//    }

              
       //Title Validation
      varTemp = document.getElementById("txtBlogTitle");  
      alertName = "Blog Header ";
      isMandatory = 'True';
     if(bValidate(varTemp, "General" ,isMandatory , alertName) != true)
     {
         //errors += "Blog header should not be empty."; 
         status = false; 
         return false;
      }
      else
      {
            if(varTemp.value.length > 200 )
             {
                        errors += "Post header should not contain more than 200 characters ." +'<br/>'; 
                        varTemp.value = varTemp.value.substring(0,199);
						varTemp.focus();
						status=false;
						return false;
						
			}
      }   
     
        alertName="Blog Content";
        varTemp = document.getElementById("ta"); // Rich TinyMCE html textarea
        var MessageTextValue =varTemp.value;
	    MessageTextValue = tinyMCE.getInstanceById("ta").getHTML();
	    if (MessageTextValue=="")
	    {
	      if(mandatoryFieldsErrorFlag == false) 
	      {
			    mandatoryFieldsErrorFlag = true;
	      }
    	  errors += "Post content can not be blank."; 				
	      status=false;
	      return false;
	    }
	

 return true;
}


function ValidateForLogin(isLogin)
{
   
    if(isLogin == "false")
    {
         ShowInformationMessageBox("You need to login first to access this feature."); 
        return false;
    }
    else
    {
        return true;
    }
}

function countInstances(string, word) 
{
   
  var substrings = string.split(word);
  return substrings.length - 1;
}

function SetParameterToFlash()
{
   // alert("start");
     document.PollGraph.SetVariable("LegendText",document.getElementById('hidLegendText').value);
     document.PollGraph.SetVariable("LegendValues",document.getElementById('hidLegendValues').value);
      document.getElementById("divFlashPollResult").style.display = "block";
      document.getElementById("divOpinionPollGadget").style.display = "none";
      
   //  alert("end");
}
   
   function SetParameterToFlashOnLoad()
{
   // alert("start");
     document.PollGraph.SetVariable("LegendText",document.getElementById('hidLegendText').value);
     document.PollGraph.SetVariable("LegendValues",document.getElementById('hidLegendValues').value);
     document.getElementById("divFlashPollResult").style.display = "block";
     document.getElementById("divOpinionPollCollapsedGadget").style.display = "none";
     document.getElementById("btnViewOpinionPoll").style.display = "none";
      
    // alert("end");
     return false;
}
  
function ViewOpinionPoll()
{
  
     document.getElementById("divOpinionPollGadget").style.display = "block";
     document.getElementById("divFlashPollResult").style.display = "none";
     return false;
     
}
     
function ViewPollResult()
{

  
     document.getElementById("divOpinionPollGadget").style.display = "none";
     document.getElementById("divFlashPollResult").style.display = "block";
      //setTimeout('SetParameterToFlash()',500);
     SetParameterToFlash();
     return false;
     
}
function ValidateVote()
{
   // alert("visibility 3= " + document.getElementById("tdAnswer3"));
   // alert("visibility 5= " + document.getElementById("tdAnswer5"));
    var objTd;
    var flag = false;
    var registrationErrorsDiv = document.getElementById("WarningMsgs_divPollWarning");
    var rdo = document.getElementsByName("PollAnswers");
    for(i=0;i<rdo.length;i++)
    {
     if(rdo[i].checked)
     {
        flag = true;
     }
    }
//     rdo = document.getElementsByName("rdbAnswer2");
//     if(rdo.checked)
//     {
//        flag = true;
//     }
//     objTd = document.getElementById("tdAnswer3");
//     if(objTd != null)
//     {
//         rdo = document.getElementsByName("rdbAnswer3");
//         if(rdo.checked)
//         {
//            flag = true;
//         }
//     }
//     objTd = document.getElementById("tdAnswer4");
//     if(objTd != null)
//     {
//         rdo = document.getElementsByName("rdbAnswer4");
//         if(rdo.checked)
//         {
//            flag = true;
//         }
//     }
//     objTd = document.getElementById("tdAnswer5");
//     if(objTd != null)
//     {
//         rdo = document.getElementsByName("rdbAnswer5");
//         if(rdo.checked)
//         {
//            flag = true;
//         } 
//     }
    // alert(flag);
     if(flag == false)
     {
        var registrationErrorsDiv = document.getElementById("PollWarning_RegistrationErrors");
                registrationErrorsDiv.style.display = "block";
                document.getElementById("PollWarning_divWarningInfo").style.display = "block";
                registrationErrorsDiv.innerHTML = "Please select an option to vote ";
//         document.getElementById("PollWarning_divWarningInfo").style.display = "block";
//         document.getElementById("PollWarning_divWarningInfo").innerHTML = " Please select an option to vote ";
         
         return false;
       // document.getElementById("WarningMsgsControl_divWarningInfo").style.display = "block";
     }
     return true;
     
}
function DisplayPostAddedMessage()
{
    var AcceptanceStaus = null;
    var msg="Congratulations! New post added successfully.";
    ShowMessageBox(msg);
}



function prevBlogClick()
{
  
     var btnObj=document.getElementById('hidPrevButton');
     if (btnObj != null)
     { 
        if ((document.all)||(is_Safari > 0))
        {   
            btnObj.click();
            
        }
        else
        {   

            var e = document.createEvent("MouseEvents");
            e.initEvent("click", true, true);
            btnObj.dispatchEvent(e);
        }
     } 
     return false;   
    
}

function nextBlogClick()
{
   
     var btnObj=document.getElementById('hidNextButton');
     if (btnObj != null)
     { 
        if ((document.all)||(is_Safari > 0))
        {   
            btnObj.click();
            
        }
        else
        {   

            var e = document.createEvent("MouseEvents");
            e.initEvent("click", true, true);
            btnObj.dispatchEvent(e);
        }
     } 
     return false;   
    
}







/* Added for blog post preview*/

function getPostPreview(print_area)
		{

			CallButtonClick("hidbtnShowPreviewDetails");
			return false;
			
	}
	function showPostPreview()
	{
//	alert("in preview");
	    var print_area="divPagePreview";
			//setTimeout('10000');
			 var varTemp = document.getElementById("txtBlogTitle");  
             var alertName = "Blog Name";
             var isMandatory = 'True';
             errors = "";
//             if(bValidate(varTemp, "General" ,isMandatory , alertName) != true)
//             {   
//                varTemp.focus();
//               // var registrationErrorsDiv = document.getElementById("WarningMsgs_RegistrationErrors");
//                registrationErrorsDiv.style.display = "block";
//                document.getElementById("WarningMsgsAddPost_divWarningInfo").style.display = "block";
//                registrationErrorsDiv.innerHTML = "";
//                registrationErrorsDiv.innerHTML = errors; 
//			          status = false;
//			          return false; 
//             } 
//              else
//              {
//              
//                    if(varTemp.value.length > 256 )
//                     {
//                        errors = alertName + " should not contain more than 256 characters." +'<br/>'; 
//				        varTemp.focus();
//			            status = false;
//			            return false; 
//			        }
//             }   
   		     var Title =  document.getElementById("txtBlogTitle").value;	
		     if(Title.length > 28)
		     {
		        Title = Title.substring(0, 30) + "..";
		     }
		   // alert("text = "+document.getElementById("ta").value);
		    // ta.InnerText.ToString()
			 var Description  = document.getElementById("hidPostContent").value;//document.getElementById("hidPostContent").value;
		     var len = Description.length;
//             if(len > 1024)
//             {
//                 errors = alertName + " should not contain more than 1024 characters." +'<br/>'; 
//				        document.getElementById("hidPostContent").focus();
//			            status = false;
//			            return false; 
//             }
//		    
//		     if(Description .length > 98)
//		     {
//		     
//		     Description = Description.substring(0, 100) + "..";
//			 }
//			 document.getElementById("lblPreviewBlogName").innerHTML = Title;//document.getElementById("txtBlogName").value;
//	         document.getElementById("lblShortDescription").innerHTML =Description; //document.getElementById("txtDescription").value;
	         document.getElementById("lblCreatorName").innerHTML = document.getElementById("hidUserName").value;
	         
	         document.getElementById("lblPostHeading").innerHTML = Title;//document.getElementById("txtBlogName").value;
	         //alert(Description);
	         document.getElementById("lblBlogPostContents").innerHTML =Description;
	         
	       //  document.getElementById("lblLastUpdatedDate").innerHTML ="Last updated "+;
	         
	         
	         document.getElementById("tblPreviewTopBG").className = "clsPagePreviewTopBGCycling";
	             document.getElementById("tdPreviewRight").style.display = "block";
	             document.getElementById("tdPreviewLeft").style.display = "block";
	             document.getElementById("tblPreviewMiddle").style.width = "951px";

	         //change BG according to theme
//	         var ddlCategory = document.getElementById("ddlBlogCategory").value;
//	         if(ddlCategory == 4)
//	         {
//                 document.getElementById("tblPreviewTopBG").className = "clsPagePreviewTopBGCycling";
//	             document.getElementById("tdPreviewRight").style.display = "block";
//	             document.getElementById("tdPreviewLeft").style.display = "block";
//	             document.getElementById("tblPreviewMiddle").style.width = "951px";

////                document.getElementById("tblPreviewTopBG").style.background = "url('../../Images/backgroundImages/Blogs/blue_box_top_center.png')"; 
////                 document.getElementById("tblPreviewTopBG").style.backgroundRepeat = "no-repeat";
//                 
//	         }
//	         else
//	         {
//	            document.getElementById("tblPreviewTopBG").className = "clsPagePreviewTopBGPlain";
//	            document.getElementById("tdPreviewLeft").style.display = "none";
//	             document.getElementById("tdPreviewRight").style.display = "none";
//	             document.getElementById("tblPreviewMiddle").style.width = "967px";
//	            
//	         }
	   
	
			//Creating new page
			var pp = window.open();
			//Adding HTML opening tag with <HEAD> … </HEAD> portion 
			pp.document.writeln('<HTML><HEAD><title>Blog Preview</title><LINK href=../../CustomizedCSS/BlogHomePage.css  type="text/css" rel="stylesheet">')
			pp.document.writeln('<HTML><HEAD><title>Blog Preview</title><LINK href=../../Css/TopFrame.css  type="text/css" rel="stylesheet">')
			pp.document.writeln('<HTML><HEAD><title>Blog Preview</title><LINK href=../../CustomizedCSS/Buttons.css  type="text/css" rel="stylesheet">')
			pp.document.writeln('<HTML><HEAD><title>Blog Preview</title><LINK href=../../CustomizedCSS/ViewBlogComments.css  type="text/css" rel="stylesheet">')
			
			
			pp.document.writeln('<base target="_self"></HEAD>')
			//Adding Body Tag
			pp.document.writeln('<body MS_POSITIONING="GridLayout" bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0">');
			//Adding form Tag
			pp.document.writeln('<form  method="post">');
			pp.document.writeln(document.getElementById(print_area).innerHTML);
			pp.document.writeln('</form></body></HTML>');		
			
	   		return true;
		}		
	
	
	

