function TarifrechnerCheckForm(form) {
	return true;	
}
function SelectTarif() {
	var id = window.location.hash.substring(1, window.location.hash.length);
	if(!isNaN(id)) {
		alert(id);
	}
}
function setupDatarows() {
}
function ToggleArea(sender, callback) {
	var mode = 0;
	if(document.getElementById(sender.id + 'box' ).style.display == 'none') {
		sender.innerHTML = sender.innerHTML.replace(/\+/, '-');
		document.getElementById(sender.id + 'box').style.display = 'block';
		mode = 1;
	}
	else {
		sender.innerHTML = sender.innerHTML.replace(/-/, '+');
		document.getElementById(sender.id + 'box').style.display = 'none';
		mode = 0;
	}
	if(typeof(callback) == 'function' ) {
		callback(mode);
	}
	return false;
}
function Highlight() {
  var tokens = window.location.href.split( '#' );
  if( tokens.length == 2 ) {
	$( '#title' + tokens[ 1 ] ).css( 'background-color', 'red' );
  }
}
$(function() {
  /* load ajax listings */
  $('.ajax-tariflist').each(function(i, item) {
    $.ajax({
		  url: 'http://' + location.host + '/wp-content/plugins/tarifrechner/ajax.php',
		  type: 'POST',
      dataType: 'html',
      timeout: 20000,
      data: {
        method: 'tariflist',
        id: item.id
      },
      error: function(){},
		  success: function(data) {
		    item.innerHTML = data;
		    $(item).css('background', 'none');
		  }
    });
  });
	/* tr hover stuff */
	$( 'tr.tr0, tr.tr1' ).hover(
		function() {
			$( this ).addClass( 'tr0hover' );
		},
		function() {
			$( this ).removeClass( 'tr0hover' );
		}
	);
	/* options field */
	var tarifrechner_advanced_options_field = window.tarifrechner_advanced_options_field_status || 0;
	if( tarifrechner_advanced_options_field == 1 ) {
		$( '#tarifrechner_advanced_options' ).attr( 'innerHTML', $( '#tarifrechner_advanced_options' ).attr( 'innerHTML' ).replace( /\+/, '-' ) );
		$( '#tarifrechner_advanced_options_table' ).show();
	}
	$( '#tarifrechner_advanced_options' ).click( function() {
		var area = '#tarifrechner_advanced_options_table';
		var index = 1;
		if( $(area).is(":hidden") ) {
			this.innerHTML = this.innerHTML.replace( /\+/, '-' );
			$( area ).show();
			$( '#tarifrechner_advanced_options_field' ).attr( 'value', index );
		}
		else {
			this.innerHTML = this.innerHTML.replace( /-/, '+' );
			$( area ).hide();
			$( '#tarifrechner_advanced_options_field' ).attr( 'value', 0 );
		}
		return( false );
	});
	Highlight();
});