//===================================================================== EMAIL VALIDATOR // function isEmailAddr(email){ var result = false var theStr = new String(email) var index = theStr.indexOf("@"); if (index > 0){ var pindex = theStr.indexOf(".",index); if ((pindex > index+1) && (theStr.length > pindex+1)) result = true; } return result; } $(function(){ $("input.numeric").numeric(); //Setting Tabs Here.... $( ".buttons").button(); $(".accordion").accordion({ collapsible: true, autoHeight:false }); $( "#tabs" ).tabs({autoHeight:true, selected:0}); $( "#tabs" ).tabs( "cookie", { expires: 30 } ); $('#tabs').bind('tabsshow', function(event, ui){ if($("#tabs").tabs('option','selected')==0){ $("#existing_list").show(); }else{ $("#existing_list").hide(); } $(".accordion").accordion("destory"); $(".accordion").accordion({ collapsible: true, autoHeight:false }); }); //$( "input:submit, .buttons").button(); //******************************* checkList ==========================// $( ".checkList" ).click(function() { $( "#Check-List:ui-dialog" ).dialog( "destroy" ); $totalList=$( "#totalList" ).val(); if($totalList==0){ $( "#Check-List" ).dialog({ autoOpen: false, resizable: false, width: "auto", height: "auto", modal: true, buttons: [ { text: "Close", click: function() {$('#username').val("");$('#pwd').val("");$("#errLoginMsg").html("");$(this).dialog("close");} } ] }); $( "#Check-List" ).dialog( "open" ); return false; } }); //******************************* Duplicate List ==========================// DuplicateList(); //******************************* Share List ==========================// ShareList(); ListCantShare(); UpdateDataList(); //******************************* Product Detail ==========================// ProductDetail(); //******************************* Product Remove From List ==========================// RemoveProductTrigger(); RemoveProductTriggerFinalList(); //******************************* Login ==========================// $( ".login_module" ).click(function() { $( "#dialog-login:ui-dialog" ).dialog( "destroy" ); $( "#dialog-login" ).dialog({ autoOpen: false, resizable: false, width:500, modal: true, buttons: [ { text: "Login", click: function() { if($('#username').val()==''){ $('#errLoginMsg').html('
Please enter email address.
'); }else if($('#pwd').val()==''){ $('#errLoginMsg').html('
Please enter password.
'); } else{ var loginVal=$("#loginForm").serialize(); $('#errLoginMsg').html('Logging in... Logging in...'); $.ajax({ data: "sid="+Math.random()+"&"+loginVal, url: "ajax/login.php", type:"POST", success:function(msg){ if(msg==1){ location.replace("account"); }else{ $('#errLoginMsg').html('
'+msg+'
'); } } }); } } }, { text: "Cancel", click: function() {$('#username').val("");$('#pwd').val("");$("#errLoginMsg").html("");$(this).dialog("close");} } ] }); $( "#dialog-login" ).dialog( "open" ); return false; }); //******************************* Register ==========================// $( "#dialog-register:ui-dialog" ).dialog( "destroy" ); $( ".register_module" ).click(function() { myLink = $(this).attr("href"); $( "#dialog-register" ).dialog({ autoOpen: false, resizable: false, width:550, height:"auto", modal: true, buttons: [ { text: "Register", click: function() { if($('#rfname').val()==''){ $('#errRegMsg').html('
Please enter first name.
'); }else if($('#rlname').val()==''){ $('#errRegMsg').html('
Please enter last name.
'); }else if($('#remail_address').val()==''){ $('#errRegMsg').html('
Please enter email address.
'); }else if($('#rpassword').val()==''){ $('#errRegMsg').html('
Please enter password.
'); }else if($('#rcpassword').val()==''){ $('#errRegMsg').html('
Please enter confirm password.
'); }else if($('#rpassword').val()!=$('#rcpassword').val()){ $('#errRegMsg').html('
Password do not match.
'); } else{ var registerVal=$("#registerForm").serialize(); $('#errRegMsg').html(' Creating Account...'); $.ajax({ data: "sid="+Math.random()+"&"+registerVal, url: "ajax/register.php", type:"POST", success:function(msg){ if(msg==1){ location.replace("account"); }else{ $('#errRegMsg').html('
'+msg+'
'); } } }); } } }, { text: "Cancel", click: function() { $('#rfname').val("");$('#rlname').val("");$('#remail_address').val("");$("#rpassword").val("");$("#rcpassword").val("");$("#errRegMsg").html("");$(this).dialog("close"); } } ] }); $( "#dialog-register" ).dialog( "open" ); return false; }); //******************************* My Profile ==========================// $( ".profile" ).click(function(){ $( "#dialog-profile-conf:ui-dialog" ).dialog( "destroy" ); $("#successProfile").html(""); $("#opassword").val(""); $("#npassword").val(""); $("#ncpassword").val(""); $("#successProfileMsg").show(); $( "#dialog-profile-conf" ).dialog({ autoOpen: false, resizable: false, width: 500, height: "auto", modal: true, buttons: [ { text: "Save", click: function() { if($('#fname').val()==''){ $('#errProfileMsg').html('
Please enter first name.
'); }else if($('#lname').val()==''){ $('#errProfileMsg').html('
Please enter last name.
'); }else{ var profileVal=$("#profileForm").serialize(); $('#errProfileMsg').html(' Updating profile...'); $.ajax({ data: "sid="+Math.random()+"&"+profileVal, url: "ajax/profile.php", type:"POST", success:function(msg){ if(msg=="Success! Your profile has been updated."){ $('#successProfile').html('
'+msg+'
'); $("#successProfileMsg").hide(); var options = { buttons: { Close: function () { $("#errProfileMsg").html(""); $(this).dialog('close'); } } }; $("#dialog-profile-conf").dialog('option', options); }else{ $('#errProfileMsg').html('
'+msg+'
'); } } }); } } }, { text: "Cancel", click: function() { $("#errProfileMsg").html("");$(this).dialog("close"); } } ] }); $( "#dialog-profile-conf" ).dialog( "open" ); return false; }); //******************************* Manage Downloads ==========================// $( "#dialog-manage-download-conf:ui-dialog" ).dialog( "destroy" ); $( "#dialog-manage-download-conf" ).dialog({ autoOpen: false, resizable: false, width:400, modal: true }); registerDwnLink(); //******************************* Quantity Alert Message ==========================// $( "#dialog-qty-msg:ui-dialog" ).dialog( "destroy" ); $( "#dialog-qty-msg" ).dialog({ autoOpen: false, resizable: false, draggable: false, width:"auto", height:90, modal: true }); //******************************* Contact Module ==========================// $( ".contact_module" ).click(function() { $( "#dialog-contact:ui-dialog" ).dialog( "destroy" ); $( "#dialog-contact" ).dialog({ autoOpen: false, resizable: false, width: 790, modal: true, buttons: [ { text: "Submit", click: function() { if($('#feedback_name').val()==''){ $('#errFeedbackMsg').html('
Please enter name.
'); }else if($('#feedback_email').val()==''){ $('#errFeedbackMsg').html('
Please enter email address.
'); }else if($('#feedback_email').val()!='' && !isEmailAddr($('#feedback_email').val())){ $('#errFeedbackMsg').html('
Please enter Email Address in the Form: yourname@yourdomain.com.
'); }else if($('#feedback_description').val()==''){ $('#errFeedbackMsg').html('
Please enter description.
'); }else if($('#enquiry_code').val()=="" || $('#enquiry_code').val()=="Enter Code"){ $('#errFeedbackMsg').html('
Please enter code.
'); }else{ var feedbackVal=$("#feedbackForm").serialize(); $('#errLoginMsg').html('Sending feedback... Sending feedback...'); $.ajax({ data: "sid="+Math.random()+"&"+feedbackVal, url: "ajax/send-mails.php", type:"POST", success:function(msg){ var res = msg.split("|"); if(res[0]==1){ $('#errFeedbackMsg').html('
'+res[1]+'
'); $('#feedbackForm')[0].reset(); }else{ $('#errFeedbackMsg').html('
'+res[1]+'
'); } } }); } } }, { text: "Cancel", click: function() {$('#feedbackForm')[0].reset();$("#errFeedbackMsg").html("");$(this).dialog("close");} } ] }); $( "#dialog-contact" ).dialog( "open" ); return false; }); //Slider ... $('#coin-slider').coinslider({ width: 718, // width of slider panel height: 344, // height of slider panel delay: 5000, // delay between images in ms effect: 'straight', // random, swirl, rain, straight navigation: true, // prev next and buttons hoverPause: true // pause on hover }); //Slider... }); $(document).ready(function() { $.featureList( $("#tabs li a"), $("#output li"), { start_item : 1 } ); paginationListener(); }); function paginationListener(){ $('.pagination a').click(function(){ uriName = $(this).attr('href').split("?"); urlFile = "ajax.php"; params = uriName[1]; DIVCTL = "#"+$(this).attr('rel'); $(DIVCTL).html(' Loading data...'); $.ajax({ data: "sid="+Math.random()+"&mod=2&"+params, url: urlFile, type:"GET", success:function(msg){ $(DIVCTL).html(msg); paginationListener(); ProductDetail(); } }); return false; }); } //******************************* Login ==========================// function Login(){ if($('#username').val()==''){ $('#errLoginMsg').html('
Please enter email address.
'); }else if($('#pwd').val()==''){ $('#errLoginMsg').html('
Please enter password.
'); } else{ var loginVal=$("#loginForm").serialize(); $('#errLoginMsg').html('Logging in... Logging in...'); $.ajax({ data: "sid="+Math.random()+"&"+loginVal, url: "ajax/login.php", type:"POST", success:function(msg){ if(msg==1){ location.replace("account"); }else{ $('#errLoginMsg').html('
'+msg+'
'); } } }); } } //******************************* Forgot Password ==========================// function ForgotPassword(){ $( "#dialog-login:ui-dialog" ).dialog( "destroy" ); $('#successForgot').html(""); $('#forgotemail').val(""); $("#successForgotMsg").show(); $( "#dialog-forgot" ).dialog({ autoOpen: false, resizable: false, width:500, modal: true, buttons: [ { text: "Submit", click: function() { if($('#forgotemail').val()==''){ $('#errForgotMsg').html('
Please enter email address.
'); }else{ var forgotVal=$("#forgotPasswordForm").serialize(); $('#errForgotMsg').html(' Retrieving Password...'); $.ajax({ data: "sid="+Math.random()+"&"+forgotVal, url: "ajax/forgot-pas.php", type:"POST", success:function(msg){ if(msg=="Invalid email address." || msg=="There was an error while sending email. Please try again later." || msg=="Sorry! This email was not found in our database."){ $('#errForgotMsg').html('
'+msg+'
'); }else{ $('#successForgot').html('
'+msg+'
'); $("#successForgotMsg").hide(); var options = { buttons: { Close: function () { $("#errForgotMsg").html(""); $(this).dialog('close'); } } }; $("#dialog-forgot").dialog('option', options); } } }); } } }, { text: "Cancel", click: function() { $("#errForgotMsg").html("");$("#forgotemail").val("");$(this).dialog("close");} } ] }); $( "#dialog-forgot" ).dialog( "open" ); } function ForgotPasswordNormal(){ if($('#forgotemail').val()==''){ $('#errForgotMsg').html('
Please enter email address.
'); }else{ var forgotVal=$("#forgotPasswordForm").serialize(); $('#errForgotMsg').html(' Retrieving Password...'); $.ajax({ data: "sid="+Math.random()+"&"+forgotVal, url: "ajax/forgot-pas.php", type:"POST", success:function(msg){ if(msg=="Invalid email address." || msg=="There was an error while sending email. Please try again later." || msg=="Sorry! This email was not found in our database."){ $('#errForgotMsg').html('
'+msg+'
'); }else{ $('#successForgot').html('
'+msg+'
'); $("#successForgotMsg").hide(); var options = { buttons: { Close: function () { $("#errForgotMsg").html(""); $(this).dialog('close'); } } }; $("#dialog-forgot").dialog('option', options); } } }); } } //******************************* Register ==========================// function Register() { if($('#rfname').val()==''){ $('#errRegMsg').html('
Please enter first name.
'); }else if($('#rlname').val()==''){ $('#errRegMsg').html('
Please enter last name.
'); }else if($('#remail_address').val()==''){ $('#errRegMsg').html('
Please enter email address.
'); }else if($('#rpassword').val()==''){ $('#errRegMsg').html('
Please enter password.
'); }else if($('#rcpassword').val()==''){ $('#errRegMsg').html('
Please enter confirm password.
'); }else if($('#rpassword').val()!=$('#rcpassword').val()){ $('#errRegMsg').html('
Password do not match.
'); }else{ var registerVal=$("#registerForm").serialize(); $('#errRegMsg').html(' Creating Account...'); $.ajax({ data: "sid="+Math.random()+"&"+registerVal, url: "ajax/register.php", type:"POST", success:function(msg){ if(msg==1){ location.replace("account"); }else{ $('#errRegMsg').html('
'+msg+'
'); } } }); } } function AddToList(coupon_id,prod_id,frm){ var val=$(frm).serialize(); qty = frm.qty.value; if(qty!=""){ if(qty>0 && qty<1000){ var $qty = qty; $('#listUpdateMsg').html(' Updating List...'); $.ajax({ data: "sid="+Math.random()+"&prod_id="+prod_id+"&coupon_id="+coupon_id+"&qty="+$qty+"&"+val, url: "ajax/add_to_shooping_list.php", type:"POST", success:function(msg){ var $msgarray = msg.split("|"); $('#listUpdateMsg').html('
'+$msgarray[0]+'

