/********************************************************************************************/
/* Web Team 2009 - Vibal Publishing House Inc.												*/ 
/* This code is intended for study purposes.                                                */
/* You may use these functions as you wish, for commercial or non-commercial applications,  */
/* but please note that the author offers no guarantees to their usefulness, suitability or */
/* correctness, and accepts no liability for any losses caused by their use.                */
/********************************************************************************************/

$(document).ready(function(){   

	
	// INDEX.PHP 
	$("#ilearn").click(function (){ document.location = 'ilearn.php' }).mouseover(function(){ $(this).css({"cursor":"pointer"}) });    
	$("#iteach").click(function (){ document.location = 'iteach.php' }).mouseover(function(){ $(this).css({"cursor":"pointer"}) });    
	$("#iguide").click(function (){ document.location = 'iguide.php' }).mouseover(function(){ $(this).css({"cursor":"pointer"}) });
	
	$("#learn").click(function (){ document.location = 'ilearn.php' }).mouseover(function(){ $(this).css({"cursor":"pointer"}) });    
	$("#teach").click(function (){ document.location = 'iteach.php' }).mouseover(function(){ $(this).css({"cursor":"pointer"}) });    
	$("#guide").click(function (){ document.location = 'iguide.php' }).mouseover(function(){ $(this).css({"cursor":"pointer"}) });
	
	$("#ubd").click(function (){ document.location = 'ubd.php' }).mouseover(function(){ $(this).css({"cursor":"pointer"}) });
	
	$("#ilearn").css({"background":"url(../images/ilearn_tab.png) no-repeat top center"});
	$("#iteach").css({"background":"url(../images/iteach_tab.png) no-repeat top center"});
	$("#iguide").css({"background":"url(../images/iguide_tab.png) no-repeat top center"});	
	$(".features #featured").click(function (){ document.location = 'products.php?m=pv&pid=65' }).mouseover(function(){ $(this).css({"cursor":"pointer"}) });    	
	
	// ABOUT_US.PHP	
	$(".about_us #products").click(function (){ document.location = 'http://vibalpublishing.com/products.php' }).mouseover(function(){ $(this).css({"cursor":"pointer"}) });    		
	$(".topStories1 #wiki").click(function (){ document.location = 'http://en.wikipilipinas.org/index.php?title=Vibal_Publishing_House%2C_Inc.' }).mouseover(function(){ $(this).css({"cursor":"pointer"}) });
	
	//ilearn.php interactive activities
	$("#interactive_act").mouseover(function(){ $(this).css({"cursor":"pointer"}) });
	
	//function for retrieving a cookie value
		function readCookie(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
			for(var i=0;i < ca.length;i++) {
				var c = ca[i];
				while (c.charAt(0)==' ') c = c.substring(1,c.length);
				if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
			}
		return null;
		}

	// REGISTER POP-UP
	/*
	$(".reg#register").click(function(){
		$('#reg').dialog('open');			
			return false;
	});*/
	
	// LOGIN POP-UP
	$(".log#login").click(function(){
		$('#log').dialog('open');			
			return false;
	});
	
	$("#act_btn").click(function(){
		$("#act").dialog('open');			
			return false;
	});
	
	$("#ff_up_act_hs_btn").click(function(){
		$("#ff_up_act_hs").dialog('open');			
			return false;
	});
	
	$("#ff_up_act_gs_btn").click(function(){
		$("#ff_up_act_gs").dialog('open');			
			return false;
	});

		//Register Functions
		var fname = $("#fname"),			
			lname = $("#lname"),
			mname = $("#datepicker"),
			gender = $("#gender"),
			uname = $("#uname"),
			pass = $("#pass"),
			pass2 = $("#pass2"),
			loc = $("#loc"),
			school = $("#school"),
			orderCode = $("#orderCode"),
			email = $("#email"),
			cap = $("#cap"),
			
			allFields = $([]).add(fname).add(lname).add(mname).add(gender).add(uname).add(pass).add(pass2).add(loc).add(school).add(orderCode).add(email).add(cap),
			
			tips = $("#validateTips");
			Apply = $([]).add(fname).add(mname).add(lname);
		
		function updateTips(t) {
			
			tips.text(t).effect("highlight",{},1500);
		}

		function checkLength(o,n,min,max) {
		
			if ( o.val().length > max || o.val().length < min ) {	
				o.addClass('ui-state-error');
				updateTips("Length of " + n + " must be between "+min+" and "+max+".");
				return false;
			} else {
				return true;
			}

		}
		
		function checkRegexp(o,regexp,n) {

			if ( !( regexp.test( o.val() ) ) ) {
				o.addClass('ui-state-error');
				updateTips(n);
				return false;
			} else {
				return true;
			}

		}
		
		function checkLength2(o,txt,x,min,max) { 
			if ( o.length > max || o.length < min ) {
				$("#"+x).addClass('ui-state-error');				
				if(x == "position" || x == "bdate" || x == "status"){
					updateTips("You must select your desire "+x+".");
				}else{
					updateTips("Length of " + txt + " must be between "+min+" and "+max+".");
				}	
				return false;				
			} else {
				$("#"+x).removeClass('ui-state-error');	
				return true;
			}				
		}		
		
		function checkRegexp2(o,x,regexp,n) {
			
			if ( !( regexp.test( o ) ) ) {
				$("#"+x).addClass('ui-state-error');
				updateTips(n);				
				return false;
			} else {
				$("#"+x).removeClass('ui-state-error');	
				return true;				
			}		
		}	
		
		//comparison for passwords
		function checkPass(a,b,obj1,obj2,notice){
			if (a != b) {
				obj1.addClass('ui-state-error');
				obj2.addClass('ui-state-error');
				updateTips(notice);
				return false;
			} else {
				return true;
			}
		}
		
		function checkSch(a,b,c){
			if (a == "(Select your school Here...)") {
				b.addClass('ui-state-error');				
				updateTips(c);
				return false;
			} else {
				return true;
			}
		}
		
		function checkLoc(a,b,c){
			if (a == "(Select Location Here...)") {
				b.addClass('ui-state-error');				
				updateTips(c);
				return false;
			} else {
				return true;
			}
		}
		
		function checkreCap(a,b,c){
			if (a == "") {
				b.addClass('ui-state-error');				
				updateTips(c);
				return false;
			} else {
				return true;
			}
		}
		
		function checkBday(a,b,c){
			if (a == "") {
				b.addClass('ui-state-error');				
				updateTips(c);
				return false;
			} else {
				return true;
			}
		}
		
		function checkPHP(b,c){
			b.addClass();
			updateTips(c);
		}
	$("#Click2Apply").click(function(){			
		$("#CareerDesc").hide("slow");
		$(".CareerAppForm").show("slow");			
	}).mouseover(function(){ $(this).css({"cursor":"pointer"}) });	
	$("#Click2Back").click(function(){			
		$(".CareerAppForm").hide("slow");
		$("#CareerDesc").show("slow");			
	}).mouseover(function(){ $(this).css({"cursor":"pointer"}) });
	
	$(".btn").mouseover(function(){ $(this).css({"cursor":"pointer"}) });
	
	// datepicker
	$(function() {
		$('#datepicker').datepicker({
			changeMonth: true,
			changeYear: true,
			yearRange: '1980:2009' 		
		});
	});
	

    // apply 
	
	$("#apply").click(function(){			
		f = document.apply;						
		var bValid = true;			
		Apply.removeClass('ui-state-error');
		
		bValid = bValid && checkLength2(f.fname.value,"First Name","fname",3,16);				
		bValid = bValid && checkRegexp2(f.fname.value,"fname",/^[a-z]([0-9a-z_])+$/i,"First Name may consist of a-z, 0-9, underscores, begin with a letter.");
		bValid = bValid && checkLength2(f.mname.value,"Middle Name","mname",2,16);		
		bValid = bValid && checkRegexp2(f.mname.value,"mname",/^[a-z]([0-9a-z_])+$/i,"Middle Name may consist of a-z, 0-9, underscores, begin with a letter.");
		bValid = bValid && checkLength2(f.lname.value,"Last Name","lname",3,16);			
		bValid = bValid && checkRegexp2(f.lname.value,"lname",/^[a-z]([0-9a-z_])+$/i,"Last Name may consist of a-z, 0-9, underscores, begin with a letter.");				
		bValid = bValid && checkLength2(f.position.value,"Position","position",1,80);				
		bValid = bValid && checkLength2(f.bdate.value,"Birth Date","datepicker",1,10);			
		bValid = bValid && checkLength2(f.status.value,"Status","status",1,80);						
		bValid = bValid && checkLength2(f.email.value,"e-mail","email",1,30);			
		bValid = bValid && checkRegexp2(f.email.value,"email",/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i,"eg. inquire@vibalpublishing.com");
		bValid = bValid && checkLength2(f.phone.value,"Phone","phone",7,30);					
		bValid = bValid && checkRegexp2(f.phone.value,"phone",/^([0-9-])+$/i,"Phone number may consist of 0-9, eg. 123-4567.");				
		bValid = bValid && checkLength2(f.mobile.value,"Mobile","mobile",11,30);							
		bValid = bValid && checkRegexp2(f.mobile.value,"mobile",/^([0-9-+])+$/i,"Mobile number may consist of 0-9, eg. +63123456789.");								
		var ext = $('#myFile').val().split('.').pop().toLowerCase();
		var allow = new Array('doc');
		if(jQuery.inArray(ext, allow) == -1) {			
			updateTips("Invalid file extension, eg. 'myfile.doc'");
		}else{
			if(bValid){
				updateTips("Successfully transmitted data.");				
				$("#validateTips").hide("fast");
				$("#submit").show("slow");
				for(i=0;i < f.gender.length;i++){
					if(f.gender[i].checked){
						gender = f.gender[i].value
					}
				}
				filename = document.getElementById('myFile').value;					
				applicationSend(f.fname.value,
								f.mname.value,
								f.lname.value,
								f.position.value,
								gender,f.bdate.value,
								f.status.value,
								f.email.value,
								f.phone.value,
								f.mobile.value,
								f.recaptcha_challenge_field.value,
								f.recaptcha_response_field.value,filename);			
			}		
		}
	});		
    		
	$("#reg").click(function (){ 
					//field validation
					emtot = document.register;
					
					var bValid = true;
					allFields.removeClass('ui-state-error');

					bValid = bValid && checkLength(fname,"First Name",2,20);
					bValid = bValid && checkRegexp(fname,/^[a-z]([0-9a-z_])+$/i,"First Name may consist of a-z, 0-9, underscores, begin with a letter.");
					
					bValid = bValid && checkLength(lname,"Last Name",2,20);
					bValid = bValid && checkRegexp(lname,/^[a-z]([0-9a-z_])+$/i,"Last Name may consist of a-z, 0-9, underscores, begin with a letter.");
					
					bValid = bValid && checkreCap(emtot.bday.value,mname,"Please choose your Birthday.");
					
					//bValid = bValid && checkLength(mname,"Birthday",2,20);
					//bValid = bValid && checkRegexp(mname,/^[a-z]([0-9a-z_])+$/i,"Middle Name may consist of a-z, 0-9, underscores, begin with a letter.");
					
					bValid = bValid && checkLength(uname,"Username",3,16);
					bValid = bValid && checkRegexp(uname,/^[a-z]([0-9a-z_])+$/i,"Username may consist of a-z, 0-9, underscores, begin with a letter.");
					
					bValid = bValid && checkLength(pass,"password",5,16);
					bValid = bValid && checkRegexp(pass,/^[a-z]([0-9a-z_])+$/i,"Password may consist of a-z, 0-9, underscores, begin with a letter.");
					
					bValid = bValid && checkPass(emtot.pass.value,emtot.pass2.value,pass,pass2,"** Passwords does not match each other. **");					
					
					bValid = bValid && checkLoc(emtot.loc.value,loc,"Select your location from the dropdown box.");
					bValid = bValid && checkSch(emtot.school.value,school,"Select your school from the dropdown box.");
					
					bValid = bValid && checkLength(email,"e-Mail",6,80);
					bValid = bValid && checkRegexp(email,/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i,"eg. inquire@vibalpublishing.com");
					
					bValid = bValid && checkreCap(emtot.recaptcha_response_field.value,cap,"Please input the image in the Captcha.");					
					
					if (bValid) {							
						document.getElementById('errorREG').style.visibility='visible' 	
						//add 2 more function values for the captcha values.
						registerResult(emtot.fname.value,									   
									   emtot.lname.value,
									   emtot.bday.value,
									   emtot.gender.value,
									   emtot.uname.value,
									   emtot.pass.value,
									   emtot.pass2.value,
									   emtot.school.value,
									   emtot.orderCode.value,
									   emtot.email.value,
									   emtot.recaptcha_challenge_field.value,
									   emtot.recaptcha_response_field.value);									   
						//ajax end here
						
						//the PHP code in the register_script is executed at this line.
						//window.location = 'index.php';
					}else{ document.getElementById('validateImage').style.visibility='visible' }
			});
			
		/* LOGIN JS */
	$("#log").dialog({
			bgiframe: true,
			autoOpen: false,
			height: 240,
			width: 350,
			maxWidth: 350,
			maxHeight: 240,
			minWidth: 350,
			minHeight: 240,
			modal: true,
			draggable: false,
			buttons: {
				'Log In': function() {
					var UN = $("#UN").val();
					var PWD = $("#PWD").val();
					
					document.getElementById('error').style.visibility='visible' 						 
					loginResult(UN,PWD);
					//login_script.php code execute at this line	
				},
				Cancel: function() {
					$(this).dialog('close');
				}
			}, 
	});
	//for ilearn activity list
	$("#act").dialog({
			bgiframe: true,
			autoOpen: false,
			height: 220,
			width: 420,
			maxWidth: 420,
			maxHeight: 220,
			minWidth: 420,
			minHeight: 220,
			modal: true,
			draggable: false,
			buttons: {				
				Close: function() {
					$(this).dialog('close');
				}
			}, 
	});
	//for other followup activities
	$("#ff_up_act_hs").dialog({
			bgiframe: true,
			autoOpen: false,
			height: 350,
			width: 500,
			maxWidth: 500,
			maxHeight: 350,
			minWidth: 500,
			minHeight: 350,
			modal: true,
			draggable: false,
			buttons: {				
				Close: function() {
					$(this).dialog('close');
				}
			}, 
	});
	
	$("#ff_up_act_gs").dialog({
			bgiframe: true,
			autoOpen: false,
			height: 275,
			width: 500,
			maxWidth: 500,
			maxHeight: 275,
			minWidth: 500,
			minHeight: 275,
			modal: true,
			draggable: false,
			buttons: {				
				Close: function() {
					$(this).dialog('close');
				}
			}, 
	});
	
	$("#Inquiry").click(function (){ document.location.href = 'http://www.vibalpublishing.com/news.php?m=nv&nid=42' }).mouseover(function(){ $(this).css({"cursor":"pointer"}) });    				
	
	$("#feed_me").click(function(){  				
	
	    regexp = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i;
		$("#validateTips").css({"color":"maroon","text-indent":"115px"});
		$(".feedback").css({"height":"350px"});
		$(".feedback form").css({"height":"350px"});
		if(!document.feeds.name.value){								
			$("#validateTips").show("slow");
			tips.text("** Enter your name **").effect("highlight",{},1500);		
			$("#name").addClass('ui-state-error');		
			$("#submit").hide("slow");
		}else{
		    $("#name").removeClass('ui-state-error');
			if(!document.feeds.mail.value || !regexp.test( document.feeds.mail.value )){		
				$("#validateTips").show("slow");
				tips.text("** Enter your e-mail address **").effect("highlight",{},1500);		
				$("#mail").addClass('ui-state-error');
				$("#submit").hide("slow");
			}else{
				$("#mail").removeClass('ui-state-error');
				if(!document.feeds.school.value){		
					$("#validateTips").show("slow");
					tips.text("** Enter your school name **").effect("highlight",{},1500);		
					$("#school").addClass('ui-state-error');
					$("#submit").hide("slow");
				}else{
					$("#school").removeClass('ui-state-error');
					if(!document.feeds.message.value){					    
						$("#validateTips").show("slow");
						tips.text("** Enter your message **").effect("highlight",{},1500);		
						$("#message").addClass('ui-state-error');
						$("#submit").hide("slow");	
					}else{
						$("#message").removeClass('ui-state-error');
						$("#validateTips").hide("slow");
						$("#submit").show("slow");
						return true;
					
					// submit...
					//alert(document.feeds.name.value+" "+document.feeds.mail.value+" "+document.feeds.message.value);	
                    /*feedbackSend(document.feeds.name.value,
								 document.feeds.mail.value,
								 document.feeds.message.value,
								 document.feeds.recaptcha_challenge_field.value,
								 document.feeds.recaptcha_response_field.value); 					
								 */
					}				
				}			
				
			}			
		}			
	});
	
	

	//end 	
	
	// END
});


