pictureslider = 0;
loadpicture=false;
changed = false;
swfphotoloader=0;
previousentry="";
foundemailentry="";

function hideinfo() {
$(document).ready(function() {
$("#wimpyTarget").css('display','none');
$("#closeplayer").css('display','none');
$("#showplayer").css('display','block');
 });
}

function show(sitename) {
$(document).ready(function() {
if(!swfobject.hasFlashPlayerVersion("9.0.0")){
    $.post("/flashneeded/", function(data) {
        $("#flashneeded").html(data);
    }); 
}else{
var MySettings = new Object();
MySettings.startPlayingOnload = 'no';
MySettings.wimpyApp = '/audio/'+sitename+'/nmplaylist.xml';
makeWimpyPlayer(MySettings);
$("#wimpyTarget").css('display','block');
}});
}

function regPasswordCheck(){
$(document).ready(function() {
   $("#updateForm").validate();
   $("#useremail").rules('add',{required: true});
   $("#oldpassword").rules('add',{required: true});
   $("#newpassword").rules('add',{required: true, minlength: 8, maxlength:35});
   $("#newpasswordconfim").rules('add',{required: true, equalTo:'#newpassword'});
});
}

function regCheck() {
$(document).ready(function() {  
   $("#regF").validate({submitHandler: function(form) {$("#salesmessage").show();$(form).ajaxSubmit();}});
   var result = "";
   result = $(".nobord:checked").val();
   $("#pw1").rules('add',{required: true, minlength: 8, maxlength:35});
   $("#pw2").rules('add',{required: true, equalTo:'#pw1'});
   $("#email").rules('add',{required: true, email: true, maxlength:35});
   $("#email2").rules('add',{required: true, email: true, equalTo:'#email'});
   $("#TermAgreement").rules('add','required');
   $("#recaptcha_response_field").rules('add','required');
   $("label[for=pw1]").html("<br/><br/>Please enter a password between 8 and 20 characters in length");
   $("label[for=name]").html("<br/><br/>Please enter your name.  Must be between 8 and 35 characters in length.");
   $("label[for=TermAgreement]").html("<br/>You must agree to the terms in order to ...");
   $("label[for=recaptcha_response_field]").html("<br/>Please enter a valid CAPTCHA");
   SiteNameOnly("siteid");
   SiteNameOnly("notemoteid");
   riHover();
		
   if(result == "shopper"){
	$("#emailConfirm").css('display','block');
	$("#passwordConfirm").css('display','block');
        $(".websitename").css('display','none');
        $('#siteid').rules('remove');
        $('#notemoteid').rules('remove');
	$("#countrypc").css('display','none');
        $("#nmid").css('display','none');
   }else if(result == "seller"){
        $("#emailConfirm").css('display','block');
	$("#passwordConfirm").css('display','block');
        $(".websitename").css('display','none');
        $('#siteid').rules('remove');
	$("#countrypc").css('display','none');
        $("#nmid").css('display','block');
        $("#notemoteid").rules('add',{required: true, minlength: 2, maxlength:35});
   }else if(result == "pro"){
	$("#emailConfirm").css('display','block');
	$("#passwordConfirm").css('display','block');
        $(".websitename").show();
        $("#siteid").rules('add',{required: true, minlength: 2, maxlength:80});
        $("#countrypc").css('display','block');
        $('#notemoteid').rules('remove');
        $("#nmid").css('display','none');
   }});
}

function loginCheck(){
    $("#loginF").validate();
    $("#email").rules('add',{required: true, minlength: 8, maxlength:35});
    $("#pw").rules('add',{required: true, minlength: 8, maxlength:35});
}

function loginInitialize() {
$(document).ready(function() {
   loginCheck();
   seHover();
   riHover();
 });
}

function ErrorDisplay(form, id) {
$(document).ready(function() {
    if(id == 'emailDups')	{
         $("#email").css('border','1px dotted red');
         $("#email2").css('border','1px dotted red');
         $("#dup").html("<br/>This email address has already been registered.");
         $("#dup").css('display','block');
     }else if(id == 'siteDups'){
         $("#permanentSite").css('border','1px dotted red');
     }else {
       $("#"+form).validate().element("#"+id);
     }
 });
}

function ErrorDisplayFile(form, id, message) {
$(document).ready(function() {
    $("#"+id).html("<br/>"+message);    
    $("#".id).css('display','block');
    $("#"+form).validate();                
 });
}

function regFPUCheck() {
$(document).ready(function() {
 // $("#fpuForm").validate();
  $("#website").rules('add',{maxlength:35});
  $(".keyword").rules('add',{maxlength:35});
  $("#hboxeditor").rules('add',{maxlength:19000});
  $("#quote").rules('add',{maxlength:250});
  $("#fpuForm input").css('color','blue');
  if(readCookie("loggedin") == 1){
      location.replace("/");
  }
  ckeditor();
  $("#dispname").bind("keyup",function(){
       CharRemove(this);});
   $("#loadbimage").click(function(){
      $.post("/biupload", function(data) {
      $("#loadbackground").html(data);
     });
   });
   URLRemove("website");
 });
// deletepicture();
// updatepicture();
// siteBackground();
// siteBackgroundTypeCheck();
// submitphotos();
 submitForm();
}

function submitForm(){
$("#submitbutton").click(function() {
    var text = $('#hboxeditor').val();
    if(text.search("&lt;\\s*form ") != -1){
        alert("You must remove <form> tags from your submission.");
        return false;
    }else
        return true;
});
}

function logoset(){
$(document).ready(function() {
 if(readCookie("loggedin") == 1){
      location.replace("/");
  }
  regIllustrationCheck();
  result = $(".illustratep:checked").val();
  if(result == 'illustration'){
      $(".illusview").show();
      $(".view").hide();
  }
  else{
      $(".illusview").hide();
      $(".view").show();
  }
  illusChoose();

  $("#logobutton").click(function(){
        $.post("/photoaudiouploadsystem/illustration?illustration="+$("#illusect option:selected").val(), function(data) {
            window.location=window.location;
    });
  });
});
}

function regBIOCheck() {
 $(document).ready(function() {
  $("#bioForm").validate();
 $("#dispname").rules('add',{required:true, maxlength:35});
 $("#hboxeditor").rules('add',{maxlength:5000});
  $("#bioForm input").css('color','blue');
  if(readCookie("loggedin") == 1){
      location.replace("/");
  }
  regIllustrationCheck();
  result = $(".illustratep:checked").val();
  if(result == 'illustration'){
      $(".illusview").show();
      $(".view").hide();
  }

  else{
      $(".illusview").hide();
      $(".view").show();
  }
  illusChoose();
  $(".addItem").show();
  illusChoose();
  addEntry();
  showListings();
  hideListings();
  $("#dispname").bind("keyup",function(){
       CharRemove(this);});
 });
 $(".deletepublication").click(function() {
    var confirmation = window.confirm("Are you sure you want to delete this listing?");
    if(confirmation == true)
        window.location="/actm/bios?delete=cuisine&URL="+$(this).attr("url");
});
viewHelp();
submitForm();
}

function regSTATCheck() {
 $(document).ready(function() {
  $("#detail").rules('add',{maxlength:200});
  $(".insep").rules('add',{maxlength:35});
  var compare = $(".insep").text();
  $('.showTime').timeEntry({spinnerImage: 'img/spinnerDefault.png'});
  NumOnly("years");
  professionSelected();
  textCounterstats();
  performanceartistSelected();
  selections = $("#protype option:selected").text() + '';
  if(selections.indexOf('business (venue)') == -1)
      $(".venue").show();
  else
      $(".venue").hide();

  $("#engagements").change(function() {
       countSelected(this,3,'warning2');
  });
/*   $("#genre").change(function() {
       countSelected(this,10,'warning3');
  });
  $("#instruments").change(function() {
       countSelected(this,10,'warning4');
  });
  $("#dances").change(function() {
       countSelected(this,10,'warning5');
  });

 if($("#protype option:selected").text().indexOf('musician/singer',0) != -1
          || $("#protype option:selected").text().indexOf('dancer',0) != -1){
          $("#other").show();
          }
  if($("#protype option:selected").text().indexOf('other',0) != -1){
          $("#other").show(); 
  } 
  if($('#performanceartist').is(':checked') && $("#businesstype").val() == 'pro')
      $(".performer").show();
  else
      $(".performer").hide();*/
 });
 regVSTATCheck();

 $("#businesstype").change(function() {
    if($("#businesstype option:selected").text() == 'Business'){
        $(".venue").hide();
        $("#hours").show();
        $(".pro").hide();
       /* if($("#protype option:selected").text().indexOf('other',0) != -1)
            $("#other").show();
        else
            $("#other").hide(); */
        $("#eventtype").hide();
    }else if($("#businesstype option:selected").text() == 'Venue'){
        $(".venue").show();
        $(".pro").hide();
     //   $("#other").hide();
    /*    if($("#description option:selected").text().indexOf('Other',0) != -1)
            $("#other").show();
        else
            $("#other").hide(); */
        if($("#eventsheld option:selected").text().indexOf('Other',0) != -1)
            $("#eventtype").show();
    }else{
        $(".venue").hide();
        $(".pro").hide();
     /*   if($("#protype option:selected").text().indexOf('other',0) != -1)
            $("#other").show();
        else
            $("#other").hide(); */
        $("#eventtype").hide();
    }
 });
}

function regSubscribe(){
  $(".deletepublication").click(function() {
    var confirmation = window.confirm("Are you sure you want to delete this listing?");
    if(confirmation == true)
        window.location="/actm/subscription?delete=true&Location="+$(this).attr("url");
});
}

function professionSelected(){
$("#protype").change(function() {
  var selections = $("#protype option:selected").text() + '';

  if(selections.indexOf('business (venue)') != -1){
     $(".venue").show();
  }

 if(selections.indexOf('professional/business (non-venue)') != -1){
    $(".venue").hide(); 
 }
 
 $("#businesstype").val($("#protype :selected").val())
});
}

function performanceartistSelected(){
$("#performanceartist").click(function() {
    if($(this).is(':checked')){
        $(".performer").show();
    }else{
        $(".performer").hide();
    }
});
}

function regVSTATCheck() {
  $("#eventtp").rules('add',{maxlength:100});
  $("#patronsize").rules('add',{maxlength:5});
  $("#years").rules('add',{maxlength:3});
  $('.showTime').timeEntry({spinnerImage: 'img/spinnerDefault.png'});
  eventSelect();
  NumOnly("groupsize");
  NumOnly("patronsize");
 /* if($("#description option:selected").text().indexOf('Other',0) != -1)
         $("#other").show(); */
  $("#statForm input").css({'color':'blue'});
  $("#eventsheld").change(function() {
       countSelected(this,10,'warning');
  });
  $("#genre").change(function() {
       countSelected(this,10,'warning2');
  });
 /*  if($("#description option:selected").text().indexOf('Other',0) != -1)
         $("#other").show();
  $("#description").change(function() {
       if($("#description option:selected").text().indexOf('Other',0) != -1)
         $("#other").show();
       else
        $("#other").hide();
  });*/
}

function URLRemove(id) {
 $("#"+id).bind("keyup",function() {
     var site = $(this).val();
     $(this).val(site.replace(/[^A-Za-z_123456789.]/g,""));
 });
}

function CharRemove(id) {
 $(document).ready(function() {
     var site = $(id).val();
     $(id).val(site.replace(/[^A-Z\sa-z\d]/g,""));
 });
}

function NoCommas() {
 $(".keyword").bind("keyup",function() {
     var site = $(this).val();
     $(this).val(site.replace(/[,]/g,""));
 });
}

function NumOnly(id) {
 $("#"+id).bind("keyup",function() {
     var site = $(this).val();
     $(this).val(site.replace(/[^0-9]/g,"").replace(/^0\d/g,"0"));
 });
}

function NumOnlyC(classname) {
 $("."+classname).bind("keyup",function() {
     var site = $(this).val();
     $(this).val(site.replace(/[^0-9]/g,"").replace(/^0\d/g,"0"));
 });
}

function NumDigOnly(id) {
 $("#"+id).bind("keyup",function() {
     var site = $(this).val();
     $(this).val(site.replace(/[^0-9.]/g,"").replace(/^0\d/g,"0"));
 });
}

function NumDigOnly2Digits(id) {
 $("#"+id).bind("keyup",function() {
     var site = $(this).val();
     site = site.replace(/[^0-9.]/g,"").replace(/^0\d/g,"0");
     if(Limit2(site)){
         $(this).val(site);
         previousentry=site;
     }         
     else
         $(this).val(previousentry);
 });
}

function Limit2(f) {
var re = /^\d{1,3}(\.\d{0,2})?$/g;
return re.test(f);
}