'+$msgarray[1]+'
'); RemoveProductTrigger(); ProductDetail(); } }); }else{ $( "#errorMsg" ).html( "Quantity range should be 1-999." ); $( "#dialog-qty-msg:ui-dialog" ).dialog( "open" ); } }else{ $( "#errorMsg" ).html( "Please enter quantity." ); $( "#dialog-qty-msg:ui-dialog" ).dialog( "open" ); } } function RemoveFromList(coupon_id,prod_id,frm){ var val=$(frm).serialize(); qty = frm.qty.value; if(qty!=""){ if(qty>0 && qty<1000){ var $qty = qty; $('#listUpdateMsg').html(' Updating List...'); $.ajax({ data: "sid="+Math.random()+"&act=rflist"+"&prod_id="+prod_id+"&coupon_id="+coupon_id+"&qty="+$qty+"&"+val, url: "ajax/add_to_shooping_list.php", type:"POST", success:function(msg){ var $msgarray = msg.split("|"); $('#listUpdateMsg').html('
'+$msgarray[0]+'

'+$msgarray[1]+'
'); RemoveProductTrigger(); ProductDetail(); } }); }else{ $( "#errorMsg" ).html( "Quantity range should be 1-999." ); $( "#dialog-qty-msg:ui-dialog" ).dialog( "open" ); } }else{ $( "#errorMsg" ).html( "Please enter quantity." ); $( "#dialog-qty-msg:ui-dialog" ).dialog( "open" ); } } function RemoveProductTrigger(){ $( ".rData" ).click(function() { $( "#dialog-confirm:ui-dialog" ).dialog( "destroy" ); myLink = $(this).attr("href"); $.urlParam = function(name){ var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(myLink); if (!results) { return 0; } return results[1] || 0; } var list_id = $.urlParam('list_id'); var prod_id = $.urlParam('prod_id'); var ctl = $.urlParam('ctl'); var existinglist = $.urlParam('existinglist'); if(existinglist=="true"){ var elist = 1; } if(ctl!="list_operations"){ $( "#dialog-confirm" ).dialog({ autoOpen: false, resizable: false, width:400, height:"auto", modal: true, buttons: [{ text: "Yes", click: function() { $('#listUpdateMsg').html(' Updating List...'); //$('#updateExistingList').html(' Updating List...'); $.ajax({ data: "sid="+Math.random()+"&act=remove&list_id="+list_id+"&prod_id="+prod_id+"&elist="+elist, url: "ajax/add_to_shooping_list.php", type:"POST", success:function(msg){ var $msgarray = msg.split("|"); $('#listUpdateMsg').html('
'+$msgarray[0]+'

