0xV3NOMx
Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64



Your IP : 13.59.69.58


Current Path : /proc/thread-self/root/var/www/html/orms-gug/js/
Upload File :
Current File : //proc/thread-self/root/var/www/html/orms-gug/js/home_old.js

var urlarr = window.location.pathname.split('/');
var $url="http://"+window.location.host+"/";
var $hoststr = '';
for(var j=1;j<urlarr.length-1;j++)
{
	$hoststr += window.location.pathname.split('/')[j]+"/"; 
}	
$host_url = $url+$hoststr+"app.php?a=";
$image_path = $url+$hoststr+"jqGrid3.5/cmes/tarka/images/";


function loadhomedropdown() 
{
	
	$("#TDISABILITY").hide();
	$("#PDISABILITY").hide();
	$.ajax({
	type: "POST",
	async:false,
	url:$host_url+'getdropdown', 
	success: function getcatcoderesponce(responce)
	{
		responce = eval('(' + responce + ')');
		
		$("#postdetails").hide();
		document.getElementById("1S1").options.length = 0;		
		var post =responce.data['post'];			
		$op = new Option("Select Post",0);
		$op.id=0;//specifying the id  for options
		document.getElementById("1S1").options.add($op)
		for($i=0;$i < post.length;$i++)                                  
		{            
			$op = new Option(post[$i]['value'], post[$i]['internal_code']);
			$op.id=post[$i]['internal_code'];//specifying the id  for options
			document.getElementById("1S1").options.add($op);
		}
		document.getElementById("1S2").options.length = 0;		
		var course =responce.data['course'];
		setCookie('course',course);		
		$op = new Option("Select Qualifying Exam","");
		$op.id=0;//specifying the id  for options
		document.getElementById("1S2").options.add($op)
		for($i=0;$i < course.length;$i++)                                  
		{            
			$op = new Option(course[$i]['value'], course[$i]['internal_code']);
			$op.id=course[$i]['internal_code'];//specifying the id  for options
			document.getElementById("1S2").options.add($op);
		}
		
		loadapplieddetails();
		
	}
	});		
} 

function postdeportment()
{
	$.ajax({
	type: "POST",
	async:false,
	url:$host_url+'getdropdown', 
	success: function getcatcoderesponce(responce)
	{
		responce = eval('(' + responce + ')');
		document.getElementById("S3").options.length = 0;		
		var catcode =responce.data['catcode'];			
		$op = new Option("Select Category",0);
		$op.id=0;//specifying the id  for options
		document.getElementById("S3").options.add($op)
		for($i=0;$i < catcode.length;$i++)                                  
		{            
			$op = new Option(catcode[$i]['value'], catcode[$i]['internal_code']);
			$op.id=catcode[$i]['internal_code'];//specifying the id  for options
			document.getElementById("S3").options.add($op);
		}
	}	
	});	
}

/* function getage()
{
	alert(Date.getTime);
	date = document.getElementById('T2').value;
	
} */

function getage() 
{
      if (isDate($('#T2').val())) 
	  {
        var age = calculateAge(parseDate($('#T2').val()), new Date());
      	$("#T3").val(age);   
      } else {
        $("#T3").val('');   
      }      
   
}

//convert the date string in the format of dd/mm/yyyy into a JS date object
function parseDate(dateStr) 
{
  var dateParts = dateStr.split("/");
  return new Date(dateParts[2], (dateParts[1] - 1), dateParts[0]);
}

//is valid date format
function calculateAge (dateOfBirth, dateToCalculate) 
{
    var calculateYear = dateToCalculate.getFullYear();
    var calculateMonth = dateToCalculate.getMonth();
    var calculateDay = dateToCalculate.getDate();

    var birthYear = dateOfBirth.getFullYear();
    var birthMonth = dateOfBirth.getMonth();
    var birthDay = dateOfBirth.getDate();

    var age = calculateYear - birthYear;
    var ageMonth = calculateMonth - birthMonth;
    var ageDay = calculateDay - birthDay;

    if (ageMonth < 0 || (ageMonth == 0 && ageDay < 0)) {
        age = parseInt(age) - 1;
    }
    return age;
}

