/* add this otpions */ addthis_pub = 'pitcherocom'; addthis_options = 'favorites, facebook, stumbleupon, digg, delicious, google, myspace, reddit, live, more'; window.js_sport_id = '0'; var openDivs = new Array(); var number = 0; var win=null; String.prototype.reverse = function(){ splitext = this.split(""); revertext = splitext.reverse(); reversed = revertext.join(""); return reversed; } function URLcheck(string) { if(confirm('You are about to navigate away from Pitchero.\nPitchero is not responsible for the content of external internet sites.\n\nIf you have a popup blocker, hold down the control button and click OK')) { window.open(string, '_blank'); } } function showHideFlash() { var e=document.getElementsByTagName("embed"); for(i=0;i 1) { makeHttpRequest('/clubsignup/ajax.php?field=' + field + '&value=' + value + '&sport_id=' + sport_id, 'document.getElementById(\'' + div + '\').innerHTML='); } } function validateClubSignup() { if(checkPostcode('postcode') && check2('clubname') && checkTeamName() && checkAddress() && checkTac() && document.form.postcode.value != '') { // check we have content for each bit disable(document.form.submit); return true; } else { return false; } } function getData() { stop(); } function attachImages(maximum, div, formfield, club_id) { day = new Date(); id = day.getTime(); //newwindow = window.open('/myAccount/attachImages.php?club_id=' + club_id + '&max=' + maximum + '&div=' + div + '&formfield=' + formfield,'myWin','toolbar=no,width=700,height=400,top=300,left=300'); eval("page" + id + " = window.open('/myAccount/attachImages.php?club_id=" + club_id + "&max=" + maximum + "&div=" + div + "&formfield=" + formfield + "','myWin','toolbar=no,width=700,height=400,top=300,left=300');"); } function openDoc(url) { day = new Date(); id = day.getTime(); eval("page" + id + " = window.open(URL, 'myWin','toolbar=no,width=600,height=450,top=300,left=300,scrollbars=1');"); } function trim(a){ var tmp=new Array(); for(j=0;j 0) { do { if (this[i] === search_term) { return true; } } while (i--); } return false; } function checkAlbum(club_id, string, checkbox) { var IDarray = string.split(","); if(document.getElementById(checkbox).checked==true) { if(IDarray) { for(i=0;i limitNum) { limitField.value = limitField.value.substring(0, limitNum); } else { limitCount.value = limitNum - limitField.value.length; } } function noTeam() { window.location = '3.php?sport_id=' + window.js_sport_id; } function checkAddDocument() { // make sure we have a name if(document.addForm.title.value) { return true; } else { alert('As a minimum, you must select a file to upload and specify a title'); return false; } } function checkAddOfficial() { // make sure we have a name if(document.form.name.value) { return true; } else { alert('As a minimum, you must enter a name for your official'); return false; } } function checkDeleteOfficial(message) { if(confirm(message)) { return true; } else { return false; } } function checkDeleteSponsor(message) { if(confirm(message)) { return true; } else { return false; } } function checkAddSponsor() { // make sure we have a name if(document.addForm.name.value) { return true; } else { alert('As a minimum, you must enter a name for your sponsor'); return false; } } function checkAssociation(string, message) { if(confirm(message)) { window.location=string; } } function check(field) { var box = ('document.form.' + field); makeHttpRequest('/ajax/signup_checker.php?field=' + field + '&string=' + document.getElementById(field).value, 'document.getElementById("div_' + field + '").innerHTML='); document.getElementById("div_" + field).innerHTML='Checking....'; return true; } function check2(field) { var box = ('document.form.' + field); //alert(document.getElementById(field).value); if(document.getElementById(field).value.length >= 2) { makeHttpRequest('/ajax/query.php?field=' + field + '&string=' + document.getElementById(field).value, 'document.getElementById("div_' + field + '").innerHTML='); document.getElementById("div_" + field).innerHTML='Checking....'; return true; } else { document.getElementById("div_" + field).innerHTML=' Please include a club name!'; } } function checkPostcode(field) { // post code needs to be checked against country_id var box = ('document.form.' + field); //alert(document.getElementById(field).value); if(document.getElementById(field).value.length >= 0) { makeHttpRequest('/ajax/query.php?field=' + field + '&string=' + document.getElementById(field).value + '&pc2=' +document.getElementById('postcode2').value + '&country_id=' + document.getElementById('country_id').value, 'document.getElementById("div_' + field + '").innerHTML='); document.getElementById("div_" + field).innerHTML='Checking....'; return true; } } function validateClub() { if(check2('name') && checkTeamName() && checkAddress() && checkPostcode('postcode') && checkTac() && document.form.postcode.value != '') { return true; } else { return false; } } function checkPasswords() { if(!document.form.password.value) { var error = 'No password specified.'; } else if(document.form.password.value != document.form.password2.value) { var error = 'Passwords do not match.'; } else if(document.form.password.value.length < 6) { var error = 'Password should be at least 6 characters.'; } // output if(error) { document.getElementById("div_password2").innerHTML=' ' + error; return false; } else { document.getElementById("div_password2").innerHTML=''; return true; } } function checkDay() { if(document.form.dob_day.value.length == 2) document.form.dob_month.focus(); } function checkMonth() { if(document.form.dob_month.value.length == 2) document.form.dob_year.focus(); } function checkYear() { // only validate if we have a year selected // else return please choose dob if(document.form.dob_year.value) { // first check all numbers are he right length if(!document.form.dob_year.value || !document.form.dob_month.value || !document.form.dob_day.value) { var error = 'Day, Month and Year required.'; } else if(document.form.dob_year.value.length != 4) { var error = 'Year must be 4 digits eg. "1980".'; } else if(document.form.dob_day.value.length != 2) { var error = 'Day must be 2 digits eg. "01".'; } else if(document.form.dob_month.value.length != 2) { var error = 'Month must be 2 digits eg. "01".'; } else if(document.form.dob_day.value == 0 || document.form.dob_day.value >= 32) { var error = 'There are not ' + document.form.dob_day.value + ' days in a month!'; } else if(document.form.dob_month.value == 0 || document.form.dob_month.value >= 13) { var error = 'There are not ' + document.form.dob_month.value + ' months in a year!'; } else if(document.form.dob_year.value >= 2007 || document.form.dob_year.value <= 1907) { var error = 'Being born in ' + document.form.dob_year.value + ' is unlikely!'; } // output if(error) { document.getElementById("div_dob").innerHTML=' ' + error; //document.getElementById("div_dob").innerHTML=''; return false; } else { document.getElementById("div_dob").innerHTML=''; return true; } } else { document.getElementById("div_dob").innerHTML=' Please select your Full DoB'; //document.getElementById("div_dob").innerHTML=''; return false; } } function checkTac() { if(document.form.tac.checked == false) { document.getElementById("div_tac").innerHTML=' You must agree to the terms and conditions.'; return false; } else { document.getElementById("div_tac").innerHTML=''; return true; } } function checkTeamName() { if(document.form.teamname.value == '') { document.getElementById("div_teamname").innerHTML=' You must enter a primary team name; e.g. \'First Team\' '; return false; } else { document.getElementById("div_teamname").innerHTML=''; return true; } } function checkNames() { if((document.form.firstname.value == '') || (document.form.lastname.value == '') || (document.form.firstname.value.length < 2) || (document.form.lastname.value.length < 2)) { document.getElementById("div_lastname").innerHTML=' Firstname and Lastname must be entered and be larger than 2 characters'; return false; } else { document.getElementById("div_lastname").innerHTML=''; return true; } } function checkAddress() { if((document.form.address1.value == '') || (document.form.address2.value == '')) { if(document.form.address1.value == '') { document.getElementById("div_address1").innerHTML=' Please enter a postal address for your club.'; } else { document.getElementById("div_address1").innerHTML=''; } if(document.form.address2.value == '') { document.getElementById("div_address2").innerHTML=' Please enter a postal address for your club.'; } else { document.getElementById("div_address2").innerHTML=''; } return false; } else { document.getElementById("div_address1").innerHTML=''; document.getElementById("div_address2").innerHTML=''; return true; } } function validate() { if(checkPasswords() && checkNames() && checkYear() && checkTac() && document.getElementById("div_emailchecker")) { //alert('Validate ok.'); return true; } else { //alert('Validate false.'); return false; } } function checkEmail(str) { var at="@" var dot="." var lat=str.indexOf(at) var lstr=str.length var ldot=str.indexOf(dot) if (str.indexOf(at)==-1){ //alert("Invalid E-mail ID") return false; } if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){ //alert("Invalid E-mail ID") return false; } if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){ //alert("Invalid E-mail ID") return false; } if (str.indexOf(at,(lat+1))!=-1){ //alert("Invalid E-mail ID") return false; } if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){ //alert("Invalid E-mail ID") return false; } if (str.indexOf(dot,(lat+2))==-1){ //alert("Invalid E-mail ID") return false; } if (str.indexOf(" ")!=-1){ //alert("Invalid E-mail ID") return false; } return true; } function sportSelected(id) { makeHttpRequest('ajax.php?y=' + Math.random() + '&sport_id=' + id, 'document.getElementById("competitions").innerHTML='); document.getElementById('competitions').innerHTML=''; document.getElementById('regions').innerHTML=''; document.getElementById('divisions').innerHTML=''; document.getElementById('teams').innerHTML=''; document.getElementById('info').innerHTML=''; window.js_sport_id = id; //alert(window.js_sport_id); } function competitionSelected(id) { makeHttpRequest('ajax.php?y=' + Math.random() + '&competition_id=' + id, 'document.getElementById("regions").innerHTML='); document.getElementById('regions').innerHTML=''; document.getElementById('divisions').innerHTML=''; document.getElementById('teams').innerHTML=''; document.getElementById('info').innerHTML=''; } function regionSelected(competition_id, region_id) { makeHttpRequest('ajax.php?y=' + Math.random() + '&competition_id=' + competition_id + '®ion_id=' + region_id, 'document.getElementById("divisions").innerHTML='); document.getElementById('divisions').innerHTML=''; document.getElementById('teams').innerHTML=''; document.getElementById('info').innerHTML=''; } function divisionSelected(competition_id, division_id) { makeHttpRequest('ajax.php?y=' + Math.random() + '&competition_id=' + competition_id + '&division_id=' + division_id, 'document.getElementById("teams").innerHTML='); document.getElementById('teams').innerHTML=''; document.getElementById('info').innerHTML=''; } function teamSelected(competition_id, team_id) { makeHttpRequest('ajax.php?y=' + Math.random() + '&competition_id=' + competition_id + '&team_id=' + team_id, 'document.getElementById("info").innerHTML='); document.getElementById('info').innerHTML=''; } function userMenu(option) { makeHttpRequest('../clubIncludes/userMenu.php?option=' + option, 'document.getElementById("user-content").innerHTML='); //document.getElementById('user-content').innerHTML='Checking....'; } function result_info(id) { if(document.getElementById('result_' + id).style.display == "none") { document.getElementById('result_' + id).style.display = ""; } else { document.getElementById('result_' + id).style.display = "none"; } document.getElementById('result_' + id).focus(); } function playerImage(dir, player_id) { document["playerimage" + player_id].src = dir + '/' + document.getElementById("image_" + player_id).value; } function show(id) { document.getElementById(id).style.display = ""; return true; } function hide(id) { document.getElementById(id).style.display = "none"; return true; } function showhide(id) { if(document.getElementById(id).style.display == "none") { document.getElementById(id).style.display = ""; if(document[id + "_arrow"]) { document[id + "_arrow"].src = "/images/arrow_down.gif"; } } else { document.getElementById(id).style.display = "none"; if(document[id + "_arrow"]) { document[id + "_arrow"].src = "/images/arrow.gif"; } } } function fixture_info(id) { if(document.getElementById('fixture_' + id).style.display == "none") { document.getElementById('fixture_' + id).style.display = ""; } else { document.getElementById('fixture_' + id).style.display = "none"; } document.getElementById('fixture_' + id).focus(); } function showMessage(id) { if(document.getElementById(id).style.display == "none") { document.getElementById(id).style.display = ""; } else { document.getElementById(id).style.display = "none"; } document.getElementById(id).focus(); } function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { oldonload(); func(); } } } // ajax wait period // http://forums.devshed.com/javascript-development-115/time-restraint-430177.html?&highlight=onkeyup+AJAX var count = 0; function ajaxWait(field) { count = count+1; setTimeout("ajaxCheck("+count+")",500); } function ajaxCheck(currCount) { if(currCount == count) { count = 0; siteSearch(); } } function siteSearch(field) { var field = 'search_string'; var box = ('document.form.' + field); if(document.getElementById(field).value.length > 1) { makeHttpRequest('/search/ajax.php?string=' + document.getElementById(field).value, 'document.getElementById("div_' + field + '").innerHTML='); document.getElementById("div_" + field).innerHTML='Searching....'; return true; } else { document.getElementById("div_" + field).innerHTML=''; } } function makeHttpPostRequest(url, params, callback_function, refreshrequired) { var number = Math.random(); var loading = 'Loading.....'; params = params + '&n=' + number; //eval(callback_function + '(loading)'); if (window.XMLHttpRequest) { // Mozilla, Safari,... http_request = new XMLHttpRequest(); if (http_request.overrideMimeType) { http_request.overrideMimeType('text/xml'); } } else if (window.ActiveXObject) { // IE try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } http_request.open("POST", url, true); //Send the proper header information along with the request http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); http_request.setRequestHeader("Content-length", params.length); http_request.setRequestHeader("Connection", "close"); http_request.onreadystatechange = function() {//Call a function when the state changes. if(http_request.readyState == 4 && http_request.status == 200) { eval(callback_function + '(http_request.responseText)'); } // this ensures that the page has loaded AND that we require a data refresh if (refreshrequired) { refreshAfterPost(); } } http_request.send(params); return false; } function makeHttpRequest(url, callback_function, return_xml, refreshrequired) { var loading = 'Loading.....'; eval(callback_function + '(loading)'); // IE sometimes caches requests, so send a random number with each query var number = Math.random(); var http_request = false; if (window.XMLHttpRequest) { // Mozilla, Safari,... http_request = new XMLHttpRequest(); if (http_request.overrideMimeType) { http_request.overrideMimeType('text/xml'); } } else if (window.ActiveXObject) { // IE try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if (!http_request) { alert('Unfortunatelly you browser doesn\'t support this feature.'); return false; } http_request.onreadystatechange = function() { if (http_request.readyState == 4) { if (http_request.status == 200) { if (return_xml) { eval(callback_function + '(http_request.responseXML)'); } else { eval(callback_function + '(http_request.responseText)'); } // this ensures that the page has loaded AND that we require a data refresh if (refreshrequired) { getData(); } } else { alert('There was a problem with the request.(Code: ' + http_request.status + ')'); } } } http_request.open('GET', url + '&rand=' + number, true); http_request.send(null); return false; } function searchName() { if(document.form.fullname.value.length >= 2) { makeHttpRequest('ajax.php?string=' + document.form.fullname.value, 'document.getElementById("div_fullname").innerHTML='); document.getElementById("div_fullname").innerHTML='Checking....'; //return true; } } function checkAll(field) { for (i = 0; i < field.length; i++) field[i].checked = true ; } function uncheckAll(field) { for (i = 0; i < field.length; i++) field[i].checked = false ; } function check_boxes(field, total_boxes, checkbox){ var i; if(document.getElementById(checkbox).checked==true) { if(total_boxes == '1') { field.checked=true; } else { for (i=0 ; i < total_boxes ; i++ ){ field[i].checked=true; } } } else { if(total_boxes == '1') { field.checked=false; } else { for (i=0 ; i < total_boxes ; i++ ){ field[i].checked=false; } } document.getElementById(checkbox).checked=false; } } // thanks to tim for this little gem // http://www.briardene.com/js/js.js // Determine Browser Height and Width definition function GetHeightDef() { if (self.innerHeight){ // FF and Safari HeightDef = self.innerHeight; WidthDef = self.innerWidth; } else if (document.documentElement && document.documentElement.clientHeight) { // IE 6 HeightDef = document.documentElement.clientHeight; WidthDef = document.documentElement.clientWidth; } else if (document.body){ // IE HeightDef = document.body.clientHeight; WidthDef = document.body.clientWidth; } } function uploadPanel() { GetHeightDef(); // divs are called // uploadingscreen and uploadingpanel var panelWidth = 450; var panelHeight = 200; document.getElementById('uploadingscreen').style.height = HeightDef + "px"; document.getElementById('uploadingscreen').style.width = WidthDef + "px"; // now position the panel document.getElementById('uploadingpanel').style.top = (HeightDef - (panelHeight+100))/2 + "px"; document.getElementById('uploadingpanel').style.left = (WidthDef - panelWidth)/2 + "px"; document.getElementById('uploadingscreen').style.display=''; document.getElementById('uploadingpanel').style.display=''; } function disable(string) { string.disabled=true; return true; } function selectArchive() { var myindex = document.archiveForm.archive_id.selectedIndex var SelValue = document.archiveForm.archive_id.options[myindex].value var baseURL = SelValue; window.location.href = baseURL; return true; } function checkThreadTitle() { if(document.post.title.value) { return true; } else { alert('Your thread needs a title!'); document.post.title.focus(); return false; } } function fullscreen(div) { GetHeightDef(); // divs are called // uploadingscreen and uploadingpanel var panelWidth = 550; var panelHeight = 300; document.getElementById('stafscreen').style.height = HeightDef + "px"; document.getElementById('stafscreen').style.width = WidthDef + "px"; // now position the panel document.getElementById(div).style.top = (HeightDef - (panelHeight+100))/2 + "px"; document.getElementById(div).style.left = (WidthDef - panelWidth)/2 + "px"; document.getElementById('stafscreen').style.display=''; document.getElementById(div).style.display=''; } function reportContent() { if ((document.report.comment.value != '') && (document.report.name.value != '') && (document.report.email.value != '')) { makeHttpPostRequest('/v2/ajax.reportContent.php', 'action=report&media_id=' + document.report.media_id.value + '&name=' + document.report.name.value + '&email=' + document.report.email.value + '&comments=' + document.report.comment.value + '&user_id=' + document.report.user_id.value, 'document.getElementById(\'reportContent\').innerHTML='); return false; }else{ alert('please make sure you enter all the information required'); return false; } }