function SiteNameOnly(id) {
 $("#"+id).bind("keyup",function() {
     var site = $(this).val();
     $(this).val(site.replace(/[^0-9a-z\s'A-Z]/g,""));
 });
}

function regIllustrationCheck() {
 $(".illustratep").click(function() {
    var result = "";
    result = $(".illustratep:checked").val();
    if(result == 'illustration'){
       $(".view").hide();
       $(".illusview").show();       
    }
    else{
        $(".view").show();
        $(".illusview").hide();
        $("#illusect").val("");
    }
  });
}

function illusChoose() {
$("#illusect").change(function() {
 $("#illushere").html("<img src='" + $(this).val() + "'");
});
}

function regHOFCheck() {
 $(document).ready(function() {
   $("#hofForm").validate();
   $("#name").rules('add',{required: true, maxlength:35});
   $("#hboxeditor").rules('add',{maxlength:1500});
   $("#hofForm input").css('color','blue');
   $(".addItem").show();
   if(readCookie("loggedin") == 1){
        location.replace("/");
   }
   addEntry();
   showListings();
   hideListings();
    $(".deletepublication").click(function() {
    var confirmation = window.confirm("Are you sure you want to delete this listing?");
    if(confirmation == true)
        window.location="/actm/hof?delete=hof&URL="+$(this).attr("url");
    });
  deletepicture();
  updatepicture();
  viewHelp();
  submitForm();
 });  
}

function stretch(){
$(document).ready(function() {
    $(".stretch").height($(".titledisp").height()+10)
});
}

function regMECheck() {
 $(document).ready(function() {
   $("#meForm").validate();
   $("#title").rules('add',{required: true, maxlength:35});
   $("#datepicker").rules('add',{maxlength:10});
   $("#hboxeditor").rules('add',{maxlength:5000});
   $("#city").rules('add',{maxlength:100});
   $("#meForm input").css('color','blue');
   $(".addItem").show();
   if(readCookie("loggedin") == 1){
        location.replace("/");
   }
   eventSelect();
   addEntry();
   showListings();
   hideListings();
   date();
   stateLocator();
   stateSelect();
   $("#stateinfo").removeAttr('disabled')
   cityLocator();
    $(".deletepublication").click(function() {
    var confirmation = window.confirm("Are you sure you want to delete this listing?");
    if(confirmation == true)
        window.location="/actm/me?delete=me&URL="+$(this).attr("url");
});
   updatepicture();
   viewHelp();
   submitForm();
   $("#reviewtype").change(function(){
    if($(this).val() == 'venue')
        $("#venuetype").show();
    else
        $("#venuetype").hide();
   });
 });  
}

function deletepicture(){
$(".deletepicture").click(function() {
var confirmation = window.confirm("Are you sure you want to delete this treasure?");

if(confirmation == true){ 
    $.post($(this).attr("url"), function(data) {       
    });
     if($("#mainpicture").length)
        $("#mainpicture").remove();
     var count = $(this).attr('countval');
    $("#pic"+count).remove();
    $(this).remove();
    var totalphotocount = $("#photocount").attr('count');
    $("#photocount").html("Ur Total Photo Count: " + (totalphotocount -1));
    $("#photocount").attr('count',totalphotocount - 1);
    }});
}

/*function deletepicturerefresh(){
$(".deletepicturerefresh").click(function() {
var confirmation = window.confirm("Are you sure you want to delete this treasure?");
if(confirmation == true){
    $.post($(this).attr("url"), function(data) {
        window.location=$(this).attr("url");
    });
}});
}*/

function updatepicture(){
$(".updatepicture").click(function() {
    var wait = "#wait"+$(this).attr('countval');
    $.post($(this).attr("url")+"&description="+$("#input"+$(this).attr('countval')).val(), function(data) {
        $(wait).html('Updated');
    });});    
}

function deletesong(){
 $(".deletesong").click(function() {
    var confirmation = window.confirm("Are you sure you want to delete this treasure?");
    if(confirmation == true)
        window.location=$(this).attr("url");
});
}

function regCUISINECheck() {
 $(document).ready(function() {
   $("#cuisineForm").validate();
   $("#title").rules('add',{required: true, maxlength:35});
   $("#hboxeditor").rules('add',{maxlength:2000});
   $('#cost').rules('add',{required: true, maxlength:13});
   $("#cuisineForm input").css('color','blue');
   $(".addItem").show();
   if(readCookie("loggedin") == 1){
        location.replace("/");
   }

   $('#cost').priceFormat({
            limit: 7,
            centsLimit: 2
   });
   addEntry();
   showListings();
   hideListings();
    $(".deletepublication").click(function() {
    var confirmation = window.confirm("Are you sure you want to delete this listing?");
    if(confirmation == true)
        window.location="/actm/cuisine?delete=cuisine&URL="+$(this).attr("url");
});
    viewHelp();
    hasFile();
 });
}

function regPOETRYCheck() {
$(document).ready(function() {
$("#poetryForm").validate();
$("#name").rules('add',{required: true, maxlength:35});
$("#hboxeditor").rules('add',{required: true, maxlength:500});
$("#poetryForm input").css('color','blue');
if(readCookie("loggedin") == 1){
   location.replace("/");
}
addEntry();
showListings();
hideListings();
$(".deletepublication").click(function() {
var confirmation = window.confirm("Are you sure you want to delete this listing?");
if(confirmation == true)
    window.location="/actm/poetry?delete=poetry&URL="+$(this).attr("url");
});});
viewHelp();
submitForm();
textCounterNotes();
}

function regJOURNALCheck() {
 $(document).ready(function() {
   $("#journalForm").validate();
   $("#commentary").rules('add',{required: true, maxlength:500});
   $("#journalForm input").css('color','blue');
  if(readCookie("loggedin") == 1){
        location.replace("/");
  }
     
  $(".addItem").show();
 });
 addEntry();
 showListings();
 hideListings();
  $(".deletepublication").click(function() {
    var confirmation = window.confirm("Are you sure you want to delete this listing?");
    if(confirmation == true)
        window.location="/actm/journal?delete=journal&URL="+$(this).attr("url");
});
}

function regVIDEOCheck() {
  $(document).ready(function() {
    $("#videoForm").validate();
    $("#hboxeditor").rules('add',{maxlength:19000});
/*		//	$("#name").rules('add','required');
		//	$("#artist").rules('add','required');
    $("#vsearch").rules('add',{maxlength:200});
    $("#videoForm input").css('color','blue');*/
    $(".addItem").show();
        if(readCookie("loggedin") == 1){
            location.replace("/");
       }
    ckeditor();
    videoLoader("prettyPhoto");
    videoSearch();
    addVideo();
    removeVideo();
    submitForm();
 });  
}

function videoSearch(){
$("#vsearch").bind("keypress",function(e) {
    if(e.keyCode == 13){       
        $("#busy").ajaxStart(function(){
          $(this).show();
          $("#glazz").hide();
      });        
    $("#vsearchresults").load("/videofinder?vsearch=" + jQuery.trim($("#vsearch").val().replace(/ /g,"%20")));
    $("#busy").ajaxStop(function(){
         $(this).hide();
         $("#glazz").show();
         videoLoader();
       });
      }
    });
}

function videoNext(nextLink){
    $(document).ready(function() {
     removeSelectedVideos();
     addSelectedVideos();
     $("#busy").ajaxStart(function(){
          $(this).show();
          $("#glazz").hide();
      });
    $("#vsearchresults").load("/videofinder?next="+nextLink);
    $("#busy").ajaxStop(function(){
         $(this).hide();
         $("#glazz").show();
       });
    });
}

function videoPrevious(previousLink){
    $(document).ready(function() {
    removeSelectedVideos();
    addSelectedVideos();
     $("#busy").ajaxStart(function(){
          $(this).show();
          $("#glazz").hide();
      });
    $("#vsearchresults").load("/videofinder?previous="+previousLink);
    $("#busy").ajaxStop(function(){
         $(this).hide();
         $("#glazz").show();
       });
    });
}

function addSelectedVideos(){
myArray = $("#all_users div input:checked");
jQuery.each(myArray, function() {
var id = $(this).attr("userid");
$("#user"+id).clone().appendTo("#selected_users");
$("input:checkbox:checked").attr('checked','');
});
}

function removeSelectedVideos(){
myArray = $("#selected_users div input:checked");
jQuery.each(myArray, function() {
id = $(this).attr("userid");
/*    $("#user"+id).removeClass("innertxt2");
$("#user"+id).addClass("innertxt");
$("#user"+id).clone().prependTo("#all_users");*/
$("#selected_users #user"+id).remove();
});
}

function addVideo(){
$("#addVideo").click(function() {
   addSelectedVideos();
  });
}

function removeVideo(){
$("#removeVideo").click(function() {
    removeSelectedVideos();
  });
}

function videoLoader(reltype){
$(document).ready(function() {
$("a[rel^='"+reltype+"']").prettyPhoto({
        animationSpeed: 'fast', /* fast/slow/normal */
        padding: 40, /* padding for each side of the picture */
        opacity: 0.65, /* Value betwee 0 and 1 */
        showTitle: false, /* true/false */
        default_width: 800,
	default_height: 500,
        allowresize: true, /* true/false */
        counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
        theme: 'facebook', /* light_rounded / dark_rounded / light_square / dark_square */
        callback: function(){}
});
});
}
function maxlength(){
$("#commentary").keypress(function(event){
  var key = event.which;
  //all keys including return.
  if(key >= 33 || key == 13) {
	var maxLength = $(this).attr("maxlength");
	var length = this.value.length;
	if(length >= maxLength) {
		event.preventDefault();
 }}});
}

function regHUBBACheck() {
 $(document).ready(function($) {
  try{maxlength();}catch(e){}
  $("#commentary").bind('paste', function(e){$(this).val('');$(this).text('');})
 });
}

function regEVENTCheck() {
$(document).ready(function() {
    $("#eventForm").validate();
    $("#title").rules('add',{required:true, maxlength:50});
    $("#hboxeditor").rules('add',{maxlength:1000});
    $("#phone").rules('add',{maxlength:15});
    NumOnly("phone");
    $("#datepicker").rules('add','required');
    $("#enddatepicker").rules('add','required');
    $("#eventForm input").css('color','blue');
    $(".addItem").show();
    if(readCookie("loggedin") == 1){
        location.replace("/");
    }    

    $('#showTime').timeEntry({spinnerImage: 'img/spinnerDefault.png'});
    $('#cost').priceFormat({
        limit: 7,
        centsLimit: 2
    });
    eventSelect();
    addEntry();
    showListings();
    hideListings();
    date2();
    date3();
    stateLocator();
    stateSelect();
    $("#stateinfo").removeAttr('disabled');
    cityLocator();
 
    $(".deletepublication").click(function() {
    var confirmation = window.confirm("Are you sure you want to delete this listing?");
    if(confirmation == true)
        window.location="/actm/events?delete=events&URL="+$(this).attr("url");
});
textCounter();
});
}

function duplicate(){
$(".eventtitle").click(function(){
    $("#duplicatedisabled").hide();
    $("#duplicate").show();
});
}

function submitPICTUREReg() {
$(document).ready(function() {
    $("#pictureForm").submit();
 });
}

function regStoreCheck(brief) {
 $(document).ready(function() {
   $("#storeForm").validate();
   $("#item").rules('add',{required:true,maxlength:35});
   $("#handlingfees").rules('add',{required:true});
   if($("#freeshipping").attr('checked') != true && $("#cataloged").attr("checked") != true){
        $(".shippingselections").rules('add',{required:true});
//        $("#measurementtype").rules('add',{required:true});
   }
   $("#price").rules('add',{required:true});
   if($("#hboxeditor").length)
      $("#hboxeditor").rules('add',{maxlength:5000});
   $("#returnpolicy").rules('add',{maxlength:200});
   textCounterBD();
   NumDigOnly("shippingweight");
   NumDigOnly("itemlength");
   NumDigOnly("itemwidth");
   NumDigOnly("itemheight");
   $("#comments").rules('add',{maxlength:200});
   $("#itempounds").rules('add',{maxlength:7});
   $("#itemounces").rules('add',{maxlength:7});
   $("#itemlength").rules('add',{maxlength:4});
   $("#itemwidth").rules('add',{maxlength:4});
   $("#itemheight").rules('add',{maxlength:4});
 //  $("#price").rules('add',{required:true,maxlength:13});
 //  $("#shippingprice").rules('add',{required:true,maxlength:12});
//   $("#hboxeditor").rules('add',{maxlength:5000});
   $("#tags").rules('add',{required:true, maxlength:50});
   $("#storeForm input").css('color','blue');
   NumOnly("discount");
   ckeditornotesnl();
   addEntry();
    $(".deletepublication").click(function() {
    var confirmation = window.confirm("Are you sure you want to delete this listing?");
    if(confirmation == true)
        window.location="/actm/store?delete=store&URL="+$(this).attr("url");
});
showListings();
hideListings();
updatepicture();
selectedCategory();
NumOnly("quantity");
viewHelp();
getChangeCouriers();
freeShipping();
deletepicture();
noInternationalShipping();
computeShipping();
computeInternationalShipping();
measurementTypeDisp();
ppVerify();
checkInternationalShipping();
NumDigOnly2Digits("currencycalculator");
currencyUpate();
if($('#Local').attr('checked') || $('#Freight').attr('checked')){
    $("#weightdimensions").hide();
    $("#couriers").hide();
    $("#shipname").html('');
    $("#ishippingrate").hide();
    if($('#Local').attr('checked')){
        $("#freeshipping").attr('checked','');
        $("#freeshipping").attr('disabled','true');
        $("#shipinternational").attr('checked','');
        $("#shipinternational").attr('disabled','true');
        $(".internationalselections").hide();
    }
}
//catalogItem();
catalogInternationally();
catalogFreeShipping();
nonshippingItems();
if($("#category :selected").text() == 'Real Estate'){
$(".shipping").hide();
$(".shippingoptions").hide();
$(".shippingselections").rules('remove');
}
sizeSelect();
showCalculator();
$(".flasherr").effect("pulsate", { times:500 }, 2000);
storeSizes();
if(brief == true)
    storebriefInitialize();
});
NumOnlyC("numo");
}

function storePriceInfo(){
    $('#price').priceFormat({
        limit: 10,
        centsLimit: 2
    });
    $('#handlingfees').priceFormat({
        limit: 7,
        centsLimit: 2
    });
    $('#shippingprice').priceFormat({
        limit: 7,
        centsLimit: 2
    });
    $('#shippingpricelocal').priceFormat({
        limit: 7,
        centsLimit: 2
    });
    $('#shippingpriceinternational').priceFormat({
        limit: 7,
        centsLimit: 2
    });
    $('#flatcatnational').priceFormat({
        limit: 7,
        centsLimit: 2
    });
    $('#flatcatinternational').priceFormat({
        limit: 7,
        centsLimit: 2
    });
    $('#customcost').priceFormat({
        limit: 7,
        centsLimit: 2
    });
     $('#xxlcost').priceFormat({
        limit: 7,
        centsLimit: 2
    });
     $('#xlargecost').priceFormat({
        limit: 7,
        centsLimit: 2
    });
     $('#lrgecost').priceFormat({
        limit: 7,
        centsLimit: 2
    });
     $('#mediumcost').priceFormat({
        limit: 7,
        centsLimit: 2
    });
     $('#smallcost').priceFormat({
        limit: 7,
        centsLimit: 2
    });
     $('#xsmcost').priceFormat({
        limit: 7,
        centsLimit: 2
    });
     $('#xxscost').priceFormat({
        limit: 7,
        centsLimit: 2
    });
}

function sizeSelect(){
$(".itemsizes").click(function(){
    if($("#sizes:checked").val() == 'many'){
        $("#sizesinfo").show();
        $("#priceinfo").hide();
        $("#numberinstock").hide();
        $("#price").rules('remove');
        $("#quantity").rules('remove');
    }else{
        $("#sizesinfo").hide();
        $("#priceinfo").show();
        $("#numberinstock").show();
        $("#price").rules('add',{maxlength:13});
        $("#quantity").rules('add',{required:true});
    }
});
}
function nonshippingItems(){
$("#category").change(function(){
if($("#category :selected").text() == 'Real Estate'){
      $(".shipping").hide();
      $(".shippingoptions").hide();
      $(".shippingselections").rules('remove');
}else{
    $(".shipping").show();
    $(".shippingoptions").show();
    $(".shippingselections").rules('add',{required:true});
}
});
}

function catalogItem(){
$("#cataloged").click(function(){
    if($(this).attr('checked')){
        $("#catalogsale").show();
        $("#separatesale").hide();
        $("#catofferedinternationally").show();
        $("input:radio[@name='shippingtype']").rules('remove');
        $("#measurementtype").rules('remove');
    }else{
       $("#catalogsale").hide();
       $("#separatesale").show();
       $("#catofferedinternationally").hide();
       $("input:radio[@name='shippingtype']").rules('add',{required:true});
       $("#measurementtype").rules('add',{required:true});
    }
});
}

function catalogInternationally(){
$("#sellinternationallycat").click(function(){
    if($(this).attr('checked')){
        if(!$("#freeshippingcat").attr("checked"))
            $("#catinternational").show();
        $("#catexclude").show();
    }else{
       $("#catinternational").hide();
       $("#catexclude").hide();
    }
});
}

function catalogFreeShipping(){
$("#freeshippingcat").click(function(){
    if($(this).attr('checked')){
        $("#catnational").hide();
        $("#catinternational").hide();
    }else{
        $("#catnational").show();
        if($("#sellinternationallycat").attr('checked'))
            $("#catinternational").show();
    }
});
}

function updateAddress(){
$("#countrydestination").change(function(){
if($(this).val() != 'US' && $(this).val() != 'United States')
    $("#states").hide();
else
    $("#states").show();
$("#destcountry").val($(this).val());
});
}

function updateStates(){
$("#stateinfo").change(function(){
$("#deststate").val($("#stateinfo :selected").text());
});
}


function anotherAddress(){
$("#otheraddress").click(function(){
if($(this).is(':checked')){
    $("#shippingaddress").show();
    $("#loginF").hide();
}else{
$("#shippingaddress").hide();
$("#loginF").show();
if($("#updatedtotal").val() != '' && $("#updatedtotal").val() != undefined){
     $("#totalamt").html('$'+$("#normaltotalprice").val());
     $("#catshipping").html('$'+$("#normalshippingprice").val());
     $("#cattotalprice").val($("#normaltotalprice").val());
     $("#catshippingprice").val($("#normalshippingprice").val().replace("$",''));
}}});
}

function currencyUpate(){
$("#submitCurrencybutton").click(function(){
currencyRate=$("#currencycalculator").val();
if(currencyRate == ''){
    alert("Please enter a currency rate value before updating.");
    $("#currencycalculator").css('border','2px solid red');
    return false;
}
$("#busycurrency").ajaxStart(function(){
  $(this).show();
});

$.post("/checkout/?currency=true&currencyRate="+currencyRate, function(data) {
$("#currencyupdate").html(data);
});
$("#busycurrency").ajaxStop(function(){
  $(this).hide();
});
});
}

function measurementTypeDisp(){
$("#measurementtype").change(function() {
    if($("#measurementtype option:selected").val() == 'english'){
        $("#weightinfo").show();
        $("#measurementinfo").show();
        $("#packageinfo").show();
        $(".english").show();
        $(".metric").hide();
    }else{
        $("#weightinfo").show();
        $("#measurementinfo").show();
        $("#packageinfo").show();
        $(".english").hide();
        $(".metric").show();
    }
});
}

function computeShipping(){
$("#calculateb").click(function(){
$("#busynational").ajaxStart(function(){
  $(this).show();
});
if($("#measurementtype option:selected").val() == ''){
    $("#measurementtype").css("border","2px solid red");
    alert("You must select a Unit of Measure (metric/english) before using the Calculator.");
    return;
}
if($("#packagetype option:selected").val() == ''){
    $("#packagetype").css("border","2px solid red");
    alert("You must select a package type before using the Calculator.");
    return;
}
unitofmeasure="unitofmeasure="+jQuery.trim($("#measurementtype  option:selected").val());
shippingtype="&shippingtype=national";
servictype = "&servicetype="+jQuery.trim($("#servicetype  option:selected").val());
packagetype = "&packagetype="+jQuery.trim($("#packagetype  option:selected").val());
zipcodeorigin = "&zipcodeorigin="+$("#postalcode").val();
zipcodedestination = "&zipcodedestination="+$("#zipcodedestination").val();
country="&countrydestination="+$("#origincountry").val();
kilograms="&kilograms="+$("#itemkilograms").val();
if($("#irregularpackage").attr('checked') == true)
    irregularpackage="&irregularpackage="+"NONRECTANGULAR"
else
    irregularpackage="&irregularpackage="+"RECTANGULAR"

pounds="&pounds="+$("#itempounds").val();
ounces="&ounces="+$("#itemounces").val();
width="&width="+$("#itemwidth").val();
lngth="&length="+$("#itemlength").val();
height="&height="+$("#itemheight").val();
girth="&girth="+$("#itemgirth").val();
query=unitofmeasure+shippingtype+servictype+packagetype+zipcodeorigin+country+zipcodedestination+kilograms+irregularpackage+pounds+ounces+width+lngth+height+girth;
$.post("/calculate/?"+query, function(data) {
    $("#shippingcostcomputation").html(data);
      });
});
$("#busynational").ajaxStop(function(){
  $(this).hide();
});
}

function calcChippingNational(zipcode){
var unitofmeasure="unitofmeasure="+jQuery.trim($("#unitofmeasure").val());
var shippingtype="&shippingtype=national";
var servictype = "&servicetype="+jQuery.trim($("#nationalservicetype").val());
var packagetype = "&packagetype="+jQuery.trim($("#packageType").val());
var zipcodeorigin = "&zipcodeorigin="+$("#originPostalCode").val();
var zipcodedestination = "&zipcodedestination="+zipcode;
var country="&countrydestination="+$("#origincountry").val();
var kilograms="&kilograms="+$("#kilograms").val();
if($("#irregularpackage").val() == 'true')
    var irregularpackage="&irregularpackage="+"NONRECTANGULAR"
else
    var irregularpackage="&irregularpackage="+"RECTANGULAR"

var pounds="&pounds="+$("#pounds").val();
var ounces="&ounces="+$("#ounces").val();
var width="&width="+$("#width").val();
var lngth="&length="+$("#length").val();
var height="&height="+$("#height").val();
var girth="&girth="+$("#girth").val();
var query=unitofmeasure+shippingtype+servictype+packagetype+zipcodeorigin+country+zipcodedestination+kilograms+irregularpackage+pounds+ounces+width+lngth+height+girth;
$.post("/calculate/?"+query, function(data) {
    $("#shippingcostcomputation").html(data);
      });
}

function computeShippingSale(){
$("#calculateb").click(function(){
$("#busynational").ajaxStart(function(){
  $(this).show();
});
if($("#zipcodedestination").val() == ''){
    $("#zipcodedestination").css("border","2px solid red");
    alert("You must enter a Zip/Postal Code befoe using the Calculator.");
    return;
}

var unitofmeasure="unitofmeasure="+jQuery.trim($("#unitofmeasure").val());
var shippingtype="&shippingtype=national";
var servictype = "&servicetype="+jQuery.trim($("#nationalservicetype").val());
var packagetype = "&packagetype="+jQuery.trim($("#packageType").val());
var zipcodeorigin = "&zipcodeorigin="+$("#originPostalCode").val();
var zipcodedestination = "&zipcodedestination="+$("#zipcodedestination").val();
var country="&countrydestination="+$("#origincountry").val();
var kilograms="&kilograms="+$("#kilograms").val();
if($("#irregularpackage").val() == 'true')
    var irregularpackage="&irregularpackage="+"NONRECTANGULAR"
else
    var irregularpackage="&irregularpackage="+"RECTANGULAR"

var pounds="&pounds="+$("#pounds").val();
var ounces="&ounces="+$("#ounces").val();
var width="&width="+$("#width").val();
var lngth="&length="+$("#length").val();
var height="&height="+$("#height").val();
var girth="&girth="+$("#girth").val();
var query=unitofmeasure+shippingtype+servictype+packagetype+zipcodeorigin+country+zipcodedestination+kilograms+irregularpackage+pounds+ounces+width+lngth+height+girth;
$.post("/calculate/?"+query, function(data) {
    $("#shippingcostcomputation").html(data);
      });
});
$("#busynational").ajaxStop(function(){
  $(this).hide();
});
}

function computeInternationalShippingSale(){
$("#calculateIb").click(function(){
$("#busyinternational").ajaxStart(function(){
  $(this).show();
});
if($("#countrydestination option:selected").val() == ''){
    $("#countrydestination").css("border","2px solid red");
    alert("You must select a destination country befoe using the Calculator.");
    return;
}
if($("#izipcodedestination").val() == ''){
    $("#izipcodedestination").css("border","2px solid red");
    alert("You must provide a zip/postal code befoe using the Calculator.");
    return;
}

var unitofmeasure="unitofmeasure="+$("#unitofmeasure").val();
var shippingtype="&shippingtype=international";
var iservictype = "&iservicetype="+jQuery.trim($("#internationalservicetype").val());
var packagetype = "&packagetype="+jQuery.trim($("#packageType").val());
var zipcodeorigin = "&zipcodeorigin="+$("#originPostalCode").val();
var country = "&countrydestination="+$("#countrydestination").val();
var zipcodedestination="&zipcodedestination="+$("#izipcodedestination").val();
var origincountry="&origincountry="+$("#originCountry").val();
var kilograms="&kilograms="+$("#kilograms").val();
var currencyrate="&currencyrate="+$("#currencyRate").val();
if($("#irregularpackage").val() == 'true')
    var irregularpackage="&irregularpackage="+"NONRECTANGULAR"
else
    var irregularpackage="&irregularpackage="+"RECTANGULAR"

var pounds="&pounds="+$("#pounds").val();
var ounces="&ounces="+$("#ounces").val();
var width="&width="+$("#width").val();
var lngth="&length="+$("#length").val();
var height="&height="+$("#height").val();
var girth="&girth="+$("#girth").val();


query=unitofmeasure+shippingtype+iservictype+packagetype+zipcodeorigin+zipcodedestination+currencyrate+country+origincountry+kilograms+irregularpackage+pounds+ounces+width+lngth+height+girth;


$.post("/calculate/?"+query, function(data) {
    $("#shippingcostIntcomputation").html(data);
      });
});
$("#busyinternational").ajaxStop(function(){
  $(this).hide();
});
}

function ppVerify(){
$("#submitVerifybutton").click(function(){
$("#ppaccountdisp").hide();
$("#busyverify").ajaxStart(function(){
  $(this).show();
});

first="&FirstName="+$("#firstname").val();
last="&LastName="+$("#lastname").val();
emailaddress="&PPEmail="+$("#emailaccount").val();
query=first+last+emailaddress;
$.post("/checkout/?verify=true"+query, function(data) {
    $("#ppaccountverification").html(data);
    if($("#verificationresponse").text().indexOf('has been validated') != -1)
        window.location="/actm/store"
});
$("#busyverify").ajaxStop(function(){
  $(this).hide();
});
});
}

function computeInternationalShipping(){
$("#calculateIb").click(function(){
$("#busyinternational").ajaxStart(function(){
  $(this).show();
});
if(!$("#nationalservices").is(":visible") && ($("#currencycalculator").val() == '' || $("#currencycalculator").val() == '0.00')){
    alert("You must provide a currency rate for your currency denomination to USD ($)")
    $("#currencycalculator").css('border','2px solid red');
    $("#currencycalculator").focus();
    return false;
}
if($("#measurementtype option:selected").val() == ''){
    $("#measurementtype").css("border","2px solid red");
    alert("You must select a Unit of Measure (metric/english) befoe using the Calculator.");
    return;
}
if($("#iservicetype option:selected").val() == ''){
    $("#measurementtype").css("border","2px solid red");
    alert("You must select a shipment type befoe using the Calculator.");
    $("#iservicetype").css('border','2px solid red');
    return;
}
if($("#packagetype option:selected").val() == ''){
    $("#packagetype").css("border","2px solid red");
    alert("You must select a package type befoe using the Calculator.");
    return;
}
unitofmeasure="unitofmeasure="+jQuery.trim($("#measurementtype  option:selected").val());
shippingtype="&shippingtype=international";
iservictype = "&iservicetype="+jQuery.trim($("#iservicetype  option:selected").val());
packagetype = "&packagetype="+jQuery.trim($("#packagetype  option:selected").val());
zipcodeorigin = "&zipcodeorigin="+$("#postalcode").val();
country = "&countrydestination="+$("#countrydestination").val();
zipcodedestination="&zipcodedestination="+$("#izipcodedestination").val();
ocountry = "&origincountry="+$("#origincountry").val();
kilograms="&kilograms="+$("#itemkilograms").val();
currencyrate="&currencyrate="+$("#currencycalculator").val();
if($("#irregularpackage").attr('checked') == true)
    irregularpackage="&irregularpackage="+"NONRECTANGULAR"
else
    irregularpackage="&irregularpackage="+"RECTANGULAR"

pounds="&pounds="+$("#itempounds").val();
ounces="&ounces="+$("#itemounces").val();
width="&width="+$("#itemwidth").val();
lngth="&length="+$("#itemlength").val();
height="&height="+$("#itemheight").val();
girth="&girth="+$("#itemgirth").val();

query=unitofmeasure+shippingtype+iservictype+packagetype+zipcodeorigin+zipcodedestination+currencyrate+country+ocountry+kilograms+irregularpackage+pounds+ounces+width+lngth+height+girth;

$.post("/calculate/?"+query, function(data) {
    $("#shippingcostIntcomputation").html(data);
      });
});
$("#busyinternational").ajaxStop(function(){
  $(this).hide();
});
}

function showCalculator(){
$("#Calculated").click(function() {
if($(this).is(':checked')){
    getServiceTypes();
    $("#shippingcalculatorinfo").show();
}else
    $("#shippingcalculatorinfo").hide();
});
}

function getChangeCouriers(){
$("#shippingtypes").click(function() {
    shippingchange = true;
    if($('#Local').attr('checked') || $('#Freight').attr('checked')){
        $("#USPS").removeAttr('checked');
        $("#UPS").removeAttr('checked');
        $("#FedEx").removeAttr('checked');
        $("#Generic").removeAttr('checked');
        $(".servicetypes").hide();
        $(".flatrate").hide();
        if($('#Freight').attr('checked')){
            $("#freightcourier").html(' Include Freight Courier in the shipping comments section below.');
            $(".shipping").show();
            $("#freeshipping").removeAttr('disabled');
            $("#shipinternational").removeAttr('disabled');
       }else{
            $("#freightcourier").html('No Shipping Services required.');
            $(".shipping").hide();
            $(".nationalselections").show();
            $("#shipinternational").attr('checked','');
            $("#shipinternational").attr('disabled','true');
            $(".internationalselections").hide();
            $("#freeshipping").attr('checked','');
            $("#freeshipping").attr('disabled','true');
        }
        if($("#nationalservices").is(":visible")){
            $("#freightcourier").show();
        }
        $("#freightcourieri").show();
        //$(".calculator").hide();
        $(".services").hide();
        $("#measurementtype").rules('remove');
        $("#weightdimensions").hide();
        $("#couriers").hide();
        $("#shipname").html('');
        $("#ishippingrate").hide();
    }else if($('#Flat').attr('checked')){
        $("#USPS").attr('checked','checked');
        $("#UPS").attr('checked','checked');
        $("#FedEx").attr('checked','checked');
        $("#Generic").attr('checked','checked');
        $(".flatrate").show();
        /*if($("#nationalservices").is(":visible")){alert('')
            $("#nationalflatrate").show();
        }
        $("#internationalflatrate").show();*/       
        getServiceTypes();
        $(".servicetypes").show();
        $("#freightcourier").hide();
        $("#freightcourieri").hide();
       // $(".calculator").hide();
        $(".services").show();
        $(".shipping").show();
        $("#shipname").html('National Shipping');
        $("#freeshipping").removeAttr('disabled');
        $("#shipinternational").removeAttr('disabled');
        if(!$('#shipinternational').attr('checked')){
            $("#ishippingrate").hide();
        }else
            $("#ishippingrate").show();
    }
});
}

function getServiceTypes(){
$("#busy").ajaxStart(function(){
  $(this).show();
});
query = "&USPS=true&UPS=true";

$.post("/actm/store?shippingchange=true"+query, function(data) {
    $("#nationalservicescalc").html(data);
});

$.post("/actm/store?internationalchange=true"+query, function(data) {
    $("#internationalservicescalc").html(data);
    
});
$("#busy").ajaxStop(function(){
 $(this).hide();
});
}


function freeShipping(){
$("#freeshipping").click(function() {
    if($(this).attr('checked') == true){
        $(".shipping").hide();
        $(".shippingselections").rules('remove');
        $("#shippingType").hide();
    }else{
        $(".shipping").show();
        $(".shippingselections").rules('add',{required:true});
        $("#shippingType").show();
        if($("#shipinternational").attr('checked') == false)
            $("#.internationalselections").hide();
    }
});
}

function noInternationalShipping(){
$("#shipinternational").click(function() {
    if($(this).attr('checked') == false){
        $(".internationalselections").hide();
    }else{
        $(".internationalselections").show();
        if($("#freeshipping").attr('checked') == true)
            $("#ishippingrate").hide();
        else if($('#Freight').attr('checked')){
            $("#freightcourier").html(' Include Freight Courier in the shipping comments section below.');
            $(".shipping").show();
            $("#ishippingrate").hide();
            $("#freeshipping").removeAttr('disabled');
            $("#shipinternational").removeAttr('disabled');
        }
    }
});
}

function checkInternationalShipping(){
if($("#shipinternational").attr('checked') == false)
    $(".internationalselections").hide();
}

function selectedInternationalDisp(enabled){
if(enabled == 'false'){
    $("#shippingpriceinternational").attr('disabled','true');
    $("#shippingweight").attr('disabled','true');
    $("#comments").attr('disabled','true');
}else{
    $("#shippingpriceinternational").removeAttr('disabled');
    $("#shippingweight").removeAttr('disabled');
    $("#comments").removeAttr('disabled');
}}

function selectedCategory() {
$("#category").change(function() {
     var hidden = $("#currentCategory").val();
     var selected = $("#category option:selected").text();
     if((selected != 'Compact Discs' || selected != 'Vinyl Records' || selected != 'Cassette Tapes' || selected != '8 Track Tapes')
         && (hidden == 'Compact Discs' ||  hidden == 'Vinyl Records' || hidden == 'Cassette Tapes' || hidden == '8 Track Tapes')){
         var confirmation = window.confirm("Are you sure you want to change this category?  Doing so will erase any uploaded mp3 files associated with this item.");
         if(confirmation == true){
             $.post("/actm/music?removeall=true&recording="+jQuery.trim($("#treasureURL").val().replace(/ /g,"%20")),function(data) {});
             $("#currentCategory").val('deleted')
         }           
     }       
});}

function regRentalsCheck() {
 $(document).ready(function() {
   $("#rentalForm").validate();
   $("#item").rules('add',{required:true,maxlength:35});
   $("#price").rules('add',{maxlength:13});
   $("#briefdescription").rules('add',{required:true,maxlength:200});
   $("#hboxeditor").rules('add',{maxlength:5000});
   $("#rentalForm input").css('color','blue');
   showListings();
   hideListings();
   addEntry();
    $(".deletepublication").click(function() {
    var confirmation = window.confirm("Are you sure you want to delete this listing?");
    if(confirmation == true)
        window.location="/actm/rentals?delete=store&URL="+$(this).attr("url");
});
updatepicture();
});
}

function regWantedCheck() {
 $(document).ready(function() {
   $("#wantedForm").validate();
   $("#item").rules('add',{required:true,maxlength:35});
   $("#description").rules('add',{required:true,maxlength:500});
   $("#wantedForm input").css('color','blue');
   addEntry();
    $(".deletepublication").click(function() {
    var confirmation = window.confirm("Are you sure you want to delete this listing?");
    if(confirmation == true)
        window.location="/actm/wanted?delete=wanted&URL="+$(this).attr("url");
});
});
}

function regSwapCheck() {
 $(document).ready(function() {
   $("#wantedForm").validate();
   $("#item").rules('add',{required:true,maxlength:35});
   $("#description").rules('add',{required:true,maxlength:500});
   $("#wantedForm input").css('color','blue');
   addEntry();
    $(".deletepublication").click(function() {
    var confirmation = window.confirm("Are you sure you want to delete this listing?");
    if(confirmation == true)
        window.location="/actm/swap?delete=swap&URL="+$(this).attr("url");
});
});
}

function regServicesCheck() {
$(document).ready(function() {  
    $("#servicesForm").validate();
    $("#name").rules('add',{required:true,maxlength:35});
    $("#hboxeditor").rules('add',{maxlength:5000});
    $("#tags").rules('add',{required:true, maxlength:50});
    $("#category").rules('add','required');
    $("#servicesForm input").css('color','blue');
    if(readCookie("loggedin") == 1){
        location.replace("/");
    }
    addEntry();
    showListings();
    hideListings();
    if($("#category option:selected").text().indexOf('Other',0) != -1)
         $("#other").show();
     $("#category").change(function() {
       if($("#category option:selected").text().indexOf('Other',0) != -1)
         $("#other").show();
       else
        $("#other").hide();
  });
   $(".deletepublication").click(function() {
    var confirmation = window.confirm("Are you sure you want to delete this listing?");
    if(confirmation == true)
        window.location="/actm/services?delete=services&URL="+$(this).attr("url");
});
    characterCounter();
    updatepicture();
    viewHelp();
 });  
}

function textCounter(){
$("#description").bind('keyup',function()
{$("#charactercounter").html("Character Count: " + $(this).val().length)
});
}

function textCounterstats(){
$("#detail").bind('keyup',function()
{$("#charactercounter").html("Character Count: " + $(this).val().length)
});
}

function textCounterNotes(){
$("#hboxeditor").bind('keyup',function()
{$("#charactercounter").html("Character Count: " + $(this).val().length)
});
}

function textCounterAbstract(){
$("#abstract").bind('keyup',function()
{$("#charactercounterabstract").html("Character Count: " + $(this).val().length)
});
}

function textCounterBD(){
$("#briefdescription").bind('keyup',function()
{$("#bdcharactercount").html("Character Count: " + $(this).val().length)
});
}

function textmax(){
$(document).ready(function() {
    $(".askform").each(function (item){
        $(this).validate();
    });
    $(".replytxt").each(function (item){
           $(this).rules('add',{required:true,minlength:25,maxlength:1000});
    });
    $("#commentform").each(function (item){
        $(this).validate();
    });
    $("#commentary").each(function (item){
           $(this).rules('add',{required:true,minlength:25,maxlength:100});
    });
    textCounterCommentAsk();
});
}


function textCounterCommentAsk(){
 $(document).ready(function() {
$("#commentary").bind('keyup',function() {
$("#charactercounter").html("Character Count: " + $("#commentary").val().length);
});
});
}

function textCounterAsk(id,counter){
$("#commentcountary").html("Character Count: " + $("#"+id).val().length);
}


function regMeetCheck() {
 $(document).ready(function() {
   $("#meetForm").validate();
   $("#musiciandesc").rules('add',{maxlength:500});
   $("#dancedesc").rules('add',{maxlength:500});
   $("#actingdesc").rules('add',{maxlength:500});
   $("#readerdesc").rules('add',{maxlength:500});
   $("#meetingdesc").rules('add',{maxlength:500});

   $("#roletp").rules('add',{maxlength:35});

   $("#artisttitle").rules('add',{maxlength:35});
   $("#musiciantitle").rules('add',{maxlength:35});
   $("#dancertitle").rules('add',{maxlength:35});
   $("#actortitle").rules('add',{maxlength:35});
   $("#writertitle").rules('add',{maxlength:35});
   $("#othertitle").rules('add',{maxlength:35});

   
   $("#artistgroup").click(function() {
    if($('#artistgroup').attr('checked'))
        $("#artisttitle").rules('add',{required:true,maxlength:35});
    else
        $("#artisttitle").rules('remove');
    $("#meetForm").validate();
   });
   
   $("#musicgroup").click(function() {
    if($('#musicgroup').attr('checked'))
        $("#musiciantitle").rules('add',{required:true,maxlength:35});
    else
        $("#musiciantitle").rules('remove');
    $("#meetForm").validate();
   });

  $("#dancegroup").click(function() {
    if($('#dancegroup').attr('checked'))
        $("#dancertitle").rules('add',{required:true,maxlength:35});
    else
        $("#dancertitle").rules('remove');
    $("#meetForm").validate();
   });

  $("#actinggroup").click(function() {
    if($('#actinggroup').attr('checked'))
        $("#actortitle").rules('add',{required:true,maxlength:35});
    else
        $("#actortitle").rules('remove');
    $("#meetForm").validate();
   });


   $("#bookgroup").click(function() {
    if($('#bookgroup').attr('checked'))
        $("#writertitle").rules('add',{required:true,maxlength:35});
    else
        $("#writertitle").rules('remove');
    $("#meetForm").validate();
   });

   $("#meetinggroup").click(function() {
    if($('#meetinggroup').attr('checked'))
        $("#othertitle").rules('add',{required:true,maxlength:35});
    else
        $("#othertitle").rules('remove');
    $("#meetForm").validate();
   });

   $("#meetForm input").css('color','blue');

   if(readCookie("loggedin") == 1){
        location.replace("/");
   }

   $("#instrumentation").change(function() {
         countSelected(this,10,'warning');
    });
   $("#fsound").change(function() {
         countSelected(this,3,'warning2');
    });
    $("#role").change(function() {
         countSelected(this,5,'warning3');
    });
    $("#fsounddance").change(function() {
         countSelected(this,3,'warning4');
    });
    $("#dancesp").change(function() {
         countSelected(this,5,'warning5');
    });
    $("#meetingtypes").change(function() {
         countSelected(this,5,'warning6');
    });
    $("#joininstrumentation").change(function() {
         countSelected(this,5,'warning7');
    });
    $("#danceinstrumentation").change(function() {
         countSelected(this,5,'warning8');
    });
    $("#genrefavorites").change(function() {
         countSelected(this,5,'warning9');
    });
    $("#dancefavorites").change(function() {
         countSelected(this,5,'warning10');
    });


   if($('#artistgroup').attr('checked'))
        $("#artisttitle").rules('add',{required:true,maxlength:35});
   if($('#musicgroup').attr('checked'))
        $("#musiciantitle").rules('add',{required:true,maxlength:35});
   if($('#dancegroup').attr('checked'))
        $("#dancertitle").rules('add',{required:true,maxlength:35});
   if($('#actinggroup').attr('checked'))
        $("#actortitle").rules('add',{required:true,maxlength:35});
   if($('#bookgroup').attr('checked'))
        $("#writertitle").rules('add',{required:true,maxlength:35});
   if($('#meetinggroup').attr('checked'))
        $("#othertitle").rules('add',{required:true,maxlength:35});

    
    roleSelect();
    meetingSelect("Other","meetingtype");
    $(".mgroup").hide();
    $(".dgroup").hide();
    $(".agroup").hide();
    $(".atheletes").hide();
    $(".artists").hide();
    $(".pgroup").hide();
    $(".bgroup").hide();
    $(".meetinggroup").hide();

    
    $(".addItem").show();
    devGroup("musicgroup","createGroup","mgroup","roletype");
    devGroup("dancegroup","createDanceGroup","dgroup");
    devGroup("actinggroup","createActingGroup","agroup");
    devGroup("artistgroup","meetArtists","artists");
    devGroup("bookgroup","createBookGroup","bgroup");
    devGroup("meetinggroup","MeetingGroup","meetinggroup","meetingtype");

$("#meetingdesc").bind('keyup',function()
{$("#characterconnect").html("Character Count: " + $(this).val().length)
});
$("#artistdesc").bind('keyup',function()
{$("#characterservices").html("Character Count: " + $(this).val().length)
});
$("#actingdesc").bind('keyup',function()
{$("#charactergoods").html("Character Count: " + $(this).val().length)
});
$("#readerdesc").bind('keyup',function()
{$("#characterinformation").html("Character Count: " + $(this).val().length)
});
 });
}

function regAccountCheck() {
if(readCookie("loggedin") == 1){
            location.replace("/");
        }
$("#accountForm input").css('color','blue');
$('#accountForm').validate({
rules : {
description : {numchecked : true},
other: {required: true, maxlength:35},
name: {required: true, maxlength:35},
email : {required: true, email: true, maxlength:35},
telephone: {maxlength:15},
country: {required:true,maxlength:35},
state: {maxlength:35},
website:{maxlength:35},
hboxeditor:{maxlength:19000},
quote:{maxlength:250},
detail:{maxlength:200},
zipcode: {maxlength:10}}});
$(".keyword").rules('add',{maxlength:35});
NoCommas();
$(".insep").rules('add',{maxlength:35});
var compare = $(".insep").text();
$('.showTime').timeEntry({spinnerImage: 'img/spinnerDefault.png'});
NumOnly("years");
professionSelected();
textCounterstats();

$("#engagements").change(function() {
   countSelected(this,3,'warning2');
});

$("#country").change(function() {
   $("#UNI").val('');
   $("#city").rules('add',{required:true, minlength:2, maxlength:35});
   $("#actualcity").val('')
});

$("#stateinfo").change(function() {
$("#found").hide();
$("#city").val("");
$("#city").rules('add',{required:true, minlength:2, maxlength:35});
$("#actualcity").val('')
});

if($("#protype option:selected").val() == 'venue')
  $(".venue").show();
else
  $(".venue").hide();

$("#feedback").click(function() {
  if($(this).is(":checked"))
      $(".onlysell").hide();
  else {
      $(".onlysell").show();
      $(".venue").hide();
  }
});
eventSelect();
if($("#UNI").val() == ''){
$("#city").rules('add',{required:true, minlength:2, maxlength:35});
}
$("#actualcity").rules('add',{required:true, minlength:2, maxlength:35});
stateLocator();
stateSelect();
cityLocator();
$("#stateinfo").removeAttr('disabled');
updatepicture();
}

function regPurchaseCheck() {
if(readCookie("loggedin") == 1){
location.replace("/");
}
NumOnlyC("ratingnum");
$(".ratingsubmit").click(function() {
    if($(this).parent().parent().find(".ratingnum").val().length > 3 || $(this).parent().parent().find(".ratingnum").val() > 100){
        alert('Ratings cannot exceed 100%');
        return false;
     }
     if($(this).parent().parent().find(".ratingnum").val() < 60){
        var confirmation = window.confirm("Are you sure you want to rate this member that poorly?");
        if(confirmation == true)
            return true;
        else
            return false;
     }
     if($(this).parent().parent().find(".ratingcomment").val().length > 100){
         alert('Comments cannot exceed 10 characters in length.')
         return false;
     }
     return true;
});
}

function submitAccountReg() {
$("#submitbutton_s").click(function() {
     $("#UNI").val($("#locres").val());
     $("#city").val($("#locres :selected").text());
     $("#hboxeditor").val();
     $("#accountForm").submit();
});
}

function submitAccountRegView() {
$("#submitbutton_sv").click(function() {
     $("#UNI").val($("#locres").val());
     $("#city").val($("#locres :selected").text());
     $("#hboxeditor").val();
     $("#saveandview.x").val("asdfasdf");
     $("#accountForm").submit();
});
}

function regAccountSiteCheck() {
$(document).ready(function() {
$("#siteForm").validate();
$("#permanentSite").rules('add',{required: true, minlength: 4, maxlength:30});
  URLRemove("permanentSite");
  accountConfirmation();
 });
}

function accountConfirmation(){
$("#siteavailable").click(function() {
    if($("#permanentSite").val().length > 3){
    var confirmation = window.confirm("If available, are you sure you want " + $("#permanentSite").val() + " as your url?");
    if(confirmation == true)
        return true;
    else
        return false;
}return true;});
}

function dispEditBC(){
   $(".editDisplayButton").bind("mouseenter",function(){
   $(this).css({'text-decoration': 'underline','cursor':'pointer'});
   });
   $(".editDisplayButton").bind("mouseleave",function(){
   $(this).css({'text-decoration': 'none'});});
}

function regPublicationsCheck() {
$(document).ready(function() {  
    $("#publicationsForm").validate();
    $("#name").rules('add',{required:true, maxlength:35});
    $("#tags").rules('add',{required:true, maxlength:50});
    $("#hboxeditor").rules('add',{maxlength:19000});
    $("#publicationsForm input").css('color','blue');
    $(".addItem").show();
    if(readCookie("loggedin") == 1){
         location.replace("/");
    }
    addEntry();
    showListings();
    hideListings();
     $(".deletepublication").click(function() {
    var confirmation = window.confirm("Are you sure you want to delete this listing?");
    if(confirmation == true)
        window.location="/actm/publications?delete=publications&URL="+$(this).attr("url");
    });
    updatepicture();
    viewHelp();
    submitForm();
    textCounterAbstract();
 });  
}

function regProductionsCheck() {
$(document).ready(function() {
    $("#productionsForm").validate();
    $("#name").rules('add',{required:true, maxlength:50});
    $("#hboxeditor").rules('add',{maxlength:19000});
    $("#productionsForm input").css('color','blue');
    $(".addItem").show();
    if(readCookie("loggedin") == 1){
         location.replace("/");
    }    
    date();
    addEntry();
    showListings();
    hideListings();
    $(".deletepublication").click(function() {
    var confirmation = window.confirm("Are you sure you want to delete this listing?");
    if(confirmation == true)
        window.location="/actm/productions?delete=productions&URL="+$(this).attr("url");
});
updatepicture();
viewHelp();
submitForm();
 });
}

function regEmailChangeCheck() {
$(document).ready(function() {  
    $("#emailChangeForm").validate();
    $("#new1").rules('add',{required:true,email:true,maxlength:35});
    $("#new2").rules('add',{required:true,email: true,equalTo:'#email'});
 });  
}

function addEntry() {
$("#addItem").click(function() {
window.location = $("#NewEntryURL").attr('href');
});
}

function showListings() {
$("#showlistings").click(function() {
$("#listingtable").show();
$(this).hide();
$("#hidelistings").show();
});
}

function hideListings() {
$("#hidelistings").click(function() {
$("#listingtable").hide();
$(this).hide();
$("#showlistings").show();
});
}

function sliderReg() {
    $(document).ready(function() {
 $('div .sliderGallery').each(function() {
    var ul = $('ul',this);
    var itemsWidth = ul.innerWidth() - $(this).outerWidth();    
    $("#hand").draggable({axis:'x',containment:'#slide'});

if(ul.innerWidth() > 442){
    $('.slider', this).slider({
          min: -40,
          max: itemsWidth+80,
          step:(itemsWidth+80)/8,
          slide: function (event, ui) {             
                $('#hand').css('left',ui.value*(301/itemsWidth));
                ul.css('left',-1*ui.value);         
     }});}
 });});
}

function Enable(itemID) {    
var element = "#"+itemID+" :input";
$(element).css('color','blue');

if($(element).attr('disabled') == undefined) {
        $(element).attr('disabled','true');
        $("#"+itemID+" .addItem").hide();
}
else {                
      $(element).removeAttr('disabled');
      $("#email").attr('readonly','true');
      $("#email").css('background','lightgrey');
      $("#"+itemID+" .addItem").show();
}}

function createCookie(name,value,days) {
if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
}
else
expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}

return null;
}

function eraseCookie(name) {
    createCookie(name,"",-1);
}

function stateLocator(){
$("#country").change(function() {
    var country = $("#country").val();
    $("#stateinfo").html('');
    $("#found").hide();
    $("#city").val(""); 
    if(country == 'US'){          
      $("#busy").ajaxStart(function(){
          $(this).show();             
      });
      $.post("/locator?country=" + jQuery.trim($("#country").val()), function(data) {
           $("#states").html(data)
      });
      $("#busy").ajaxStop(function(){
         $(this).hide();       
       });
    }else
       $("#stateinfo").attr('disabled','disabled');
    });
 }


 function stateSearchLocator(){
$("#country").change(function() {
    $("#city").val('');
    var country = $("#country").val();
    if(country == 'US'){
      $("#stateinfo").show();
    }else
      $("#stateinfo").hide();
    });
 }
 
function stateSelect(){
$("#stateinfo").change(function() {
    $("#city").val("");
    $("#found").hide();
});
}
 
function cityLocator(){
$("#city").bind("keyup",function() {
if($("#city").val().length >= 3){
    $("#busy").ajaxStart(function(){
      $(this).show();
      $("#glazz").hide();
  });
      $.post("/locator?country=" + jQuery.trim($("#country").val()) + "&stateinfo=" + jQuery.trim($("#stateinfo").val()) +   "&city=" + jQuery.trim($("#city").val().replace(/ /g,"%20")), function(data) {
      $("#found").html(data);
      $("#found").show();
      //   $(this).autocompete(data);
       mapDisp();
      $("#busy").ajaxStop(function(){
     $(this).hide();
     $("#glazz").show();
   });
});}});
}

function searchnm(){
stateSearchLocator();
citySearchLocator();
searchType();
stateSelect();
worldSearch();
searchTextRequired();
date();
citySelect();
seHover();
}

function searchnmMember(){
searchTypeMember();
searchTextRemove();
searchTextRequiredME();
searchTextRequiredMEImageClick();
}

function clearValue(id){
    $("#"+id).val('');
}

function citySelect(){
 $("#city").click(function() {
    $(this).val('')
 });
}

function citySearchLocator(){
$("#city").bind('keyup',function(event) {
if($("#city").val().length >= 3 && event.keyCode != 40 && event.keyCode != 38 && event.keyCode != 13){
    $("#found").html('');
    var country = $("#country").val();
    if(country == 'US')
        url = "/locator?country=" + jQuery.trim($("#country").val()) + "&stateinfo=" + jQuery.trim($("#stateinfo").val()) +   "&city=" + jQuery.trim($("#city").val().replace(/ /g,"%20") + "&search=b");
    else
         url = "/locator?country=" + jQuery.trim($("#country").val()) + "&city=" + jQuery.trim($("#city").val().replace(/ /g,"%20") + "&search=b");
   $.post(url, function(data) {
     $("#found").html(data);
  //   mapDisp();
     $("#locres option:first").attr("selected","selected");
     citySearchSelected();
     citySearchBlurSelected();
     cityScrollBlurSelected();
     cityScrollEnteredSelected();
});    
     $("#found").fadeIn("slow");
}else if(event.keyCode == 40){
        if($("#locres option").size() >= 1){
        $("#locres").focus();
        $("#locres option:eq(0)").attr("selected","selected");
        $("#city").val($("#locres option:selected").text());
        mapSearchDisp();
        }cityScrollFoundList();
}else if(event.keyCode == 13){
       $("#city").val($("#locres option:selected").text());
       $("#found").fadeOut("slow");
       $("#city").focus();
}});
}

function citySearchSelected(){
$("#locres").click(function() {
    $("#UNI").val($("#locres").val());
    $("#lat").val($('#'+ $("#locres").val()+'lat').val());
    $("#longt").val($('#' + $("#locres").val()+'longt').val());
    $("#city").val($("#locres :selected").text());
   // $("#found").fadeOut("slow");
  //  $("#city").focus();
});
}

function submitenter(myfield,e){
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;

if (keycode == 13){
    if(requiredSearch())
        myfield.form.submit();
   return false;
}else
   return true;
}

function cityScrollFoundList(){
$("#locres").change(function() {
    $("#city").val($("#locres option:selected").text());
});
$("#locres").bind('keyup',function(event) {
    if(event.keyCode == 13){
        $("#city").focus();
    }
});
}

function citySearchBlurSelected(){
$("#city").bind("blur",function() {
    if($("*:focus").attr("id") != 'locres'){
        $("#UNI").val($("#locres").val());
        $("#lat").val($('#'+ $("#locres").val()+'lat').val());
        $("#longt").val($('#' + $("#locres").val()+'longt').val());
        $("#city").val($("#locres :selected").text());
      //  $("#found").fadeOut("slow");
}});
}

function cityScrollBlurSelected(){
$("#locres").bind("blur",function() {
    if($("*:focus").attr("id") != 'locres'){
        $("#UNI").val($("#locres").val());
        $("#lat").val($('#'+ $("#locres").val()+'lat').val());
        $("#longt").val($('#' + $("#locres").val()+'longt').val());
        $("#city").val($("#locres :selected").text());
        $("#found").fadeOut("slow");
}});
}

function cityScrollEnteredSelected(){
$("#locres").bind("keyup",function(event) {
    if(event.keyCode == 13){
    $("#UNI").val($("#locres").val());
    $("#lat").val($('#'+ $("#locres").val()+'lat').val());
    $("#longt").val($('#' + $("#locres").val()+'longt').val());
    $("#city").val($("#locres :selected").text());
  //  $("#found").fadeOut("slow");
}});
}

function searchType(type){
var url = 'empty';
generalType(type);
$("#searchdate").hide();
$("#searchtypechanges").hide();
$("#locationinfo").hide();
if(type == 'store'){
    $("#worldsearch").show();
    $("#searchtypechanges").show();
    $("#locationinfo").show();
    if($('#worldwide').attr('checked'))
        $(".location").attr('disabled','disabled');
    url = '/search/?locator=1&type=store'
}else if(type == 'wanted'){
    $("#searchtypechanges").show();
    $("#worldsearch").show();
    $("#locationinfo").show();
    if($('#worldwide').attr('checked'))
        $(".location").attr('disabled','disabled');
    url = '/search/?locator=1&type=wanted';
}else if(type == 'services'){
    $("#worldsearch").show();
    $("#searchtypechanges").show();
    $("#locationinfo").show();
    if($('#worldwide').attr('checked'))
        $(".location").attr('disabled','disabled');
    url = '/search/?locator=1&type=services';
}else if(type == 'rentals'){
    $("#worldsearch").show();
    $("#searchtypechanges").show();
    $("#locationinfo").show();
    if($('#worldwide').attr('checked'))
        $(".location").attr('disabled','disabled');
    url = '/search/?locator=1&type=rentals';
}else if(type == 'publications'){
    publicationsType();
}else if(type == 'members'){
    membersType();
}else if(type == 'events'){
     $("#searchtypechanges").hide();
     $("#locationinfo").show();
     $("#searchdate").show();
     $('#worldwide').attr('checked',false)
}else{
    membersType();
}

if(type == null || type.length == 0 || type == undefined)
    $("#searchtype").val('members');
else
    $("#searchtype").val(type);
if(url != 'empty' && type != 'videos'){
    $.post(url, function(info) {
        $("#searchtypechanges").show();
        $("#searchtypechanges").html(info);
    });
}}

function searchTextRemove(){
$("#searchField").click(function(){
    $(this).val("");
});
}

function searchTextRequiredME(){
$("#searchField").keypress(function(e) {
if($(this).val().length < 3 && e.keyCode == 13){
        alert('Please enter more than 2 characters when searching');
        return false;
}else if($(this).val().length >= 35 && e.keyCode == 13){
        alert('Please enter no more than 35 characters when searching');
        return false;
}else if(e.keyCode == 13){
    var searchtype= $("#search input:checked").val();
    if(searchtype == 'services' || searchtype == 'store')
        window.location = "/search?worldwide=on&searchtype="+$("#search input:checked").val()+"&searchtext="+$("#searchField").val();
    else
        window.location = "/search?searchtype="+$("#search input:checked").val()+"&searchtext="+$("#searchField").val();
}});
}

function searchTextRequiredMEImageClick(){
$("#searchclick").click(function() {
if($("#searchField").val().indexOf('Search') != -1){
    alert('Please enter more than 2 characters when searching');
    return false;
}
if($("#searchField").val().length < 3){
    alert('Please enter more than 2 characters when searching');
    return false;
}else if($("#searchField").val().length >= 35){
    alert('Please enter no more than 35 characters when searching');
    return false;
}else{
    var searchtype= $("#search input:checked").val();
    if(searchtype == 'services' || searchtype == 'store')
        window.location = "/search?worldwide=on&searchtype="+$("#search input:checked").val()+"&searchtext="+$("#searchField").val();
    else
        window.location = "/search?searchtype="+$("#search input:checked").val()+"&searchtext="+$("#searchField").val();
}return false;});
}

function searchTypeMember(type){
$("#search input").click(function(){
    if($(this).val() == 'advanced')
        window.location = "/search";
});
}

function requiredSearch(){
 if((!$('#worldwide').attr('checked') && $("#city").val() == '') && $("#searchtype").attr('value') != 'publications' && $("#searchtype").attr('value') != 'store' && $("#searchtype").attr('value') != 'members'){
        $("#cityerrormessage").click();
        return false;
    }

    if($("#searchtype").val() == 'events' && $("#datepicker").val() == 'Date'){
        $("#dateerrormessage").click();
        return false;
    }     

    if($("#searchtext").val().length < 2  && $("#searchtype").val() != 'events' && $("#searchtype").val() != 'wanted'){
        $("#errormessage").click();
        $("#searchtext").css('background','yellow');
        return false;
    }

    if($("#searchtype").val() != 'members' && $("#searchtype").val() != 'store' && $("#searchtype").val() != 'videos' && $("#searchtype").val() != 'publications' && $("#searchtype").val() != 'events' && $("#subsearchtype").length != 0 && $("#subsearchtype :selected").text() == ''){
        $("#errorsubsearch").click();
        return false;
    }

    if($("#searchtext").val().length > 35){
        $("#errormessagemax").click();
        return false;
    }

    if($("#UNI").val() == '' && !$('#worldwide').attr('checked') && $("#searchtype").attr('value') != 'publications' && $("#searchtype").attr('value') != 'videos' && $("#searchtype").attr('value') != 'store' && $("#searchtype").attr('value') != 'members'){
        $("#cityselecterrormessage").click();
        return false;
    }

    if($("#searchtype").attr('value') == 'members' && $("#searchtext").val().length < 2){
        $("#errormessage").click();
        return false;
    }else
        return true;
}

function searchTextRequired(){
$("#searchbutton").click(function() {
   return requiredSearch();
});
}

function membersType(){
//$("#subsearchtype").attr('disabled','disabled');
$(".location").attr('disabled','disabled');
$("#city").css('background','#d4d0cd');
$("#searchdate").hide();
}

function publicationsType(){
$(".location").attr('disabled','disabled');
$("#subsearchtype").removeAttr('disabled');
$("#city").css('background','#d4d0cd');
$("#searchdate").hide();
}

function locationWorldwide(){
    $(".location").attr('disabled','disabled');
}

function generalType(type){
    $(".location").removeAttr('disabled');
    $("#city").css('background','white');
    if(type == 'services'){
        $("#worldsearch").show();
        $("#searchtypechanges").show();
        $("#locationinfo").show();
        if($('#worldwide').attr('checked'))
            $(".location").attr('disabled','disabled');
        $("#searchdate").hide();
    }else if(type == 'rentals'){
        $("#worldsearch").show();
        $("#searchtypechanges").show();
        $("#locationinfo").show();
        if($('#worldwide').attr('checked'))
            $(".location").attr('disabled','disabled');
        $("#searchdate").hide();
    }else if(type == 'events'){
        $("#locationinfo").show();
        $("#searchdate").show();
    }else if(type == 'wanted'){
        $("#locationinfo").show();
        $("#worldsearch").show();
        $("#searchtypechanges").show();
        if($('#worldwide').attr('checked'))
            $(".location").attr('disabled','disabled'); 
    }else if(type == 'store'){
        $("#worldsearch").show();
        $("#searchtypechanges").show();
        $("#locationinfo").show();
        if($('#worldwide').attr('checked'))
            $(".location").attr('disabled','disabled');
        $("#searchdate").hide();
    }else{
        $("#worldsearch").hide();
        $("#searchdate").hide();
    }       
}

function worldSearch(){
$("#worldwide").click(function() {
    if($('#worldwide').attr('checked')){
        $(".location").attr('disabled','disabled');
        $("#city").css('background','#d4d0cd');
    }
    else{
        $(".location").removeAttr('disabled');
        $("#city").css('background','white');
    }        
});
}

function map(lat, longitude, name) {
  if (GBrowserIsCompatible()) {
    var map = new GMap2(document.getElementById("map_canvas"));
    map.addControl(new GLargeMapControl());
    map.addControl(new GMapTypeControl());
    map.setCenter(new GLatLng(lat, longitude), 8);
    // Set the default center and zoom
    var marker = new GMarker(new GLatLng(lat, longitude));
    map.addOverlay(marker);
    //map.disableDragging();
}}

function date(){
$('#datepicker').datepicker({
    changeMonth: true,
    changeYear: true,
    yearRange: '-90:+0'
});
}

function date2(){
$('#datepicker').datepicker({
    changeMonth: true,
    changeYear: true,
    yearRange: '-0:+1'
});
}

function date3(){
$('#enddatepicker').datepicker({
    changeMonth: true,
    changeYear: true,
    yearRange: '-0:+1'
});
}

function mapDisp(){
$("#locres").click(function(){
    $("label.error").empty();
    var id = $(this).val();
    var lat = $("#"+id+"lat").val();
    var longt = $("#"+id+"longt").val();
    var name = $("#"+id+"name").val();
    $("#city").val(name);
    $("#UNI").val($("#locres").val());
    map(lat,longt,name);
});
}

function cityInitialize(){
    $("#locres option:first").attr("selected","selected");
    var id = $("#locres option:first").val();
    $("#UNI").val(id);
}

function mapSearchDisp(){
$("#locres").change(function(){
    mapSearchSelect();
});
}

function mapSearchSelect(){
    var id = $("#locres").val();
    var lat = $("#"+id+"lat").val();
    var longt = $("#"+id+"longt").val();
    var name = $("#"+id+"name").val();
    $("#city").val(name);
    $("#UNI").val($("#locres").val());
    map(lat,longt,name);
}

function countSelected(select,maxNumber,display){
   var selectedOptions = [];
   for(var i=0; i<select.options.length; i++){
     if(select.options[i].selected && !new RegExp(i,'g').test(selectedOptions.toString())){
        selectedOptions.push(i);
     }

     if(!select.options[i].selected && new RegExp(i,'g').test(selectedOptions.toString())){
      selectedOptions = selectedOptions.sort(function(a,b){return a-b});
       for(var j=0; j<selectedOptions.length; j++){
            selectedOptions.splice(j,1);
         }
       }
    if(selectedOptions.length > maxNumber){
        $("#"+display).html("only " + maxNumber + " selections allowed");
        select.options[i].selected = false;
        selectedOptions.pop();
        document.body.focus();
     }}     
   }


function stopRKey(evt) {
  var evt = (evt) ? evt : ((event) ? event : null);
  var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
  if ((evt.keyCode == 13) && (node.type=="text"))  {return false;}
}

function roleSelect(id,selectText,cid){
   var contains = false;
   var osel = false;
   $('#role :selected').each(function(i, selected){
       if($(this).text() == 'other')
           osel = true;}); 
   if(osel == true)
       $("#roletype").show();
    
   $("#role").change(function(){
       $('#role :selected').each(function(i, selected){
       if($(this).text() == 'other')
           contains = true;});
       
       if(contains == true)
         $("#roletype").show();
       else
        $("#roletype").hide();
        contains = false;
    });   
}

function meetingSelect(selectText,id){
   var contains = false;
   var osel = false;
   $('#meetingtypes :selected').each(function(i, selected){
       if($(this).text() == selectText)
           osel = true;});
   if(osel == true && $("#meetinggroup:checked").val()=='MeetingGroup')
       $("#"+id).show();

   $("#meetingtypes").change(function(){
       $('#meetingtypes :selected').each(function(i, selected){
       if($(this).text() == selectText)
           contains = true;});

       if(contains == true)
         $("#"+id).show();
       else{
           $("#"+id).hide();
           $('#'+id+' option').attr('selected', false);
       }        
        contains = false;
    });
}

function eventSelect(){
   if($("#eventsheld option:selected").text().indexOf('Other',0) != -1)
            $("#eventtype").show();

   $("#eventsheld").change(function(){
       if($("#eventsheld option:selected").text().indexOf('Other',0) != -1){
           $("#eventtype").show();
           $("#eventtp").rules('add',{required: true, minlength:5});
       }
       else{
           $("#eventtp").val('');
           $("#eventtype").hide();
           $("#eventtp").rules('remove');
        }
    });
}

function rate() {
$("#rate").click(function() {
if($(this).attr('rated') == 'true'){
    $("#starshiner").show();
    $("#rating").val('0');
    $(this).attr('rated','false');

}else{
    $("#starshiner").hide();
    $("#rating").val('-1');
    $(this).attr('rated','true');
}});
}

function starsetter(){
     $("#starshiner").hide();
     $("#rate").attr('rated','true');
}

function devGroup(id,val,cid,oid) {
$("#"+id).click(function() {
if($("#"+id+":checked").val()==val) {
    $("."+cid).show();
    roleSelect();
    meetingSelect("Other","meetingtype");
    meetingSelect("Join a Band ***","jointype");
    meetingSelect("Join a Dance Troupe ***","dancetype");
}
else {
    $("."+cid).hide();
    if(oid != null)
        $("#"+oid).hide();
}});
}

function player() {
$(document).ready(function() {
flowplayer("player", "/flash/flowplayer.commercial-3.1.5.swf",{
    canvas:  {backgroundColor: "#ffffff",
    backgroundGradient: 'none'},
          plugins: {controls: null},
          play: null,
          key: '#$aa3f93f2d9ceb6965cc',
          clip: {autoPlay: true,
                   autoBuffering: true,
                   scaling: 'fit',
                   duration: 40,
                   fadeOutSpeed: 8000,
                   fadeInSpeed: 8000,
                   bufferLength: 3,
                   linkUrl: 'http://www.phoneboogie.com',
                   linkWindow: '_blank'
                  },
          playlist: ['/img/phone.gif',
              {url: '/flash/phone.flv',duration:19,onBeforeFinish: function(){
                return false;
            }}],
        logo: {
            opacity: 0
        }
          });
});
}

function login() {
 $("#logina").click(function() {
  $.post('/login', function(data) {
        $("#butter").html(data);
});});
}

function dispEdit(element){
   $(element).bind("mouseenter",function(){
   $(this).css({'text-decoration': 'underline','color':'blue','cursor':'pointer'});});
   $(element).bind("mouseleave",function(){
   $(this).css({'text-decoration': 'none','font-style':'normal'});});
}

function nmfront(){
   login();
   viewInfo();
  // player();   
}

function scrollRight(){
$("#sright").click(function() {
if(($("#picturesize").val() - pictureslider)/6 > 0 && pictureslider != 0){
    $(".block").animate({"left": "+=468px"}, "fast");
    pictureslider += 6;
    $("#sleft").show();
    if(pictureslider == 0){
        $(this).hide();
    }
}});}

function sLeft(){
$("#sleft").click(function() {
var diff = $("#picturesize").val() - Math.abs(pictureslider);
if(diff > 6){
    $(".block").animate({"left": "-=468px"}, "fast");
    pictureslider -= 6;
    $("#sright").show();
    if($("#picturesize").val() - Math.abs(pictureslider) <= 6)
        $(this).hide();
}});}

function back(){
window.onbeforeunload = function () {
   location.replace("/");
}}

/*function load(swfobj,fileid){
    $.swfupload.getInstance('#swfupload-control').addPostParam('description',$('#photoinput'+fileid).val());
    swfobj.swfupload('startUpload');
}

function loadback(swfobj,fileid){
    $.swfupload.getInstance('#swfupload-controlback').addPostParam('description',$('#photoinput'+fileid).val());
    swfobj.swfupload('startUpload');
}*/

function photoloaders(){
    submitphotos();
    usesimpleloader();
    deletepicture();
}

function submitphotos(){
$("#photosubmit").click(function() {
    if(changed == true){
    var confirmation = window.confirm("Are you sure you want to load photos without saving your changes?");
    if(confirmation == true)
        swfphotoloader.swfupload('startUpload');
    else{
        return false;
}}else
     swfphotoloader.swfupload('startUpload');
});
}

function hasFile(){
$("input:file").change(function() {
$("#simpleloaderform #submitbutton").show();
});
}



function usesimpleloader(){
$("#usesimpleloader").click(function() {
$("#simpleloaderform").show();
$("#simpleloader2").hide();
$("#photosubmit").hide();
$("#simpleloaderform #submitbutton").hide();
});
}


function photoLoader(paramload,type,posturl,url,picturelimit,filetype,buttonid){
var ERROR = false;
pictures = [];
count = 0;
var uploadfiletype;
var uploadfiledescription;
var uploadfilesize;
var buttonidentity;
var control;
var log;
var field;
var loader;
if(filetype == 'MP3'){
       uploadfiletype = "*.mp3;";
       uploadfiledescription = "Audio files";
       uploadfilesize = "450KB";
}else{
    uploadfiletype = "*.jpg;*.gif;*.png;";
    uploadfiledescription = "Image files";
    uploadfilesize = "10MB";
}
if(buttonid != null){
    buttonidentity = buttonid;
    control = 'swfupload-controlback';
    log='logb';
    field='fieldb';
    loader = '</li><input id="photoinput'+count+'" type="text" maxlength="25"><input type="button" id="upload'+count+'" value="Submit" onclick="javascript:loadback(pictures[0],'+count+');">';
}else{
    buttonidentity='button';
    control = 'swfupload-control';
    log='log';
    field='field';
    loader = '</li><input id="photoinput'+count+'" type="text" maxlength="25"><input type="button" id="upload'+count+'" value="Submit" onclick="javascript:load(pictures[0],'+count+');">';
}

var swf = $('#'+control).swfupload({
     upload_url: url,
     file_size_limit : uploadfilesize,
     file_types : uploadfiletype,
     file_types_description : uploadfiledescription,
     file_upload_limit : picturelimit,
     flash_url : "/js/swfupload.swf",
     button_image_url:'/img/button_sprite.png',
     button_width : 125,
     button_height : 35,
     button_text : "<span class='redText'>Browse</span>",
     button_text_style:".redText { color: #0000ff;font-size:24px;font-weight:bold;margin-left:25px;display:block; }",
     button_placeholder : $('#'+buttonidentity)[0],
     button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
     button_cursor: SWFUpload.CURSOR.HAND,
     debug: false,
     post_params : {"post_param_name" : paramload,
     "post_param_name2" : posturl}
     })
     .bind('fileQueued', function(event, file){
         count += 1;         
         var listitem='<li id="'+file.id+'" >'+
             '<em>'+file.name+'</em> ('+Math.round(file.size)+' Bytes) <span class="progressvalue" ></span>'+
             '<div class="progressbar" ><div class="progress" ></div></div>'+
             '<p class="status" ></p>'+
             '<span class="cancel" >&nbsp;</span>';
         $("#photosubmit").show();
         $('#'+log).append(listitem);
         $('li#'+file.id+' .cancel').bind('click', function(){ //Remove from queue on cancel click
             var swfu = $.swfupload.getInstance('#'+control);
             swfu.cancelUpload(file.id);
             $('li#'+file.id).slideUp('fast');
             $('#photoinput'+count).remove();
             $('#upload'+count).remove();
             var stats = $.swfupload.getInstance('#'+control).getStats();
             if(stats.files_queued == 0){
                 $('#'+field).slideUp('fast');
                 window.location = "/actm/"+type+"?"+posturl;
             }                 
         }); 
         // start the upload since it's queued
         pictures[0] = $(this); //rules('add',{required: true, maxlength:10})         
     })
     .bind('fileQueueError', function(event, file, errorCode, message){
        try {
            if (errorCode == SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED) {
                    alert("You have attempted to queue too many files.\n" + (message === 0 ? "You have reached the upload limit." : "You may select " + (message > 1 ? "up to " + message + " files." : "one file.")));
                    ERROR = true;
                    window.location.reload(false);
                    return;
            }else if(errorCode == SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT){
                    alert("File too big, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
                    ERROR = true;
                    window.location = "/actm/"+type+"?"+posturl;
                    return;
            }else if(errorCode == SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE){
                    alert("Zero byte file, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
                    ERROR = true;
                    window.location.reload(false);
                    return;
            }else if(errorCode == SWFUpload.QUEUE_ERROR.INVALID_FILETYPE){
                    alert("Invalid File Type, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
                    ERROR = true;
                    window.location.reload(false);
                    return;
            }else{
                    alert("An unexpected error occured.  We apologize for the incovenience.  Should the problem persist, kindly contact \n\
                        our Webmaster: info@notemote.com");
                    ERROR = true;
                    window.location.reload(false);
                    return;
            }
    } catch (ex) {
}})
     .bind('fileDialogComplete', function(event, numFilesSelected, numFilesQueued){
         if(numFilesSelected != 0 && ERROR == false)
            $("#"+field).css('display','block');

     })
     .bind('uploadStart', function(event, file){
         $.swfupload.getInstance('#'+control).addPostParam("watermark", $("#watermark:checked").val());
         $.swfupload.getInstance('#'+control).addPostParam("recording", $("#recording option:selected").val());
         $.swfupload.getInstance('#'+control).addPostParam("filename", file.name);
         var item=$('#'+log+ ' li#'+file.id);
         item.addClass('success').find('p.status').html('Pending...');
         $('#'+log+ 'li#'+file.id).find('span.progressvalue').text('0%');
         $('#'+log+ 'li#'+file.id).find('span.cancel').hide();
     })
     .bind('uploadProgress', function(event, file, bytesLoaded){
         //Show Progress
         var percentage=Math.round((bytesLoaded/file.size)*100);
         var item=$('#'+log+ ' li#'+file.id);
         item.addClass('success').find('p.status').html('Uploading...');
         item.find('div.progress').css('width', percentage+'%');
         item.find('span.progressvalue').text(percentage+'%');
     })
     .bind('uploadSuccess', function(event, file, serverData){
         var item=$('#'+log+ ' li#'+file.id);
         item.find('div.progress').css('width', '100%');
         item.find('span.progressvalue').text('100%');
         $(".status").text("");
         item.addClass('success').find('p.status').html('Done!!!');
     })
     .bind('uploadComplete', function(event, file){
         // upload has completed, try the next one in the queue
         var stats = $.swfupload.getInstance('#'+control).getStats();
         if(stats.files_queued == 0){
             window.location = "/actm/"+type+"?"+posturl;
         }
         else{
             $.swfupload.getInstance('#'+control).removePostParam(file.name);
             $(this).swfupload('startUpload');
         }})
     .bind('uploadError ', function(event, file){
         // upload has completed, try the next one in the queue
         //alert(event.detail);
     })

    swfphotoloader = swf;
}

function mailaddress(){
$("#subject").bind('focus', function() {
$.post('/maildispatcher/find', function(data) {
        $("#to").html(data);
});});}

function captcha(){
$(document).ready(function() {
Recaptcha.create("6LfPwwsAAAAAAKt6AfOG_zdmcOkWNLqNyfEBG2fU&lang=en",'recaptcha_image', {
        theme: 'custom',
        custom_theme_widget: 'recaptcha_widget',
        callback: Recaptcha.focus_response_field
  });
  $("#recaptcha_widget").css('display','inline');
});}


function mapit(lat, longitude,name){
if (GBrowserIsCompatible()) {
    var map = new GMap2(document.getElementById('map'));
    map.addControl(new GLargeMapControl());
    map.addControl(new GMapTypeControl());
    map.setCenter(new GLatLng(lat, longitude), 14);
    // Set the default center and zoom
    var marker = new GMarker(new GLatLng(lat, longitude));
    map.addOverlay(marker);
    GEvent.addListener(marker, "click", function(){
    marker.openInfoWindowHtml("<div style='font-family:Arial;font-size:8pt'><strong>"+name+"...</strong></i></div><img src='/img/nmhome.gif' style='margin-left:150px;' alt=''/>");
    });
    marker.openInfoWindowHtml("<div style='font-family:Arial;font-size:8pt'><strong>"+name+"...</strong></i></div><img src='/img/nmhome.gif' style='margin-left:150px;' alt=''/>");
    var myPano = new GStreetviewPanorama(document.getElementById("pano"));
   // svOverlay = new GStreetviewOverlay();
  //  map.addOverlay(svOverlay);
    GEvent.addListener(map,"click", function(overlay,latlng) {
      myPano.setLocationAndPOV(latlng);
    });
   // myPano.setLocationAndPOV(new GLatLng(lat,longitude));
}}

function mapitAddress(address,name){
if (GBrowserIsCompatible()) {
    address = address.replace(/%2C/g,"");
    var map = new GMap2(document.getElementById('map'));
    map.addControl(new GLargeMapControl());
    map.addControl(new GMapTypeControl());
    var geocoder = new GClientGeocoder();
    geocoder.getLatLng(address,function(point){
    // Set the default center and zoom
    if(point == null){       
        geocoder.getLatLng(address,function(point2){
            if(point2 == null)
                alert(address + " not found");
            else{
                var marker = new GMarker(point2);
                map.setCenter(point2, 16);
                map.addOverlay(marker);
                name=name.replace(new RegExp('\\+','g'),' ');
                name = unescape(name);
                GEvent.addListener(marker, "click", function(){
                marker.openInfoWindowHtml("<div style='font-family:Arial;font-size:8pt'><strong>"+name+"...</strong></i></div><img src='/img/nmhome.gif' style='margin-left:150px;' alt=''/>");
                });
                marker.openInfoWindowHtml("<div style='font-family:Arial;font-size:8pt'><strong>"+name+"...</strong></i></div><img src='/img/nmhome.gif' style='margin-left:150px;' alt=''/>");
                var myPano = new GStreetviewPanorama(document.getElementById("pano"));
                svOverlay = new GStreetviewOverlay();
                map.addOverlay(svOverlay);
                GEvent.addListener(map,"click", function(overlay,point2) {
                  myPano.setLocationAndPOV(point2);
                });
                myPano.setLocationAndPOV(point2);
            }
        });
    }else{
    var marker = new GMarker(point);
    map.setCenter(point, 16);
    map.addOverlay(marker);
    name=name.replace(new RegExp('\\+','g'),' ');
    name = unescape(name);
    GEvent.addListener(marker, "click", function(){
    marker.openInfoWindowHtml("<div style='font-family:Arial;font-size:8pt'><strong>"+name+"...</strong></i></div><img src='/img/nmhome.gif' style='margin-left:150px;' alt=''/>");
    });
    marker.openInfoWindowHtml("<div style='font-family:Arial;font-size:8pt'><strong>"+name+"...</strong></i></div><img src='/img/nmhome.gif' style='margin-left:150px;' alt=''/>");
    var myPano = new GStreetviewPanorama(document.getElementById("pano"));
    svOverlay = new GStreetviewOverlay();
    map.addOverlay(svOverlay);
    GEvent.addListener(map,"click", function(overlay,point) {
      myPano.setLocationAndPOV(point);
    });
    myPano.setLocationAndPOV(point);
}});}}

function morestat(){
$(".memberInfo").show();
$("#more").hide();
}

function regGallery(){
$("#pictureForm").validate();
$("#title").rules('add',{required: true, maxlength:35});
$("#hboxeditor").rules('add',{maxlength:19000});
addEntry();
showListings();
hideListings();
$(".deletepublication").click(function() {
    var confirmation = window.confirm("Are you sure you want to delete this listing?");
    if(confirmation == true){
       if($(this).attr('type') == 'galleryh')
             window.location="/actm/galleryh?delete=galleryh&URL="+$(this).attr("url");
       else
         window.location="/actm/gallery?delete=gallery&URL="+$(this).attr("url");
    }
});
deletepicture();
updatepicture();
viewHelp();
ckeditornl();
submitForm();
}

function analytics(){
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
try {
var pageTracker = _gat._getTracker("UA-3376991-3");
pageTracker._trackPageview();
}
catch(err) {}
}

function asynanalytics(){
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-3376991-3']);
_gaq.push(['_trackPageview']);
var ga = document.createElement('script');ga.type = 'text/javascript';ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0];s.parentNode.insertBefore(ga, s);
}

function determineChanged(){
$(':input').bind("change keyup", function() {
   changed = true;
});

$('iframe').bind("focus", function() {
    changed = true;
});

$('li a, .change').click(function() {
if(changed == true){
var confirmation = window.confirm("Are you sure you want to leave this page without saving your changes?");
if(confirmation == true)
    return true;
else
    return false;
}});
}

function showApplet(){
    $('#photozone').show();
}

function playSong(){
$(".songplayer").click(function() {
    wimpyButtonPlayPause($(this).attr('song'));
});
}

function regMobile(){
$("#phoneform").validate();
$("#submitphone").click(function(){
    if($("#phoneform").valid())
        submitPhone();
    return false;
})
$("#phonenumber").rules('add',{required: true, minlength: 4});
NumOnly("phonenumber");
$("#messageSenderForm").validate();
$("#message").rules('add',{maxlength: 120});
findcarriers();
phoneConfirmation();
$(".deletepublication").click(function() {
var confirmation = window.confirm("Are you sure you want to delete this listing?");
if(confirmation == true)
    window.location="/actm/mobilenotification?delete=true&Location="+$(this).attr("url");
});
}

function findcarriers(){
$("#country").change(function() {
  var selections = $("#country option:selected").text() + '';
   $.post("/mobilenotification?country="+selections, function(data) {
      $("#carrier").html(data);
     });
});
}

function submitPhone(){
var selections = $("#carrier option:selected").val() + ''; 
$.post("/mobilenotification/?carrier="+selections+"&phonenumber="+jQuery.trim($("#phonenumber").val()), function(data) {
$("#identifier").html(data);
$(".confirmationmessage").show();
});
}

function phoneConfirmation(){
$("#checkconfirmation").click(function(){
var selections = $("#carrier option:selected").val() + '';
$.post("/mobilenotification/?confirmation=true&carnm="+selections+"&phonenumber="+jQuery.trim($("#phonenumber").val())+"&identifiernumber="+jQuery.trim($("#identifiernumber").val()), function(data) {
    $("#confirmationmessage").html(data);
});return false;});
}

function characterCounter(){
$("#charactercounter").html("Character Count: " + ($('#hboxeditor').val().length));
}

function ckeditor(){
CKEDITOR.config.toolbar_MA=[
    ['Cut','Copy','Paste','Print'],
    [ 'TextColor','BGColor' ],
    ['Styles','Format','FontSize','Font'],
    '/',
    ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
    ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'],
    ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
    ['Link','Unlink'],
    ['Table','HorizontalRule','Smiley','SpecialChar'],
    [ 'ShowBlocks'],
    ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat']
];
CKEDITOR.config.disableNativeSpellChecker=true;
CKEDITOR.config.scayt_autoStartup=false;
CKEDITOR.config.width=750;
CKEDITOR.config.removePlugins='scayt';
    $('#hboxeditor').ckeditor(function() {this.on('focus', function() {
    changed = true;
    setInterval( "characterCounter()", 500 );
  });}, {toolbar:'MA',skin : 'v2'} );
}

function ckeditornl(){
CKEDITOR.config.toolbar_MA=[
    ['Cut','Copy','Paste','Print'],
    [ 'TextColor' ],
    ['Styles','Format','Font'],
    '/',
    ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
    ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
    ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
    ['Table','HorizontalRule','Smiley','SpecialChar'],
    [ 'ShowBlocks'],
    ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat']
];
CKEDITOR.config.disableNativeSpellChecker=true;
CKEDITOR.config.scayt_autoStartup=false;
CKEDITOR.config.width=750;
CKEDITOR.config.removePlugins='scayt';
    $('#hboxeditor').ckeditor(function() {this.on('focus', function() {
    changed = true;
    setInterval( "characterCounter()", 500 );
  });}, {toolbar:'MA',skin : 'v2'} );
}

function ckeditornotes(){
CKEDITOR.config.toolbar_MA=[ 
    ['Cut','Copy','Paste','Print'],
    [ 'TextColor','BGColor' ],
    ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
    ['Link','Unlink'],
    ['Smiley','SpecialChar'],
    ['Undo','Redo','-','Replace','-','SelectAll','RemoveFormat']
];
CKEDITOR.config.disableNativeSpellChecker=true;
CKEDITOR.config.scayt_autoStartup=false;
CKEDITOR.config.width=750;
CKEDITOR.config.removePlugins='scayt';
    $('#hboxeditor').ckeditor(function() {this.on('focus', function() {
    changed = true;
    setInterval( "characterCounter()", 500 );
  });}, {toolbar:'MA',skin : 'v2'} );
}

function ckeditornotesnl(){
CKEDITOR.config.toolbar_MA=[
    ['Cut','Copy','Paste','Print'],
    [ 'TextColor','BGColor' ],
    ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
    ['Smiley','SpecialChar'],
    ['Undo','Redo','-','Replace','-','SelectAll','RemoveFormat']
];
CKEDITOR.config.disableNativeSpellChecker=true;
CKEDITOR.config.scayt_autoStartup=false;
CKEDITOR.config.width=750;
CKEDITOR.config.removePlugins='scayt';
    $('#hboxeditor').ckeditor(function() {this.on('focus', function() {
    changed = true;
    setInterval( "characterCounter()", 500 );
  });}, {toolbar:'MA',skin : 'v2'} );
}

function ckeditorPlacer(photos){
CKEDITOR.config.toolbar_MA=[
    ['Cut','Copy','Paste','Print'],
    [ 'TextColor','BGColor' ],
    ['Styles','Format','FontSize','Font'],
    '/',
    ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
    ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'],
    ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
    ['Link','Unlink'],
    ['Table','HorizontalRule','Smiley','SpecialChar'],
    [ 'ShowBlocks','Image'],
    '/',
    ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat']
];
CKEDITOR.config.disableNativeSpellChecker=true;
CKEDITOR.config.width=750;
CKEDITOR.config.scayt_autoStartup=false;
CKEDITOR.config.removePlugins='scayt';
    $('#hboxeditor').ckeditor(function() {this.on('focus', function() {
    changed = true;
    setInterval( "characterCounter()", 500 );
  });}, {toolbar:'MA',skin : 'v2'} );

CKEDITOR.on( 'dialogDefinition', function( ev )
{
    var dialogName = ev.data.name;
        var dialogDefinition = ev.data.definition;
 
    if ( dialogName == 'image' )
        {
            dialogDefinition.removeContents( 'advanced' );
            dialogDefinition.removeContents( 'Link' );
            dialogDefinition.removeContents( 'Upload' );
            var infoTab = dialogDefinition.getContents( 'info' );            
            infoTab.remove('txtUrl');
            infoTab.remove('browse');
            infoTab.remove('txtAlt');
            infoTab.add( {
                    id : 'sites',
                    type : 'select',
                    label : 'Select an illustration',
                    items : [['','']],
                    onChange : function()
                    {
                        var preview = CKEDITOR.document.getById('cowbell');
                        if(this.getValue())
                            preview.setAttribute('src',this.getValue());
                        else
                            preview.setAttribute('src','/img/smalllogo.png');
                    },
                    onLoad : function(){                        
                      for(i=0;i<(photos.length/2);i++) // will always be even
                            this.add(photos[i+i],photos[i+(i+1)]);
                    },commit : function( type, element )
                        {
                                if ( type == 1 && ( this.getValue() || this.isChanged() ) )                                                                                {
                                        element.setAttribute( '_cke_saved_src', decodeURI( this.getValue() ) );

                                        element.setAttribute( 'src', decodeURI( this.getValue() ) );
                                }
                                else if ( type == 8 )
                                {
                                        element.setAttribute( 'src', '' );	// If removeAttribute doesn't work.
                                        element.removeAttribute( 'src' );
                                }


                        }
            });
}});
}

function siteBackground(){
$("#wall").click(function(){
    $("#imagediv").html("<img src='/img/backgrounds/"+$("#wall option:selected").val()+".jpg' alt='' width='60px' height='60'>");
});
}

function siteBackgroundTypeCheck(){
$("input[type='radio']").click(function(){
    if($(this).val() == 'images'){
        $("#imagesback").show();
        $("#bcolordiv").hide();
    }else if($(this).val() == 'color'){
        $("#bcolordiv").show();
        $("#imagesback").hide();
    }        
});
}

function tabs(){
$(document).ready(function() {
//When page loads...
$(".tab_content").hide(); //Hide all content
$("ul.tabs li:first").addClass("active").show(); //Activate first tab
$(".tab_content:first").show(); //Show first tab content

//On Click Event
$("ul.tabs li").click(function() {
$("ul.tabs li").removeClass("active"); //Remove any "active" class
$(this).addClass("active"); //Add "active" class to selected tab
$(".tab_content").hide(); //Hide all tab content

var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
$(activeTab).show(); //Fade in the active ID content
return false;
});
});
}

function printDiv(){
$("#printdiv").click(function(){
window.print();
});}

function sendPage(){
$("#sendpage").click(function(){
    addnewline = $(this).attr('body').replace(/(<[/].*?>)/ig,"%0D%0A");
   // alert($(this).attr('body').replace(/(<[/].*?>)/ig,"%0D%0A"))
});
}

function changeMidsection(){
$(document).ready(function() {
    $(".midsection").css('background',"#000");
});
}

function exampleSiteView(){
$("#examplesites").change(function(){
window.location=$("#examplesites option:selected").val();
});
}

function tutorialView(){
$("#tutorials").change(function(){
window.location=$("#tutorials option:selected").val();
});
}

function waterMark(){
$("#watermark").click(function(){
   if($("#watermark:checked").val() == 'on'){
       $("#watermarkparam").val('yes')
   }
});
}

function viewInfo(){
$("#viewinfo").click(function(){
   $("#memberinfo") .show();
});
}

function momneeds(){
$(".momneeds").click(function(){
   if($(this).text() == 'Music'){
       goToByScroll("music");
   }else if($(this).text() == 'Dance'){
       goToByScroll("dance");
   }else if($(this).text() == 'Goods/Products'){
       goToByScroll("theatre");
   }else if($(this).text() == 'Information'){
       goToByScroll("writing");
   }else if($(this).text() == 'Services'){
       goToByScroll("arts");
   }else if($(this).text() == 'Connections'){
       ugoToByScroll("meet");
   }
   return false;
});
}

function goToByScroll(id){
 $('html,body').animate({scrollTop: $("#"+id).offset().top},'slow');
}

function momfound(id){
goToByScroll(id);
}


function marketofferings(){
$(".momneeds").click(function(){
    $('.momneeds').css('background','none');
    $(this).css('background','yellow');
    var dname = "." + $(this).attr('id');
   $(".mdescription > div").hide();
   $(dname).show();
});
}

function marketofferingsSelect(id){
var dname = "." + $("#"+id+"_1").parent().attr('id');
$(".mdescription > div").hide();
$(dname).show();
}

function viewPictures(){
$("#viewpics").click(function(){
    if($(".pictures").is(":visible")){
        $(".pictures").hide();
        $(this).text('View Pictures');
    }else{
        $(".pictures").show();
        $(this).text('Close Pictures');
    }
    return false;
});
}

/*function viewCatalog(){
$(".storeitem").click(function(){alert($(this).attr('href'))
$.post($(this).attr('href'), function(data) {
  $("#hofd").html(data);
 });
return false;
});
}*/

function viewHelp(){
$("#helpbutton").click(function(){
    if($("#help").is(":visible")){
        $("#help").hide();
        $(this).text('View Help');
    }else{
        $("#help").show();
        $(this).text('Close Help');
    }
});
}

function categorySearchNav(searchtype){
    $("#maincategories").hide();
    $("#home").html('<a href="" style="color:#fed200;text-decoration:underline;">search</a> -> ' + searchtype);
    $("#searchtype").val(searchtype);
    $("#subsearchtype").show();
}

function showSearchLogin(){
$(".loginsearch").click(function() {
    $("#searchloginarea").slideDown('fast').show();
    $('#imagehome-link').css('top','420px');
    return false;
});
$("#hidesearchloginarea").click(function() {
    $("#searchloginarea").slideUp('fast');
    $('#imagehome-link').css('top','260px');
    return false;
});
}

function showMemberInfo(){
$("#moreinfo").click(function() {
    $("#membercenterseller").slideDown('fast').show();
    $("#hidememberinfoarea").show();
    $(this).hide();
    return false;
});
$("#hidememberinfoarea").click(function() {
    $("#membercenterseller").slideUp('fast');
    $("#moreinfo").show();
    $(this).hide();
    return false;
});
}

function removeSelectC(){
var selected;
$("#category").change(function() {
searchType($(this).attr('value'));
selected = $(this);
});
}

function fronthover(){
$(".linkdiv a").mouseenter(function() {
    $(this).css('border','1px solid yellow')
}).mouseleave(function() {
    $(this).css('border','');
});
}

function fronthovershared(){
$(".linkdivshared a").mouseenter(function() {
    $(this).css('border','1px solid yellow')
}).mouseleave(function() {
    $(this).css('border','');
});
}

function regComm(){
$(document).ready(function() {
$("#howsearch").keypress(function(e) {
if($(this).val().length < 3 && e.keyCode == 13){
        alert('Please enter more than 2 characters when searching');
        return false;
}else if($(this).val().length >= 35 && e.keyCode == 13){
        alert('Please enter no more than 35 characters when searching');
        return false;
}
return true;
});
$("#searchbutton").click(function() {
if($(".formcategorysearch").val().length < 3){
        alert('Please enter more than 2 characters when searching');
        return false;
}else if($(".formcategorysearch").val().length >= 35){
        alert('Please enter no more than 35 characters when searching');
        return false;
}
return true;
});
addTopic();
ckeditor();
$("#topicname").click(function(){$(this).val("")})
});
}

function addTopic() {
$("#addtopic").click(function() {
if($("#addtopic:checked").val()=="addtopic") {
window.location = $("#NewTopicURL").attr('href');
}});
}

function deleteComment(offset){
var deleteditem = ".deletecomment";
if(offset != undefined)
    deleteditem += offset;
$(".deletecomment").click(function() {
   var item = $(this).attr('href');
   var message = $("#when"+item).val();
   var writer = $("#writer"+item).attr('href');
   var confirmation = window.confirm("Are you sure you want to delete this comment?");
   if(confirmation == true){ 
       $.post("/hubba?message="+message+"&writer="+writer, function(data) { 
           $("#div"+item).fadeOut("slow");
        });
        var deletions = Number($("#deletions").val()) + 1;
        $("#deletions").val(deletions);
   }
   return false;
});
}

function deleteQuestion(offset){
var deleteditem = ".deletecomment";
if(offset != undefined)
    deleteditem += offset;
$(".deletecomment").click(function() {
   var item = $(this).attr('href');
   var message = $("#when"+item).val();
   var writer = $("#writer"+item).attr('href');
   var confirmation = window.confirm("Are you sure you want to delete this comment?");
   if(confirmation == true){
       $.post("/ask?message="+message+"&writer="+writer, function(data) {
           $("#div"+item).fadeOut("slow");
        });
        var deletions = Number($("#deletions").val()) + 1;
        $("#deletions").val(deletions);
   }
   return false;
});
}

function moreComments(offset){
$(".morelink").click(function(){
$("#busy").show();
var adjust = 0;
if(offset != undefined)
    adjust = offset - Number($("#deletions").val());
else
    adjust = - Number($("#deletions").val());
$.post($(this).attr('href')+adjust, function(data) {  
    if(offset != undefined){
        $("#comments"+offset).html(data);
    }else
        $("#comments").html(data);
});
$("#deletions").val(0);
$("#busy").hide();
return false;
});
}

function morePubComments(offset){
$(".morelink").click(function(){
$("#busy").show();
$.post($(this).attr('href')+offset, function(data) {
    if(offset != 0){
        $("#comments"+offset).html(data);
    }else
        $("#comments").html(data);
});
$("#busy").hide();
return false;
});
}

function riHover(){
$(".myButtonR").mouseenter(function() {
    $(".myButtonR input").css('background','url(/img/registerb.png) no repeat');
}).mouseleave(function() {
    $(".myButtonR input").css('background','url(/img/register.png) no repeat');
});
}

function riSelect(){
$(".myButtonR").click(function(){
    window.location="/actm/maineditorpage";
});
}

function bHover(){
$(".myButtonB").mouseenter(function() {
    $(".myButtonB input").css('background','url(/img/buyb.png) no repeat');
    $(".myButtonB input").css('color','black');
}).mouseleave(function() {
    $(".myButtonB input").css('background','url(/img/buy.png) no repeat');
    $(".myButtonB input").css('color','white');
});
}

function seHover(){
$(".myButtonS").mouseenter(function() {
    $(".myButtonS input").css('background','url(/img/searchb.png) no repeat');
    $(".myButtonS input").css('color','black');
}).mouseleave(function() {
    $(".myButtonS input").css('background','url(/img/search.png) no repeat');
    $(".myButtonS input").css('color','white');
});
}

function guestCheckout(){
$("#guestcheckout").click(function(){
    if($(otheraddress).is(':checked')){
        if($("#street").val() == '' || $("#zipcode").val() == '' || $("#actualcity").val() == ''){
            alert('You requested that the seller send these goods to a different address.  To successfully complete this order, you must provide the street, postal code, city and country information; otherwise uncheck to another address checkbox. ');
            return false;
        }
    }
    $("#salesmessage").show();
});
}

function goHome(){
$(".graytopbottom").mouseenter(function() {
    $(this).css('cursor','pointer')
}).mouseleave(function() {
    $(this).css('cursor','none');
});
$(".graytopbottom").click(function(){
   window.location = "/";
});
}

function regVideoCheck() {
 $(document).ready(function() {
   $("#videodescriptionform").validate();
   $("#title").rules('add',{required:true,maxlength:50});
   $("#description").rules('add',{required:true,maxlength:100});
   $("#keywords").rules('add',{required:true,maxlength:50});
   $("#category").rules('add',{required:true,maxlength:35});
   videoUploadMessage();
 });
}



function videoUploadMessage(){
$("#videoupload").click(function(){
    $("#salesmessage").show();
});
$("#salesmessage").click(function(){
    $("#salesmessage").hide();
});
}

function catalogCalc(){
$(".purchaseorder").change(function(){
    var id = $(this).attr('id').replace( "submitBtn", "itemprice" );
    var purchaseid = $(this).attr('id').replace( "submitBtn", "storeURL" );
    var quantityid = $(this).attr('id').replace( "submitBtn", "amtBuy" );
    var curqntid = $(this).attr('id').replace( "submitBtn", "curQnt" );

    if($(this).is(':checked')){
        if($("#"+quantityid).length == 0){//no more than 1
            total = (Number($("#totalcosttally").val()) + (Number($("#"+id).val().replace('$','').replace(/,/g,'')))).toFixed(2);
            $("#totalcosttally").val(total);            
            $("#totalcost").html(" $"+ addCommas(total) + " ");
            
            quantity = $("#amtsToBuy").val() + " " + $('#'+purchaseid).val().replace('$','') + "_1%";
            if($("#"+$(this).attr('id').replace("submitBtn","size")).length != 0){
                curval = " " + $('#'+purchaseid).val() + "?" + $("#"+$(this).attr('id').replace("submitBtn","size")).val() + $('#'+purchaseid).val() + "_1";
                purchases = $("#storeURL").val() + $('#'+purchaseid).val().replace('$','') + "?" + $("#"+$(this).attr('id').replace("submitBtn","size")).val() + "%";
            }
            else {
                curval = " " + $('#'+purchaseid).val() + "_1";
                purchases = $("#storeURL").val() + $('#'+purchaseid).val().replace('$','') + "%";
            }                
        }
        else{  //more than 1
            $('#'+quantityid).attr('disabled',false);
            $('#'+quantityid).val(1);
            total = (Number($("#totalcosttally").val()) + (Number($("#"+id).val().replace('$','')*$('#'+quantityid).val()))).toFixed(2);
            $("#totalcosttally").val(total);
            $("#totalcost").html(" $"+ addCommas(total) + " ");            

            if($("#"+$(this).attr('id').replace("submitBtn","size")).length != 0){//size info
                curval = " " + $('#'+purchaseid).val() + "?" + $("#"+$(this).attr('id').replace("submitBtn","size")).val() + "_" + $('#'+quantityid).val();
                purchases = $("#storeURL").val() + $('#'+purchaseid).val().replace('$','') + "?" + $("#"+$(this).attr('id').replace("submitBtn","size")).val() + "%";
                quantity = $("#amtsToBuy").val() + $('#'+purchaseid).val().replace('$','') + "?" + $("#"+$(this).attr('id').replace("submitBtn","size")).val() + "_" + $('#'+quantityid).val() + "%";
            }
            else{
                curval = " " + $('#'+purchaseid).val() + "_" + $('#'+quantityid).val();
                purchases = $("#storeURL").val() + $('#'+purchaseid).val().replace('$','') + "%";
                quantity = $("#amtsToBuy").val() + $('#'+purchaseid).val().replace('$','') + "_" + $('#'+quantityid).val() + "%";
            }
        }
        $("#"+curqntid).val(curval);
        $("#storeURL").val(purchases);
        $("#amtsToBuy").val(quantity);              
    }else{
       if($("#"+quantityid).length == 0){//no more than 1
            total = ($("#totalcosttally").val() - ($("#"+id).val().replace('$','').replace(/,/g,''))).toFixed(2);
            $("#totalcosttally").val(total);
            $("#totalcost").html(" $"+ addCommas(total) + " ");
            if($("#"+$(this).attr('id').replace("submitBtn","size")).length != 0)//size info
                changed = $("#storeURL").val().replace($('#'+purchaseid).val().replace('$','') + "?" + $("#"+$(this).attr('id').replace("submitBtn","size")).val()+"%",'');
            else
                changed = $("#storeURL").val().replace($('#'+purchaseid).val().replace('$','')+"%",'');
            toReplace = " " + $('#'+purchaseid).val() + "_1%";
            changedquantity = $("#amtsToBuy").val().replace(toReplace,'');
       }else{

             if($("#discount"+id.replace('itemprice','')).length != 0){//discounted item
                 if($('#'+quantityid).val() > 1){
                       if($("#size"+id.replace('itemprice','')).length != 0)//size info
                           total = (Number($("#totalcosttally").val()) - ((Number($("#"+$("#size"+id.replace('itemprice','')).val()+"discount"+id.replace('itemprice','')).val()))*Number($('#'+quantityid).val()))).toFixed(2);
                       else
                           total = (Number($("#totalcosttally").val()) - ((Number($("#"+"discountprice"+id.replace('itemprice','')).val()))*Number($('#'+quantityid).val()))).toFixed(2);
                   }
                   else
                       total = (Number($("#totalcosttally").val()) - ($("#"+id).val().replace('$','')*$('#'+quantityid).val())).toFixed(2);                   
                        
                }else
                    total = ($("#totalcosttally").val() - ($("#"+id).val().replace('$','')*$('#'+quantityid).val())).toFixed(2);

            $('#'+quantityid).val(1);
            $('#'+quantityid).attr('disabled',true);
            
            $("#totalcosttally").val(total);
            $("#totalcost").html(" $"+ addCommas(total) + " ");
            if($("#"+$(this).attr('id').replace("submitBtn","size")).length != 0){
                changed = $("#storeURL").val().replace($('#'+purchaseid).val().replace('$','') + "?" + $("#"+$(this).attr('id').replace("submitBtn","size")).val()+"%",'');
                toReplace = $('#'+purchaseid).val().replace('$','') + "?" + $("#"+$(this).attr('id').replace("submitBtn","size")).val() + "_" + $('#'+quantityid).val() + "%";
            }
            else{
                changed = $("#storeURL").val().replace($('#'+purchaseid).val().replace('$','')+"%",'');
                toReplace = $('#'+purchaseid).val().replace('$','') + "_" + $('#'+quantityid).val() + "%";
            }            
            changedquantity = $("#amtsToBuy").val().replace(toReplace,'');               
        }
        $("#storeURL").val(changed);
        $("#amtsToBuy").val(changedquantity);
    }
});
}

function catalogQuantity(){
$(document).ready(function() {
$(".quantitybuy").change(function(){
    var id = $(this).attr('id').replace( "amtBuy", "submitBtn" );
    var purchaseid = $(this).attr('id').replace( "amtBuy", "itemprice" );
    var itemurl = $(this).attr('id').replace( "amtBuy", "storeURL" );
    var curqntid = $(this).attr('id').replace( "amtBuy", "curQnt" );    
    if($("#"+id).is(':checked')){
        toReplace = $("#"+curqntid).val();        
        if(toReplace != ""){
            if($("#"+$(this).attr('id').replace("amtBuy","size")).length != 0){
                 changedquantity = toReplace.replace(/ST_.*_/g,"");
                 $("#"+curqntid).val($('#'+itemurl).val() + "?" + $("#"+$(this).attr('id').replace("amtBuy","size")).val() + "_" + $(this).val())
            }              
            else {
                 changedquantity = toReplace.replace(/ST_.*_/g,"");
                 $("#"+curqntid).val($('#'+itemurl).val() + "_" + $(this).val())
            }
            
            //add to the quantity
            if($("#discount"+id.replace('submitBtn','')).length != 0 && changedquantity > 1){//discounted item
                if($("#"+$(this).attr('id').replace("amtBuy","size")).length != 0)//size info
                   total = (Number($("#totalcosttally").val()) - ((Number($("#"+$("#"+$(this).attr('id').replace("amtBuy","size")).val()+"discount"+id.replace('submitBtn','')).val()))*Number(changedquantity))).toFixed(2);
               else
                   total = (Number($("#totalcosttally").val()) - ((Number($("#"+"discountprice"+id.replace('submitBtn','')).val()))*Number(changedquantity))).toFixed(2);
              alert('replace ' + $("#"+"discountprice"+id.replace('submitBtn','')).val())
            }else
                total = (Number($("#totalcosttally").val()) - ((Number($("#"+purchaseid).val().replace('$','')))*Number(changedquantity))).toFixed(2);

            $("#totalcosttally").val(total);          
        }

         //remove from the quantity         
            if($("#discount"+id.replace('submitBtn','')).length != 0){//discounted item
               if($(this).val() > 1){
                   if($("#"+$(this).attr('id').replace("amtBuy","size")).length != 0)//size info
                       total = (Number($("#totalcosttally").val()) + ((Number($("#"+$("#"+$(this).attr('id').replace("amtBuy","size")).val()+"discount"+id.replace('submitBtn','')).val()))*Number($(this).val()))).toFixed(2);
                   else
                       total = (Number($("#totalcosttally").val()) + ((Number($("#"+"discountprice"+id.replace('submitBtn','')).val()))*Number($(this).val()))).toFixed(2);
               }
               else
                    total = (Number($("#totalcosttally").val()) + ((Number($("#"+purchaseid).val().replace('$','')))*($(this).val()))).toFixed(2);
            }else
                total = (Number($("#totalcosttally").val()) + ((Number($("#"+purchaseid).val().replace('$','')))*Number($(this).val()))).toFixed(2);


        $("#totalcosttally").val(total);
        $("#totalcost").html(" $"+ addCommas(total) + " ");
        changedquantity = $("#amtsToBuy").val().replace($.trim(toReplace),$.trim($("#"+curqntid).val()));
        $("#amtsToBuy").val(changedquantity);       
    }
});});
}

function catalogCheckOut(){
$("#submitBtnCatSellections").click(function(){
    if(!$(".purchaseorder").is(':checked')){
        alert('Please select item(s) to be purchased.');
        return false;
    }
});
}

function messageReg(){
$(document).ready(function() {
$("#messageForm").validate();
$("#subject").rules('add',{required:true, maxlength:35});
$("#message").rules('add',{required:true, maxlength:200});
$("#submitbutton").click(function(){
    $(this).attr('disabled','true');
    $("#messageForm").submit();
});
});
}

function updateRefresh(location){
$(window).unload(function() {
  if(location.indexOf('actm') == -1)
    window.location = "http://www.notemote.com/"+location+"/";
  else
    window.location = "/maildispatcher/";
});
}

function dispListings(){
$(document).ready(function() {
    if(window.location.href.indexOf('?') != -1){
        $('#listingtable').show();
        $("#hidelistings").show();
        $("#showlistings").hide();
        window.location.hash='listings';
    }   
});
}

function exampleShowImage(){
$("div a").click(function(){
    $('.centercolumn div').hide();
    $("#frontchanger").show();
    if($(this).html() == 'Blogs'){
        $("#frontchanger").attr('src','/img/exampleblogs.jpg');
        return false;
    }else if($(this).html() == 'Galleries'){
        $("#frontchanger").attr('src','/img/examplegallery.jpg');
        return false;
    }else if($(this).html() == 'About'){
        $("#frontaboutpart").show();
        $("#frontaboutpart div").show();
        $("#frontchanger").hide();
        return false;
    }
    else if($(this).html().indexOf('For Sale') != -1 ){
        $("#frontchanger").attr('src','/img/examplestore.jpg');
        return false;
    }else if($(this).html().indexOf('Services') != -1 ){
        $("#frontchanger").attr('src','/img/exampleservices.jpg');
        return false;
    }else if($(this).html().indexOf('Rentals') != -1 ){
        $("#frontchanger").attr('src','/img/examplerentals.jpg');
        return false;
    }else if($(this).html().indexOf('Wanted') != -1 ){
        $("#frontchanger").attr('src','/img/examplewanted.jpg');
        return false;
    }else if($(this).html().indexOf('Events') != -1 ){
        $("#frontchanger").attr('src','/img/exampleevents.jpg');
        return false;
    }else if($(this).html().indexOf('notes.jpg') != -1 ){
        $("#frontchanger").attr('src','/img/examplenotes.jpg');
        return false;
    }
});
}

function mailCampaign(){
$("#mailcampaignform").validate();
$("#password").rules('add',{required: true, minlength: 8, maxlength:35});
$("#name").rules('add',{required: true, minlength: 1, maxlength:75});
$("#email").rules('add',{required: true, maxlength:75});
$("#url").rules('add',{maxlength:75});
$("#yourname").rules('add',{required: true, maxlength:75});
$("#membertype").rules('add',{required: true, minlength: 5, maxlength:50});
}

function exampleShow(){
$("#emailsend").click(function(){
    $("#emailnow").val("1");
    return true;
});
}

function checkEmailInfo(){
$("#email").keypress(function(){
     $.post("/example/emailexists/?data="+$(this).val(), function(data) {
           $("#emailfound").html(data);
           $("#emailfi").val($.trim((data)));
    });
});
}

function checkEmailSame(){
checkEmailSame2();
$("#email").change(function(){
    if($("#email").val() == $("#emailfi").val()){
        foundemailentry = true;
        alert('email has already been sent');
    }        
});
}

function checkEmailSame2(){
$("#email").blur(function(){
     $.post("/example/emailexists/?data="+$(this).val(), function(data) {
         $("#emailfound").html(data);
         $("#emailfi").val($.trim((data)));
         if($("#email").val() != '' && foundemailentry != true && ($("#email").val() == $("#emailfi").val()))
            alert('email has already been sent')
     });
    
});
}

function isHiding(){
    var $s = $('.menudisp');

    $s.wrapInner('<div />'); // wrap inner contents
    var hidden = $s.height() < $s.children('div').height();

    $s.children('div').replaceWith( $s.children('div').html() ); //unwrap

    return hidden;
}
function clickMore(){
$("#morepubs").click(function(){
    return false;
});
}
function showMore(){
$("#morepubs").hover(function(){
    $(".menudisp").animate({height:$('#innermenu').height()},250);
    $(this).hide();
});
}

function hideAgain(){
$(".menudisp").hover(function(){},function () {$(".menudisp").animate({height:40},250);$('#morepubs').show();});
}

function slider() {
$('.thumb img').data('ad-title', '');
var galleries = $('.ad-gallery').adGallery();
$('#switch-effect').change(
  function() {
    galleries[0].settings.effect = $(this).val();
    return false;
  }
);
  
$('#toggle-slideshow').click(
  function() {
    galleries[0].slideshow.toggle();
    return false;
  }
);
$('#toggle-description').click(
  function() {
    if(!galleries[0].settings.description_wrapper) {
      galleries[0].settings.description_wrapper = $('#descriptions');
    } else {
      galleries[0].settings.description_wrapper = false;
    }
    return false;
  }
);
}

function admin(){
$(".admin").click(function(){
    $("#admin").show();
    return false;
});
$(".admin").mouseenter(function() {
    $("#admin").show();
}).mouseleave(function() {    
});
}

function adminHide(){
$("#hideadmin").click(function(){
    $("#admin").hide();
    return false;
});
}

function setTimeInterval(){
$(".required").effect("pulsate", { times:500 }, 3500);
}

function setTimeHomeInterval(){
$("#homeb").effect("pulsate", { times:500 }, 3500);
}

function storeSizes(){
$("#custom").click(function(){
    if($(this).is(':checked')){
        $("#customdescription").rules('add',{required: true, maxlength:35});
        $("#customquantity").rules('add',{required: true, maxlength:5});
        $("#customcost").rules('add',{required: true});
    }else{
         $("#customdescription").rules('remove');
         $("#customquantity").rules('remove');
        $("#customcost").rules('remove');
    }
});
$("#xxl").click(function(){
    if($(this).is(':checked')){
        $("#xxldescription").rules('add',{required: true, maxlength:35});
        $("#xxlquantity").rules('add',{required: true, maxlength:5});
        $("#xxlcost").rules('add',{required: true});
    }else{
         $("#xxldescription").rules('remove');
         $("#xxlquantity").rules('remove');
        $("#xxlcost").rules('remove');
    }
});
$("#xlarge").click(function(){
    if($(this).is(':checked')){
        $("#xlargedescription").rules('add',{required: true, maxlength:35});
        $("#xlargequantity").rules('add',{required: true, maxlength:5});
        $("#xlargecost").rules('add',{required: true});
    }else{
         $("#xlargedescription").rules('remove');
         $("#xlargequantity").rules('remove');
        $("#xlargecost").rules('remove');
    }
});
$("#lrge").click(function(){
    if($(this).is(':checked')){
        $("#lrgedescription").rules('add',{required: true, maxlength:35});
        $("#lrgequantity").rules('add',{required: true, maxlength:5});
        $("#lrgecost").rules('add',{required: true});
    }else{
         $("#lrgedescription").rules('remove');
         $("#lrgequantity").rules('remove');
        $("#lrgecost").rules('remove');
    }
});
$("#medium").click(function(){
    if($(this).is(':checked')){
        $("#mediumdescription").rules('add',{required: true, maxlength:35});
        $("#mediumquantity").rules('add',{required: true, maxlength:5});
        $("#mediumcost").rules('add',{required: true});
    }else{
         $("#mediumdescription").rules('remove');
         $("#mediumquantity").rules('remove');
        $("#mediumcost").rules('remove');
    }
});
$("#small").click(function(){
    if($(this).is(':checked')){
        $("#smalldescription").rules('add',{required: true, maxlength:35});
        $("#smallquantity").rules('add',{required: true, maxlength:5});
        $("#smallcost").rules('add',{required: true});
    }else{
         $("#smalldescription").rules('remove');
         $("#smallquantity").rules('remove');
        $("#smallcost").rules('remove');
    }
});
$("#xsm").click(function(){
    if($(this).is(':checked')){
        $("#xsmdescription").rules('add',{required: true, maxlength:35});
        $("#xsmquantity").rules('add',{required: true, maxlength:5});
        $("#xsmcost").rules('add',{required: true});
    }else{
         $("#xsmdescription").rules('remove');
         $("#xsmquantity").rules('remove');
        $("#xsmcost").rules('remove');
    }
});
$("#xxs").click(function(){
    if($(this).is(':checked')){
        $("#xxsdescription").rules('add',{required: true, maxlength:35});
        $("#xxsquantity").rules('add',{required: true, maxlength:5});
        $("#xxscost").rules('add',{required: true});
    }else{
         $("#xxsdescription").rules('remove');
         $("#xxsquantity").rules('remove');
        $("#xxscost").rules('remove');
    }
});
}

function storebriefInitialize(){
if($("#custom").is(':checked')) {
$("#customdescription").rules('add',{required: true, maxlength:35});
$("#customquantity").rules('add',{required: true, maxlength:5});
$("#customcost").rules('add',{required: true});
}
if($("#xxl").is(':checked')) {
$("#xxldescription").rules('add',{required: true, maxlength:35});
$("#xxlquantity").rules('add',{required: true, maxlength:5});
$("#xxlcost").rules('add',{required: true});
}
if($("#xlarge").is(':checked')) {
$("#xlargedescription").rules('add',{required: true, maxlength:35});
$("#xlargequantity").rules('add',{required: true, maxlength:5});
$("#xlargecost").rules('add',{required: true});
}
if($("#lrge").is(':checked')) {
$("#lrgedescription").rules('add',{required: true, maxlength:35});
$("#lrgequantity").rules('add',{required: true, maxlength:5});
$("#lrgecost").rules('add',{required: true});
}
if($("#medium").is(':checked')) {
$("#mediumdescription").rules('add',{required: true, maxlength:35});
$("#mediumquantity").rules('add',{required: true, maxlength:5});
$("#mediumcost").rules('add',{required: true});
}
if($("#small").is(':checked')) {
$("#smalldescription").rules('add',{required: true, maxlength:35});
$("#smallquantity").rules('add',{required: true, maxlength:5});
$("#smallcost").rules('add',{required: true});
}
if($("#xsm").is(':checked')) {
$("#xsmdescription").rules('add',{required: true, maxlength:35});
$("#xsmquantity").rules('add',{required: true, maxlength:5});
$("#xsmcost").rules('add',{required: true});
}
if($("#xxs").is(':checked')) {
$("#xxsdescription").rules('add',{required: true, maxlength:35});
$("#xxsquantity").rules('add',{required: true, maxlength:5});
$("#xxscost").rules('add',{required: true});
}
}

function storebriefUnitialize(){
$("#customdescription").rules('remove');
$("#customquantity").rules('remove');
$("#customcost").rules('remove');
$("#xxldescription").rules('remove');
$("#xxlquantity").rules('remove');
$("#xxlcost").rules('remove');
$("#xlargedescription").rules('remove');
$("#xlargequantity").rules('remove');
$("#xlargecost").rules('remove');
$("#lrgedescription").rules('remove');
$("#lrgequantity").rules('remove');
$("#lrgecost").rules('remove');
$("#mediumdescription").rules('remove');
$("#mediumquantity").rules('remove');
$("#mediumcost").rules('remove');
$("#smalldescription").rules('remove');
$("#smallquantity").rules('remove');
$("#smallcost").rules('remove');
$("#xsmdescription").rules('remove');
$("#xsmquantity").rules('remove');
$("#xsmcost").rules('remove');
$("#xxsdescription").rules('remove');
$("#xxsquantity").rules('remove');
$("#xxscost").rules('remove');
}

function flash(){
$(".flash").effect("pulsate", { times:8 }, 2000);
function callback() {
$(".marketplace").show()};
}

function addCommas(nStr){
nStr += '';
x = nStr.split('.');
x1 = x[0];
x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
        x1 = x1.replace(rgx, '$1' + ',' + '$2');
}
return x1 + x2;
}

function memberInfoView(){
$("#expand").click(function(){
    $("#addressinfo").show();
    $("#retract").show();
    $(this).hide();
    mapflash();
    return false;
});
}

function memberInfoHide(){
$("#retract").click(function(){
    $("#addressinfo").hide();
    $("#expand").show();
    $(this).hide();
    return false;
});
}

function mapflash(){
$("#mapit").effect("pulsate", { times:8 }, 2000);
function callback() {
$("#mapit").show()};
}

function splitStore(info,id,discount){
$(document).ready(function() {
var temp = new Array();
temp = info.split("]");
$("#split"+id).append("<div class='split'></div>");
for (var i = 0; i < temp.length; i++){
subtemp = temp[i].split(":");
for (var k = 0; k < subtemp.length; k++){
    sizesInfo(subtemp[k],subtemp,id,discount)
}}});
}

function sizesInfo(sizes,subtemp,id,discount){
if(sizes == 'custom'){
    $("#size"+id).append("<option value='custom'>custom</option>");
    $("#split"+id).append("<div id='custom"+id+"'></div>");
    $("#custom"+id).append("<input id='customquantity"+id+"' value='"+subtemp[1]+"' type='hidden'/>");
    $("#custom"+id).append("<input id='customsize"+id+"' value='"+subtemp[2]+"' type='hidden'/>");
    $("#custom"+id).append("<input id='customcost"+id+"' value='"+subtemp[3]+"' type='hidden'/>");
    if(discount != 0 && subtemp[3] != null && subtemp[3] != 'undefined')
        discountedprice = computeDiscount(discount,id,subtemp[3].replace("US",""),'custom');
    showSizeInfo(subtemp,id,discount,discountedprice);
}  
else if(sizes == 'xxl'){
    $("#size"+id).append("<option value='xxl'>xx-large</option>");
    $("#split"+id).append("<div id='xxl"+id+"'></div>");
    $("#xxl"+id).append("<input id='xxlquantity"+id+"' value='"+subtemp[1]+"' type='hidden'/>");
    $("#xxl"+id).append("<input id='xxlsize"+id+"' value='"+subtemp[2]+"' type='hidden'/>");
    $("#xxl"+id).append("<input id='xxlcost"+id+"' value='"+subtemp[3]+"' type='hidden'/>");
     if(discount != 0 && subtemp[3] != null && subtemp[3] != 'undefined')
        discountedprice = computeDiscount(discount,id,subtemp[3].replace("US",""),'xxl');
    showSizeInfo(subtemp,id);
}
else if(sizes == 'xlarge'){
    $("#size"+id).append("<option value='xlarge'>x-large</option>");
    $("#split"+id).append("<div id='xlarge"+id+"'></div>");
    $("#xlarge"+id).append("<input id='xlargequantity"+id+"' value='"+subtemp[1]+"' type='hidden'/>");
    $("#xlarge"+id).append("<input id='xlargesize"+id+"' value='"+subtemp[2]+"' type='hidden'/>");
    $("#xlarge"+id).append("<input id='xlargecost"+id+"' value='"+subtemp[3]+"' type='hidden'/>");
     if(discount != 0 && subtemp[3] != null && subtemp[3] != 'undefined')
        discountedprice = computeDiscount(discount,id,subtemp[3].replace("US",""),'xlarge');
    showSizeInfo(subtemp,id);
}
else if(sizes == 'lrge'){
    $("#size"+id).append("<option value='lrge'>large</option>");
    $("#split"+id).append("<div id='lrge"+id+"'></div>");
    $("#lrge"+id).append("<input id='lrgequantity"+id+"' value='"+subtemp[1]+"' type='hidden'/>");
    $("#lrge"+id).append("<input id='lrgesize"+id+"' value='"+subtemp[2]+"' type='hidden'/>");
    $("#lrge"+id).append("<input id='lrgecost"+id+"' value='"+subtemp[3]+"' type='hidden'/>");
     if(discount != 0 && subtemp[3] != null && subtemp[3] != 'undefined')
        discountedprice = computeDiscount(discount,id,subtemp[3].replace("US",""),'lrge');
    showSizeInfo(subtemp,id);
}
else if(sizes == 'medium'){
    $("#size"+id).append("<option value='medium'>medium</option>");
    $("#split"+id).append("<div id='medium"+id+"'></div>");
    $("#medium"+id).append("<input id='mediumquantity"+id+"' value='"+subtemp[1]+"' type='hidden'/>");
    $("#medium"+id).append("<input id='medium"+id+"' value='"+subtemp[2]+"' type='hidden'/>");
    $("#medium"+id).append("<input id='mediumcost"+id+"' value='"+subtemp[3]+"' type='hidden'/>");
     if(discount != 0 && subtemp[3] != null && subtemp[3] != 'undefined')
        discountedprice = computeDiscount(discount,id,subtemp[3].replace("US",""),'medium');
    showSizeInfo(subtemp,id);
}
else if(sizes == 'small'){
    $("#size"+id).append("<option value='small'>small</option>");
    $("#split"+id).append("<div id='small"+id+"'></div>");
    $("#small"+id).append("<input id='smallquantity"+id+"' value='"+subtemp[1]+"' type='hidden'/>");
    $("#small"+id).append("<input id='smallsize"+id+"' value='"+subtemp[2]+"' type='hidden'/>");
    $("#small"+id).append("<input id='smallcost"+id+"' value='"+subtemp[3]+"' type='hidden'/>");
     if(discount != 0 && subtemp[3] != null && subtemp[3] != 'undefined')
        discountedprice = computeDiscount(discount,id,subtemp[3].replace("US",""),'small');
    showSizeInfo(subtemp,id);
}
else if(sizes == 'xsm'){
    $("#size"+id).append("<option value='xsm'>x-small</option>");
    $("#split"+id).append("<div id='xsm"+id+"'></div>");
    $("#xsm"+id).append("<input id='xsmquantity"+id+"' value='"+subtemp[1]+"' type='hidden'/>");
    $("#xsm"+id).append("<input id='xsmsize"+id+"' value='"+subtemp[2]+"' type='hidden'/>");
    $("#xsm"+id).append("<input id='xsmcost"+id+"' value='"+subtemp[3]+"' type='hidden'/>");
     if(discount != 0 && subtemp[3] != null && subtemp[3] != 'undefined')
        discountedprice = computeDiscount(discount,id,subtemp[3].replace("US",""),'xsm');
    showSizeInfo(subtemp,id);
}
else if(sizes == 'xxs'){
    $("#size"+id).append("<option value='xxs'>xx-small</option>");
    $("#split"+id).append("<div id='xxs"+id+"'></div>");
    $("#xxs"+id).append("<input id='xxsquantity"+id+"' value='"+subtemp[1]+"' type='hidden'/>");
    $("#xxs"+id).append("<input id='xxssize"+id+"' value='"+subtemp[2]+"' type='hidden'/>");
    $("#xxs"+id).append("<input id='xxscost"+id+"' value='"+subtemp[3]+"' type='hidden'/>");
     if(discount != 0 && subtemp[3] != null && subtemp[3] != 'undefined')
        discountedprice = computeDiscount(discount,id,subtemp[3].replace("US",""),'xxs');
    showSizeInfo(subtemp,id);
}}

function showSizeInfo(subtemp,id,discount,discountedprice){
if($("#cost"+id).html() == ''){
$("#cost"+id).append(subtemp[3].replace("US",""));
$("#sizeinfo"+id).append(subtemp[2]);
$("#itemprice"+id).val(subtemp[3].replace("US",""));
if(discount != 0)
    $("#shdiscprice"+id).html("$" + discountedprice);
}
}

function sizeSelection(id,costid,num){
var numid = num;
$("#"+id).focus(function() {
    $(this).data('oldValue',$(this).val());}
  );
$("#"+id).change(function() {
$("#"+costid).html($("#"+$(this).val()+"cost"+numid).val().replace("US",""));
if($("#submitBtn"+numid).is(':checked')){
    changed = $("#storeURL").val().replace($('#storeURL'+num).val() + "?" + $(this).data('oldValue')+"%",'');
    change = $('#storeURL'+num).val() + "?" + $(this).data('oldValue') + "_" + $("#amtBuy"+num).val() + "%";
    changedquantity = $("#amtsToBuy").val().replace(change,'');
    $("#storeURL").val(changed);
    $("#amtsToBuy").val(changedquantity);
    $("#submitBtn"+numid).attr('checked','true')
    $("#submitBtn"+numid).trigger('click').trigger('change');
}
if($("#discount"+numid).length != 0)
    $("#shdiscprice"+numid).html("$" + $("#"+$(this).val()+"discount"+numid).val());
$("#itemprice"+numid).val($("#"+$(this).val()+"cost"+numid).val().replace("US",""));
$("#sizeinfo"+numid).html($("#"+$(this).val()+"size"+numid).val());
});
}

function quantityDisp(quantity, id){
if(quantity > 5 && quantity <= 10){
    $("#split"+id).append("<select class='quantitybuy' id='amtBuy"+id+
        "' style='width:35px;display:inline;' disabled><option>1</option><option>2</option></select>");
}else if(quantity > 10){
    $("#split"+id).append("<select class='quantitybuy' id='amtBuy"+id+
        "' style='width:35px;display:inline;' disabled><option>1</option><option>2</option><option>3</option><option>4</option></select>");
}
}

function quantityChange(){
$(".quantitybuy").change(function() {
    $("#amtsToBuy").val($(this).val());
});
}

function sizeSingleItemSelection(url,costid){
$(document).ready(function() {
$("#size1").focus(function() {
    $(this).data('oldValue',$(this).val());}
  );
$("#size1").change(function() {
    $("#"+costid).html($("#"+$(this).val()+costid).val().replace("US",""));
    $("#sizeinfo1").html($("#"+$(this).val()+"size1").val());
    $("#storeURL").val(url + "?" + $(this).val());
    if($("#"+$(this).val()+"discount1").length != 0)
        $("#shdiscprice1").html("$" + $("#"+$(this).val()+"discount1").val());
   });});
}



function setstoreURL(URL){
$(document).ready(function() {
$("#storeURL").val(''+URL+"?"+$("#size1").first().val()+"%");
$("#amtsToBuy").val(URL+"?"+$("#size1").val()+"_"+$("#amtBuy1").val()+"%");
$("#size1").change(function() {
    $("#storeURL").val(''+URL+"?"+$(this).val()+"%");
});
});
}

function quantityChange(URL){
$(".quantitybuy").change(function() {
    $("#amtsToBuy").val(URL+"?"+$("#size1").val()+"_"+$(this).val()+"%");
});
}

function quantityChangeWO(URL){
$(".quantitybuy").change(function() {
    $("#amtsToBuy").val(URL+"_"+$(this).val()+"%");
});
}

function computeDiscount(discount,id,price,sizeinfo){
discountinfo = Number(100-$("#discountinfo"+id).val())/100;
price = price.replace("$","");
if(sizeinfo != null && isNaN(price) == false){
    discountedprice = Number(price.replace("$",""))*discountinfo;
    $("#"+sizeinfo+id).append("<input id='"+sizeinfo+"discount"+id+"' value='"+discountedprice+"' type='hidden'/>");
}
else{
    discountedprice = Number(price.replace("$",""))*discountinfo;
    if(discountedprice != 0){
        $("#shdiscprice"+id).html("$" + discountedprice);
        $("#discountprice"+id).val(discountedprice);
    }
}

return discountedprice
}

function googleSearch(){
$("#yourname").click(function() {
    $(this).val('');
});
}

function updateMemberType(){
$("#selleronly").change(function() {
    if($(this).is(':checked')){
         $.post("/actm/account?accounttype=true&feedback=true", function(data) {
            location.reload();
        });
    }else{
        $.post("/actm/account?accounttype=true", function(data) {
            location.reload();
        });
    }
});
}

function answers(){
$(".topic").click(function() {
    $("#"+$(this).attr('id')+"show").slideDown('fast');
    return false;
});
}