function isDate(txtDate) 
{
  var currVal = txtDate;
  if (currVal == '')
    return true;

  //Declare Regex
  var rxDatePattern = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
  var dtArray = currVal.match(rxDatePattern); // is format OK?

  if (dtArray == null)
    return false;

  //Checks for dd/mm/yyyy format.
  var dtDay = dtArray[1];
  var dtMonth = dtArray[3];
  var dtYear = dtArray[5];

  if (dtMonth < 1 || dtMonth > 12)
    return false;
  else if (dtDay < 1 || dtDay > 31)
    return false;
  else if ((dtMonth == 4 || dtMonth == 6 || dtMonth == 9 || dtMonth == 11) && dtDay == 31)
    return false;
  else if (dtMonth == 2) {
    var isleap = (dtYear % 4 == 0 && (dtYear % 100 != 0 || dtYear % 400 == 0));
    if (dtDay > 29 || (dtDay == 29 && !isleap))
      return false;
  }

  return true;
}


function enableappeared(id)
{
	//$("input[name=fqualify]:checked").val();

	if(document.getElementById(id).value == 'T')
	{
		$("#TDISABILITY").show();
		$("#PDISABILITY").show();
		
	}else 
	{
			$("#TDISABILITY").hide();
			$("#PDISABILITY").hide();
	} 
}

/* function savepersonaldetails()
{
	var myobject = {};

	fldorder = 'T1,T2,T3,T4,T5,T6,T7,T8,T9,S3,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27';
	mandfields = 'T1';
	fieldarr = fldorder.split(",");
	
	myobject = onsavevalidate.call(myobject, 999);
	if (myobject != 999)
	{
		document.getElementById(myobject).focus();
		return false;
	}
	var fieldarrval = new Object();
	for(i=0; i<fieldarr.length; i++)
	{
		alert(document.getElementById(fieldarr[i]).value);
		fieldarrval[fieldarr[i]] = document.getElementById(fieldarr[i]).value;
	} 		
	var fieldarrvalue  = encodeURIComponent(JSON.stringify(fieldarrval)); 
	var data = "fieldarrvalue="+fieldarrvalue;
	if(Object.size(fieldarrval)>0)
	{
		$upload = $host_url+"savepersonaldetails&"+data;	
		document.getElementById("form_module_image_upload").setAttribute("action",$upload);		
		return AIM.submit(document.getElementById("form_module_image_upload"), 'same_tab',{'onComplete' : savepersonaldetailssuccess});
		
		
		/* $.ajax({
			type: "POST",
			url: $host_url+"savepersonaldetails",
			data:"fieldarrvalue="+fieldarrvalue,
			success:savepersonaldetailssuccess
		});   
	}
}

function savepersonaldetailssuccess()
{
	
} */

/* function saveeducationaldetails()
{
	var myobject = {};
	fldorder = 'T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50';
	fldorder +=',T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80';
	mandfields = 'T28';
	var fieldarrval = new Object();
	fieldarr = fldorder.split(",");

	myobject = onsavevalidate.call(myobject, 999);
	if (myobject != 999)
	{
		document.getElementById(myobject).focus();
		return false;
	}
	
	for(i=0; i<fieldarr.length; i++)
	{
		fieldarrval[fieldarr[i]] = document.getElementById(fieldarr[i]).value;
	} 	
	var fieldarrvalue  = encodeURIComponent(JSON.stringify(fieldarrval));
	if(Object.size(fieldarrval)>0)
	{
		$.ajax({
			type: "POST",
			url: $host_url+"saveeducationaldetails",
			data:"fieldarrvalue="+fieldarrvalue,
			success:saveeducationaldetailsssuccess
		});  
	}
}

function saveeducationaldetailsssuccess()
{
	
	
} */


