﻿/*-------- Simple http request -----*/
var fullDIV='';
var fullWait='';
var fullWhide='';
function FullSendRequest(url,data, div,wait,waitcod, waithide) {
	fullDIV=div;
	fullWhide=waithide;
	document.getElementById(wait).className=waitcod;
	http.abort();
//	alert("sent "+data);
	http.open("POST",url,true);
	http.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	http.onreadystatechange = FullHandleResp; 
//	alert("sent "+data);
	http.send(data); 
}
function FullHandleResp() { 
  if ( http.readyState == 4) {
    result = http.responseText;
	document.getElementById(fulDIV).innerHTML=result;
	document.getElementById(fullWait).className=fullWhide;
	document.title=fultitl;
  }
} 

////////////\\\\\\\\\\


/*--------login form -----*/
var curlogin;
function ShowLogin(ldiv){
	if(ldiv.id=="aemail")
		curlogin="emil";
	else
		curlogin="cp";
	document.getElementById("ti").innerHTML=(ldiv.id=="aemail")?"[ Webmail ]":"[ Control panel ]";
	document.getElementById("loginfrm").className='lshow';
//	document.getElementById("login").focus();
}

function FrmClose(){
	document.getElementById("loginfrm").className='hid';
}
function docheck(frm){
	if(curlogin=="emil"){
		frm.login_username.value=frm.user.value+"@irvinesuperfun.com";
		return true;
	}else{
		frm.action="../cp.php";
		frm.cp_username.value=frm.user.value;
		frm.cp_password.value=frm.secretkey.value;
		frm.cp_submit.value=frm.Submit.value;
		return true;
	}
}

function GoLogin(){
alert(curlogin);
	if(curlogin=="emil"){
			
	}else{
		info="cp_submit=Login";
		info+="&cp_username="+document.getElementById("tlogin").getAttribute("value");
		info+="&cp_password="+document.getElementById("tpass").getAttribute("value");
		urlf="http://irvinesuperfun.com/cp.php";
		alert (info);
		sendRequest(urlf,info);
	}
}

/*testimonial*/
function SendTestimonial(){
var frm= document.getElementById('tstmform');
if(frm["tsName"].value.length==0){
	alert("Please fill your name!");
	frm["tsName"].focus();
	return;
}
if(frm["tsSubject"].value.length==0){
	alert("Please fill subject!");
	frm["tsSubject"].focus();
	return;
}
if(frm["tsMsg"].value.length==0){
	alert("Please fill your testimonial content!");
	frm["tsMsg"].focus();
	return;
}
var data='&name='+frm["tsName"].value+'&subject='+frm["tsSubject"].value+'&msg='+frm["tsMsg"].value.replace(/\n/g,'<br\>');
sendtstmnl(data);
}
function sendtstmnl(tstmnlinfo){
document.getElementById("cntwit").className='';
document.getElementById("cntbtn").className='hid';	
document.getElementById("cntres").className='hid';

sendRequest('system/submittestimonial.php',tstmnlinfo);

}

/* contact */
function SendMsg(){
var frm= document.getElementById('cntform');
//alert(frm.length);
var data='';
for(i=0;i<frm.length;i++) {
	  data += '&'+frm[i].name+'='+frm[i].value;
}
//alert(data);
sendcontact(data);
}
function sendcontact(cntinfo){
document.getElementById("cntwit").className='';
document.getElementById("cntbtn").className='hid';	
document.getElementById("cntres").className='hid';

sendRequest('system/sendcontact.php',cntinfo);

}
function sendRequest(url,data) {
	http.abort();
//	alert("sent "+data);
	http.open("POST",url,true);
	http.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	http.onreadystatechange = handleResp; 
//	alert("sent "+data);
	http.send(data); 
}
function handleResp() { 
  if ( http.readyState == 4) {
    result = http.responseText;
    document.getElementById("cntbtn").className='';
	document.getElementById("cntwit").className='hid';
	document.getElementById("cntres").innerHTML=result;
	document.getElementById("cntres").className='';
	
  }
} 
////////////////\\\\\\\\\\\\\

