//Common functions


// Function to disable window while  partial updating (using ajax)
    function pageLoad()
    {      
       var manager = Sys.WebForms.PageRequestManager.getInstance();
       manager.add_endRequest(endRequest);
       manager.add_beginRequest(OnBeginRequest);
    }
    function OnBeginRequest(sender, args)
    {    
     $get('ctl00_divDisableBackground').style.display='block'
     $get('ctl00_divDisableBackground').className ='BackgroundAJAX';   
    }
    function endRequest(sender, args)
    {
    $get('ctl00_divDisableBackground').style.display='none'
       $get('ctl00_divDisableBackground').className ='';
    } 

// Function to disable window ends

    
  
    
function CallPrint(strid)
{
  //<input value="print" type=button onclick="CallPrint('divPrint')" />
    //<div class="TabDiv" id="divPrint"></DIV>
    
 var prtContent = document.getElementById(strid);
 var WinPrint = window.open('/print.aspx','','left=0,top=0,width=700px,height=400px,toolbar=0,scrollbars=1,status=0');
 WinPrint.document.write("<div align='right'><a href='javascript:window.print();'>Print</a></div>"+prtContent.innerHTML);
//alert(WinPrint.document.getElementById("PrintContent").innerHTML)
//alert(prtContent.innerHTML)
 //WinPrint.document.getElementById("PrintContent").innerHTML = prtContent.innerHTML;
// WinPrint.document.close();
// WinPrint.focus();
 //WinPrint.print();
 //WinPrint.close();
 //prtContent.innerHTML=strOldOne;
}


    function confirmDelete()
   {
      return confirm("Are you sure you want to delete it.");
   }
   
   function ValidateFileUploadImage(sender, args)
  {
  //alert(sender.controltovalidate)
 
    //var regex = /^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w ]*.*))+\.(jpg|JPG|jpeg|JPEG|bmp|BMP|png|PNG)$/;  // for complete path
    var regex = /^.+[.](jpg|JPG|jpeg|JPEG|bmp|BMP|png|PNG)$/; // this check just file name e:g abc.jpg
	Val=args.Value
	if (!regex.test(Val)) 
      {     
	     args.IsValid = false;
         return;
      }

    args.IsValid = true;
  }
   function ValidateFileUpload(sender, args)
  {
    var regex = /^.+[.](pdf|PDF|rtf|RTF|doc|DOC|zip|ZIP|ppt|PPT|xls|XLS)$/; // this check just file name e:g abc.jpg
	Val=args.Value
	if (!regex.test(Val)) 
      {     
	     args.IsValid = false;
         return;
      }

    args.IsValid = true;
  }
 function ValidateEmail(sender, args)
  {
    var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/; // this check just file name e:g abc.jpg
	Val=args.Value
	if (!regex.test(Val)) 
      {     
	     args.IsValid = false;
         return;
      }

    args.IsValid = true;
  }
  function ValidateDropDown(sender, args)
  {
  
      if (args.Value == 0) 
      {
         args.IsValid = false;
         return;
      }

    args.IsValid = true;
  }
  
  //To validate FCKeditor 
var fckBody; 
    function FCKeditor_OnComplete(fckInstance)
    {       
        fckBody = fckInstance;
    } 
    function ValidateEditorBody(source, args) //To validate FCKeditor set  ValidateEmptyText="true" of custom validator
    {      
         args.IsValid = fckBody.GetXHTML(true) != "";   
    }
    
       
 
  
function highLight(src)
{
     src.className="highlight";
}

function highLight_Out(src)
{
    src.className="highlight_non";
}

function checkStatus(radioObj)
{id="ctl00$CPAdminInner$TabContainer1$TabPnlAddEvnt$rdbNewsOrEvents"
	val="";
	radioObj=document.getElementById(id);
	if(!radioObj)
	return "";
    var radioLength = radioObj.length;
    
    for(var i = 0; i < radioLength; i++)
     {
	    if(radioObj[i].checked) {
		    val= radioObj[i].value;
	    }
    }



}

function popitup(url,width,height) {
newwindow=window.open(url,'name','left=130,top=70,scrollbars=yes,width='+width+',height='+height+'');
if (window.focus) {newwindow.focus()}
return false;
}
 
// functions for Category starts here 
 function selectOperation()
        {
      
            flag="T"
	        st="Please provide ::";
	        
	        namePre="ctl00$ContentPlaceHolder1$CMS1$TabContainerAccount$TabPanel1$"
	        IdPre="ctl00_ContentPlaceHolder1_CMS1_TabContainerAccount_TabPanel1_"
            
            var radioGrp = document.getElementsByName(namePre+'rdOperation');
           
            for(i=0; i < radioGrp.length; i++)
            {
	            if (radioGrp[i].checked == true) 
	            {
		        var radioValue = radioGrp[i].value;
	            }
            }
           // alert(radioValue)
            switch (radioValue)
            {
                case "N": //Add new 
                     document.getElementById('dvAddEditCt').style.display="block";
                     
                      document.getElementById(IdPre+'txtCategory').value=""
                      document.getElementById(IdPre+'txtCatBrief').value=""
                      
                        document.getElementById('divOpChoice').style.display="none";
                        document.getElementById('divOpSel').style.display="block";
                        document.getElementById('lblOpSel').innerText="Add Section";
                     return false
                     break;
                case "E": //Edit Category 
                
                     if(SetVisibilty())
                     {
                     
                      document.getElementById(IdPre+'txtCategory').value= document.getElementById(IdPre+'hdCatName').value
                 
                      
                        document.getElementById('divOpChoice').style.display="none";
                        document.getElementById('divOpSel').style.display="block";
                        document.getElementById('lblOpSel').innerText="Edit selected Section";
                            
                     }
                     return false
                     break;
                case "D": //Delete Category 
                     if(document.getElementById(IdPre+'ddADDCategories').selectedIndex!="0")
                     {
                        return confirmDelete()
                    }else
                    {
                     alert("Select section to Delete")
                     return false
                    }
                    
                    break;
           }
  }