function saveeducationaldetails()
{
	var myobject = {};
	fldorder = 'T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T50';
	fldorder +=',T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80';
	mandfields = 'T28';
	var fieldarrval = new Object();
	fieldarr = fldorder.split(",");

	myobject = onsavevalidate.call(myobject, 999);
	if (myobject != 999)
	{
		document.getElementById(myobject).focus();
		return false;
	}
	var ug = document.getElementById('TBA42').value;
	var pg = document.getElementById('T49').value;
	for(i=0; i<fieldarr.length; i++)
	{
		fieldarrval[fieldarr[i]] = document.getElementById(fieldarr[i]).value;
	} 	
	var fieldarrvalue  = encodeURIComponent(JSON.stringify(fieldarrval));
	if(Object.size(fieldarrval)>0)
	{
		$.ajax({
			type: "POST",
			url: $host_url+"saveeducationaldetails",
			data:"fieldarrvalue="+fieldarrvalue+"&ug="+ug+"&pg="+pg,
			success:saveeducationaldetailsssuccess
		});  
	}
}

function saveeducationaldetailsssuccess($responce)
{
	$responce = eval('(' + $responce + ')'); 
	
	if($responce.error_code==0)
	{		
		alert($responce.data);
		return;
	}
	else
	{
		alert($responce.data);
		return;		
	}
	
}

function saveexperiencedetails()
{
	var myobject = {};
	fldorder = 'T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50';
	fldorder +=',T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80';
	mandfields = 'T28';
	var fieldarrval = new Object();
	fieldarr = fldorder.split(",");

	myobject = onsavevalidate.call(myobject, 999);
	if (myobject != 999)
	{
		document.getElementById(myobject).focus();
		return false;
	}
	
	for(i=0; i<fieldarr.length; i++)
	{
		fieldarrval[fieldarr[i]] = document.getElementById(fieldarr[i]).value;
	} 
	
	
	//////////////////////======to read multiple records====///////////
	var inputFileds = document.getElementsByTagName('input');
	var chkCnt = 0;
	var rowCnt = 0;
	var foreign_arr = {};
	for (var counter=0; counter < inputFileds.length; counter++) 
	{       
		if ( inputFileds[counter].type.toUpperCase()=='TEXT'  && inputFileds[counter].name == "foreignvisit"  )
		{   
			++rowCnt;
			if(document.getElementById(rowCnt+'IT7').value != 'T')
			{
				++chkCnt;
				foreign_arr[chkCnt] = new Object();
				foreign_arr[chkCnt]['course'] = document.getElementById(rowCnt+'IT1').value;
				foreign_arr[chkCnt]['purpose'] = document.getElementById(rowCnt+'IT2').value;
				foreign_arr[chkCnt]['from']   = document.getElementById(rowCnt+'IT3').value;
				foreign_arr[chkCnt]['to']  = document.getElementById(rowCnt+'IT4').value;
				foreign_arr[chkCnt]['total']  = document.getElementById(rowCnt+'IT5').value;
				foreign_arr[chkCnt]['period']  = document.getElementById(rowCnt+'IT6').value;
			}	
		}
	}
	var dataString ="&array="+encodeURIComponent(JSON.stringify(foreign_arr));
	$.ajax({
	type:"POST",
	url:$host_url+"saveexperiencedetails",
	data:dataString,
	cache:false,
	success:function($responce)
	{	
		$responce = eval('('+$responce+')');
		if($responce.error_code == 0)
		{
			alert($responce.data);
		}
		else
			alert($responce.data);
	}	
	});

	alert(Object.size(fieldarrval));
}

function savepublicationdetails()
{
	var myobject;
		
		fldorder = 'S1,S2,S3,S4,S6,S8,S12,S9,S10,S11,S12,S13,S14,S15,S16,S17,S18,S19,S20,S21,S22,S23';
		mandfields = 'S1,S2,S3,S4,S6,S19,S20,S21,S22,S23';
		
		myobject = onsavevalidate.call(myobject, 999);
		if (myobject != 999)
		{
			document.getElementById(myobject).focus();
			return false;
		}
}

function saveforeignvisit()
{
		var myobject;
		
		fldorder = 'S1,S2,S3,S4,S6,S8,S12,S9,S10,S11,S12,S13,S14,S15,S16,S17,S18,S19,S20,S21,S22,S23';
		mandfields = 'S1,S2,S3,S4,S6,S19,S20,S21,S22,S23';
		
		myobject = onsavevalidate.call(myobject, 999);
		if (myobject != 999)
		{
			document.getElementById(myobject).focus();
			return false;
		}

}