/////// page manager \\\\\\\\
var emppg='<h1 class="titl">Page not found!</h1><div id="cntnt" style=""></div>';
var upagemanager="pagemanage.php";
var ubase="http://irvinesuperfun.com";
var fultitl="Irvine Super Fun and Learning Center";
var divid;
function makeRequest(url,data) {
	http.abort();
	http.open("POST",url,true);
	http.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	http.onreadystatechange = handleResponse; 
	http.send(data); 
//	alert("sent "+data);
}
function handleResponse() { 
  //window.status=http.responseText.length;
  if ( http.readyState == 4) {
  	result=emppg; 
    result = http.responseText;

	if(result.length<5)
		result=emppg;

	values=	result.split("|",2);
	setcurent(values[0]);
    el=document.getElementById(divid);
    el.innerHTML=values[1];
//	document.getElementById(msgid).className='lshow';
//	document.getElementById("ldingwin").className='lhid';
	document.title=fultitl;
	fixheight();
	
	//20080716 for google urchin	
	_uacct = "UA-4320055-1";
	urchinTracker();

 }
} 
//////////\\\\\\\\\\

// application \\\
function SubmitApp(){
document.getElementById('regres').innerHTML='<div style="border-color: #009933; border-width: 2px; border-style: solid; padding: 10px; margin-left:30px; margin-top: 50px; width: 90%; background-color: #FFFFFF;"><p style="" id="wait"><img alt="" src="images/progress.gif" />&nbsp;&nbsp; Sending information, Please wait...</p></div>';
document.getElementById('regres').style.display='';
document.getElementById('regres').style.bordercolor='#009933';
document.getElementById('regres').style.borderwidth='2px';
document.getElementById('regres').style.borderstyle='solid'; 
document.getElementById('regres').style.padding='10px'; 
document.getElementById('regres').style.marginleft='30px';
document.getElementById('regres').style.margintop='50px';
document.getElementById('regres').style.width='90%'; 
document.getElementById('regres').style.backgroundcolor='#FFFFFF';
var frm= document.getElementById('regform');
//alert(frm.length);
var data='';
for(i=0;i<frm.length;i++) {
	if(frm[i].type=='radio'){
		if(frm[i].checked)
		  data += '&'+frm[i].name+'='+frm[i].value;
	}else{
	  data += '&'+frm[i].name+'='+frm[i].value;
	}
}
//data='?'+data.substring(1,data.length);
//alert(data);
appRequest(makepath('dopreview'),data);
}
function ConfirmApp(){
document.getElementById('regres').innerHTML='<div style="border-color: #009933; border-width: 2px; border-style: solid; padding: 10px; margin-left:30px; margin-top: 50px; width: 90%; background-color: #FFFFFF;"><p style="" id="wait"><img alt="" src="images/progress.gif" />&nbsp;&nbsp; Sending information, Please wait...</p></div>';
document.getElementById('regres').style.display='';
document.getElementById('regres').style.bordercolor='#009933';
document.getElementById('regres').style.borderwidth='2px';
document.getElementById('regres').style.borderstyle='solid'; 
document.getElementById('regres').style.padding='10px'; 
document.getElementById('regres').style.marginleft='30px';
document.getElementById('regres').style.margintop='50px';
document.getElementById('regres').style.width='90%'; 
document.getElementById('regres').style.backgroundcolor='#FFFFFF';
var frm= document.getElementById('regform');
//alert(frm.length);
var data='';
for(i=0;i<frm.length;i++) {
	if(frm[i].type=='radio'){
		if(frm[i].checked)
		  data += '&'+frm[i].name+'='+frm[i].value;
	}else{
	  data += '&'+frm[i].name+'='+frm[i].value;
	}
}
//data='?'+data.substring(1,data.length);
//alert(data);
appRequest(makepath('doregister'),data);
}
function appRequest(url,data) {
	http.abort();
	http.open("POST",url,true);
	http.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	http.onreadystatechange = appResponse; 
	http.send(data); 
	document.getElementById('regres').scrollIntoView();
	fixheight();
//	alert("sent "+data);
}
function appResponse() { 
  if ( http.readyState == 4) {
  	result=emppg; 
    result = http.responseText;

	if(result.length<5)
		result=emppg;

//	document.getElementById('regres').style.display='none';

	values=	result.split("|",2);
	if(values[0]=='true'){
		document.getElementById('regres').innerHTML=values[1];
		document.getElementById('regform').style.display='none';
	}else{
		document.getElementById('regres').innerHTML='<div style="border-color: #009933; border-width: 2px; border-style: solid; padding: 10px; margin-left:30px; margin-top: 50px; width: 90%; background-color: #FFFFFF;">'+values[1]+"<\div>";
	}
	document.title=fultitl;
	document.getElementById('regres').scrollIntoView();
	document.getElementById("rnav").style.height='490px';
	fixheight();
 }
} 
function doedit(){
		document.getElementById('regres').innerHTML='';
		document.getElementById('regres').style.display='none';
		document.getElementById('regform').style.display='';
}
///////////\\\\\\\\\\\\\\

