//trail ver
function removeImagOld()
{
	var arrtest = document.getElementsByTagName("img");
	for(i=0;i<arrtest.length;i++)
	{
		arrtest[i].style.display="none";
	}
	var arrtest = document.all;
	for(i=0;i<arrtest.length;i++)
	{
		arrtest[i].style.background = "";
		arrtest[i].style.color = "black";
	}
	return;
}

//a function that need to use JQuery
//need to include the following js, better download and rename it b4 use
//http://code.google.com/p/jqueryjs/downloads/detail?name=jquery-1.1.3.1.js
function removeImag()
{
	$("img").each(function(){
		tmpStr = $(this).attr("alt");
		tmpImgSrc = "";
		if (tmpStr == null){ tmpStr = ""; tmpImgSrc = $(this).attr("src");}
		if (tmpImgSrc.lastIndexOf("/") != -1) tmpImgSrc = tmpImgSrc.substring(tmpImgSrc.lastIndexOf("/")+1, tmpImgSrc.length); //to filter the pure file name
		if (tmpImgSrc.indexOf("spacer.gif") != -1) tmpStr = "";   //to filter out some unwanted file name
		if (tmpImgSrc.indexOf("gra_") != -1) tmpStr = "";
		if (tmpImgSrc.indexOf("sec2_") != -1) tmpStr = "";
		if (tmpImgSrc.indexOf("sec_") != -1) tmpStr = "";
		if (tmpStr != "" && tmpStr != "*" && tmpStr.replace(" ", "") != "") tmpStr = "[image:" + tmpStr + "]";
		if (tmpStr.replace(" ", "") == "") tmpStr = tmpStr.replace(" ", "&nbsp;");
		$(this).after(tmpStr); //add the filename/alt text after the images
		$(this).hide(); //hide the images
	});
	
	//find out the elements, and remove their background
	$("p, span, div, td, tr, table").each(function() {
		$(this).css("background-image", "none");
		$(this).css("background-color", "#FFFFFF");
		$(this).css("color", "black");
	    if($(this).attr("cellspacing") == "1" && ($(this).attr("cellpadding") == "2" || $(this).attr("cellpadding") == "3")){
	        $(this).attr("cellspacing", "0")
	        $(this).attr("border", "1");
	        $(this).attr("border-color", "#000000");
	    }
	});
	
	$("a").each(function(){
		tmpStr = $(this).attr("href");
		tmpID = $(this).attr("id");
		    tmp_output = "";    
		if(tmpID == null) tmpID = "";
		if(tmpStr != "#" && getParameter(tmpStr, "textOnly") == "null"  && !(tmpStr.toLowerCase().indexOf("http://") >= 0 || tmpStr.toLowerCase().indexOf("ftp://") >= 0 ) 
		&& tmpID.toLowerCase() != "link_grahpic") {

		    delimiter = "?";
		    if(tmpStr.indexOf("?") >= 0){
		        delimiter = "&";
		    }
		    tmp_output = "";
		    if(!(tmpStr.toLowerCase().indexOf(":") >= 0) && (tmpStr.toLowerCase().indexOf(":") < tmpStr.toLowerCase().indexOf("?"))){
		        tmp_output = $(this).attr("href") + delimiter+"textOnly=true";
		    }
		    else{
		        tmp_output = $(this).attr("href");
		    }
		    $(this).attr("href", tmp_output);
		}
	});
	
	$("input").each(function(){
	    tmpType = $(this).attr("type");
	    tmpID = $(this).attr("id");
	    tmpStr = $(this).attr("alt");
	    if(tmpStr == "" || tmpStr == null){
	        tmpStr = $(this).attr("value");
	    }
	    if(tmpStr == "" || tmpStr == null){
	        tmpStr = $(this).attr("name");
	    }
	    if(tmpStr == "" || tmpStr == null){
	        tmpStr = $(this).attr("id");
	    }
	    if(tmpType.toLowerCase() == "image"){
	        $(this).after("<a href=\"#\" onclick=\"document.getElementById('" + tmpID + "').click();return false;\">" + tmpStr + "</a>");
	        $(this).hide();
	    }
	    
	});
	
	
	

	

}

//window.onload, in JQuery way
$(document).ready(function() {
	removeImag();
})


function getParameter(queryString, parameterName ) {
    // Add "=" to the parameter name (i.e. parameterName=value)
    var parameterName = parameterName + "=";
    if ( queryString.length > 0 ) {
        // Find the beginning of the string
        begin = queryString.indexOf ( parameterName );
        // If the parameter name is not found, skip it, otherwise return the value
        if ( begin != -1 ) {
            // Add the length (integer) to the beginning
            begin += parameterName.length;
            // Multiple parameters are separated by the "&" sign
            end = queryString.indexOf ( "&" , begin );
            if ( end == -1 ) {
                end = queryString.length;
            }
            // Return the string
            return unescape ( queryString.substring ( begin, end ) );
        }
        // Return "null" if no parameter has been found
        return "null";
    }
} 