/* function savereferences()
{
	var myobject;
		
		fldorder = 'S24,S25,S26,S27,S28,S29,S30,S31,S32,S33,S34,S35,S36,S37,S38,S39,S40,S41';
		mandfields = 'S24,S27,S30,S33,S36,S39';
		
		myobject = onsavevalidate.call(myobject, 999);
		if (myobject != 999)
		{
			document.getElementById(myobject).focus();
			return false;
		}
	
} */

function savereferences()
{
	var myobject;
		
	fldorder = 'S24,S25,S26,S27,S28,S29,S30,S31,S32,S33,S34,S35,S36,S37,S38,S39,S40,S41';
	mandfields = 'S24,S27,S30,S33,S36,S39';
	var fieldarrval = new Object();
	fieldarr = fldorder.split(",");
	
	myobject = onsavevalidate.call(myobject, 999);
	if (myobject != 999)
	{
		document.getElementById(myobject).focus();
		return false;
	}		
	for(i=0; i<fieldarr.length; i++)
	{
		fieldarrval[fieldarr[i]] = document.getElementById(fieldarr[i]).value;
	} 	
	
	var fieldarrvalue  = encodeURIComponent(JSON.stringify(fieldarrval));

	if(Object.size(fieldarrval)>0)
	{
		$.ajax({
			type: "POST",
			url: $host_url+"savereferences",
			data:"fieldarrvalue="+fieldarrvalue,
			success:savereferencesuccess
		});  
	}
	
}

function savereferencesuccess($responce)
{
	$responce = eval('(' + $responce + ')'); 
	
	if($responce.error_code==0)
	{		
		alert($responce.data);
		return;
	}
	else
	{
		alert($responce.data);
		return;		
	}
}

/* function DisplayUserSelectedPhoto()
{
	var filepath;
	var valid_file_extentions = new Array("jpg");

	var ext=$("#student_photo_upload").val();
	filepath=ext;
	ext = ext.substring(ext.length-3,ext.length);
	ext = ext.toLowerCase();  

	if(ext != "" && valid_file_extentions == 'jpg' && valid_file_extentions == 'jpeg')
	{	      
		alert("Please Select the Valid Photo!");
		$("#student_photo_upload").val('')
		return false;
	}
	var lstr_data="filepath="+filepath;
	
	$upload = $host_url+"saveUserSelectedPhoto&"+lstr_data;	
	
	//$.blockUI({ message: "<h1 class='h1' style='font-size:12px'><img src='img/ajax-loader.gif' border='0'></h1>" });
	document.getElementById("form_module_image_upload").setAttribute("action",$upload);		
	return AIM.submit(document.getElementById("form_module_image_upload"), 'same_tab',{'onComplete' : DiaplayUserSelectedPhotoResponse});		 
		
}



function DiaplayUserSelectedPhotoResponse($responce)
{
	$responce = eval('(' + $responce + ')'); 
	// $.unblockUI();
	if($responce.error_code==0)
	{		
		$("#student_photo").attr("src", $responce.data);
	}
	else if($responce.error_code==-1)	
		$("#student_photo").attr("src", "img/default_photo.jpg"); 
	else if($responce.error_code==-2)	
	{
		alert($responce.data);
		$("#student_photo").attr("src", "img/default_photo.jpg");
		$("#student_photo_upload").val("");
	} 
}

function DisplayUserSelectedSign()
{
	var filepath;
	var valid_file_extentions = new Array("jpg");

	var ext=$("#student_sign_upload").val();
	filepath=ext;
	ext = ext.substring(ext.length-3,ext.length);
	ext = ext.toLowerCase();  

	if(ext != "" && valid_file_extentions == 'jpg' && valid_file_extentions == 'jpeg')
	{	      
		alert("Please Select the Valid Photo!");
		$("#student_sign_upload").val('')
		return false;
	}
	var lstr_data="filepath="+filepath;
	
	$upload = $host_url+"saveUserSelectedSign&"+lstr_data;	
	
	//$.blockUI({ message: "<h1 class='h1' style='font-size:12px'><img src='img/ajax-loader.gif' border='0'></h1>" });
	document.getElementById("form_module_image_upload").setAttribute("action",$upload);		
	return AIM.submit(document.getElementById("form_module_image_upload"), 'same_tab',{'onComplete' : DiaplayUserSelectedSignResponse});		 
		
}

function DiaplayUserSelectedSignResponse($responce)
{
	$responce = eval('(' + $responce + ')'); 
	// $.unblockUI();
	if($responce.error_code==0)
	{		
		$("#student_sign").attr("src", $responce.data);
	}
	else if($responce.error_code==-1)	
		$("#student_sign").attr("src", "img/default_photo.jpg"); 
	else if($responce.error_code==-2)	
	{
		alert($responce.data);
		$("#student_sign").attr("src", "img/default_photo.jpg");
		$("#student_sign_upload").val("");
	} 
} */

