$(document).ready(function() {
    $("body").pngFix(); 
    //resize();
    
    $("a[rel^='prettyPhoto']").prettyPhoto(
    {
    showTitle: false,
    theme: 'light_square'}
    );
    
    $(".source").removeAttr("onclick");
    $(".quote-link").remove();
    
    $(".banner_click").click(function () {
    var div_id = $(this).attr("name");
    
        if ($("#"+div_id).is(":hidden")) {
        $("#"+div_id).show();
        } else {
        $("#"+div_id).hide();
        }
    
    return false;
    });
    
});


function resize() {
    var leftcol_h = $("#lk").height();
    var rightcol_h = $("#rk").height();
    var center_h = $("#ck").height();
    //var max_h = (leftcol_h>rightcol_h && leftcol_h>center_h?leftcol_h:center_h>rightcol_h?center_h:rightcol_h);
    var max_h = $("#three_columns").height();
    if(leftcol_h < max_h) $("#lk").css("height",max_h); 
    if(rightcol_h < max_h) $("#rk").css("height",max_h); 
    //if(center_h < max_h) $("#ck").css("height",max_h); 
    //$("#rk").css("height",max_h); 
    
}

function cleanWord(text)
{
	text = text.replace(/<(P|B|U|I|STRIKE)>&nbsp;<\/\1>/g, ' ');
	text = text.replace(/<o:p>[\s\S]*?<\/o:p>/ig, "&nbsp;");

	text = text.replace(/<!--\[[\s\S]*?\]-->/ig, ""); //<!--[.....]-->	-	<!--[if gte mso 9]>...<![endif]-->
	text = text.replace(/<!\[[\s\S]*?\]>/ig, "");		//	<! [if !vml]>
	text = text.replace(/<\\?\?xml[^>]*>/ig, "");	//<xml...>, </xml...>

	text = text.replace(/<o:p>\s*<\/o:p>/ig, "");

	text = text.replace(/<\/?[a-z1-9]+:[^>]*>/gi, "");	//<o:p...>, </o:p>
	text = text.replace(/<([a-z1-9]+[^>]*) class=([^ |>]*)(.*?>)/gi, "<$1$3");
	text = text.replace(/<([a-z1-9]+[^>]*) [a-z]+:[a-z]+=([^ |>]*)(.*?>)/gi, "<$1$3"); //	xmlns:v="urn:schemas-microsoft-com:vml"

	// Remove mso-xxx styles.
	text = text.replace(/\s*mso-[^:]+:[^;"]+;?/gi, "");

	// Remove margin styles.
	text = text.replace(/\s*margin: 0cm 0cm 0pt\s*;/gi, "");
	text = text.replace(/\s*margin: 0cm 0cm 0pt\s*"/gi, "\"");

	//if (removeIndents)

		text = text.replace(/\s*TEXT-INDENT: 0cm\s*;/gi, "");
		text = text.replace(/\s*TEXT-INDENT: 0cm\s*"/gi, "\"");

	text = text.replace(/\s*TEXT-ALIGN: [^\s;]+;?"/gi, "\"");
	text = text.replace(/\s*PAGE-BREAK-BEFORE: [^\s;]+;?"/gi, "\"");
	text = text.replace(/\s*FONT-VARIANT: [^\s;]+;?"/gi, "\"");
	text = text.replace(/\s*tab-stops:[^;"]*;?/gi, "");
	text = text.replace(/\s*tab-stops:[^"]*/gi, "");

	// Remove FONTS
		text = text.replace(/<FONT[^>]*>([\s\S]*?)<\/FONT>/gi, '$1');
		text = text.replace(/\s*face="[^"]*"/gi, "");
		text = text.replace(/\s*face=[^ >]*/gi, "");
		text = text.replace(/\s*FONT-FAMILY:[^;"]*;?/gi, "");

	// Remove Class attributes
	text = text.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3");

	// Remove styles.
		text = text.replace(/<(\w[^>]*) style="([^\"]*)"([^>]*)/gi, "<$1$3");

	// Remove empty styles.
	text = text.replace(/\s*style="\s*"/gi, '');

	// Remove Lang attributes
	text = text.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3");

	var iter = 0;
	while (text.toLowerCase().indexOf('<span') != -1 && text.toLowerCase().indexOf('</span>') != -1 && iter++ < 20)
		text = text.replace(/<span[^>]*?>([\s\S]*?)<\/span>/gi, '$1');

	// Remove empty tags
	text = text.replace(/<([^\s>]+)[^>]*>[\s\n\t\r]*<\/\1>/g, '');
	text = text.replace(/<([^\s>]+)[^>]*>\s*<\/\1>/g, '');
	text = text.replace(/<([^\s>]+)[^>]*>\s*<\/\1>/g, '');

	//text = text.replace(/<\/?xml[^>]*>/gi, "");	//<xml...>, </xml...>
	text = text.replace(/<xml[^>]*?(?:>\s*?<\/xml)?(?:\/?)?>/ig, '');
	text = text.replace(/<meta[^>]*?(?:>\s*?<\/meta)?(?:\/?)?>/ig, '');
	text = text.replace(/<link[^>]*?(?:>\s*?<\/link)?(?:\/?)?>/ig, '');
	text = text.replace(/<style[\s\S]*?<\/style>/ig, '');


		text = text.replace(/&nbsp;/ig, ' ');
		text = text.replace(/\s+?/gi, ' ');



		text = text.replace(/<table([\s\S]*?)>/gi, "<table>");


		text = text.replace(/<tr([\s\S]*?)>/gi, "<tr>");
		text = text.replace(/<td([\s\S]*?)>/gi, "<td>");


	return text;
};
