//Common functions
function highLight(src)
{
     src.className="highlight";
}

function highLight_Out(src)
{
    src.className="highlight_non";
}
function showPreviousPage()
{
history.go(-1)
}
	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;
		    }
	    }

	
	
	}

//Script For admin  Section Categories [Job]
 function selectOperation()
        {
       
            flag="T"
	        st="Please provide ::";
	        
	        namePre="ctl00$CPHldMain$TabContainer1$TabPnlAddEvnt$"
	        IdPre="ctl00_CPHldMain_TabContainer1_TabPnlAddEvnt_"
            
            var radioGrp = document.getElementsByName(namePre+'rdOperation');
           
            for(i=0; i < radioGrp.length; i++)
            {
	            if (radioGrp[i].checked == true) 
	            {
		        var radioValue = radioGrp[i].value;
	            }
            }
           
            switch (radioValue)
            {
                case "N": //Add new 
                     document.getElementById('dvAddEditCt').style.display="block";
                     
                      document.getElementById(IdPre+'txtCategory').value=""
                      document.getElementById(IdPre+'ddStatus').selectedIndex=0;
                        
                     return false
                     break;
                case "E": //Edit Category 
                
                     if(SetVisibilty())
                     {
                     
                      document.getElementById(IdPre+'txtCategory').value= document.getElementById(IdPre+'hdCatName').value
                      if(document.getElementById(IdPre+'hdCatStatus').value=="I")
                      {
                      document.getElementById(IdPre+'ddStatus').selectedIndex= 2;
                      }else
                          {
                              if(document.getElementById(IdPre+'hdCatStatus').value=="A")
                              {
                              document.getElementById(IdPre+'ddStatus').selectedIndex= 1;
                              }else
                              document.getElementById(IdPre+'ddStatus').selectedIndex=0;
                          }
                          
                     }
                     return false
                     break;
                case "D": //Delete Category 
                     if(document.getElementById(IdPre+'ddCategories').selectedIndex!="0")
                     {
                        return confirmDelete()
                    }else
                    {
                     alert("Select category to Delete")
                     return false
                    }
                    
                    break;
           }
  }
function ValidateCategory()
{
    tempstname=""
    tempst=""
    flag="T"

    IdPre="ctl00_CPHldMain_TabContainer1_TabPnlAddEvnt_"

	flagLong="T"
	st="Please provide ::";
	
	    if(document.getElementById(IdPre+'txtCategory').value=="")
		{
		
			st=st + "\n - Category.";
			flag="F";
		}
		if(document.getElementById(IdPre+'ddStatus').selectedIndex=="0")
		{
		
			st=st + "\n - Category Status.";
			flag="F";
		}
	
		 
	if (flag=="F")
		{
			alert(st);
			return false;
		}
		else
		{
		 return true;
		}
  }
function SetVisibilty()
   {
    
	        IdPre="ctl00_CPHldMain_TabContainer1_TabPnlAddEvnt_"
            if(document.getElementById(IdPre+'ddCategories').selectedIndex!="0")
              {
              
             
                document.getElementById('dvAddEditCt').style.display="block";
                return true
              }
            else
            {   
            alert("Select category to Edit")
             document.getElementById('dvAddEditCt').style.display="none";
             return false
            }
   }    
// Function Categories [Job] Ends
function confirmDelete()
   {
      return confirm("Are you sure you want to delete it.");
   }
   
 // Validatins  for Job Openings (admin) sections starts  here
 function ValidatejobopeningsADD()
{

tempstname=""
tempst=""
flag="T"

  IdPre="ctl00_CPHldMain_TabContainerAccount_TabPanelMngAc_"

	flagLong="T"
	st="Please provide ::";
	
	   if(document.getElementById(IdPre+'ddlCategory').selectedIndex=="0")
		{
		
			st=st + "\n - Job Category.";
			flag="F";
		}
		   if(document.getElementById(IdPre+'txtJobCode').value=="")
		{
		
			st=st + "\n - Job Code.";
			flag="F";
		}
		   if(document.getElementById(IdPre+'txtJobTitle').value=="")
		{
		
			st=st + "\n - Title.";
			flag="F";
		}
		
		if(document.getElementById(IdPre+'txtJobLevel').value=="")
		{
		
			st=st + "\n - Level.";
			flag="F";
		}
		
			if(document.getElementById(IdPre+'txtJobProfile').value=="")
		{
		
			st=st + "\n - Profile.";
			flag="F";
		}
		if(document.getElementById(IdPre+'txtJobEligibility').value=="")
		{
		
			st=st + "\n - Eligibilty.";
			flag="F";
		}
	if (flag=="F")
		{
			alert(st);
			return false;
		}
		else
		{
		 return true;
		}
}

   
function ValidateApplicant()
{


tempstname=""
tempst=""
flag="T"
	flagLong="T"
	st="Please provide ::";
	IdPre="ctl00_CPHldMain_"
	  
		   if(document.getElementById(IdPre+'txtName').value=="")
		{
		
			st=st + "\n - Name.";
			flag="F";
		}
		   if(document.getElementById(IdPre+'txtDOB').value=="")
		{
		
			st=st + "\n - Date Of Birth.";
			flag="F";
		}
		if(document.getElementById(IdPre+'txtCity').value=="")
		{
		
			st=st + "\n - City.";
			flag="F";
		}
		if(document.getElementById(IdPre+'txtEmail'))
		{
		var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
			Val=document.getElementById(IdPre+'txtEmail').value
			if(!regex.test(Val))
			{
			st=st + "\n - Valid Email ID.";
			flag="F";
			}
		}
		
		if(document.getElementById(IdPre+'txtJobExpYear').value!="")
			{
				var regex = /^\d+$/;
					Val=document.getElementById(IdPre+'txtJobExpYear').value
					if(!regex.test(Val))
				{
					st=st + "\n - Valid Exp in Year";
					flag="F";
				}
		}
	
		if(document.getElementById(IdPre+'txtJobExpMonth').value!="")
			{
			
				var regex = /^\d+$/;
					Val=document.getElementById(IdPre+'txtJobExpMonth').value
					if(!regex.test(Val))
				    { 
				   
					st=st + "\n - Valid exp in Month";
					flag="F";
					}else
					{
					 
					    intMnth=parseInt(Val)
					   if(intMnth>12)
				        {
				        st=st + "\n - No of Months should be less then 12";
					    flag="F";
					    }
					    
				    }
					
		}			
		///////////////////////////////////
		
		if(document.getElementById(IdPre+'ddlUGCourse').selectedIndex==0)
		{              
		
			st=st + "\n - Under Graduate Course .";
			flag="F";
		}else
		{
		var valueOther= document.getElementById(IdPre+'ddlUGCourse').selectedIndex;
		var str = document.getElementById(IdPre+'ddlUGCourse').options[valueOther].value;

		    if (str == '9999')
		    { 
	     	    if( document.getElementById(IdPre+'txtUGCourseOther').value=="")
	     	    {
	     	        st=st + "\n - Under Graduate Course .";
			        flag="F";
	     	    }
	 	     }
		
		}
				
	   if(document.getElementById(IdPre+'txtUGInstitute').value=="")
		{
		
			st=st + "\n - Under Graduate Institute.";
			flag="F";
		}	
		if(document.getElementById(IdPre+'ddlUGyear').selectedIndex==0)
		{              
		
			st=st + "\n - Under Graduation Year .";
			flag="F";
		}
		//////////////////////////////////
		
		
		
		 if(document.getElementById(IdPre+'UpldCV').value=="")
		{
		
			st=st + "\n - Upload Resume.";
			flag="F";
		}
	
	if (flag=="F")
		{
			alert(st);
			return false;
		}
		else
		{
		 return true;
		}
}