function savepostdetails()
{
	var myobject;
	fldorder = '1S1,1S2';
	mandfields = '1S1,1S2';
	myobject = onsavevalidate.call(myobject, 999);
	if (myobject != 999)
	{
		document.getElementById(myobject).focus();
		return false;
	}
	//alert( document.getElementById("student_photo").src);	
	if($("#student_photo").val() == 'default_photo.jpg')
	{
		alert("Select valid photo file(accepts only jpg or jpeg)");
		$("#student_photo_upload").val('')
		return false;
	}	
	if($("#student_sign").val() == 'signature.png')
	{
		alert("Select valid sign file(accepts only jpg or jpeg)");
		$("#student_sign_upload").val('')
		return false;
	}	
	var inputFileds = document.getElementsByTagName('input');
	var chkCnt = 0;
	var rowCnt = 0;
	var post_arr = {};
	for (var counter=0; counter < inputFileds.length; counter++) 
	{       
		if ( inputFileds[counter].type.toUpperCase()=='HIDDEN'  && inputFileds[counter].name == "postname"  )
		{   
			++rowCnt;
			if(document.getElementById(rowCnt+'HS3').value != 'T')
			{
				++chkCnt;
				if(trim(document.getElementById(chkCnt+"S1").value) == '')
				{
					alert("Select Post");
					document.getElementById(chkCnt+"S1").focus();
					return false;
				}	
				if(trim(document.getElementById(chkCnt+"S2").value) == '')
				{
					alert("Select Qualifying Exam");
					document.getElementById(chkCnt+"S2").focus();
					return false;
				}		
				post_arr[chkCnt] = new Object();
				post_arr[chkCnt]['post'] = document.getElementById(rowCnt+'S1').value;
				post_arr[chkCnt]['course'] = document.getElementById(rowCnt+'S2').value;
			}
		}
	}	
	var dataString ="&post_arr="+encodeURIComponent(JSON.stringify(post_arr));
	$.ajax({
	type:"POST",
	url:$host_url+"savePostDetails",
	data:dataString,
	cache:false,
	success:function($responce)
	{	
		$responce = eval('('+$responce+')');
		if($responce.error_code == 0)
		{
			alert($responce.data);
			document.getElementById("ctab_post").className = "vsuccess";
			/* var post = document.getElementById('1S1').value; 
			var subject = document.getElementById('1S2').value; 
			document.getElementById('postdata').value = 'Application for "'+post+'" in Department of "'+subject+'"'; */
			
		}
		else
			alert($responce.data);
	}	
	});
}