//in page
function DoPage(page){
	/*
	for(x in pgs){
		if(pgs[x]==page){
			document.location.search="#page="+(pgst[x]);
		}
	}
	*/
	document.getElementById("topbar").style.visibility="hidden";
	curnt="snow";
	//20080317document.getElementById("tvimg").setAttribute("src","images/"+curnt+".gif");
	document.getElementById("page").innerHTML=pageload;
	document.getElementById("rnav").style.height='490px';
	fixheight();
	divid="page";
	var data="cmd=changepage&p="+page;
	makeRequest(upagemanager,data);
}
var curnt="mhom";
function setcurent(vll){
	curnt=vll;
	//20080317document.getElementById("tvimg").setAttribute("src","images/"+curnt+".gif");
	if(curnt=="mpa"){ 
		staticbar();
	}
}
function OnMnuOver(btn){
	btn.className='mnuin';
	var nam=btn.id;
	//20080317document.getElementById("tvimg").setAttribute("src","images/"+nam+".gif");
}
function OnMnuOut(btn){
btn.className='mnuout';
//20080317document.getElementById("tvimg").setAttribute("src","images/"+curnt+".gif");
}
function fixheight(){
var cth=document.getElementById('maincontain').clientHeight;
//alert(cth);
document.getElementById("rnav").style.height=cth-240+'px';

var mbh=document.getElementById('mainbody').clientHeight;
//alert(mbh);
document.getElementById('pars').style.marginTop=mbh-170+'px';
document.getElementById('pars').className="";

document.getElementById('loginfrm').style.top=mbh-180+'px';
}
function frmclos(pos){
//document.getElementById('clos').style.color='rgb(255, 0, 0)';
if(pos==1)
window.status='Close login form';
else
window.status='';
}

var pgs=new Array('home','phil','reg','drop','opr','team','prg');
var pgst=new Array('home','philosophy','registration','dropin','operation','ourteam','program');

function ldmanag(){
fixheight();
getoffer('');
//091204ofrmng(1);
var u=document.location.search;
if(u){
var i=u.indexOf("page=");
if(i>0){
	ne=u.indexOf("&",i);
	if(ne<1)
		ne=u.indexOf("#",i);
	if(ne>0)
		p=u.substring(i+5,ne);
	else
		p=u.substring(i+5);
	//alert(p);
	for(x in pgs){
		if(pgst[x]==p){
			DoPage(pgs[x]);
		}
	}
}
}
//init();//for gallery
//091204ControlSlide(true)//start slide
}

