//Array declaration

var m_array_course_exam;
var m_array_course_stream;
var m_array_stream_college;
var m_row,m_col;

var m_str_None;
m_str_None = "------------------------------------------None------------------------------------------";


//=================FOR COURSE AND EXAM START==================================================
//Array creation
function create_array_course_exam(row,col)
{
	m_array_course_exam=new Array(row);
	for(m_row=0;m_row<row;m_row++)
	{
		m_array_course_exam[m_row]=new Array(col);	
	}
}




//Inserting data in a Array
function add_data_course_exam(row,col,m_str)
{
	m_array_course_exam[row][col]=m_str;	
}




//Combo exam
function populate_exam(combo,filter_val,filter_col,col_val,col_txt)
{
	var nCount;
	var m_val;

	//--Counting no of record
	nCount=0;
	
	for(m_row=0;m_row<m_array_course_exam.length;m_row++)
	{
		m_val=m_array_course_exam[m_row][filter_col];
		if(m_val==filter_val)
		{
			nCount++;
		}
	}


	
	combo.length=0;
	combo.length=nCount;

	//--Populating filter value	
	nCount=0
	for(m_row=0;m_row<m_array_course_exam.length;m_row++)
	{
		m_val=m_array_course_exam[m_row][filter_col];
		if(m_val==filter_val)
		{
			combo.options[nCount].value=m_array_course_exam[m_row][col_val];
			combo.options[nCount].text=m_array_course_exam[m_row][col_txt];
			nCount++;
		}
	}
}


//=================FOR COURSE AND EXAM END==============================


//=================FOR COURSE AND STREAM START==============================
//Array creation
function create_array_course_stream(row,col)
{
	m_array_course_stream=new Array(row);
	for(m_row=0;m_row<row;m_row++)
	{
		m_array_course_stream[m_row]=new Array(col);	
	}
}




//Inserting data in a Array
function add_data_course_stream(row,col,m_str)
{
	m_array_course_stream[row][col]=m_str;	
}




//Combo exam
function populate_stream(combo,filter_val,filter_col,col_val,col_txt)
{
	var nCount;
	var m_val;

	//--Counting no of record
	nCount=0;
	
	for(m_row=0;m_row<m_array_course_stream.length;m_row++)
	{
		m_val=m_array_course_stream[m_row][filter_col];
		if(m_val==filter_val)
		{
			nCount++;
		}
	}


	
	combo.length=0;
	combo.length=nCount;

	//--Populating filter value	
	nCount=0
	for(m_row=0;m_row<m_array_course_stream.length;m_row++)
	{
		m_val=m_array_course_stream[m_row][filter_col];
		if(m_val==filter_val)
		{
			combo.options[nCount].value=m_array_course_stream[m_row][col_val];
			combo.options[nCount].text=m_array_course_stream[m_row][col_txt];
			nCount++;
		}
	}
}


//=================FOR COURSE AND EXAM END==============================


//=================FOR STREAM AND COLLEGE START==============================
//Array creation

function create_array_stream_college(row,col)
{
	m_array_stream_college=new Array(row);
	for(m_row=0;m_row<row;m_row++)
	{
		m_array_stream_college[m_row]=new Array(col);	
	}
}




//Inserting data in a Array
function add_data_stream_college(row,col,m_str)
{
	m_array_stream_college[row][col]=m_str;	
}




