// JavaScript Document $(document).ready(function(){ //disable all buttons in list-*.php such as delete, enable, disable $("#action :input[@name=action]").each(function(){ $(this).attr("disabled", "disabled"); }); //add click event to "Clear Selected" button $("#clear").click(function(){ $("#action :input[@name=action]").each(function(){ $(this).attr("disabled", "disabled"); }); }); //add click event to all checkboxes in list-*.php $("#action :checkbox").click(function(){ var checked = false; $("#action :checkbox").each(function(){ if(($(this).attr("checked")) == true){ checked = true; } }); if(checked){ $("#action :input[@name=action]").each(function(){ $(this).removeAttr("disabled"); }); }else{ $("#action :input[@name=action]").each(function(){ $(this).attr("disabled", "disabled"); }); } }); //handle form submit $("#action").submit(function(){ return confirmSelected(); }); }); function NewWindow(mypage, myname, w, h, scroll, resizable, status) { var winl = (screen.width - w) / 2; var wint = (screen.height - h) / 2; winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable='+resizable+',status='+status+''; win = window.open(mypage, myname, winprops) if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); } } // validate form function validate(objForm, file, submitOnSuccess) { $("#status").ajaxStart(function(){ $(this).html('Validating Submission...'); }); $.ajax({ type:"POST", url: file, data:getRequestBody(objForm), success:function(xml){ if(xml == 0){ if(submitOnSuccess == null){ $("#status").html('Submission Valid! Processing...
'); objForm.submit(); }else{ $("#status").html(''); } }else{ $("#status").html('' + xml + '
'); } } }); } /*function confirmPayment(objForm, file, submitOnSuccess) { $("#status").ajaxStart(function(){ $(this).html('Validating Submission...'); }); $.ajax({ type:"POST", url: file, data:getRequestBody(objForm), success:function(xml){ if(xml == 0){ if(submitOnSuccess == null){ $("#status").html('Submission Valid! Processing...
'); //alert('We are now processing your payments.\nThis may take a few minutes.\nPlease do not refresh the page.'); objForm.submit(); }else{ $("#status").html(''); } }else{ $("#status").html('' + xml + '
'); } } }); } */ function getRequestBody(fobj) { var str = ""; var ft = ""; var fv = ""; var fn = ""; var els = ""; for(var i = 0;i < fobj.elements.length;i++) { els = fobj.elements[i]; ft = els.title; fv = els.value; fn = els.name; switch(els.type) { case "text": case "hidden": case "password": case "textarea": case "file": str += fn + "=" + encodeURI(fv) + "&"; break; case "checkbox": case "radio": if(els.checked) str += fn + "=" + encodeURI(fv) + "&"; break; case "select-one": str += fn + "=" + els.options[els.selectedIndex].value + "&"; break; case "select-multiple": for(j=0; jPlease select an image from the drop down select.

'); $.ajax({ type:"GET", url:'ajax/getpreviewimage.php', data:'intFolderID='+intFolderID+'&txtExtension='+txtExtension, success:function(xml){ $('#filelist').html(xml); } }); } // get files for folder with id = intFolderID function getProductFiles(intFolderID, txtExtension) // txtExtension: image, file or flash { $('#imageHolder').html('

Please select an image from the drop down select.

'); $.ajax({ type:"GET", url:'ajax/getproductimage.php', data:'intFolderID='+intFolderID+'&txtExtension='+txtExtension, success:function(xml){ $('#filelist').html(xml); } }); } //display image when selected function displayIntroImage(intFileID) { $('#imageHolder').html(''); } // get files for folder with id = intFolderID function getFrameFiles(imageHolder, filelist, intFolderID, txtExtension, txtSelectName) // txtExtension: image, file or flash { $('#'+imageHolder).html('

Please select an image from the drop down select.

'); $.ajax({ type:"GET", url:'ajax/getframeimage.php', data:'imageHolder='+imageHolder+'&intFolderID='+intFolderID+'&txtExtension='+txtExtension+'&txtSelectName='+txtSelectName, success:function(xml){ $('#'+filelist).html(xml); } }); } //display image when selected function displayFrameIntroImage(imageHolder, intFileID) { $('#'+imageHolder).html(''); } // build the category checkbox list function buildCategoryList(categoryList) { $('#categoryContainer').html(categoryList); } // open add category popup function addCategory() { var intPageID = $("input:hidden[@name=intPageID]").val(); if(intPageID == null){ NewWindow('popup/addcategory.php', 'AddCategory', 400, 200, 1, 1, 0); }else{ NewWindow('popup/addcategory.php?intPageID='+intPageID, 'AddCategory', 400, 200, 1, 1, 0); } } //when clicked, disable username field function disableUsername(autoGenerate) { if(autoGenerate.checked) { $('#txtUsername').attr("disabled", "disabled"); $('#txtUsername').attr("name", ''); } else { $('#txtUsername').removeAttr("disabled"); $('#txtUsername').attr("name", 'txtusername'); } } // add new folder popup function addFolder(path) { NewWindow(path+'/addFolder.php', 'AddFolder', 400, 200, 1, 1, 0); } // build the folder dropdown select menu function buildFolderList(folderlist) { $('#folderSelectContainer').html(folderlist); } // add a child element to the given parent element function addChildToParent(parentid){ var parent = $('#'+parentid); var numberofchild = $('#numberofchild'); var numberofchildi = ($('#numberofchild').val() - 1) + 2; numberofchild.value = numberofchildi; var li = $('
  • '); // change the childHTML to the HTML code you need var childHTML = ' '; li.html(childHTML + 'remove'); parent.append(li); } // removes a child element from the given parent element function removeChildFromParent(parentid, childid) { $("#"+childid).remove(); } //close retrievePassword popup function closePopup() { $('#txtForgotUsername').val(''); $('#pwdStatus').html(''); $('#forgotPasswordWindow').hide(); } //open retrievePassword popup function openPopup() { $('#forgotPasswordWindow').show(); } //retrievePassword function retreivePassword() { $('#pwdStatus').ajaxStart(function(){ $(this).html(' Validating Submission...'); }); $.ajax({ type:"POST", url:"retreivepassword.php", data:'txtForgotUsername=' + $('#txtForgotUsername').val(), success:function(xml){ if(xml == 0){ $('#pwdStatus').html('Your password has been send to your email.'); }else{ $('#pwdStatus').html('' + xml + '
    '); } } }); } // FOR CHIA function checkType(value) { if(value == 5) { $('#image_list').css("display","none"); } else { $('#image_list').css("display","block"); } } function poststore (p) { var myForm = document.createElement("form"); myForm.method="post" ; myForm.action = 'http://www.blinkoptical.com.au/store_locator.php' ; var myInput = document.createElement("input") ; myInput.setAttribute("name", 'txtState') ; myInput.setAttribute("value", p); myForm.appendChild(myInput) ; document.body.appendChild(myForm) ; myForm.submit() ; document.body.removeChild(myForm) ; }