/***********************************************
* Floating Top Bar script- © Dynamic Drive (www.dynamicdrive.com)
* Sliding routine by Roy Whittle (http://www.javascript-fx.com/)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var persistclose=1 //set to 0 or 1. 1 means once the bar is manually closed, it will remain closed for browser session
var startX = 200 //set x offset of bar in pixels
var startY = 200 //set y offset of bar in pixels
var verticalpos="fromtop" //enter "fromtop" or "frombottom"

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function closebar(){
if (persistclose)
document.cookie="remainclosed=1"
document.getElementById("topbar").style.visibility="hidden"
}
function staticbar(){
	barheight=document.getElementById("topbar").offsetHeight
	var ns = (navigator.appName.indexOf("Netscape") != -1) || window.opera;
	var d = document;
	function ml(id){
		var el=d.getElementById(id);
		if (!persistclose || persistclose && get_cookie("remainclosed")=="")
		el.style.visibility="visible"
		if(d.layers)el.style=el;
		el.sP=function(x,y){this.style.left=x+"px";this.style.top=y+"px";};
		el.x = startX;
		if (verticalpos=="fromtop")
		el.y = startY;
		else{
		el.y = ns ? pageYOffset + innerHeight : iecompattest().scrollTop + iecompattest().clientHeight;
		el.y -= startY;
		}
		return el;
	}
	window.stayTopLeft=function(){
		if (verticalpos=="fromtop"){
		var pY = ns ? pageYOffset : iecompattest().scrollTop;
		ftlObj.y += (pY + startY - ftlObj.y)/8;
		}
		else{
		var pY = ns ? pageYOffset + innerHeight - barheight: iecompattest().scrollTop + iecompattest().clientHeight - barheight;
		ftlObj.y += (pY - startY - ftlObj.y)/8;
		}
		ftlObj.sP(ftlObj.x, ftlObj.y);
		if(curnt=="mpa") {
			checkpos();
			setTimeout("stayTopLeft()", 10);
		}
	}
	ftlObj = ml("topbar");
	stayTopLeft();
}

//find browser
var ff=0;
var pf = navigator.userAgent.toLowerCase();
if(pf.indexOf("firefox")>-1) ff=1
////\\\\\\\\\\	

function checkpos(){
var tp=document.getElementById("topbar").offsetTop-100;
var sp;	
for(i=9;i>0;i--){
	el=document.getElementById("sec"+i);
	if(el!=null){
		sp=el.offsetTop;
		if(tp>sp){
			callframe(i)
			break;
		}
	}
}
if(i==0)
	callframe(1);

}
function callframe(n){
if(ff>0)
 document.getElementById("activityid").SetVariable("nu", n);
else
 activity.SetVariable("nu", n);
}

///////////\\\\\\\\\\\\\


//get offer
function getOfHR() { 
  if ( http.readyState == 4) { 
    result = http.responseText;
    el=document.getElementById(getoftag);
    //alert(result);
    el.innerHTML=result;
    el.className='';
 }
} 
function getMakeRequest(url,data) {
  http.open("POST",url,true);
  http.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
  http.onreadystatechange = getOfHR; 
  http.send(data); 
}
function getoffer(sdata){
getoftag="offertext";//"spcoffr";
surl="tools/getoffer.php";
getMakeRequest(surl,sdata);
}
//end get offer

//get otestimonial
function gettestresp() { 
  if ( http.readyState == 4) { 
    result = http.responseText;
    el=document.getElementById(gettesttag);
    //alert(result);
    el.innerHTML=result;
    el.className='';
 }
} 
function getTestRequest(url,data) {
  http.open("POST",url,true);
  http.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
  http.onreadystatechange = gettestresp; 
  http.send(data); 
}
function gettest(sdata){
gettesttag="testimonialtext";
surl="tools/gettest.php";
getTestRequest(surl,sdata);
}
//end get offer


function makepath(name){
return 'system/'+name+'.php';
}
function getHTTPObject() { 
  var xmlhttp; 
  /*@cc_on 
  @if (@_jscript_version >= 5) 
    try { 
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); 
    } catch (e) { 
      try { 
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
      } catch (E) { 
        xmlhttp = false; 
      } 
    } 
  @else 
  xmlhttp = false; 
  @end @*/ 
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') { 
    try { 
      xmlhttp = new XMLHttpRequest(); 
    } catch (e) { 
      xmlhttp = false; 
    } 
  } 
  return xmlhttp; 
} 
var http = getHTTPObject(); // We create the HTTP Object 
var httpr = getHTTPObject(); // We create the HTTP Object 