/* @@@@@@@@@@@@@@@@@@@@@@@@@@ */
 function ValidateProjectADD()
{

tempstname=""
tempst=""
flag="T"

  IdPre="ctl00_CPHldMain_TabContainerAccount_TabPanelMngAc_"

	flagLong="T"
	st="Please provide ::";
	
	  
		   if(document.getElementById(IdPre+'txtTitle').value=="")
		{
		
			st=st + "\n - Title.";
			flag="F";
		}
		
		if(document.getElementById(IdPre+'txtDetail').value=="")
		{
		
			st=st + "\n - Detail.";
			flag="F";
		}
		
		
	if (flag=="F")
		{
			alert(st);
			return false;
		}
		else
		{
		 return true;
		}
}
 function ValidateInquiryForm()
{

tempstname=""
tempst=""
flag="T"

  IdPre="ctl00_CPHldMain_"

	flagLong="T"
	st="Please provide ::";
	
	  
		   if(document.getElementById(IdPre+'txtName').value=="")
		{
		
			st=st + "\n - Name.";
			flag="F";
		}
		
		if(document.getElementById(IdPre+'txtCompanyDetail').value=="")
		{
		
			st=st + "\n - Company Detail.";
			flag="F";
		}
		
		if(document.getElementById(IdPre+'txtComEmail'))
		{
		var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
			Val=document.getElementById(IdPre+'txtComEmail').value
			if(!regex.test(Val))
			{
			st=st + "\n - Valid Email ID.";
			flag="F";
			}
		}
		
	if(document.getElementById(IdPre+'txtContactDetail').value=="")
		{
		
			st=st + "\n - Contact Detail.";
			flag="F";
		}
		
	if (flag=="F")
		{
			alert(st);
			return false;
		}
		else
		{
		 return true;
		}
}

 function ValidateCustomerCareForm()
{

tempstname=""
tempst=""
flag="T"

  IdPre="ctl00_CPHldMain_"

	flagLong="T"
	st="Please provide ::";
	
	  
		   if(document.getElementById(IdPre+'txtName').value=="")
		{
		
			st=st + "\n - Name.";
			flag="F";
		}
		
		if(document.getElementById(IdPre+'txtCompanyDetail').value=="")
		{
		
			st=st + "\n - Company Detail.";
			flag="F";
		}
		
		if(document.getElementById(IdPre+'txtComEmail'))
		{
		var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
			Val=document.getElementById(IdPre+'txtComEmail').value
			if(!regex.test(Val))
			{
			st=st + "\n - Valid Email ID.";
			flag="F";
			}
		}
		
	if(document.getElementById(IdPre+'txtComment').value=="")
		{
		
			st=st + "\n - Comments.";
			flag="F";
		}
		
	if (flag=="F")
		{
			alert(st);
			return false;
		}
		else
		{
		 return true;
		}
}

 // Validatins  for Prod Categories (admin) sections starts  here
function ValidateProCatADD()
{

tempstname=""
tempst=""
flag="T"

  IdPre="ctl00_CPHldMain_TabContainerAccount_TabPanelMngAc_"

	flagLong="T"
	st="Please provide ::";
	
	 
		   if(document.getElementById(IdPre+'txtBrief').value=="")
		{
		
			st=st + "\n - Brief.";
			flag="F";
		}
		   if(document.getElementById(IdPre+'txtDescription').value=="")
		{
		
			st=st + "\n - Description.";
			flag="F";
		}
	
	if (flag=="F")
		{
			alert(st);
			return false;
		}
		else
		{
		 return true;
		}
}

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;
}
