﻿$(document).ready(function() { $.cookies.setOptions({ hoursToLive: 2000 }); $.cookies.del('HCEmailAuth'); $("#emailFromFriend").val($.cookies.get('from_email')); $('#messageFriend').val(''); $("#sendToFriendLink").toggle(function() { $("#emailFriendContainer").slideDown("fast") }, function() { $("#emailFriendContainer").slideUp("fast") }); var f = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/; $("#submitEmailFriend").click(function() { $(".error").hide(); var b = false; var c = $("#emailToFriend").val(); if (c == '') { $("#emailToFriend").after('<span class="error">Your friend\'s email is required.</span>'); b = true } else if (!f.test(c)) { $("#emailToFriend").after('<span class="error">Your friend\'s email is not valid.</span>'); b = true } var d = $("#emailFromFriend").val(); if (d == '') { $("#emailFromFriend").after('<span class="error">Your email is required.</span>'); b = true } else if (!f.test(d)) { $("#emailFromFriend").after('<span class="error">Your email is not valid.</span>'); b = true } var e = $("#messageFriend").val(); if (b == false) { $(this).hide(); $("#sendEmailFriend li.buttons").append('<img src="http://www.headchemists.com/css/images/indicator.gif" alt="Loading" id="loading" />'); $.cookies.set('HCEmailAuth', $(document).getUrlParam("id")); $.post("SendEmail.ashx", { toEmail: c, fromEmail: d, message: e, subject: "Free Song from HeadChemists.com: " + $.trim($("h2").text()), HCEmailAuth: $.cookies.get('HCEmailAuth') }, function(a) { if (a == "success") { $.cookies.set('from_email', d); $("#sendEmailFriend").slideUp("normal", function() { $("#sendEmailFriend").before('<h5>Success</h5><p>An email was sent to ' + c + '.</p>') }) } }) } return false }) });
