// JavaScript Document

// start (document).ready
$(document).ready(function() {
	
	//start #registerForm validate												 
	$("#registerForm").validate({
		rules:
		{
			email:{required:true,email:true},
			current:{required:true},
			password:{required:true,minlength:5},
			password2:{required:true,minlength:5,equalTo:"#password"},
			photo:{required:true},
			fullname:{required:true,minlength:3},
			religion:{required:true},
			day:{required:true},
			month:{required:true},
			year:{required:true},
			marital_status:{required:true},
			address:{required:true},
			postcode:{required:true,number:true},
			country:{required:true},
			city:{required:true},
			mobile:{required:true},
			cellular:{required:true,number:true},
			codearea:{required:true},
			phone:{required:true,number:true},
			
			combo_school:{required:true},
			school:{required:true},
			level:{required:true},
			major:{required:true},
			//year2: { required:true, number:true, minlength:4, minlength:4 },
			office:{required:true},
			city_of_work:{required:true},
			office_industry_id:{required:true},
			position:{required:true},
			job_function:{required:true},
			start:{required:true},
			end:{required:true},
			job_desc:{required:true}
		},
		messages:
		{
			email:"Please enter a valid email address",
			current:"Please provide current password" ,
			password:{required:"Please provide a password",minlength:"Your password must be at least 5 characters long"},
			password2:{required:"Please provide a password",minlength:"Your password must be at least 5 characters long",equalTo:"Please enter the same password as above"},
			photo:"If you want to change, please browse it before",
			fullname:"Please enter your fullname",
			religion:"Please choose your religion",
			day:"Please enter the day",
			month:"Please enter the month",
			year:"Please enter the year",
			marital_status:"Please choose your marital status",
			address:"Please enter your address",
			postcode:"Please enter your postcode",
			country:"Please select your country",
			city:"Please select your province",
			mobile:"Please choose your mobile prefix number",
			cellular:{required:"Please enter your cellular",number:"only number"},
			codearea:"Please choose your codearea",
			phone:{required:"Please enter your phone",number:"only number"},
			
			combo_school:"Please select the school name",
			school:"Please enter the school",
			level:"Please enter the level of your educational",
			major:"Please enter the major of your educational",
			//year2: { required: "Please enter the year", number: "must be the number", minlength: "must be 4 digit" },
			office:"Please enter the company",
			city_of_work:"Please enter the city of work",
			office_industry_id:"Please choose the industry of your company",
			position:"Please enter the position",
			job_function:"Please enter the function",
			start:"Plese fill it",
			end:"Plese fill it",
			job_desc:"Please fill the job description"
		}
	});
	// end #registerForm validate
	
	// start load_city
	function load_city(){
		$.ajax({
			type:"GET",
			url: "ajax_city.php",
			data: "id=" + $('#selcountry option:selected').val(),
			success: function(result){ 
				$("#ajx_city").html(result);
			}
		});
		$('#hidden_country').val($('#selcountry option:selected').text());
	}
	//end load city
	
	// start load_mobile
	function load_mobile(){
		$.ajax({
			type:"GET",
			url: "ajax_mobile.php",
			data: "id=" + $('#selcountry option:selected').val(),
			success: function(result){ 
				$("#ajx_mobile").html(result);
			}
		});
	}
	//end load_mobile
	
	// start load_codearea
	function load_codearea(){
		$.ajax({
			type:"GET",
			url: "ajax_codearea.php",
			data: "country_id=" + $('#selcountry option:selected').val() + "&city_id=" + $('#hiddencity').val(),
			success: function(result){ 
				$("#ajx_codearea").html(result);
			}
		});
	}
	//end load_codearea
	
	$('#selcountry').change(function(){
		load_city();
		load_mobile(); 
		load_codearea();
	});
		
	//start #testimonial fadein
	$('#testimonial').innerfade({ 
		animationtype: 'fade', speed: 1000, timeout: 9000, type: 'random', containerheight: '190px' 
	});
	//end #testimonial fadein
	
	// start floating notification resume incomplete box
	// Developed by Roshan Bhattarai (http://roshanbh.com.np)
	// scroll the message box to the top offset of browser's scrool bar
	$(window).scroll(function()
	{
  		$('#notification_resume_incomplete').animate({top:$(window).scrollTop()+"px" },{queue: false, duration: 350});  
	});
  // when the close button at right corner of the message box is clicked 
	$('#close_notification').click(function()
	{
  // the messagebox gets scrool down with top property and gets hidden with zero opacity 
		$('#notification_resume_incomplete').animate({ top:"+=15px",opacity:0 }, "slow");
	});
	// start floating notification resume incomplete box
	
	window.onload=load_city();load_mobile();load_codearea();
});
// end (document).ready


function confirm_delete_education(id,school){
	var i=confirm('Do you want to delete the item for: ' + school);
	if(i==1){
		window.location.href='main.php?module=profile_education_delete&id=' + id;
	}
}

function confirm_delete_job_experience(id,office){
	var i=confirm('Do you want to delete the item for: ' + office);
	if(i==1){
		window.location.href='main.php?module=profile_job_experience_delete&id=' + id;
	}
}
