/* tables */ 
$('.oddeven tr:odd').addClass('odd');
$('div.oddeven:odd').addClass('odd');

/* equeal height divs */
//tallest = 0;
//$('.inbox').each(function() {
//	var thisHeight = $(this).height();
//	if (thisHeight > tallest) {
//		tallest = thisHeight;
//	}
//});
//$('.inbox').height(tallest);

/* images */
$('.tdImg').each(function(){
	 $(this).html('<img class="imgsmall" src="'+$(this).attr("rel")+'">');
});

/* anchor */
anchor = (document.location.hash)?document.location.hash:'#summary';
//$(".tab_content").hide();
$(anchor+'div').show();
$(anchor+'tab').addClass( 'active' );

$(".tab").click(function(e) {
	e.preventDefault();
//	window.location.hash = $(this).attr("hash");
//	window.location.reload(false);
//	return false;
	var anchor =  $(this).attr("hash");
	$(".tab_content").hide();
	$(anchor+'div').show();
	$(".active").removeClass('active');
	$(anchor+'tab').addClass( 'active' );
});

/* compress js */
$('#compressJs').click(function(){
	var abdd = $("input:checked[name=js[]]").map(function() {
		return $(this).val();
	}).get().join(); 
	$.post("/papers/docompressjs?tpl=false", $("input:checked[name=js[]]").serialize(), function(data) {
		$('.resultjscompression').html(data);
	});
});

/* compress css */
$('#compressCss').click(function(){
	var abdd = $("input:checked[name=css[]]").map(function() {
		return $(this).val();
	}).get().join(); 
	$.post("/papers/docompresscss?tpl=false", $("input:checked[name=css[]]").serialize(), function(data) {
		$('.resultcsscompression').html(data);
	});
});


/*repair html*/
$('#cleanhtml').click(function(){
	 $.post("/papers/dorepairhtml?tpl=false", { url: sDomain }, function(data) {
		  $('#repairhtml').html(data);
	 });
});

/*ajax*/
$(".ajax").live("click", function(event) {
    event.preventDefault();
    if (this.rel != 'nofollow') {
		var updatediv = '-' + this.rel;
	} else {
		var updatediv = '-' + this.id;
	}
	$.get(this.href, {
		'tpl' : 'false'
	}, function(data) {
		$('#' + updatediv).html(data).hide().fadeIn('slow');
	});
	return false;
});

//code preview
$('.showcode').each(function(e){
	var decoded = $(this).text($(this).html()).html();

	// remove if first thing is newline
	decoded = decoded.replace(/^[\n]/, '');

	// match element = value
 	decoded = decoded.replace(/([a-z\.\"]+)=("|')(.*?)("|')/ig,"<span class=\"red\">$1</span>=$2<span class=\"orange\">$3</span>$4");    

	// mach tags
 	decoded = decoded.replace(/&lt;(.*?)&gt;/ig,"&lt;<span class=\"blue\">$1</span>&gt;");    

	// wrap in pre element
	$(this).wrap('<pre>');

	//change html
	$(this).html(decoded); 
});

/* fix forms*/
$("form#nospam").attr("action",$("form#nospam").attr('rel').replace('xx',''));