// livesearch check
function showResult(str)
{

	if (str.length==0){
	  document.getElementById("livesearch").innerHTML="";
	  document.getElementById("livesearch").style.border="0px";
	  return;
	}
	xmlhttp=GetXmlHttpObject()
	if (xmlhttp==null){
		alert ("Your browser does not support XML HTTP Request");
		return;
	}
	  
	var url="livesearch.php";
	url=url+"?q="+str;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateChanged ;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
	
	function stateChanged()
	{
		if (xmlhttp.readyState==4)
		  {
		  document.getElementById("livesearch").innerHTML=xmlhttp.responseText;
		  }
	}
}
//end of livesearch check

// Register Live Check. Orayt!
var xmlhttp;



function registerResult(fname,lname,mname,gender,uname,pass,pass2,school,orderCode,email,chal,resp){

	xmlhttp=GetXmlHttpObject()
	if (xmlhttp==null){
	  alert ("Your browser does not support XML HTTP Request");
	  return;
	}

	var url="register_script.php";
	var params="fname="+fname+"&lname="+lname+"&mname="+mname+"&gender="+gender+"&uname="+uname+"&pass="+pass+"&pass2="+pass2+"&school="+school+"&orderCode="+orderCode+"&email="+email+"&chal="+chal+"&resp="+resp;

	xmlhttp.onreadystatechange=stateChanged2;
	xmlhttp.open("POST",url,true);
	
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-length", params.length);
	xmlhttp.setRequestHeader("Connection", "close");
	
	xmlhttp.send(params);
	
	function stateChanged2()
	{
		if (xmlhttp.readyState==4)
		  {
		  document.getElementById("errorREG").innerHTML=xmlhttp.responseText;
		  
		  }
	}
}

