$(document).ready(function(){ var c; if(document.getElementById('personalDetails')){ c = getCookie('profile' + 'personalDetails'); if((c==null)||(c=='visible')){ $("#personalDetails").show(); } } if(document.getElementById('journalEntries')){ c = getCookie('profile' + 'journalEntries'); if((c==null)||(c=='visible')){ $("#journalEntries").show(); } } if(document.getElementById('previousDiets')){ c = getCookie('profile' + 'previousDiets'); if((c==null)||(c=='visible')){ $("#previousDiets").show(); } previousDietsView(); } if(document.getElementById('favorites')){ c = getCookie('profile' + 'favorites'); if((c==null)||(c=='visible')){ $("#favorites").show(); } } if(document.getElementById('friends')){ c = getCookie('profile' + 'friends'); if((c==null)||(c=='visible')){ $("#friends").show(); } } if(document.getElementById('competitions')){ c = getCookie('profile' + 'competitions'); if((c==null)||(c=='visible')){ $("#competitions").show(); } } $(".ticketEditorSectionTitle").click(function(){ $(this).next(".ticketEditorSectionBody").slideToggle(100, onSlideToggleComplete); $("i",this).toggleClass("icon-minus-sign icon-plus-sign"); }); }); function onSlideToggleComplete(){ //save the hidden/visible status of the affection section in a cookie var bSectionIsHidden = $(this).is(":hidden"); var strSectionID = $(this).attr("id"); var strCookieName = 'profile' + strSectionID; var strCookieValue; if(bSectionIsHidden){ strCookieValue = "hidden"; }else{ strCookieValue = "visible"; } setCookie(strCookieName, strCookieValue, null); } function setCookie(key, value, intDurationSeconds){ if(intDurationSeconds){ var dtExpires = new Date(); dtExpires.setTime(expires.getTime() + (intDurationSeconds * 1000)); var strExpires = "; expires=" + dtExpires.toGMTString(); }else{ var strExpires = ""; } document.cookie = key + "=" + value + strExpires + "; path=/"; } function getCookie(key) { var keyValue = document.cookie.match('(^|;) ?' + key + '=([^;]*)(;|$)'); return keyValue ? keyValue[2] : null; } function personalDetailsEdit(){ var url = '/myProfile/personalDetailsEdit.php?returnURL=' + strReturnURLEncoded; document.location = url; } function friendsEdit(){ var url = '/friends/index.php?returnURL=' + strReturnURLEncoded; document.location = url; } function previousDietsView(){ var url = '/members/previousDietsView.php?userID=' + intUserID; loadDiv('previousDiets',url,'GET'); } function previousDietsEdit(){ var url = '/members/previousDietsEdit.php?userID=' + intUserID; loadDiv('previousDiets',url,'GET'); } function previousDietsEditSubmit(){ var frm = document.getElementById('formPreviousDiets'); var url = 'previousDietsEditSubmit.php'; var url = 'previousDietsEditSubmit.php?userID=' + intUserID; url += '&previousDiets=' + frm.previousDiets.value; alert(url); loadDiv('previousDiets',url,'POST'); } function loadDiv(strDivID,strURL,strGETorPOST){ var elemDiv = document.getElementById(strDivID); if(!elemDiv){ alert('attempt to loadDiv(' + strDivID + ') but no such div exists'); return; } var html = doAjaxRequest(strURL,strGETorPOST,false,null); //from /js/common.js elemDiv.innerHTML = html; }