//Combo college1
function populate_college1(combo,filter_val,filter_col,col_val,col_txt)
{
	var nCount;
	var m_val;
    // Anirban start change 28.05.2008
        form1.cmb_institution_1.style.display="block";
        form1.cmb_institution_2.style.display="block";
        form1.cmb_institution_3.style.display="block";            
    // end change 
   

	//--Counting no of record
	nCount=0;
	
	for(m_row=0;m_row<m_array_stream_college.length;m_row++)
	{
		m_val=m_array_stream_college[m_row][filter_col];
		if(m_val==filter_val)
		{
			nCount++;
		}
	}

	//alert(form1.cmb_institution_1.length);
	
	combo.length=0;
	combo.length=nCount+1;
	combo.options[0].value="0";
	combo.options[0].text=m_str_None;
	

	//--Populating filter value	
	nCount=1;
	for(m_row=0;m_row<m_array_stream_college.length;m_row++)
	{
		m_val=m_array_stream_college[m_row][filter_col];
		if(m_val==filter_val)
		{
			combo.options[nCount].value=m_array_stream_college[m_row][col_val];
			combo.options[nCount].text=m_array_stream_college[m_row][col_txt];
			nCount++;
		}
	}
       
         // Anirban paul Change 18.05.2008 start
            
              if(combo.length<=2)
               {
                 form1.cmb_institution_2.disabled=true;  
                 form1.cmb_institution_3.disabled=true;  
               }
	      else
		{
			form1.cmb_institution_2.disabled=false;  
                 	form1.cmb_institution_3.disabled=false;  
		}
        //    End of change
}



//Combo college2
function populate_college2(combo,filter_val,filter_col,col_val,col_txt,prev_combo1)
{
	var nCount;
	var m_val;
	var m_val1;
	
       //alert(form1.cmb_institution_2.length);

	
	combo.length=0;
	combo.length=prev_combo1.length-1;
	combo.options[0].value="0";
	combo.options[0].text=m_str_None;
	

	//--Populating filter value	
	nCount=1;
	for(m_row=0;m_row<m_array_stream_college.length;m_row++)
	{
		m_val=m_array_stream_college[m_row][filter_col];
		m_val1=m_array_stream_college[m_row][col_val];
		if(m_val==filter_val)
		{
			if(m_val1!=prev_combo1.value)
			{
				combo.options[nCount].value=m_array_stream_college[m_row][col_val];
				combo.options[nCount].text=m_array_stream_college[m_row][col_txt];
				nCount++;
			}
		}
	}

      // Anirban paul Change 18.05.2008 start
 
             
              if(combo.length<=2)
               {
                    form1.cmb_institution_3.disabled=true;           
               }
		else
		{
			form1.cmb_institution_3.disabled=false;        
		}
        //    End of change
}


//Combo college3
function populate_college3(combo,filter_val,filter_col,col_val,col_txt,prev_combo1,prev_combo2)
{
	
	//alert(form1.cmb_institution_3.length);
	//if(form1.cmb_institution_3.length==1);
	//{
	//  form1.cmb_institution_3.disabled=true;
	//}
	//if(form1.cmb_institution_3.length>1);
	//{
		//form1.cmb_institution_3.disabled=false;
	//}
	//else if(form1.cmb_institution_3.length>1);
	//{
		//form1.cmb_institution_3.disabled=false;
	//}

	

	var nCount;
	var m_val;
	var m_val1;
	


	
	combo.length=0;
	combo.length=prev_combo2.length-1;
	combo.options[0].value="0";
	combo.options[0].text=m_str_None;
	

	//--Populating filter value	
	nCount=1;
	for(m_row=0;m_row<m_array_stream_college.length;m_row++)
	{
		m_val=m_array_stream_college[m_row][filter_col];
		m_val1=m_array_stream_college[m_row][col_val];
		if(m_val==filter_val)
		{
			if( (m_val1!=prev_combo1.value) && (m_val1!=prev_combo2.value))
			{
				combo.options[nCount].value=m_array_stream_college[m_row][col_val];
				combo.options[nCount].text=m_array_stream_college[m_row][col_txt];
				nCount++;
			}
		}
	}
}


//=================FOR STREAM AND COLLEGE END==============================







