﻿// JScript File
// JScript File
var httpRequest=false;

function makeObject()
{
    var httpRequest;
    if(window.XMLHttpRequest)
    {
        httpRequest=new XMLHttpRequest();
    }
    else if(window.ActiveXObject)
    {
        try
        {
            httpRequest=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch(e)
        {
            httpRequest=new ActiveXObject("Microsoft.XMLHTTP");
        }            
    }
    
    return httpRequest;
}

httpRequest = makeObject();

function _processRequest()
{
    if(httpRequest==null)httpRequest = makeObject();
    if(httpRequest.readyState == 4)
    {
        if(httpRequest.status==200)
        {
            var response=httpRequest.responseText;
            var update=new Array();
            if(response.indexOf('`' != -1))
            {
                update=response.split("`");
                if(update[0]=="search")
                {
                
                    document.getElementById("dvResult").innerHTML=update[1];
                    document.getElementById("hfId").value=update[2];
                    
                
                 if(update[1]=='No result found.')
                 {
              /*For Making Items Optional*/
               //  document.getElementById("dvSubmit").style.display="none";
                 
                 }
                 else
                 {
                 /*For Making Items Optional*/
              // document.getElementById("dvSubmit").style.display="block";
                 }
                }
                if(update[0]=="AddComment")
                {
                    switch(update[1])
                    {
                        case "T":
                        document.getElementById("dvResult").innerHTML="<p>Thanks, for giving your valuable comment.</p>";
                        
                        document.getElementById("txtNameForComment").value="";
                        document.getElementById("txtEmailForComment").value="";
                        document.getElementById("txtWebForComment").value="http://";
                        document.getElementById("txtCommentForComment").value="";
                        
                        
                        break;
                        
                        case "F":
                        document.getElementById("dvResult").innerHTML="<p>Some techical problem occurs while processing your comment. Please try after some time.</p>";
                        break;
                    }
                }
                if(update[0]=="searchMantras")
                {
                    document.getElementById("dvAjaxSearch").innerHTML=update[1];
                    
                }
                if(update[0]=="searchEdit")
                {
                  
                    document.getElementById("dvResult").innerHTML=update[1];
                    document.getElementById("hfId").value=update[2];
                    //document.getElementById("dvSubmit").style.display="block";
                }
                if(update[0]=="deleteItem")
                {
                    switch(update[1])
                    {
                        case "T":
                        var c="li"+update[2];
                        var a=document.getElementById(c).innerHTML.substring(0,document.getElementById(c).innerHTML.indexOf("<div"));
                        document.getElementById(c).innerHTML="<strike>"+a+"</strike>";
                        //document.getElementById(c).style.display="none";
                        break;
                        
                        case "F":
                        var c="li"+update[2];
                        var a=document.getElementById(c).innerHTML.substring(0,document.getElementById(c).innerHTML.indexOf("<div"));
                        document.getElementById(c).innerHTML=a+"<div+ id=\"spItem" + update[2] + "\"><a href=\"javascript:void(0);\"><img src=\"images/canEditMantra.gif\" alt=\"Remove\" title=\"Remove\" onclick=\"RemoveItems('" + update[2] + "')\"></a></div> [Unable to remove, Try again]";
                        break;
                    }
                }
                if(update[0]=="deleteTags")
                {
                    switch(update[1])
                    {
                        case "T":
                        var c="liTag"+update[2];
                        var a=document.getElementById(c).innerHTML.substring(0,document.getElementById(c).innerHTML.indexOf("<div"));
                        document.getElementById(c).innerHTML="<strike>"+a+"</strike>";
                        //document.getElementById(c).style.display="none";
                        break;
                        
                        case "F":
                        var c="liTag"+update[2];
                        var a=document.getElementById(c).innerHTML.substring(0,document.getElementById(c).innerHTML.indexOf("<div"));
                        document.getElementById(c).innerHTML=a+"<div id=\"spTags" + update[2] + "\"><a href=\"javascript:void(0);\"><img src=\"images/canEditMantra.gif\" alt=\"Remove\" title=\"Remove\" onclick=\"RemoveTags('" + update[2] + "')\"></a></div> [Unable to remove, Try again]";
                        break;
                    }
                }
            }
        }
    }
}

function CallAjax()
{
    if(document.getElementById("txtName").value=="")
    {
        
        alert("Please provide Meditation Name");
        document.getElementById("txtName").focus();
        document.getElementById("txtName").style.backgroundColor="#FFFFCC";
    }
    else
    {
        document.getElementById("txtName").style.backgroundColor="#FFFFFF";
        document.getElementById("dvResult").innerHTML="<p><strong>Searching Mantras </strong></p><img src=\"images/fm_loader.gif\" alt=\"Searching\" title=\"Searching\" />";
        document.getElementById("hfId").value="";
        document.getElementById("hfChecked").value="";
       /* document.getElementById("dvSubmit").style.display="none";*/
        var a = document.getElementById("txtName").value;
        
        a=encodeURIComponent(a);
//        a=a.replace("'","''");
//        a=a.replace(")"," ");
//        a=a.replace("("," ");
        
        a=replaceAll(a,"'","''");
         a=replaceAll(a,")"," ");
          a=replaceAll(a,"("," ");
        
        var b = document.getElementById("txtKeyWords").value;
//        b=b.replace("'","''");
//        b=b.replace(")"," ");
//        b=b.replace("("," ");
        
        b=replaceAll(b,"'","''");
         b=replaceAll(b,")"," ");
          b=replaceAll(b,"("," ");
        
        b=encodeURIComponent(b);
        httpRequest.open("POST","ajaxMeditationAdmin.aspx",true);
        httpRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
        httpRequest.onreadystatechange=_processRequest;
        httpRequest.send("mode=search&text="+a+"&other="+b+"&m="+Math.random());
        
    }
}

function check(a)
{
    if(document.getElementById(a))
    {
        //alert(document.getElementById(a).checked);
        if(document.getElementById(a).checked)
        {
            document.getElementById(a).checked=false;
            AddMantrasItem(a,'0');
        }
        else
        {
            document.getElementById(a).checked=true;
            AddMantrasItem(a,'1');
        }
    }
    
    
    if(document.getElementById("chkAll").checked)
    {
        document.getElementById("chkAll").checked=false;
    }
    
            
}

function CheckAll()
{
    var a=document.getElementById("hfId").value;
    if(a!="")
    {
        var ids=new Array();
        ids=a.split(",");
        if(document.getElementById("chkAll").checked)
        {
            for(var i=0;i<ids.length;i++)
            {
                if(document.getElementById(ids[i]))
                {
                    document.getElementById(ids[i]).checked=true;
                }
            }
            document.getElementById("hfChecked").value=a;
        }
        else
        {
            for(var i=0;i<ids.length;i++)
            {
                if(document.getElementById(ids[i]))
                {
                    document.getElementById(ids[i]).checked=false;
                }
            }
            document.getElementById("hfChecked").value="";
        }
    }
}

function AddMantrasItem(Id,s)
{
    // 0 - Remove
    // 1 - Add
    switch(s)
    {
        case "0":
        Id=Id+",";
        //alert(Id);
        document.getElementById("hfChecked").value=replaceAll(document.getElementById("hfChecked").value,Id,"");
        break;
        
        case "1":
        document.getElementById("hfChecked").value+=Id+",";
        /*if(!CheckAvailable(Id))
        {
            alert("aaya");
            document.getElementById("hfChecked").value+=Id+",";
        }
        else
        {
            alert("aaya11");
        }*/   
        break;
    }
}

function CheckAvailable(Id)
{
    var f=false;
    var exId=new Array();
    if(document.getElementById("hfChecked").value!=null)
    {
        exId=document.getElementById("hfChecked").value.split(",");
        for(var i=0;i<exId.length;i++)
        {
            if(exId[i]==Id)
            {
                f=true;
                break;
            }
        }
    }
    return f;
}

function replaceAll(oldStr,findStr,repStr) {
  var srchNdx = 0;  // srchNdx will keep track of where in the whole line
                    // of oldStr are we searching.
  var newStr = "";  // newStr will hold the altered version of oldStr.
  while (oldStr.indexOf(findStr,srchNdx) != -1)  
                    // As long as there are strings to replace, this loop
                    // will run. 
  {
    newStr += oldStr.substring(srchNdx,oldStr.indexOf(findStr,srchNdx));
                    // Put it all the unaltered text from one findStr to
                    // the next findStr into newStr.
    newStr += repStr;
                    // Instead of putting the old string, put in the
                    // new string instead. 
    srchNdx = (oldStr.indexOf(findStr,srchNdx) + findStr.length);
                    // Now jump to the next chunk of text till the next findStr.           
  }
  newStr += oldStr.substring(srchNdx,oldStr.length);
                    // Put whatever's left into newStr.             
  return newStr;
}

function Validate()
{
   
    var f=false;
    var msg="";
   
   if(document.getElementById("txtName").value=="")
    {
        document.getElementById("txtName").focus();
         document.getElementById("txtName").style.backgroundColor="#FFFFCC"
        msg="Please provide name for Meditation";
        f=false;
    }
   else if(document.getElementById("ddlmantra").value=="0")
    {
        document.getElementById("ddlmantra").focus();
         document.getElementById("ddlmantra").style.backgroundColor="#FFFFCC"
        msg="Please select Mantra for Meditation";
        f=false;
    }
    
    
    
  /*   For Making Items Optional
   else if(document.getElementById("hfChecked").value=="")
    {
     msg="Please select Items for Meditation";
     f=false;
    }*/
   
    else
    {
        f=true;
        //document.getElementById("hfChecked").style.backgroundColor="#FFFFFF"
    }
    
    /*
    // Description
    if(document.getElementById("txtDesc").value=="" && f)
    {
        f=true;
        document.getElementById("txtDesc").style.backgroundColor="#FFFFFF"
    }
    else if(msg=="")
    {
        msg="Please provide the description for Mantra";
        document.getElementById("txtDesc").focus();
        document.getElementById("txtDesc").style.backgroundColor="#FFFFCC"
        f=false;
    }
    
    // Meditation
    if(document.getElementById("txtMeditation").value=="" && f)
    {
        f=true;
        document.getElementById("txtMeditation").style.backgroundColor="#FFFFFF"
    }
    else if(msg=="")
    {
        msg="Please provide the Meditation for Mantra";
        document.getElementById("txtMeditation").focus();
        document.getElementById("txtMeditation").style.backgroundColor="#FFFFCC"
        f=false;
    }
    
    // Teaching
    if(document.getElementById("txtTeaching").value=="" && f)
    {
        f=true;
        document.getElementById("txtTeaching").style.backgroundColor="#FFFFFF"
    }
    else if(msg=="")
    {
        msg="Please provide the Teaching for Mantra";
        document.getElementById("txtTeaching").focus();
        document.getElementById("txtTeaching").style.backgroundColor="#FFFFCC"
        f=false;
    }
    
    // Tags
    if(document.getElementById("txtTags").value=="" && f)
    {
        f=true;
        document.getElementById("txtTags").style.backgroundColor="#FFFFFF"
    }
    else if(msg=="")
    {
        msg="Please provide the Tags for Mantra";
        document.getElementById("txtTags").focus();
        document.getElementById("txtTags").style.backgroundColor="#FFFFCC"
        f=false;
    }
    */
    if(!f)
    {
        alert(msg);
        }
  return f;
    //  // return false;
}

//-----------------------------------------------------------------
// Edit Mantra Section
//-----------------------------------------------------------------
function CheckSelected(){
    var a=document.getElementById("ddlMantraName").value;
    if(a=="-1"){
        alert("Please select the Mantra Name");
       
        return false;}
    else
        return true;        
}

function CallAjaxForEditMeditation()
{
    if(document.getElementById("txtMedName").value=="")
    {
        alert("Please provide Meditation Name");
        document.getElementById("txtMedName").focus();
        document.getElementById("txtMedName").style.backgroundColor="#FFFFCC";
       
        return false;
    }
    else
    {
        document.getElementById("txtMedName").style.backgroundColor="#FFFFFF";
        document.getElementById("dvResult").innerHTML="<img src=\"images/fbloader.gif\" alt=\"Searching\" title=\"Searching\" />";
        
        
        var a = document.getElementById("txtMedName").value;
        a=replaceAll(a,"'","''");
        a=replaceAll(a,"("," ");
        a=replaceAll(a,")"," ");
        a=encodeURIComponent(a);
        var b = document.getElementById("txtKeyWords").value;
        b=replaceAll(b,"'","''");
        b=replaceAll(b,"("," ");
        b=replaceAll(b,")"," ");
        b=encodeURIComponent(b);
        var c=document.getElementById("txtMedID").value;
        c=encodeURIComponent(c);
        
        
        
        httpRequest.open("POST","ajaxMeditationAdmin.aspx",true);
        httpRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
        httpRequest.onreadystatechange=_processRequest;
        httpRequest.send("mode=searchEdit&text="+a+"&other="+b+"&Id="+c+"&m="+Math.random());
    }        
}
function checkAlert(a)
{
    alert("Sorry, Item "+a+" Already Selected");
}
 
function CheckInActive()
{
    var b=document.getElementById("ddlMeditationName").value;
   // alert(document.getElementById("ddlMeditationName").value);
    if(b=="0")
    {
        alert("Please select the Mantra");
        document.getElementById("chkInActive").checked=false;
        document.getElementById("ddlMeditationName").focus();
    }
    else
    {
        if(document.getElementById("chkInActive").checked)
        {
            var c=document.getElementById("txtMedName").value;
            c= replaceAll(c,"'","");
            var a=confirm("Are you sure to InActive : "+c);
            if(a)
            {
                document.getElementById("chkInActive").checked=true;
            }
            else
            {
                document.getElementById("chkInActive").checked=false;
            }            
        }
    }        
}
function RemoveItems(a,itemname)
{
    var con=confirm('Are you sure to delete the Item: '+itemname);
    
   var b=document.getElementById("txtMedID").value;
   
   if(con)
   {
   document.getElementById("spItem"+a).innerHTML="<img src=\"images/fbloader.gif\" alt=\"Searching\" title=\"Searching\" />";
    httpRequest.open("POST","ajaxMeditationAdmin.aspx",true);
    httpRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    httpRequest.onreadystatechange=_processRequest;
    httpRequest.send("mode=deleteItem&a="+a+"&b="+b+"&m="+Math.random());
    }
}
function RemoveTags(a)
{
    var b=document.getElementById("txtMedID").value;
    var con=confirm('Are you sure you want to delete the Tag ?');
    if(con)
    {
    document.getElementById("spTags"+a).innerHTML="<img src=\"images/fbloader.gif\" alt=\"Searching\" title=\"Searching\" />";
    
    httpRequest.open("POST","ajaxMeditationAdmin.aspx",true);
    httpRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    httpRequest.onreadystatechange=_processRequest;
    httpRequest.send("mode=deleteTags&a="+a+"&b="+b+"&m="+Math.random());
    }
}
//function loadjscssfile(filename, filetype)
//{
//    var f=false;
//    if (filetype=="js")
//    { //if filename is a external JavaScript file
//        var fileref=document.createElement('script')
//        fileref.setAttribute("type","text/javascript")
//        fileref.setAttribute("src", filename)
//        f=true;
//    }
//    else if (filetype=="css")
//    { 
//        //if filename is an external CSS file
//        var fileref=document.createElement("link")
//        fileref.setAttribute("rel", "stylesheet")
//        fileref.setAttribute("type", "text/css")
//        fileref.setAttribute("href", filename)
//        f=true;
//    }
//    if (typeof fileref!="undefined")
//    {
//        document.getElementsByTagName("head")[0].appendChild(fileref);
//        f=true;
//    }
//        
//    return f;
//}
//Email Check

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}


