// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
function jump(targ,selObj,restore){
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function resetHours() {
  $('hour_is_closed').checked = false;
  $('hour_open_seven_days_a_week').checked = false;
  $('hour_open_twenty_four_hours').checked = false;
}

function popupWindow(sUrl,height,width,scrollbars) {
  height = (height == null) ? '400' : height;
  width = ( width == null) ? '400' : width;
  scrollbars = (scrollbars == null) ? '0' : scrollbars;
  window.open(sUrl,'name','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=' + scrollbars + ',resizable=1,height=' + height + ',width=' + width);
}

function printwin() {
  if (window.print) window.print();
  else if (VBS) printIt();
  else alert('This script does not work in your browser');
}

function redirect(form) { 
  var index=form.select.selectedIndex
  if (form.select.options[index].value != "0") {
    location=form.select.options[index].value;
  }
}

function onBodyLoad(showPlayer,audioFile) {
  if ( $('errorExplanation') && !Element.visible('errorExplanation') ) {
    new Effect.BlindDown('errorExplanation')
  }
  if (showPlayer) {
    var so = new SWFObject('/audio/mediaplayer.swf','mpl','320','20','7');
    so.addParam('allowfullscreen','true');
    so.addParam('allowscriptaccess','always');
    so.addVariable('file',audioFile);
    so.addVariable('height','20');
    so.addVariable('width','200');
    so.addVariable('enablejs','true');
    so.addVariable('javascriptid','mpl');
    so.write('player');
  }
}

function toggleYPForm() {
  if ( $('service_tracking_purpose').value == 'Yellow Pages' ) {
    Element.show('extra-yellow');
  }
  else {
    Element.hide('extra-yellow');
  }
}

var checkflag = "false";
function check(field) {
  if (checkflag == "false") {
    for (i = 0; i < field.length; i++) {
      field[i].checked = true;
    }
    checkflag = "true";
    return "Uncheck All"; 
  }
  else {
    for (i = 0; i < field.length; i++) {
      field[i].checked = false;
    }
    checkflag = "false";
    return "Check All";
  }
}

function checkoruncheckit(field,value) {
    $(field).checked = value;
}

function printConversion(response) {
  printwin();
}

function onButtonClickForCampaign(id) {
  request = '/admin/clients/update_campaign/' + id
  row = 'row' + id
  new Ajax.Request(request, {asynchronous:true, evalScripts:true, parameters:Form.serialize(row)}); return false;
}