function savepersonaldetails()
{
	var myobject = {};

	fldorder = 'T1,T2,T3,T4,T5,T6,T7,T8,T9,T11,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26';
	mandfields = 'T1';
	fieldarr = fldorder.split(",");

	myobject = onsavevalidate.call(myobject, 999);
	if (myobject != 999)
	{
		document.getElementById(myobject).focus();
		return false;
	}
	var fieldarrval = new Object();
	for(i=0; i<fieldarr.length; i++)
	{
		fieldarrval[fieldarr[i]] = document.getElementById(fieldarr[i]).value;
	} 	
	var fqualify =  $('input[name=fqualify]:checked').val();
	var fcatcode =  document.getElementById('S3').value;
	var fieldarrvalue  = encodeURIComponent(JSON.stringify(fieldarrval)); 
	//var data = "fieldarrvalue="+fieldarrvalue;
		var inputFileds = document.getElementsByTagName('input');
	var chkCnt = 0;
	var rowCnt = 0;
	var foreign_arr = {};
	for (var counter=0; counter < inputFileds.length; counter++) 
	{       
		if ( inputFileds[counter].type.toUpperCase()=='TEXT'  && inputFileds[counter].name == "language"  )
		{   
			++rowCnt;
			if(document.getElementById(rowCnt+'HT3').value != 'T')
			{
				++chkCnt;
				foreign_arr[chkCnt] = new Object();
				foreign_arr[chkCnt]['spoken'] = document.getElementById(rowCnt+'HT1').value;
				foreign_arr[chkCnt]['written'] = document.getElementById(rowCnt+'HT2').value;
			}	
		}
	}
	
	
	
	if(Object.size(fieldarrval)>0)
	{
		$.ajax({
			type: "POST",
			url: $host_url+"savepersonaldetails",
			data:"fieldarrvalue="+fieldarrvalue+"&fqualify="+fqualify+"&fcatcode="+fcatcode+"&foreign_arr="+encodeURIComponent(JSON.stringify(foreign_arr)),
			success:savepersonaldetailsuccess
		});  
	}
}

function savepersonaldetailsuccess($responce)
{
	$responce = eval('(' + $responce + ')');
	if($responce.error_code==0)
	{		
		alert($responce.data);
		return;
	}
	else
	{
		alert($responce.data);
		return;		
	}
}


function saveresearchdetails()
{
	//////To read Multiple Records///////	
	
	var inputFileds = document.getElementsByTagName('input');
	var chkCnt = 0;
	var rowCnt = 0;
	var research_arr = {};
	for (var counter=0; counter < inputFileds.length; counter++) 
	{       
		if ( inputFileds[counter].type.toUpperCase()=='TEXT'  && inputFileds[counter].name == "researchexp" )
		{   
			++rowCnt;
			if(document.getElementById(rowCnt+'BT7').value != 'T')
			{
				++chkCnt; 
				research_arr[chkCnt] = new Object();
				research_arr[chkCnt]['Position'] = document.getElementById(rowCnt+'BT1').value;
				research_arr[chkCnt]['Emoluments'] = document.getElementById(rowCnt+'BT2').value;
				research_arr[chkCnt]['Uname']   = document.getElementById(rowCnt+'BT3').value;
				research_arr[chkCnt]['From']  = document.getElementById(rowCnt+'BT4').value;
				research_arr[chkCnt]['To']  = document.getElementById(rowCnt+'BT5').value;
				research_arr[chkCnt]['Noyears']  = document.getElementById(rowCnt+'BT6').value; 
			} 	
		}
	}
	
	var dataString ="&research_arr="+encodeURIComponent(JSON.stringify(research_arr));
	$.ajax({
	type:"POST",
	url:$host_url+"saveresearchdetails",
	data:dataString,
	cache:false,
	success:function($responce)
	{	
		$responce = eval('('+$responce+')');
		if($responce.error_code == 0)
		{
			alert($responce.data);
		}
		else
			alert($responce.data);
	}	
	});

}

