﻿function SetCurrentTab(TabId)
{
    if(document.getElementById(TabId)!=null)
        document.getElementById(TabId).className="CurrentTab";
}

function SetCurrentTabTop(TabId)
{
    if(document.getElementById(TabId)!=null)
            document.getElementById(TabId).className="current1";
}

 function ShowPage(path)
  {
        var args='width=750,height=600,left=100,top=275,toolbar=0,'; 
        args+='location=0,status=0,menubar=0,taskbar=0,resizable=1,scrollbars=1';         
        window.open(path,'',args);   
        return true;
  }

function SetActiveLink(linkId)
{ //  alert(document.getElementById(linkId));
    if(document.getElementById(linkId)!=null)
            document.getElementById(linkId).className="Active";
}

function DisplayThis(id,display)
{
     document.getElementById(id).style.display=display;
}

function SetLoginDefault(focus,Obj,txt)
{
   
        if(focus=='true' && Obj.value==txt)
        {
            Obj.value="";        
        }
        else
        {
            if(Obj.value=="")
             {
                  Obj.value=txt;      
             }
        }  
}

function SetPasswordDefault(Obj)
{
    var defaulttextbox=document.getElementById('txtpassword');
    var txtPassword=document.getElementById('ctl00_ucHeader_txtPassword');
    if(Obj.id=='txtpassword')
    {
        defaulttextbox.style.display='none';
        txtPassword.style.display='';
        txtPassword.focus();
    }
    else
    {
        if(txtPassword.value=="")
        {
            defaulttextbox.style.display='';
            txtPassword.style.display='none';
        }
    }
    
    
    
}

function ValidateUserNamePassword()
{
    if(document.getElementById('ctl00_ucHeader_txtUsername').value=='Email' || document.getElementById('ctl00_ucHeader_txtUsername').value=='')
    {
        alert('Please enter email!');
        document.getElementById('ctl00_ucHeader_txtUsername').focus();
        return false;
    }
    if(document.getElementById('txtpassword').style.display=='')
    {
        alert('Please enter password!');
        document.getElementById('txtpassword').style.display='none';
        document.getElementById('ctl00_ucHeader_txtPassword').style.display='';
        document.getElementById('ctl00_ucHeader_txtPassword').focus();
        return false;
    }
    else
        return true;
}

function ChageCollapseImage(Obj)
{
    
    if(Obj.src.indexOf('index_block_close_img')>-1)
        Obj.src=Obj.src.replace('index_block_close_img','index_block_min_img');
    else if(Obj.src.indexOf('index_block_min_img')>-1)
        Obj.src=Obj.src.replace('index_block_min_img','index_block_close_img');
    else if(Obj.src.indexOf('down_arrow_1.png')>-1)
        Obj.src=Obj.src.replace('down_arrow_1.png','Uparrow_1.png');
    else if(Obj.src.indexOf('Uparrow_1.png')>-1)
        Obj.src=Obj.src.replace('Uparrow_1.png','down_arrow_1.png');
        
}

function ShowSectionPreview(txttitleID,divID,spnTittleID,spnDescriptionID) {
  
   document.getElementById(divID).style.display='';
   var oEditor = FCKeditorAPI.GetInstance('ctl00_ContentPlaceHolder1_edSectionHtml');
   document.getElementById(spnTittleID).innerHTML = document.getElementById(txttitleID).value;
   var html = oEditor.GetXHTML(true);

   //document.getElementById(spnDescriptionID).innerText = html;
  
   document.getElementById(spnDescriptionID).innerHTML = html;
//  document.getElementById(spnDescriptionID).innerHTML="harendra";
// 
//   alert(document.getElementById(spnDescriptionID).innerHTML);
   
   return false;
}

function CheckAll(status)
{
   
    var elements=document.getElementsByTagName('input');
    
    for(var i=0;i<elements.length;i++)
    {         
       var item=elements[i];
       
        if(item.id.indexOf('chkSelect')>-1 && item.type=='checkbox')
        {
             item.checked=status;
        }
    }
    
    return false;
}
function ConfirmUnselected(type,msg)
{
        if(type=='delete')
            return confirm('Are you sure to delete the select record(s)? Please confirm.');           
        else if(type=='activate')
            return confirm('Are you sure to activate the select record(s)? Please confirm.');           
        else if(type=='deactivate')
            return confirm('Are you sure to deactivate the select record(s)? Please confirm.');           
        else
            return confirm(msg); 
}
function Confirm(type,msg)
{
    var elements=document.getElementsByTagName('input');

    var IsSelected=false;
    for(var i=0;i<elements.length;i++)
    {         
       var item=elements[i];
       
        if(item.id.indexOf('chkSelect')>-1 && item.type=='checkbox' && item.checked)
        {
             IsSelected=true;
             break;
        }
    }
   
    if(IsSelected)
    {
        if(type=='delete')
            return confirm('Are you sure to delete the select record(s)? Please confirm.');           
        else if(type=='activate')
            return confirm('Are you sure to activate the select record(s)? Please confirm.');           
        else if(type=='deactivate')
            return confirm('Are you sure to deactivate the select record(s)? Please confirm.');           
        else
            return confirm(msg);        
   }
   else
   {
        alert("Please select at least one record");
        return false;
   }
        
    
}