function CancelSection()
   {
    
        document.getElementById('divOpChoice').style.display="block";
        document.getElementById('divOpSel').style.display="none";
        document.getElementById('lblOpSel').innerText="";
        document.getElementById(IdPre+'txtCategory').value=""
        document.getElementById(IdPre+'txtCatBrief').value=""
         document.getElementById('dvAddEditCt').style.display="none";
         return false
   } 
function SetVisibilty()
   {
    
	         IdPre="ctl00_ContentPlaceHolder1_CMS1_TabContainerAccount_TabPanel1_"
            if(document.getElementById(IdPre+'ddADDCategories').selectedIndex!="0")
              {
              
             
                document.getElementById('dvAddEditCt').style.display="block";
                return true
              }
            else
            {   
            alert("Select Section to Edit")
             document.getElementById('dvAddEditCt').style.display="none";
             return false
            }
   } 
   function ValidateCategory()
{
    tempstname=""
    tempst=""
    flag="T"

    IdPre="ctl00_ContentPlaceHolder1_CMS1_TabContainerAccount_TabPanel1_"

	flagLong="T"
	st="Please provide :: ";
	
	    if(document.getElementById(IdPre+'txtCategory').value=="")
		{
		
			st=st + "\n - Section name.";
			flag="F";
		}
		if(document.getElementById(IdPre+'txtCatBrief').value=="")
		{
		
			st=st + "\n - Brief info. about section.";
			flag="F";
		}
	
		 
	if (flag=="F")
		{
			alert(st);
			return false;
		}
		else
		{
		 return true;
		}
  }   
// Function Categories  Ends

 
  





 // Validatins  for Content Form starts  here
 /*  //Not in use
function ValidateContentForm()
{

tempstname=""
tempst=""
flag="T"


  IdPre="ctl00_ContentPlaceHolder1_CMS1_TabContainerAccount_TabPanelMngAc_"

	flagLong="T"
	st="Please provide ::";
	
	 	
	  if(document.getElementById(IdPre+'ddCategory4ContentAdd').selectedIndex=="0")
		{
		
			st=st + "\n - Section.";
			flag="F";
		} 
		
	   if(document.getElementById(IdPre+'txtTitle').value=="")
		{
		
			st=st + "\n - Title.";
			flag="F";
		}
		
		var oEditor = FCKeditorAPI.GetInstance(IdPre+'EditorContent');
        var contents = oEditor.GetXHTML(true); 
	     if(contents=="")
		    {
    		
			    st=st + "\n - Content.";
			    flag="F";
		    }
  

	    
	if (flag=="F")
		{
			alert(st);
			return false;
		}
		else
		{
		 return true;
		}
}



//Script For admin  Section Categories [Job]
// functions for gallery section starts



function CreateNewFileControl()
{
IdPre=""

    var ChildNode=  document.getElementById("DivImageBrowsw").appendChild(document.createElement("Div"))
    var NewFileControl=document.createElement("input")
    divId="flUploadImage"+document.getElementById(IdPre+'totalFileControls').value
    divName="flUploadImage"+document.getElementById(IdPre+'totalFileControls').value
    NewFileControl.setAttribute('id',divId);
    NewFileControl.setAttribute('name',divName);
    NewFileControl.setAttribute('type',"file");
    ChildNode.appendChild(NewFileControl)
    
    var NewFileControl=document.createElement("span")
    NewFileControl.innerHTML="&nbsp;&nbsp;&nbsp;"
    ChildNode.appendChild(NewFileControl)
    
    var NewFileControl=document.createElement("input")
    divIdName="txtImageCaption"+document.getElementById(IdPre+ 'totalFileControls').value
    NewFileControl.setAttribute('id',divIdName);
    NewFileControl.setAttribute('name',divIdName);
    NewFileControl.setAttribute('type',"text");
    ChildNode.appendChild(NewFileControl)
   
 
    divIdName="spanUploadImage"+document.getElementById(IdPre+'totalFileControls').value
    var NewFileControl=document.createElement("span")
    NewFileControl.setAttribute('id',divIdName);
    NewFileControl.innerHTML="&nbsp;<a href='javascript:' onclick='removeFileControl(this);' ><img src='/Images/delete.gif' border='0' alt='Remove' /></a>"
    ChildNode.appendChild(NewFileControl)
  
  
   document.getElementById(IdPre+'totalFileControls').value=parseInt(document.getElementById(IdPre+ 'totalFileControls').value)+1
   if(document.getElementById(IdPre+ 'totalFileControls').value>5)
   {
   document.getElementById("AddmMoreBrowse").style.display="none";
   }
   
}

 function removeFileControl(src)
   {
   IdPre=""
      if(document.getElementById(IdPre+'totalFileControls').value>1)
      {
            var parentDiv =src.parentNode.parentNode;  
            //once the row reference is obtained, delete it passing in its rowIndex   
            document.getElementById("DivImageBrowsw").removeChild(parentDiv);  
             
            document.getElementById(IdPre+ 'totalFileControls').value=parseInt(document.getElementById(IdPre+'totalFileControls').value)-1
     
             if(document.getElementById(IdPre+'totalFileControls').value < 6)
           {
           document.getElementById("AddmMoreBrowse").style.display="Block";
           }
      }
    
   }
   
// functions for gallery section ends here   
  
  
*/