/* App Functions */
function delconf(id, user) {
conf = confirm("Are you sure you want to delete this design? This will remove your registration from the database, and cannot be undone!");
if (conf) {
var location
if (user == 'admin') {
var reason = prompt("If you wish to include a reason for deletion, please enter it below:", "");
if (reason == null || reason == "") {
location = "http://protectyourdesign.comdelete/"+id;
} else {
location = "http://protectyourdesign.com/delete/"+id+"/"+reason;
}
} else {
location = "http://protectyourdesign.com/delete/"+id;
}
window.location = location;
}
}
function delDesignFromCart(id, user, idsess) {
conf = confirm("Are you sure you want to delete this design?");
if (conf) {
var location
if (user == 'admin') {
var reason = prompt("If you wish to include a reason for deletion, please enter it below:", "");
if (reason == null || reason == "") {
location = "http://protectyourdesign.comdelete_design_cart/"+id+"/"+isess;
} else {
location = "http://protectyourdesign.com/delete_design_cart/"+id+"/"+idsess+"/"+reason;;
}
} else {
location = "http://protectyourdesign.com/delete_design_cart/"+id+"/"+idsess;
}
window.location = location;
}
}
function userdelconf(type, id) {
var confmsg = "Are you sure you want to delete this user";
if (type == 'designer') {
confmsg += " and all their designs";
}
confmsg += "?\nThis cannot be undone!";
var conf = confirm(confmsg);
if (conf) {
var reason = prompt("If you wish to include a reason for deletion, please enter it below:", "");
if (reason == null || reason == "") {
loc = "http://protectyourdesign.com/delete_user/"+id+"/"+type;
} else {
loc = "http://protectyourdesign.com/delete_user/"+id+"/"+type+"/"+reason;
}
window.location.assign(loc) ;
}
}
function memberdelconf(type, id) {
var confmsg = "Are you sure you want to delete this member";
if (type == 'designer') {
confmsg += " and all their designs";
}
confmsg += "?\nThis cannot be undone!";
var conf = confirm(confmsg);
if (conf) {
var reason = prompt("If you wish to include a reason for deletion, please enter it below:", "");
if (reason == null || reason == "") {
loc = "http://protectyourdesign.com/delete_member/"+id+"/"+type;
} else {
loc = "http://protectyourdesign.com/delete_member/"+id+"/"+type+"/"+reason;
}
window.location.assign(loc) ;
}
}
function catdelconf(id, sub) {
if (sub > 0) {
s = 'sub';
} else {
s = '';
}
var confmsg = "Are you sure you want to delete this "+s+"category?\n";
if (sub == 0) {
confmsg += "If there are any subcategories they will be deleted too.\n";
}
confmsg += "Any designs in the "+s+"category will remain, but will no longer be associated with the "+s+"category.\nThis cannot be undone!";
var conf = confirm(confmsg);
if (conf) {
loc = "http://protectyourdesign.com/delete_category/"+id+"/"+sub;
window.location.assign(loc) ;
}
}
function compdelconf(id) {
var confmsg = "Are you sure you want to delete this company?\n";
confmsg += "All client accounts for this company will be deleted too.\n";
confmsg += "Designs will no longer be visible to this company.\nThis cannot be undone!";
var conf = confirm(confmsg);
if (conf) {
loc = "http://protectyourdesign.com/delete_company/"+id;
window.location.assign(loc) ;
}
}
function load_subcats(){
jQuery.getJSON('http://protectyourdesign.com/includes/subcats.php?category='+$('#cat').val(), function(data){
$('#subcat').html('');
jQuery.each(data, function(subcat){
$('#subcat').append('');
});
});
}
function shared_design(id){
$('#u_sh_'+id).attr('onclick', "shared_design_no("+id+");");
$('#u_sh_d_'+id).show(500);
}
function shared_design_no(id){
$('#u_sh_'+id).attr('onclick', "shared_design("+id+");");
$('#u_sh_d_'+id).hide(500);
}
function add_design_to_company(design_id, user_id){
var company_id = $('#company_list_'+design_id).val();
$.ajax({
type: "POST",
url: '/pages/ajax_add_design_to_company.php',
data: "design_id="+design_id+"&company_id="+company_id+'&user_id='+user_id,
complete: function(data){
ev = 'Delete';
$('#ad_s_u_'+design_id).html(ev);
}
});
}
function del_design_from_company(design_id, user_id){
var company_id = $('#company_list_'+design_id).val();
$.ajax({
type: "POST",
url: '/pages/ajax_del_design_from_company.php',
data: "design_id="+design_id+"&company_id="+company_id+'&user_id='+user_id,
complete: function(data){
ev = 'Add';
$('#ad_s_u_'+design_id).html(ev);
}
});
}
function event_for_design(design_id, user_id){
var company_id = $('#company_list_'+design_id).val(),
ev = '';
if (company_id > 0) {
$.ajax({
type: "POST",
url: '/pages/ajax_event_design.php',
data: "design_id="+design_id+"&company_id="+company_id+'&user_id='+user_id,
complete: function(response){
if (response.responseText > 0){
ev = 'Delete';
$('#ad_s_u_'+design_id).html(ev);
} else {
ev = 'Add';
$('#ad_s_u_'+design_id).html(ev);
}
}
});
}
}
function decline_design(design_id, company_id){
$.ajax({
type: "POST",
url: '/pages/ajax_del_design_from_company.php',
data: "design_id="+design_id+"&company_id="+company_id,
complete: function(response){
$('#design_'+design_id).remove();
}
});
}
function accept_design(design_id, company_id){
$.ajax({
type: "POST",
url: '/pages/ajax_accept_design.php',
data: "design_id="+design_id+"&company_id="+company_id,
complete: function(response){
if (response.responseText == 1){
$('#accept_'+design_id).remove();
}
}
});
}
function radio_individual () {
$('#radio_type').hide();
}
function radio_company () {
$('#radio_type').show();
}