function Display_Text_Box_Source()
{    
    try
    {
    
		select_jis_group_source=document.getElementById("select_jis_group_source")
		jis_group_source_details=document.getElementById("jis_group_source_details")
    
        if(select_jis_group_source.options[select_jis_group_source.selectedIndex].value == "0")
        {
            jis_group_source_details.style.display="none";
        }       
        else
        {
           jis_group_source_details.style.display="block";
        }
     }
     catch(e)
     {}     
     finally{}
}
function go_back_to_report(admission_criteria)
{
	window.navigate("report_enquiry_list_2008.asp?admission_criteria=" + admission_criteria);
}



function go_back()
		{
			window.navigate("enquiry_list_2008.asp");
		}

function go_back_addmission(m_id)
		{
			window.navigate("addmission_taken_2008_fourth.asp?param_id=" + m_id);
		}


function Display_Text_Box()
{    
    try
    {

    
		newspaper_knew		=document.getElementById("newspaper_knew");
		newspaper_details	=document.getElementById("newspaper_details");
		
		other_knew	=document.getElementById("other_knew");
		other_details	=document.getElementById("other_details");				

    
        if(newspaper_knew.checked == true)
        {
            newspaper_details.style.display="block";
        }
        else
        {
           newspaper_details.style.display="none";
	   newspaper_details.value="";
        }
        
        if(other_knew.checked == true)
        {   
            other_details.style.display="block";
        }
        else
        {
           other_details.style.display="none";
	   other_details.value="";
        }

	if(bd_others.checked == true)
        {   
            bd_others_details.style.display="block";
        }
        else
        {
           bd_others_details.style.display="none";
        }	

     }
     catch(e)
     {}     
     finally{}
}


function Display_Text_Box_addmission()
{    
    try
    {    
		
		bd_others=document.getElementById("bd_others");
		bd_others_details=document.getElementById("bd_others_details");

		pgd_others=document.getElementById("pgd_others");
		pgd_others_details=document.getElementById("pgd_others_details");

    
        if(bd_others.checked == true)
        {   
            bd_others_details.style.display="block";
        }
        else
        {
           bd_others_details.style.display="none";
        }

	if(pgd_others.checked == true)
        {   
            pgd_others_details.style.display="block";
        }
        else
        {
           pgd_others_details.style.display="none";
        }

	

     }
     catch(e)
     {}     
     finally{}
}




function trim(str)
{
    if(!str || typeof str != 'string')
        return null;

    return str.replace(/^[\s]+/,'').replace(/[\s]+$/,'').replace(/[\s]{2,}/,' ');
}



function go_back_admission_1st(m_id)
		{
			window.navigate("addmission_2008_first.asp?param_id=" + m_id);
		}

function go_back_admission_2nd(m_id)
		{
			window.navigate("addmission_taken_2008_second.asp?param_id=" + m_id);
		}


function go_back_admission_3rd(m_id)
		{
			window.navigate("addmission_taken_2008_third.asp?param_id=" + m_id);
		}





//check dob
function checkyear(all_date)
{


if((document.getElementById(all_date).value).length>0)
	{
		y=document.getElementById(all_date).value;
		z=new String(y);
		x=new Date(z);

		if(x.getDate()!= z.substring(3,5))
		{
			alert("Enter Valid Date");
			document.getElementById(all_date).focus();
			return;
		}
		if((x.getMonth()+1)!= z.substring(0,2))
		{
			alert("Enter Valid Date");
			document.getElementById(all_date).focus();
			return;
		}
		if(x.getFullYear() != z.substring(6,10))
		{
			alert("Enter Valid Date");
			document.getElementById(all_date).focus();
			return;
		}
	






			//Check dob less than 17 years
			dob=document.getElementById("dob").value;
			z_dt=new Date();
			c_dt=new Date(dob);					
			
			if((z_dt.getFullYear()-c_dt.getFullYear())<=17)
			{
				alert("Date Of Birth Should Be Less Than 17 Years.");
				document.getElementById("dob").focus();
				return;
			}
			
			
			}
			
}