function saveDetailsofOtherExp()
{
	var dataString ="&othexpdet="+document.getElementById('S23').value;
	$.ajax({
	type:"POST",
	url:$host_url+"saveDetailsofOtherExp",
	data:dataString,
	cache:false,
	success:function($responce)
	{	
		$responce = eval('('+$responce+')');
		if($responce.error_code == 0)
		{
			alert($responce.data);
		}
		else
			alert($responce.data);
	}	
	});
}
function saveorientationdetails()
{
	//////To read Multiple Records///////	
	
	var inputFileds = document.getElementsByTagName('input');
	var chkCnt = 0;
	var rowCnt = 0;
	var orientation_arr = {};
	for (var counter=0; counter < inputFileds.length; counter++) 
	{       
		if ( inputFileds[counter].type.toUpperCase()=='TEXT'  && inputFileds[counter].name == "orientationdet" )
		{   
			++rowCnt;
			if(document.getElementById(rowCnt+'DT7').value != 'T')
			{
				++chkCnt; 
				orientation_arr[chkCnt] = new Object();
				orientation_arr[chkCnt]['Name'] = document.getElementById(rowCnt+'DT1').value;
				orientation_arr[chkCnt]['Rname'] = document.getElementById(rowCnt+'DT2').value;
				orientation_arr[chkCnt]['Sname']   = document.getElementById(rowCnt+'DT3').value;
				orientation_arr[chkCnt]['From']  = document.getElementById(rowCnt+'DT4').value;
				orientation_arr[chkCnt]['To']  = document.getElementById(rowCnt+'DT5').value;
				orientation_arr[chkCnt]['Remarks']  = document.getElementById(rowCnt+'DT6').value; 
			} 	
		}
	}
	
	//alert(Object.size(orientation_arr));
	
	var dataString ="&orientation_arr="+encodeURIComponent(JSON.stringify(orientation_arr));
	$.ajax({
	type:"POST",
	url:$host_url+"saveorientationdetails",
	data:dataString,
	cache:false,
	success:function($responce)
	{	
		$responce = eval('('+$responce+')');
		if($responce.error_code == 0)
		{
			alert($responce.data);
		}
		else
			alert($responce.data);
	}	
	});
	
}

function saveDetailsofForeignvisit()
{
	var inputFileds = document.getElementsByTagName('input');
	var chkCnt = 0;
	var rowCnt = 0;
	var foreign_arr = {};
	for (var counter=0; counter < inputFileds.length; counter++) 
	{       
		if ( inputFileds[counter].type.toUpperCase()=='TEXT'  && inputFileds[counter].name == "foreignvisit"  )
		{   
			++rowCnt;
			if(document.getElementById(rowCnt+'IT7').value != 'T')
			{
				++chkCnt;
				foreign_arr[chkCnt] = new Object();
				foreign_arr[chkCnt]['country'] = document.getElementById(rowCnt+'IT1').value;
				foreign_arr[chkCnt]['purpose'] = document.getElementById(rowCnt+'IT2').value;
				foreign_arr[chkCnt]['from']   = document.getElementById(rowCnt+'IT3').value;
				foreign_arr[chkCnt]['to']  = document.getElementById(rowCnt+'IT4').value;
				foreign_arr[chkCnt]['total']  = document.getElementById(rowCnt+'IT5').value;
				foreign_arr[chkCnt]['period']  = document.getElementById(rowCnt+'IT6').value;
			}	
		}
	}
	var dataString ="&foreign_arr="+encodeURIComponent(JSON.stringify(foreign_arr));
	$.ajax({
	type:"POST",
	url:$host_url+"saveDetailsofForeignvisit",
	data:dataString,
	cache:false,
	success:function($responce)
	{	
		$responce = eval('('+$responce+')');
		if($responce.error_code == 0)
		{
			alert($responce.data);
		}
		else
			alert($responce.data);
	}	
	});
}


function DisplayUserSelectedPhoto()
{
	var filepath;
	var valid_file_extentions = new Array("jpg");

	var ext=$("#student_photo_upload").val();
	filepath=ext;
	ext = ext.substring(ext.length-3,ext.length);
	ext = ext.toLowerCase();  

	if(ext != "" && valid_file_extentions == 'jpg' && valid_file_extentions == 'jpeg')
	{	      
		alert("Please Select the Valid Photo!");
		$("#student_photo_upload").val('')
		return false;
	}
	var lstr_data="filepath="+filepath;
	
	$upload = $host_url+"saveUserSelectedPhoto&"+lstr_data;	
	
	//$.blockUI({ message: "<h1 class='h1' style='font-size:12px'><img src='img/ajax-loader.gif' border='0'></h1>" });
	document.getElementById("form_module_image_upload").setAttribute("action",$upload);		
	return AIM.submit(document.getElementById("form_module_image_upload"), 'same_tab',{'onComplete' : DiaplayUserSelectedPhotoResponse});		 
		
}