function ShowObject(filepath)
{
    var ext=filepath.substring(filepath.indexOf('.')+1,filepath.length)
    if(ext=='swf')
    {
    
       document.getElementById('divPlay').innerHTML='<object type="application/x-shockwave-flash" data="'+filepath+'" style="visibility: visible;" width="300" height="120"></object>';
       document.getElementById('VideoPlayMainBlock').style.display='';
    
      // swfobject.embedSWF(filepath, "divPlay", "300", "120", "9.0.0");

    }
    else if(ext=='flv')
    {
        var player='/Images/player1.swf?file='+filepath;
       document.getElementById('divPlay').innerHTML='<object type="application/x-shockwave-flash" data="'+player+'" style="visibility: visible;" width="450" height="300"></object>';
       document.getElementById('VideoPlayMainBlock').style.display=''
    }
    return false;
}
var timer;
var opacityvar=50;
function SetOpacity(id)
{
    
    var obj=document.getElementById(id);
   //alert(obj);
    if(opacityvar>0)
    {
        opacityvar=opacityvar-1;
        obj.style.filter='alpha(opacity='+opacityvar+')';
        obj.style.Mozopacity=eval(opacityvar/100); 
        timer=setTimeout(SetOpacity(id),2000);
    }
    else
    {
        clearTimeout(timer);
        return false;
    }
}

function setDelay(id)
{
   var t=setTimeout("DisplayThis('"+id+"','none')",5000);
}


function HighlightParentChkBox(Obj)
{
    var str1= Obj.id.substring(0,42);
    var str1=str1+'chkModule';
     alert(str1);
   // var chkmodule=document.getElementById('ctl00_ContentPlaceHolder1_rptModule_ctl00_chkModule');
    var chkmodule=document.getElementById('ctl00_ContentPlaceHolder1_rptModule_ctl00_chkModule');
    alert(chkmodule);
}

function SetEnter(id,e)
 {
   
    if(e.which || e.keyCode)
    {
        if((e.which == 13) || (e.keyCode == 13))
        {
            document.getElementById(id).click();
            return false;
        }
        else
        {
           return true;
        }
     }
 }
 function isEmailValid(sEmail) 
{

	if (sEmail.indexOf('.') == 0 || sEmail.indexOf('.') == -1 || sEmail.indexOf('@') == 0 || sEmail.indexOf('@') == -1 || sEmail.indexOf('.') == sEmail.length - 1 || sEmail.indexOf(',') >= 0) 
	    return false;	
	else 
	    return true;
}
function validateContactUsForm()
{
    var txtName=document.getElementById('ctl00_ContentPlaceHolder1_txtName');
    var ddlTopic=document.getElementById('ctl00_ContentPlaceHolder1_ddlSelectTopic');
    var txtEmail=document.getElementById('ctl00_ContentPlaceHolder1_txtEmail');
    var txtSubject=document.getElementById('ctl00_ContentPlaceHolder1_txtSubject');
    var txtMessage=document.getElementById('ctl00_ContentPlaceHolder1_txtMessage');
    var slertStr="Following field(s) are required:";
    if(txtName.value=="")
    {
        slertStr+="\nName.";       
    }
    if(ddlTopic.value=="--------Select a Topic Here---------")
    {
        slertStr+="\nSelect a Topic.";
        
    }
    if(txtEmail.value=="")
    {
        slertStr+="\nEmail Address.";      
    }
    if(!isEmailValid(txtEmail.value) && txtEmail.value != "")
    {
        slertStr+="\nEnter Valid Email Address.";
    } 
    if(txtSubject.value=="")
    {
        slertStr+="\nSubject.";      
    }
     if(txtMessage.value=="")
    {
        slertStr+="\nMessage.";      
    }
    if(slertStr!="Following field(s) are required:")
    {
        alert(slertStr);
        return false;
    }
    
    return true;
    
}

