function init_press(){
	title ('PressRoom | whahoobi');
	getid('box_m').style.backgroundColor = 'lavender';
	getid('press_page_home').style.backgroundColor = 'white';
	var p = get_opt('content');
	if(p){
		open_content(p);	
	} else {
		open_content('mainpage');
	}
	
}
reginit("init_press()");


function open_content(t){

	if(t==0){
		getid('press_jump_title').style.display 	= 'none';
	}else{
		getid('press_jump_title').style.display 	= 'block';
	}


	getid('press_main_content').innerHTML ='';	
	getid('press_main_content').innerHTML += fetch_page('/pressroom/'+t+'.php');

	if(t == 'speakerrequest'){
		var now = new Date();
		getid('sp_month').value	= now.getMonth() + 1;
		getid('sp_day').value 	= now.getDate();
		getid('sp_year').value	= now.getFullYear();
		getid('sp_hour').value	= now.getHours();
		getid('sp_min').value	= now.getMinutes();
	}

}

function submit_speaker(){

	var sp1,sp2,sp3,sp4,sp5,sp6,sp7,sp8,sp9,sp10,sp11,sp12,sp13,sp14,sp15,sp16,sp17,sp18,sp19,sp20,sp21,sp22,sp_m,sp_d,sp_y,sp_h,spm,sp21_y,sp21_n,sp22;

	sp1 = getid('sp1').value;

	sp_m = getid('sp_month').value;
	sp_d = getid('sp_day').value;
	sp_y = getid('sp_year').value;
	sp_h = getid('sp_hour').value;
	spm = getid('sp_min').value;
	sp2 = sp_m +'-'+sp_d+'-'+sp_y+' '+sp_h+':'+spm;

	sp3 = getid('sp3').value;
	sp4 = getid('sp4').value;
	sp5 = getid('sp5').value;
	sp6 = getid('sp6').value;
	sp7 = getid('sp7').value;
	sp8 = getid('sp8').value;
	sp9 = getid('sp9').value;
	sp10 = getid('sp10').value;
	sp11 = getid('sp11').value;
	sp12 = getid('sp12').value;
	sp13 = getid('sp13').value;
	sp14 = getid('sp14').value;
	sp15 = getid('sp15').value;
	sp16 = getid('sp16').value;
	sp17 = getid('sp17').value;
	sp18 = getid('sp18').value;
	sp19 = getid('sp19').value;
	sp20 = getid('sp20').value;
	sp22 = getid('sp22').value;

	var r = http_request();
		r.open("GET", 'x.php?check='+sp22, false);
		r.send(null);
		var v = r.responseText;

		if(sp22 == '' ){
			getid('spk_erro').style.display = 'block';
			getid('erro_c').innerHTML = "Security Check Failed. Please try again."
	                getid('sp22').focus(); 
			return false;
		}else {
			if(v-0 != 1){
			getid('spk_erro').style.display = 'block';
			getid('erro_c').innerHTML = "Security Check Failed. Please try again."
	                getid('sp22').focus(); 
			return false;
			} else {

			}
		}

	var e = /^([a-zA-Z0-9._-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
        if(!e.test(sp9)){	
		getid('spk_erro').style.display = 'block';
		getid('erro_c').innerHTML = "Email was not valid. Please resubmit the form with a valid email address"
                getid('sp9').focus(); 
		return false;
	}
	
	if(empty(sp1) == false){
		getid('spk_erro').style.display = 'block';
		getid('erro_c').innerHTML = "The required field 'event' was missing. Please fill out all the fields before submitting."
		getid('sp1').focus();
		return false;
	}

	if(empty(sp3) == false){
		getid('spk_erro').style.display = 'block';
		getid('erro_c').innerHTML = "The required field 'speaker' was missing. Please fill out all the fields before submitting."
		getid('sp3').focus();
		return false;
	}

	if(empty(sp4) == false){
		getid('spk_erro').style.display = 'block';
		getid('erro_c').innerHTML = "The required field 'name' was missing. Please fill out all the fields before submitting."
		getid('sp4').focus();
		return false;
	}

	if(empty(sp5) == false){
		getid('spk_erro').style.display = 'block';
		getid('erro_c').innerHTML = "The required field 'title' was missing. Please fill out all the fields before submitting."
		getid('sp5').focus();
		return false;
	}

	if(empty(sp6) == false){
		getid('spk_erro').style.display = 'block';
		getid('erro_c').innerHTML = "The required field 'company' was missing. Please fill out all the fields before submitting."
		getid('sp6').focus();
		return false;
	}

	if(empty(sp7) == false){
		getid('spk_erro').style.display = 'block';
		getid('erro_c').innerHTML = "The required field 'address' was missing. Please fill out all the fields before submitting."
		getid('sp7').focus();
		return false;
	}

	if(empty(sp8) == false){
		getid('spk_erro').style.display = 'block';
		getid('erro_c').innerHTML = "The required field 'phone' was missing. Please fill out all the fields before submitting."
		getid('sp8').focus();
		return false;
	} else {
	        if (isNaN(sp8)) {
	        	getid('spk_erro').style.display = 'block';
			getid('erro_c').innerHTML = "Phone was not valid. Please resubmit the form with a valid phone."
	                getid('sp8').focus(); 
			return false;                
		}
	}

	if(empty(sp10) == false){
		getid('spk_erro').style.display = 'block';
		getid('erro_c').innerHTML = "The required field 'venue' was missing. Please fill out all the fields before submitting."
		getid('sp10').focus();
		return false;
	}

	if(empty(sp11) == false){
		getid('spk_erro').style.display = 'block';
		getid('erro_c').innerHTML = "The required field 'goal' was missing. Please fill out all the fields before submitting."
		getid('sp11').focus();
		return false;
	}

	if(empty(sp12) == false){
		getid('spk_erro').style.display = 'block';
		getid('erro_c').innerHTML = "The required field 'format' was missing. Please fill out all the fields before submitting."
		getid('sp12').focus();
		return false;
	}

	if(empty(sp13) == false){
		getid('spk_erro').style.display = 'block';
		getid('erro_c').innerHTML = "The required field 'type' was missing. Please fill out all the fields before submitting."
		getid('sp13').focus();
		return false;
	}

	if(empty(sp14) == false){
		getid('spk_erro').style.display = 'block';
		getid('erro_c').innerHTML = "The required field 'topic' was missing. Please fill out all the fields before submitting."
		getid('sp14').focus();
		return false;
	}

	if(empty(sp15) == false){
		getid('spk_erro').style.display = 'block';
		getid('erro_c').innerHTML = "The required field 'length' was missing. Please fill out all the fields before submitting."
		getid('sp15').focus();
		return false;
	}

	if(empty(sp16) == false){
		getid('spk_erro').style.display = 'block';
		getid('erro_c').innerHTML = "The required field 'others' was missing. Please fill out all the fields before submitting."
		getid('sp16').focus();
		return false;
	}

	if(empty(sp17) == false){
		getid('spk_erro').style.display = 'block';
		getid('erro_c').innerHTML = "The required field 'attendees' was missing. Please fill out all the fields before submitting."
		getid('sp17').focus();
		return false;
	}

	if(empty(sp18) == false){
		getid('spk_erro').style.display = 'block';
		getid('erro_c').innerHTML = "The required field 'audience' was missing. Please fill out all the fields before submitting."
		getid('sp18').focus();
		return false;
	}

	if(empty(sp19) == false){
		getid('spk_erro').style.display = 'block';
		getid('erro_c').innerHTML = "The required field 'Web URL' was missing. Please fill out all the fields before submitting."
		getid('sp19').focus();
		return false;
	}

	if(empty(sp20) == false){
		getid('spk_erro').style.display = 'block';
		getid('erro_c').innerHTML = "The required field 'pastspeaker' was missing. Please fill out all the fields before submitting."
		getid('sp20').focus();
		return false;
	}

	if(getid('sp21_y').checked){
		sp21 = getid('sp21_y').value;
	}else if(getid('sp21_n').checked){
		sp21 = getid('sp21_n').value;
	}else{
		getid('spk_erro').style.display = 'block';
		getid('erro_c').innerHTML = "The required field 'media cover' was missing. Please fill out all the fields before submitting."
		return false;
	}

	var spk = new Poster();
	spk.async	= true;
	spk.query	= 'sub_speaker';
//	spk.billboard = [53, _mem[0], ''];

	spk.value	= {
		sp1: 	sp1,
		sp2: 	sp2,
		sp3: 	sp3,
		sp4: 	sp4,
		sp5: 	sp5,
		sp6: 	sp6,
		sp7: 	sp7,
		sp8: 	sp8,
		sp9: 	sp9,
		sp10: 	sp10,
		sp11: 	sp11,
		sp12: 	sp12,
		sp13: 	sp13,
		sp14: 	sp14,
		sp15: 	sp15,
		sp16: 	sp16,
		sp17: 	sp17,
		sp18: 	sp18,
		sp19: 	sp19,
		sp20: 	sp20,
		sp21: 	sp21
	};

//	spk.valid	= {
//		sp9: 'email'
//	};


	spk.popdone	= 0;
//	spk.prepare();

	spk.post();



	clear_speaker();
	open_content('speakerrequest');
	
	var sbj = 'Request a Speaker';	
	fetch_script2 ('/pressroom/press_send.php?sp1='+sp1+'&sp2='+sp2+'&sp3='+sp3+'&sp4='+sp4+'&sp5='+sp5+'&sp6='+sp6+'&sp7='+sp7+'&sp8='+sp8+'&sp9='+sp9+'&sp10='+sp10+'&sp11='+sp11+'&sp12='+sp12+'&sp13='+sp13+'&sp14='+sp14+'&sp15='+sp15+'&sp16='+sp16+'&sp17='+sp17+'&sp18='+sp18+'&sp19='+sp19+'&sp20='+sp20+'&sp21='+sp21+'&sbj='+sbj);


}

function clear_speaker(){

	getid('sp1').value='';
//	getid('sp2').value='';
	getid('sp3').value='';
	getid('sp4').value='';
	getid('sp5').value='';
	getid('sp6').value='';
	getid('sp7').value='';
	getid('sp8').value='';
	getid('sp9').value='';
	getid('sp10').value='';
	getid('sp11').value='';
	getid('sp12').value='';
	getid('sp13').value='';
	getid('sp14').value='';
	getid('sp15').value='';
	getid('sp16').value='';
	getid('sp17').value='';
	getid('sp18').value='';
	getid('sp19').value='';
	getid('sp20').value='';
	getid('sp22').value='';


}

function submit_interview(){
	var iv1,iv2,iv3,iv4,iv5,iv6,iv7,iv8,iv9,iv10;

	iv1 = getid('iv1').value;
	iv2 = getid('iv2').value;
	iv3 = getid('iv3').value;
	iv4 = getid('iv4').value;
	iv5 = getid('iv5').value;
	iv6 = getid('iv6').value;
	iv7 = getid('iv7').value;
	iv8 = getid('iv8').value;
	iv9 = getid('iv9').value;
	iv10 = getid('iv10').value;

       var r = http_request();
                r.open("GET", 'x.php?check='+iv10, false);
                r.send(null);
                var v = r.responseText;

                if(iv10 == '' ){
                        getid('spk_erro2').style.display = 'block';
                        getid('erro2_c').innerHTML = "Security Check Failed. Please try again."
                        getid('iv10').focus();
                        return false;
                }else {
                        if(v-0 != 1){
                        getid('spk_erro2').style.display = 'block';
                        getid('erro2_c').innerHTML = "Security Check Failed. Please try again."
                        getid('iv10').focus();
                        return false;
                        } else {

                        }
                }


	var e = /^([a-zA-Z0-9._-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
        if(!e.test(iv2)){	
		getid('spk_erro2').style.display = 'block';
		getid('erro2_c').innerHTML = "Email was not valid. Please resubmit the form with a valid email address"
                getid('iv2').focus(); 
		return false;
	}


	if(empty(iv1) == false){
		getid('spk_erro2').style.display = 'block';
		getid('erro2_c').innerHTML = "The required field 'name' was missing. Please fill out all the fields before submitting."
		getid('iv1').focus();
		return false;
	}

	if(empty(iv3) == false){
		getid('spk_erro2').style.display = 'block';
		getid('erro2_c').innerHTML = "The required field 'name' was missing. Please fill out all the fields before submitting."
		getid('iv3').focus();
		return false;
	} else {
	        if (isNaN(iv3)) {
	        	getid('spk_erro2').style.display = 'block';
			getid('erro2_c').innerHTML = "Phone was not valid. Please resubmit the form with a valid phone."
	                getid('iv3').focus(); 
			return false;                
		}
	}


	if(empty(iv4) == false){
		getid('spk_erro2').style.display = 'block';
		getid('erro2_c').innerHTML = "The required field 'publication' was missing. Please fill out all the fields before submitting."
		getid('iv4').focus();
		return false;
	}

	if(empty(iv5) == false){
		getid('spk_erro2').style.display = 'block';
		getid('erro2_c').innerHTML = "The required field 'story topic' was missing. Please fill out all the fields before submitting."
		getid('iv5').focus();
		return false;
	}

	if(empty(iv6) == false){
		getid('spk_erro2').style.display = 'block';
		getid('erro2_c').innerHTML = "The required field 'deadline' was missing. Please fill out all the fields before submitting."
		getid('iv6').focus();
		return false;
	}

	if(empty(iv7) == false){
		getid('spk_erro2').style.display = 'block';
		getid('erro2_c').innerHTML = "The required field 'interviewee' was missing. Please fill out all the fields before submitting."
		getid('iv7').focus();
		return false;
	}

	if(empty(iv8) == false){
		getid('spk_erro2').style.display = 'block';
		getid('erro2_c').innerHTML = "The required field 'proposed questions' was missing. Please fill out all the fields before submitting."
		getid('iv8').focus();
		return false;
	}

	if(empty(iv9) == false){
		getid('spk_erro2').style.display = 'block';
		getid('erro2_c').innerHTML = "The required field 'additional info' was missing. Please fill out all the fields before submitting."
		getid('iv8').focus();
		return false;
	}

	var info = new Poster();
	info.async	= true;
	info.query	= 'sub_interview';
//	info.billboard = [53, _mem[0], ''];

	info.value	= {
		iv1: 	iv1,
		iv2: 	iv2,
		iv3: 	iv3,
		iv4: 	iv4,
		iv5: 	iv5,
		iv6: 	iv6,
		iv7: 	iv7,
		iv8: 	iv8,
		iv9: 	iv9
	};

//	info.valid	= {
//		iv2: 	'email'
//	};


	info.popdone	= 0;
//	info.prepare();

	info.post();


	clear_interview();
	open_content('interviewrequest');	

	var sbj = 'Interview Requests';	
	fetch_script2 ('/pressroom/press_send.php?iv1='+iv1+'&iv2='+iv2+'&iv3='+iv3+'&iv4='+iv4+'&iv5='+iv5+'&iv6='+iv6+'&iv7='+iv7+'&iv8='+iv8+'&iv9='+iv9+'&type=1&sbj='+sbj);



}

function clear_interview(){

	getid('iv1').value='';
	getid('iv2').value='';
	getid('iv3').value='';
	getid('iv4').value='';
	getid('iv5').value='';
	getid('iv6').value='';
	getid('iv7').value='';
	getid('iv8').value='';
	getid('iv9').value='';
	getid('iv10').value='';
}

function http_request () {
        var r;
        if (window.XMLHttpRequest) {
                r = new XMLHttpRequest();
        } else if (window.ActiveXObject) {
                r = new ActiveXObject("Microsoft.XMLHTTP");
        } else {
                r = false;
        }

        return r;
}

function fetch_script2 (url,t) {

        var a = Math.random();
        var d   = document.createElement('script');
        document.body.appendChild(d);
        d.type  = 'text/javascript';
        d.src = url_opt (url, '__='+a);
        d.id    = a;
        if (t!=1) setTimeout('document.body.removeChild(document.getElementById ("'+a+'"))',
                         5000);
}

function empty(s) {
	var s_r1 = s.replace(/\&nbsp;|\<br\>|\<BR\>|\<P\>|\<\/P\>/g,'');
	s_r1 = s_r1.replace(/[\n\r\t\ ]/g,'');
	var s_r_no = s_r1.length;
	if (s_r_no<=0) {
		return false;
	}else{
		return true;
	}
}