//end

//activity 
function flash(filename,height,width){	
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null){
		alert ("Your browser does not support XMLHTTP!");
		return;
	}
	var url="swf.php";
	url=url+"?file="+filename+"&height="+height+"&width="+width;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateChanged;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);

	function stateChanged()
	{
		if (xmlhttp.readyState==4){
				document.getElementById("FL").innerHTML=xmlhttp.responseText;
		}
	}
}



// LOGIN
function loginResult(UN,PWD){

	xmlhttp=GetXmlHttpObject()
	if (xmlhttp==null){
	  alert ("Your browser does not support XML HTTP Request");
	  return;
	}

	var url="login_script.php";
	url=url+"?name="+UN+"&pass="+PWD;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateChanged2;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
	
	function stateChanged2()
	{
		if (xmlhttp.readyState==4)
		  {
		  document.getElementById("error").innerHTML=xmlhttp.responseText;

		  }
	}
}

// end

//feedback sending...
function feedbackSend(a,b,c,d,e){    

	xmlhttp=GetXmlHttpObject()
	if (xmlhttp==null){
	  alert ("Your browser does not support XML HTTP Request");
	  return;
	}
	var url="feedback.php";
	var params="a="+a+"&b="+b+"&c="+c+"&d="+d+"&e="+e;

	xmlhttp.onreadystatechange=stateChanged3;
	xmlhttp.open("POST",url,true);
	
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-length", params.length);
	xmlhttp.setRequestHeader("Connection", "close");
	
	xmlhttp.send(params);	
	
	function stateChanged3()
	{
		if (xmlhttp.readyState==4)
		  {
			document.getElementById("submit").innerHTML=xmlhttp.responseText;
		  }
	}
}
function applicationSend(a,b,c,d,e,f,g,h,i,j,k,l,m){

	xmlhttp=GetXmlHttpObject()
	if (xmlhttp==null){
	  alert ("Your browser does not support XML HTTP Request");
	  return;
	}
	var url="resume.php";
	var params="a="+a+"&b="+b+"&c="+c+"&d="+d+"&e="+e+"&f="+f+"&g="+g+"&h="+h+"&i="+i+"&j="+j+"&k="+k+"&l="+l+"&m="+m;		

	xmlhttp.onreadystatechange=stateChanged;
	xmlhttp.open("POST",url,true);
	
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-length", params.length);
	xmlhttp.setRequestHeader("Connection", "close");
	
	xmlhttp.send(params);	
	
	function stateChanged()
	{
		if (xmlhttp.readyState==4)
		  {
			document.getElementById("submit").innerHTML=xmlhttp.responseText;
		  }
	}
}