'+$msgarray[1]+'
'); $( "#dialog-confirm" ).dialog( "close" ); RemoveProductTrigger(); ProductDetail(); } }); } },{ text: "No", click: function() { $(this).dialog("close"); } } ] }); $( "#dialog-confirm" ).dialog( "open" ); return false; }else{ $( "#dialog-confirm" ).dialog({ autoOpen: false, resizable: false, width:400, height:"auto", modal: true, buttons: [{ text: "Yes", click: function() { //location.replace(myLink); $('#updateManageLists').html(' Updating List...'); $.ajax({ data: "sid="+Math.random()+"&act=remove&list_id="+list_id+"&prod_id="+prod_id+"&elist="+elist, url: "ajax/list_operations.php", type:"POST", success:function(msg){ var $msgarray = msg.split("|"); $('#updateManageListsMsg').html($msgarray[0]); $('#updateManageLists').html($msgarray[1]); $( "#dialog-confirm" ).dialog( "close" ); RemoveProductTrigger(); DuplicateList(); ShareList(); ListCantShare(); } }); } },{ text: "No", click: function() { $(this).dialog("close"); } } ] }); $( "#dialog-confirm" ).dialog( "open" ); return false; } }); } function RemoveProductTriggerFinalList(){ $( ".rDataFromList" ).click(function() { $( "#dialog-confirm-remove-product:ui-dialog" ).dialog( "destroy" ); myLink = $(this).attr("href"); $.urlParam = function(name){ var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(myLink); if (!results) { return 0; } return results[1] || 0; } var list_id = $.urlParam('list_id'); var prod_id = $.urlParam('prod_id'); $( "#dialog-confirm-remove-product" ).dialog({ autoOpen: false, resizable: false, width:400, height:"auto", modal: true, buttons: [{ text: "Yes", click: function() { $('#confirmListUpdateMsg').html(' Updating List...'); $.ajax({ data: "sid="+Math.random()+"&act=remove&list_id="+list_id+"&prod_id="+prod_id, url: "ajax/confirm_list.php", type:"POST", success:function(msg){ var $msgarray = msg.split("|"); $('#confirmListUpdateMsg').html($msgarray[1]); $( "#dialog-confirm-remove-product" ).dialog( "close" ); $( ".buttons").button(); RemoveProductTriggerFinalList(); } }); } },{ text: "No", click: function() { $(this).dialog("close"); } } ] }); $( "#dialog-confirm-remove-product" ).dialog( "open" ); return false; }); } function ProductDetail(){ $(".detail_popup").click(function(){ urlLink = $(this).attr('href'); loadProductDetail(urlLink); $( "#dialog-prod-detail:ui-dialog" ).dialog( "destroy" ); $( "#dialog-prod-detail" ).dialog({ autoOpen: true, resizable: false, width:400, height: "auto", modal: true }); return false; }); } function DuplicateList(){ $( ".duplicate_list" ).click(function() { $( "#dialog-duplicate-conf:ui-dialog" ).dialog( "destroy" ); myLink = $(this).attr("href"); $( "#dialog-duplicate-conf" ).dialog({ autoOpen: false, resizable: false, width:500, height: "auto", modal: true, buttons: [ { text: "Duplicate", click: function() { if($('#dup_list_name').val()==''){ $('#errDuplicateMsg').html('
Please enter list name to duplicate.
'); }else{ document.location.href=myLink+"&list_name="+escape($('#dup_list_name').val()); } } },{ text: "Cancel", click: function() { $('#dup_list_name').val('');$('#errDuplicateMsg').html('');$(this).dialog("close"); } } ] }); $( "#dialog-duplicate-conf" ).dialog( "open" ); return false; }); } function ListCantShare(){ $( ".list_cant_share" ).click(function() { $( "#dialog-share-cant-conf:ui-dialog" ).dialog( "destroy" ); $( "#dialog-share-cant-conf" ).dialog({ autoOpen: false, resizable: false, width:400, modal: true, buttons: [ { text: "Close", click: function() { $(this).dialog("close");} } ] }); $( "#dialog-share-cant-conf" ).dialog( "open" ); return false; }); } function ShareList(){ $( ".share_list" ).click(function() { $( "#dialog-share-conf:ui-dialog" ).dialog( "destroy" ); $('#successShareMsg').show(); myLink = $(this).attr("href"); $.urlParam = function(name){ var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(myLink); if (!results) { return 0; } return results[1] || 0; } var list_id_val = $.urlParam('list_id'); $( "#dialog-share-conf" ).dialog({ autoOpen: false, resizable: false, width:400, modal: true, buttons: [ { text: "Send", click: function() { if($('#to_list_share_email').val()==''){ $('#errShareMsg').html('
Please enter valid email address(es).
'); }else if($('#to_list_share_email').val()!=''){ var element = $('#to_list_share_email').val().split(","); var msgReturn="1"; for(i=0;i'+msgReturn+''); break; } } if(msgReturn=="1"){ for(i=0;iYou can\'t share shopping list with yourself. Please remove your email address.'); break; }else{ msgReturn="1"; } } } if(msgReturn=="1"){ var sharingListVal=$("#frmSharingList").serialize(); $('#errShareMsg').html(' Sending Message...'); //$(":button:contains('Send')").attr("disabled","disabled").addClass( 'ui-state-disabled' ); //$(":button:contains('Cancel')").attr("disabled","disabled").addClass( 'ui-state-disabled' ); $.ajax({ data: "sid="+Math.random()+"&list_id="+list_id_val+"&"+sharingListVal, url: "ajax/sharing-list.php", type:"POST", success:function(msg){ if(msg=="Shopping list shared successfully."){ $('#successShare').html('
'+msg+'
'); $('#successShareMsg').hide(); var options = { buttons: { Close: function () { $('#errShareMsg').html(''); $('#successShare').html(""); $(this).dialog('close'); } } }; $("#dialog-share-conf").dialog('option', options); }else{ $('#errShareMsg').html('
'+msg+'
'); } $("#to_list_share_email").val(''); $("#list_share_note").val(''); //$(":button:contains('Send')").attr("enable","enable").addClass( 'ui-state-default' ); //$(":button:contains('Cancel')").attr("enable","enable").addClass( 'ui-state-default' ); } }); } } } }, { text: "Cancel", click: function() { $("#to_list_share_email").val('');$("#list_share_note").val('');$('#successShare').html('');$('#errShareMsg').html('');$(this).dialog("close");} } ] }); $( "#dialog-share-conf" ).dialog( "open" ); return false; }); } function UpdateDataList(){ $( ".uDataList" ).click(function() { $( "#dialog-update-list:ui-dialog" ).dialog( "destroy" ); myLink = $(this).attr("href"); $.urlParam = function(name){ var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(myLink); if (!results) { return 0; } return results[1] || 0; } var list_id = $.urlParam('list_id'); $( "#dialog-update-list" ).dialog({ autoOpen: false, resizable: false, width:400, height:"auto", modal: true, buttons: [{ text: "Yes", click: function() { //$('#confirmListUpdateMsg').html(' Updateting List...'); $('#errDataListMsg').html(' Updateting List...'); $('#generalDataListMsg').html(''); confirmData = $(('#confirmListFrm')).serialize(); $.ajax({ data: "sid="+Math.random()+"&act=update_all&"+confirmData, url: "ajax/update_list.php", type:"POST", success:function(msg){ var $msgarray = msg.split("|"); $('#errDataListMsg').html('
'+$msgarray[0]+'
'); $('#confirmListUpdateMsg').html($msgarray[1]); $("input.numeric").numeric(); RemoveProductTriggerFinalList() var options = { buttons: { Close: function () { $('#generalDataListMsg').html('Are you sure you want to update shopping list?'); $('#errDataListMsg').html(''); $(this).dialog('close'); } } }; $("#dialog-update-list").dialog('option', options); } }); } },{ text: "No", click: function() {$(this).dialog("close");} } ] }); $( "#dialog-update-list" ).dialog( "open" ); return false; }); return false; } function registerDwnLink(){ $( ".manage_download_list" ).click(function(){ loadDwnAppDialog(this); return false; }); } function loadDwnAppDialog(ctl){ myLink = $(ctl).attr("href"); $( "#dialog-manage-download-conf" ).dialog({ buttons: [ { text: "Close", click: function() { $(this).dialog("close"); } } ] }); $( "#dialog-manage-download-conf" ).dialog( "open" ); }