function validateAddNoteForm()
{
    var txtNoteTitle=document.getElementById('ctl00_ContentPlaceHolder1_txtTitle');
     if (txtNoteTitle.value=="")
    {
        alert("Enter Note Title");
        txtNoteTitle.focus();
        return false;
    }
    return true;
}

function validateAddLinkform()
{
    var txtLinkTitle=document.getElementById('ctl00_ContentPlaceHolder1_txtLTitle');
    var txtLinkUrl=document.getElementById('ctl00_ContentPlaceHolder1_txtLUrl');
    var txtLinkDescription=document.getElementById('ctl00_ContentPlaceHolder1_txtLDescription');
    var alertStr="Following field(s) are required:";
     
    if (txtLinkTitle.value=="")
    {
        alertStr+="\nLink Title";
    }
    if(txtLinkUrl.value=="")
    {
        alertStr+="\nLink Target";
    }
    if (txtLinkDescription.value=="")
    {
        alertStr+="\nLink Description";
    }
    if (alertStr !="Following field(s) are required:")
    {
        alert(alertStr);
        return false;
    }
    return true;
}
function validateAddFeedBackForm()
{
    var txtFeedBack=document.getElementById('ctl00_ContentPlaceHolder1_txtFeedBack');
     if (txtFeedBack.value=="")
    {
        alert("Enter FeedBack");
        txtFeedBack.focus();
        return false;
    }
    return true;
}

function validateIndexFrom(txt)
{

    var txtSearch=document.getElementById(txt);
    if(document.getElementById(txt).value=='')
    {
        alert("Enter Search Text");
        txtSearch.focus();
        return false;
    }
    if(!ValidateValue(txt))
    {
        alert("Enter Search Text");
        txtSearch.focus();
        return false;
    }
    else   
        return true;
}

function ValidateValue(txt)
{
    var i=0;
    i=parseInt(i);
    var count=0;
    count=parseInt(count);
    var str=document.getElementById(txt).value;
        
    while(i < str.length)
    {
         if(str.charAt(i) == ' ')
           count++;
        i++;
    }
    if(count==str.length)
        return false;
    else    
        return true;
}

function showTransferUser()
{
    var elements=document.getElementsByTagName('input');

    var IsSelected=false;
    for(var i=0;i<elements.length;i++)
    {         
       var item=elements[i];
       
        if(item.id.indexOf('chkSelect')>-1 && item.type=='checkbox' && item.checked)
        {
             IsSelected=true;
             break;
        }
    }
   
    if(IsSelected)
    {
       if(confirm('Are you sure to transfer the select record(s)? Please confirm.'))
            DisplayThis('VideoPlayMainBlock','');
           
   }
   else
   {
        alert("Please select at least one record");
        return false;
   }
}

function validateForgetPasswordForm()
{

    if(document.getElementById("ctl00_ContentPlaceHolder1_txtEmail").value=='')
    {
        alert('Please enter your email');
        document.getElementById("ctl00_ContentPlaceHolder1_txtEmail").focus();
        return false;
    }
    
    if(!isEmailValid(document.getElementById("ctl00_ContentPlaceHolder1_txtEmail").value))
    {
        alert('Please enter valid email address');
        document.getElementById("ctl00_ContentPlaceHolder1_txtEmail").focus();
        return false;
    }
    else
        return true;
}

function ValidateShareProfileForm()
{
    if(document.getElementById("ctl00_ContentPlaceHolder1_txtEmail").value=='')
    {
        alert('Please enter emaii id');
        document.getElementById("ctl00_ContentPlaceHolder1_txtEmail").focus();
        return false;
    }
    if(!isEmailValid(document.getElementById("ctl00_ContentPlaceHolder1_txtEmail").value))
    {
        alert('Please enter valid emaii id');
        document.getElementById("ctl00_ContentPlaceHolder1_txtEmail").focus();
        return false;
    }
    else
        return true;
}

function ChageImage(ID)
{
    
    if(document.getElementById(ID).src.indexOf('index_block_close_img')>-1)
        document.getElementById(ID).src=document.getElementById(ID).src.replace('index_block_close_img','index_block_min_img');
    else if(document.getElementById(ID).src.indexOf('index_block_min_img')>-1)
        document.getElementById(ID).src=document.getElementById(ID).src.replace('index_block_min_img','index_block_close_img');
    else if(document.getElementById(ID).src.indexOf('down_arrow_1.png')>-1)
        document.getElementById(ID).src=document.getElementById(ID).src.replace('down_arrow_1.png','Uparrow_1.png');
    else if(document.getElementById(ID).src.indexOf('Uparrow_1.png')>-1)
        document.getElementById(ID).src=document.getElementById(ID).src.replace('Uparrow_1.png','down_arrow_1.png');
        
}