//username & mail

function getUN(str,mode){
	if (str.length==0){
	  document.getElementById("validateUN").innerHTML="";
	  document.getElementById("validateUN").style.border="0px";
	  return;
	}
	xmlhttp=GetXmlHttpObject()
	if (xmlhttp==null){
		alert ("Your browser does not support XML HTTP Request");
		return;
	}
	  
	var url="un_email_check.php";
	url=url+"?q="+str+"&m="+mode;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateChanged ;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
	
	function stateChanged()
	{
		if (xmlhttp.readyState==4)
		  {
		  document.getElementById("validateUN").innerHTML=xmlhttp.responseText;
		  }
	}
}

function getEMAIL(str,mode) {
	if (str.length==0){
	  document.getElementById("validateEmail").innerHTML="";
	  document.getElementById("validateEmail").style.border="0px";
	  return;
	}
	xmlhttp=GetXmlHttpObject()
	if (xmlhttp==null){
		alert ("Your browser does not support XML HTTP Request");
		return;
	}
	  
	var url="un_email_check.php";
	url=url+"?q="+str+"&m="+mode;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateChanged ;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
	
	function stateChanged()
	{
		if (xmlhttp.readyState==4)
		  {
		  document.getElementById("validateEmail").innerHTML=xmlhttp.responseText;
		  }
	}
}

function schools_list(str) {
	if (str.length==0){
	  document.getElementById("validateEmail").innerHTML="";
	  document.getElementById("validateEmail").style.border="0px";
	  return;
	}
	xmlhttp=GetXmlHttpObject()
	if (xmlhttp==null){
		alert ("Your browser does not support XML HTTP Request");
		return;
	}
	  
	var url="schools_list.php";
	url=url+"?q="+str;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateChanged ;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
	
	function stateChanged()
	{
		if (xmlhttp.readyState==4)
		  {
		  document.getElementById("school_list").innerHTML=xmlhttp.responseText;
		  }
	}
}
//end of main functions
function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}
// end