//End Email Check
//WEB URL Check
function is_valid_url(url)
{
     return url.match(/^(ht|f)tps?:\/\/[a-z0-9-\.]+\.[a-z]{2,4}\/?([^\s<>\#%"\,\{\}\\|\\\^\[\]`]+)?$/);
}
//End Web URL Check

//-----------------------------------------------------------------
// Mantra Landing Section
//-----------------------------------------------------------------
function PostComment()
{
  
    var f=false;
    if(document.getElementById("txtNameForComment").value=="")
    {
        
        alert("Please provide Name");
        document.getElementById("txtNameForComment").focus();
        document.getElementById("txtNameForComment").style.backgroundColor="#FFFFCC";
        f=true;
        
        document.getElementById("txtCommentForComment").style.backgroundColor="#FFFFFF";
    }
    else if(document.getElementById("txtCommentForComment").value=="" && !f)
    {
        alert("Please provide Comment");
        document.getElementById("txtCommentForComment").focus();
        document.getElementById("txtCommentForComment").style.backgroundColor="#FFFFCC";
        f=true;
        document.getElementById("txtNameForComment").style.backgroundColor="#FFFFFF";
    }
    else if(document.getElementById("txtEmailForComment").value!="")
    {
   
    echeck(document.getElementById("txtEmailForComment").value);
    document.getElementById("txtEmailForComment").focus();
    document.getElementById("txtEmailForComment").style.backgroundColor="#FFFFCC";
    f=true;
    }
     
       
        
    else if(document.getElementById("txtWebForComment").value != "http://")
    {
    
    if(is_valid_url("txtWebForComment") !=true)
    {
    alert("Invalid Web URL");
    document.getElementById("txtWebForComment").focus();
    document.getElementById("txtWebForComment").style.backgroundColor="#FFFFCC";
    f=true;
    }
    else
    {
    document.getElementById("txtWebForComment").style.backgroundColor="#FFFFFF";
    f=false;
    }
    
    }
     
    
    else if (!f)
    {
        document.getElementById("txtNameForComment").style.backgroundColor="#FFFFFF";
        document.getElementById("txtCommentForComment").style.backgroundColor="#FFFFFF";
        document.getElementById("dvResult").innerHTML="Sending your comment.<img src=\"http://www.spiritvoyage.com/images/commentloader.gif\" alt=\"\" title=\"\" />";
        
        var a = document.getElementById("txtNameForComment").value;
        a=encodeURIComponent(a);
        
        a=replaceAll(a,"'","''");
        var b = document.getElementById("txtEmailForComment").value;
        b=encodeURIComponent(b);
       // b=b.replace("'","''");
          b=replaceAll(b,"'","''");
        var c=document.getElementById("txtWebForComment").value;
        c=encodeURIComponent(c);
       // c=c.replace("'","''");
          c=replaceAll(c,"'","''");
        var d=document.getElementById("txtCommentForComment").value;
        d=encodeURIComponent(d);
        
        //d=d.replace("'","''");
          d=replaceAll(d,"'","''");
        var e=document.getElementById("hidItemId").value;
        e=encodeURIComponent(e);
        //e=e.replace("'","''");
        e=replaceAll(e,"'","''");
        
      httpRequest.open("POST","ajaxMeditationAdmin.aspx",true);
     // httpRequest.open("POST","http://www.spiritvoyage.com/ajaxMeditationAdmin.aspx",true);
        httpRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
        httpRequest.onreadystatechange=_processRequest;
        httpRequest.send("mode=comment&name="+a+"&email="+b+"&web="+c+"&comment="+d+"&ItemId="+e+"&m="+Math.random());
    }
}
//-----------------------------------------------------------------


//-----------------------------------------------------------------
// Mantra Home Page
//-----------------------------------------------------------------
function Search(srcTerm,id)
{
   //alert("Meditation Name By Alphabet");
   //alert(srcTerm + id);
    if(document.getElementById('Anchor'+id))
    {
       document.getElementById("Anchor"+id).className="selectAlph";
    }
    for(var i=1;i<=26;i++)
    {
        if(i==id)
            continue;
        else
        {
            if(document.getElementById('Anchor'+i))
            {
                document.getElementById("Anchor"+i).className="";
            }
        }            
    }
    
    document.getElementById("dvAjaxSearch").innerHTML="<img src=\"http://www.spiritvoyage.com/pictures/loading.gif\" alt=\"Searching\" style=\"margin:0 auto; width:32px; height:32px; display:block\">"
    
    httpRequest.open("POST","ajaxMeditationAdmin.aspx",true);
    httpRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    httpRequest.onreadystatechange=_processRequest;
    httpRequest.send("mode=searchMantras&keyword="+srcTerm+"&m="+Math.random());
    
} 

//-----For Adding Tags-------
function AddTag_Edit(RecType,TagStatus,hidItemId,txtTagName)
{
  
          if(document.getElementById(hidItemId)!=null && document.getElementById(txtTagName) !=null)
          {
                if(document.getElementById(hidItemId).value!="")
                {
                     if(document.getElementById(txtTagName).value!="")
                     {
                        var recId=document.getElementById(hidItemId).value;
                        var tagName=document.getElementById(txtTagName).value;
                      // httpRequest.open("get", "http://www.spiritvoyage.com/AjaxTag.aspx?action=add&RecId="+recId+"&RecType="+RecType+"&TagText="+tagName+"&TagStatus="+TagStatus+"&m="+ Math.random(),true);
                       httpRequest.open("get", "AjaxTag.aspx?action=add&RecId="+recId+"&RecType="+RecType+"&TagText="+tagName+"&TagStatus="+TagStatus+"&m="+ Math.random(),true);    
                       // httpRequest.open("get", "http://localhost:1623/spiritvoyagenew/AjaxTag.aspx?action=add&RecId="+recId+"&RecType="+RecType+"&TagText="+tagName+"&TagStatus="+TagStatus+"&m="+ Math.random(),true);  
                       // alert('OBBBBB');
                        httpRequest.onreadystatechange = processRequestAddTag_E;
                        httpRequest.send(null);
                     }
                     else
                     {
                       if(document.getElementById("divTagmsg")!=null)
                       {
                       
                        document.getElementById("divTagmsg").innerHTML="<font color='red'>* Please provide tag name.</font><br/><br/>"
                       }
                     
                        
                        return false;
                     }
               }
               else
               {
                       if(document.getElementById("divTagmsg")!=null)
                       {
                        document.getElementById("divTagmsg").innerHTML="<font color='red'>* Item is not available!</font><br/><br/>"
                       }
                  
                  return false;
               }
         }  
          

 }

function processRequestAddTag_E()
{
          
            if(httpRequest.readyState < 4)
            {
              if(document.getElementById("divTagmsg")!=null)
              {
               //alert('OKKKKKKKK');
                document.getElementById("divTagmsg").innerHTML="<img src='http://www.spiritvoyage.com/Images/commentloader.gif' alt='Processing'><font color='#D63B02'>&nbsp;Please wait.</font>"
              }
            }
   
            if(httpRequest.readyState == 4)
            {
                        if(httpRequest.status==200)
                        {
                                    document.getElementById("divTagmsg").innerHTML="";
                                    var response=httpRequest.responseText;
                                    var update=new Array();
                                    if(response.indexOf('|' != -1))
                                    {
                                     
                                        update=response.split("|");
                                         
                                       if(update[0]=="Added")
                                       {
                                         if(document.getElementById("txtTagName")!=null)
                                         {
                                           document.getElementById("txtTagName").value="";
                                         }
                                          
                                           if(document.getElementById("divTagmsg")!=null)
                                           {
                                             document.getElementById("divTagmsg").innerHTML="<font color='red'>Tag added successfully!<br/></font><br/><br/>"
                                           }
                                       }
                                       if(update[0]=="Not Added")
                                       {
                                           if(document.getElementById("divTagmsg")!=null)
                                           {
                                             document.getElementById("divTagmsg").innerHTML="<font color='red'>* Tag is not added!</font><br/><br/>"
                                           }
                                        
                                       }
                                       if(update[0]=="Error")
                                       {
                                           if(document.getElementById("divTagmsg")!=null)
                                           {
                                             document.getElementById("divTagmsg").innerHTML="<font color='red'>* There is some server error!</font><br/><br/>"
                                           }
                                        
                                       }
                                          
                                    }
                        }            
            }
}
function UpdateMeditationValidate()
{
        var f=false;
        var msg="";
   
   if(document.getElementById("ddlMeditationName").value=="0")
    {
        document.getElementById("ddlMeditationName").focus();
        document.getElementById("ddlMeditationName").style.backgroundColor="#FFFFCC"
        msg="Please select Meditation Name";
               
        f=false;
    }
   else if(document.getElementById("txtMedName").value=="")
    {
        document.getElementById("txtMedName").focus();
        document.getElementById("txtMedName").style.backgroundColor="#FFFFCC"
        msg="Please select Meditation Name";
        
        f=false;
    }
   
    else
    {
        f=true;
        
    }
    if(!f)
    {
    alert(msg);
    }
  return f;
}

//  End Adding Tags

//For Checking Image File
    function CheckImage()
    {
    var rtn=false;
    if(document.getElementById("txtMedName").value=="")
    {
        document.getElementById("txtMedName").focus();
        document.getElementById("txtMedName").style.backgroundColor="#FFFFCC"
        alert('Please select Meditation Name');
        rtn=false;
    }
    else if(document.getElementById("flMed").value=="")
    {
    rtn=false;
    document.getElementById("flMed").focus();
    document.getElementById("flMed").style.backgroundColor="#FFFFCC"
    alert('Please Select Image for Meditation');
    }
    else
    {
    rtn=true;
    }
    return rtn;
    }
    
    function visibleUploader(id)
    {
   // alert(id);
    document.getElementById("uploaded_"+id).style.visibility="visible";
    document.getElementById("selecter_"+id).style.visibility="hidden";
   //alert(document.getElementById("hf_"+id).value);
    document.getElementById("OpenUploader").value=document.getElementById("OpenUploader").value + "FL_" + id + ",";
 
  //  alert(document.getElementById("OpenUploader").value);
    return false;
    }
//End
//
function ValidPop()
{
        var f=false;
        var msg="";
   
   if(document.getElementById("ddlMeditationName").value=="0")
    {
        document.getElementById("ddlMeditationName").focus();
        document.getElementById("ddlMeditationName").style.backgroundColor="#FFFFCC"
        alert('Please select Meditation Name');
               
        f=false;
    }
    else
    {
    f=true;
    }
     return f;
    }
//
