$(document).ready(function() { $("#header_login").validate(); $("#header-search").validate(); $("#frm-login").validate(); $("#frm-forgottenpassword").validate(); $("#frm-contact").validate(); $("#frm-newsletter").validate(); $("#frm-register").validate({ rules: { username: { required: true, minlength: 4 }, password1: { required: true, minlength: 6, maxlength:16 }, password2: { equalTo: "#password1" }, other: { required: function(element) { return $("#industry option:selected").val() == "0"; } }, cardnumber: { minlength: 10, maxlength:16, required: true, digits: true } } }); $("#frm-payment").validate({ rules: { cardnumber: { minlength: 10, maxlength:16, required: true, digits: true } } }); $("#frm-search-portlet").validate({ rules: { keywords: { required: function(element) { return $("#program_id").val() == ""; } } } }); $("#frm-profile").validate({ rules: { password2: { equalTo: "#password1" }, other: { required: function(element) { return $("#industry option:selected").val() == "0"; } } } }); $("#frm-contact .button").click( function() { $("#frm-contact").submit();} ); $("#frm-newsletter .button").click( function() { $("#frm-newsletter").submit();} ); $("#login_options").click(function() { $("#loginoptions").slideToggle() }); $("#my-industry").change(function(){ if ($("#my-industry option:selected").val() == "0") { $("#other").show(); } else {$("#other").hide();} }) $(".help").click( function() { $("#"+$(this).attr("href")).toggle(); return false; } ); $(".numbersonly").keypress(function (e) { if( e.which!=13 && e.which!=8 && e.which!=0 && (e.which<48 || e.which>57)) { return false; } else { return true; } }); $("#logout-button").click( function(){ if(confirm('Are you sure that you want to logout?')){ location.href='/framework/form/logout.php';} return false; } ); $(".checkall").click( function(){ myitem = $(this).attr("name"); if($(this).is(':checked')){ $("input.myindent[name='"+myitem+"']").attr("disabled", true); } else { $("input.myindent[name='"+myitem+"']").attr("disabled", false); } }); $(".checkall").each( function(){ myitem = $(this).attr("name"); if($(this).is(':checked')){ $("input.myindent[name='"+myitem+"']").attr("disabled", true); } else { $("input.myindent[name='"+myitem+"']").attr("disabled", false); } }); $("a.delete-shortlist").click(function(){ if(confirm("Are you sure that you want to delete this shortlist and all of it's contents?")) { id=$(this).attr("id").split("_"); $.post("/framework/form/manage_shortlist.php", {action:"delete_shortlist", shortlist_id:id[1]}, function(data){ if (data != ""){ $("#row_"+data).remove();; } } ); } }); $("a.delete-shortlist-items").click(function(){ if(confirm("Are you sure that you want to delete the selected programs from this shortlist?")) { $.post("/framework/form/manage_shortlist.php", $("#shortlist-programs").serialize(), function(data){ result = data.split("|"); if (result[0] == "0") { $("#main-content").html('
You haven\'t saved any programs to this shortlist. Why not search or browse for some programs to add now?');
}
else if (result[1] != "")
{
arrloop = result[1];
arrloop = arrloop.split(",");
$.each(
arrloop,
function( intIndex, objValue ){
$("#row_"+objValue).remove();
$("#row_"+objValue+"_desc").remove();
}
);
}
}
);
}
return false;
});
$("a.fancybox").fancybox({
'frameWidth': 370,
'frameHeight': 280,
'hideOnContentClick': false,
'callbackOnStart': function() {
if ($("#shortlist_id").val() != '')
{
$.post("/framework/form/manage_shortlist.php",
{action:"get", shortlist_id:$("#shortlist_id").val()},
function(data){
if (data != ""){
data = data.split("|");
$("#fancy_div h2").text("Update this shortlist");
$("#fancy_div #frm-create-shortlist #shortlist-title").val(data[0]);
$("#fancy_div #frm-create-shortlist #shortlist-description").val(data[1]);
}
}
);
}
},
'callbackOnShow': function() {
$("#fancy_div #frm-create-shortlist").validate({
submitHandler: function(form) {
$.post("/framework/form/manage_shortlist.php",
$("#fancy_div #frm-create-shortlist").serialize(),
function(data){
if (data == "refresh") window.location.reload(true);
}
);
return false;
}
})
},
'callbackOnClose':function() {
$("#shortlist_id").val('')
$("#fancy_div #frm-create-shortlist #shortlist-title").val('');
$("#fancy_div #frm-create-shortlist #shortlist-description").val('');
}
});
$("a.fancybox-programid").fancybox({
'frameWidth': 370,
'frameHeight': 280,
'hideOnContentClick': false
});
});
function changetab(tab) {
$('#tab_'+currentTab).removeClass('selected');
$('#'+currentTab).hide();
$('#tab_'+tab).addClass('selected');
$('#'+tab).show();
currentTab = tab;
}
function checkUser(id, checkstatus) {
for(i=0;i