function DiaplayUserSelectedPhotoResponse($responce)
{
	$responce = eval('(' + $responce + ')'); 
	// $.unblockUI();
	if($responce.error_code==0)
	{		
		$("#student_photo").attr("src", $responce.data);
	}
	else if($responce.error_code==-1)	
		$("#student_photo").attr("src", "img/default_photo.jpg"); 
	else if($responce.error_code==-2)	
	{
		alert($responce.data);
		$("#student_photo").attr("src", "img/default_photo.jpg");
		$("#student_photo_upload").val("");
	} 
}

function DisplayUserSelectedSign()
{
	var filepath;
	var valid_file_extentions = new Array("jpg");

	var ext=$("#student_sign_upload").val();
	filepath=ext;
	ext = ext.substring(ext.length-3,ext.length);
	ext = ext.toLowerCase();  

	if(ext != "" && valid_file_extentions == 'jpg' && valid_file_extentions == 'jpeg')
	{	      
		alert("Please Select the Valid Photo!");
		$("#student_sign_upload").val('')
		return false;
	}
	var lstr_data="filepath="+filepath;
	
	$upload = $host_url+"saveUserSelectedSign&"+lstr_data;	
	
	//$.blockUI({ message: "<h1 class='h1' style='font-size:12px'><img src='img/ajax-loader.gif' border='0'></h1>" });
	document.getElementById("form_module_image_upload").setAttribute("action",$upload);		
	return AIM.submit(document.getElementById("form_module_image_upload"), 'same_tab',{'onComplete' : DiaplayUserSelectedSignResponse});		 
		
}

function DiaplayUserSelectedSignResponse($responce)
{
	$responce = eval('(' + $responce + ')'); 
	// $.unblockUI();
	if($responce.error_code==0)
	{		
		$("#student_sign").attr("src", $responce.data);
	}
	else if($responce.error_code==-1)	
		$("#student_sign").attr("src", "img/default_photo.jpg"); 
	else if($responce.error_code==-2)	
	{
		alert($responce.data);
		$("#student_sign").attr("src", "img/default_photo.jpg");
		$("#student_sign_upload").val("");
	} 
}

function getaddress()
{
		var add1 = document.getElementById('T16').value;
		var add2 = document.getElementById('T17').value;
		var add3 = document.getElementById('T18').value;
		var add4 = document.getElementById('T19').value;
		
		document.getElementById('T20').value = add1;
		document.getElementById('T21').value = add2;
		document.getElementById('T22').value = add3;
		document.getElementById('T23').value = add4;
}


function savepost()
{
	var post    = document.getElementById('1S1').value;
	var subject = document.getElementById('1S2').value;
	
	var dataString ="&post="+post+"&subject="+subject;
	$.ajax({
	type:"POST",
	url:$host_url+"savepost",
	data:dataString,
	cache:false,
	success:function($responce)
	{	
		$responce = eval('('+$responce+')');
		if($responce.error_code == 0)
		{
			$("#postdetails").show();
			$("#postdettable tbody").remove();	 
			alert($responce.data.table);
			$("#postdettable").append($responce.data.table);
		}
		else
			alert($responce.data);
	}	
	});
}

function loadapplieddetails()
{
	var dataString ="";
	$.ajax({
	type:"POST",
	url:$host_url+"loadapplieddetails",
	data:dataString,
	cache:false,
	success:function($responce)
	{	
		$responce = eval('('+$responce+')');
		if($responce.error_code == 0)
		{
			$("#postdetails").show();	 
			$("#postdettable").append($responce.data.table);
		}
		else
		{	
			$("#postdetails").hide();
		}
	}	
	});
}

function main_menu(id)
{
	//alert(document.getElementById('postdeg_'+id).value);
	
	var post = document.getElementById('postdeg_'+id).value;
	setCookie("post",post);
	var subject  = document.getElementById('postsub_'+id).value;
	setCookie("subject",subject);
	var app = document.getElementById('postapplication_'+id).value;
	setCookie("app",app);
	window.location.href="main_page.html?post="+post+"&subject="+subject+"&app="+app+"&id="+id+"";
}