/**
 * [Short description]
 *
 * Javascript
 *
 * @category   [cat]
 * @package    [pack]
 * @subpackage [subpack]
 * @since      Mon Apr 10 14:56:16 EDT 2006
 * @author     Jasmin Tondreau <jtondrea@logistec.com>
 * @copyright  ©2008 logistec corporation. All rights reserved.
 * @version    0.01
 */

function setDisplay(BlockName, BlockName2, BlockName3, arrowName, changeWeight) {  // set display onLoad  v1.0
	if(document.getElementById(BlockName)) {
		if (document.getElementById(BlockName).style.display == "block") {
			document.getElementById(BlockName2).src = "images/arrow_" + arrowName + "_on.gif";
			document.getElementById(BlockName2).alt = "Close";
			if(changeWeight) document.getElementById(BlockName3).style.fontWeight = "bold";
		} else {
			document.getElementById(BlockName2).src = "images/arrow_" + arrowName + "_off.gif";
			document.getElementById(BlockName2).alt = "Open";
			if(changeWeight) document.getElementById(BlockName3).style.fontWeight = "normal";
		}
	}
}

function createCookie(name,value,days)
{
	if(days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*365));
		var expires = "; expires="+date.toGMTString();
	} else {
		var expires = "";
	}
	
	document.cookie = name+"="+value+expires+"; path=/";
}

/**  
  * Concatenates the values of a variable into an easily readable string  
  * by Matt Hackett [scriptnode.com]  
  * @param {Object} x The variable to debug  
  * @param {Number} max The maximum number of recursions allowed (keep low, around 5 for HTML elements to prevent errors) [default: 10]  
  * @param {String} sep The separator to use between [default: a single space ' ']  
  * @param {Number} l The current level deep (amount of recursion). Do not use this parameter: it's for the function's own use  
  */  
function print_r(x, max, sep, l) 
{   
     l = l || 0;   
     max = max || 10;   
     sep = sep || ' ';   
   
     if (l > max) {   
         return "[WARNING: Too much recursion]\n";   
     }   
   
     var  
         i,   
         r = '',   
         t = typeof x,   
         tab = '';   
   
     if (x === null) {   
         r += "(null)\n";   
     } else if (t == 'object') {   
   
         l++;   
   
         for (i = 0; i < l; i++) {   
             tab += sep;   
         }   
   
         if (x && x.length) {   
             t = 'array';   
         }   
   
         r += '(' + t + ") :\n";   
   
         for (i in x) {   
             try {   
                 r += tab + '[' + i + '] : ' + print_r(x[i], max, sep, (l + 1));   
             } catch(e) {   
                 return "[ERROR: " + e + "]\n";   
             }   
         }   
   
     } else {   
   
         if (t == 'string') {   
             if (x == '') {   
                 x = '(empty)';   
             }   
         }   
   
         r += '(' + t + ') ' + x + "\n";   
   
     }   
   
     return r;   
   
}; 

function ExpandMenu(sp_block_name, sp_image_dir, sp_code) {
	if (document.getElementById(sp_block_name).style.display == "block") {
		document.getElementById(sp_block_name).style.display= "none";
		document.getElementById(sp_code + "_image").src= sp_image_dir + "arrow_browse_off.gif";
		document.getElementById(sp_code + "_image").alt= "Open";
		document.getElementById(sp_code + "_text").style.fontWeight = "normal";
		createCookie("values[menu_" + sp_code + "]",0,1);
	} else if(document.getElementById(sp_block_name).style.display == "none") {
		document.getElementById(sp_block_name ).style.display= "block";
		document.getElementById(sp_code + "_image").src= sp_image_dir + "arrow_browse_on.gif";
		document.getElementById(sp_code + "_image").alt= "close";
		document.getElementById(sp_code + "_text").style.fontWeight = "bold";
		createCookie("values[menu_"+sp_code+"]",1,1);
	}
}

function ExpandBlock(sp_block_name, sp_image_dir, sp_code, bp_open) {
	if(bp_open) {
		if(document.getElementById(sp_block_name).style.display == "none") {
			document.getElementById(sp_block_name ).style.display= "block";
			document.getElementById(sp_code + "_image").src= sp_image_dir + "arrow_browse_on.gif";
			document.getElementById(sp_code + "_image").alt= "close";
			document.getElementById(sp_code + "_text").style.fontWeight = "bold";
			createCookie("values[lpanel_"+sp_code+"]",1,1);
		}		
	} else {
		if(document.getElementById(sp_block_name).style.display == "block") {
			document.getElementById(sp_block_name).style.display= "none";
			document.getElementById(sp_code + "_image").src= sp_image_dir + "arrow_browse_off.gif";
			document.getElementById(sp_code + "_image").alt= "Open";
			document.getElementById(sp_code + "_text").style.fontWeight = "normal";
			createCookie("values[lpanel_" + sp_code + "]",0,1);
		} else if(document.getElementById(sp_block_name).style.display == "none") {
			document.getElementById(sp_block_name ).style.display= "block";
			document.getElementById(sp_code + "_image").src= sp_image_dir + "arrow_browse_on.gif";
			document.getElementById(sp_code + "_image").alt= "close";
			document.getElementById(sp_code + "_text").style.fontWeight = "bold";
			createCookie("values[lpanel_"+sp_code+"]",1,1);
		}
	}
}

function ExpandBlockNews(sp_block_name, sp_block_name2, sp_code, sp_code2) {
	if (document.getElementById(sp_block_name).style.display == "block") {
		document.getElementById(sp_block_name).style.display= "none";
		document.getElementById(sp_block_name2).style.display= "block";
		createCookie("values[lpanel_" + sp_block_name + "]",0,1);
	} else if(document.getElementById(sp_block_name).style.display == "none") {
		document.getElementById(sp_block_name ).style.display= "block";
		document.getElementById(sp_block_name2).style.display= "none";
		createCookie("values[lpanel_" + sp_block_name + "]",1,1);
	}
}


function ExpandDataBlock(sp_block_name, sp_image_dir, sp_code) {
	if (document.getElementById(sp_block_name).style.display == "block") {
		document.getElementById(sp_block_name).style.display= "none";
		document.getElementById(sp_code + "_image").src= sp_image_dir + "arrow_browse_off.gif";
		document.getElementById(sp_code + "_image").alt= "Open";
		//document.getElementById(sp_code + "_text").style.fontWeight = "normal";
	} else if(document.getElementById(sp_block_name).style.display == "none") {
		document.getElementById(sp_block_name ).style.display= "block";
		document.getElementById(sp_code + "_image").src= sp_image_dir + "arrow_browse_on.gif";
		document.getElementById(sp_code + "_image").alt= "close";
		//document.getElementById(sp_code + "_text").style.fontWeight = "bold";
	}
}

function OpenTable(sp_table_name, bp_open_close) {
   	if(bp_open_close) { 
 		document.getElementById(sp_table_name).style.display= 'none'; 
 	} else {  
 		document.getElementById(sp_table_name).style.display= 'block'; 
 	}
}

function OpenCloseTable(sp_table_name) {
   	if(document.getElementById(sp_table_name).style.display == 'block') { 
 		document.getElementById(sp_table_name).style.display= 'none'; 
 	} else {  
 		document.getElementById(sp_table_name).style.display= 'block'; 
 	}
}

function OpenCloseFilter(sp_table_name) {
	if (document.getElementById(sp_table_name).style.display == "block") {
		document.getElementById(sp_table_name).style.display= "none";
		document.getElementById("filter_lnk").innerHTML= "Show Filter";
	} else if(document.getElementById(sp_table_name).style.display == "none") {
		document.getElementById(sp_table_name).style.display= "block";
		document.getElementById("filter_lnk").innerHTML= "Close Filter";
	}
}

function getValue(varname)
{
  // First, we load the URL into a variable
  var url = window.location.href;

  // Next, split the url by the ?
  var qparts = url.split("?");

  // Check that there is a querystring, return "" if not
  if (qparts.length == 0)
  {
    return "";
  }

  // Then find the querystring, everything after the ?
  var query = qparts[1];

  // Split the query string into variables (separates by &s)
  var vars = query.split("&");

  // Initialize the value with "" as default
  var value = "";

  // Iterate through vars, checking each one for varname
  for (i=0;i<vars.length;i++)
  {
    // Split the variable by =, which splits name and value
    var parts = vars[i].split("=");
    
    // Check if the correct variable
    if (parts[0] == varname)
    {
      // Load value into variable
      value = parts[1];

      // End the loop
      break;
    }
  }
  
  // Convert escape code
  value = unescape(value);

  // Convert "+"s to " "s
  value.replace(/\+/g," ");

  // Return the value
  return value;
}

function setRange(sp_code, sp_code_start, sp_code_end) { // Setup Year Range  v1.1
	var year_start_id= document.getElementById(sp_code_start).options[document.getElementById(sp_code_start).options.selectedIndex].value;
	var year_end_id= document.getElementById(sp_code_start).options[document.getElementById(sp_code_end).options.selectedIndex].value;
	var yearOptions= document.getElementById(sp_code).options;

	if(year_start_id > 0 && year_end_id > 0) {
		if(year_start_id <= year_end_id) {
			yearOptions[yearOptions.length] = new Option(year_start_id + "-" + year_end_id, year_start_id + "-" + year_end_id, false, true);
		} else if(year_start_id > year_end_id) {
			yearOptions[yearOptions.length] = new Option(year_end_id + "-" + year_start_id, year_end_id + "-" + year_start_id, false, true);
		}
	}
}

function removeRange(sp_code, sp_code_start, sp_code_end) { // Remove Year Range  v1.1
	var yearOptions= document.getElementById(sp_code).options;

	if(yearOptions[yearOptions.length - 1].value.substring(4,5) == "-") {
		document.getElementById(sp_code_start).options.selectedIndex = 0;
		document.getElementById(sp_code_end).selectedIndex = 0;
		yearOptions[yearOptions.length - 1] = null;
	}
}

function checkMinInput(formBlock, inputBlock, minValue, alertMessage) { // Form TextField checkup  v1.1
	var blockString = eval("document." + formBlock + "." + inputBlock + ".value");

	if(blockString.length > 0 && blockString.length < minValue) {
		alert(alertMessage);
		return false;
	}
	return true;
}

function setFocus() {
	if(document.login.username.value.length < 1) document.login.username.focus();
	else document.login.password.focus();
}

function setWaitingDisplay(thisFunction, params) {
	
	var param = '';
	
	for(i=0; i<params.length; i++) {
		param += "'"+params[i]+"',";
	}
	
	param = param.substring(0, param.length - 1);
	
	var tmp = eval(thisFunction + '(' + param + ');');
	return tmp;
}

// Here is advanced JavaScript'ing
// We are gonna add event handler to boxes that needed 
// to be validated at keypress!
function validateKeyOutOfContext(code) {	

	var keyb = new Array(
		"8",  // Ascii code for BACKSPACE
		"9",  // Ascii code for TAB
		"13", // Ascii code for ENTER
		"16", // Ascii code for SHIFT
		"17", // Ascii code for CTRL
		"18", // Ascii code for ALT
		"32", // Ascii code for spacebar
		"35", // Ascii code for END
		"36", // Ascii code for HOME
		"37", // Ascii code for LEFT ARROW
		"38", // Ascii code for UP ARROW
		"39", // Ascii code for RIGHT ARROW
		"40", // Ascii code for DOWN ARROW
		"46"  // Ascii code for DELETER
	);
	
	// Si nous avons un backspace, del, ctrl, alt ...
	for(var i=0; i<keyb.length; i++) {
		if(code == keyb[i]) {
			return true;
		}
	}
	
	return false;
}

function setEventHandler(obj, type, frm) {

	var btnHandler = document.getElementById(frm);
	
	// If type is digitOnly
	if(type == "digitOnly") {
		obj.onkeypress = function (e) {
			var code;
			if (!e) var e = window.event;
		    if (e.keyCode) code = e.keyCode;
			else if (e.which) code = e.which;
			
			if((code >= 48 && code <= 57 )) {
			   	return true;
			} 
			
			if(validateKeyOutOfContext(code)) {
				return true;
			}
			
			return false;
		}
		
		btnHandler.onsubmit = function () {
			var qty = obj.value;
						
			if(qty > myWdQtyLimit) {
				obj.focus();
				obj.value = myWdQtyLimit;
				
				alert(PartLimit);				
				
				return false;
			}
			
		}
		
	}
}

function setEventHandlerMaxCommentChar(obj, max) {
		
	obj.onkeypress = function (e) {
		var text = obj.value;
		var code;
		if (!e) var e = window.event;
	    if (e.keyCode) code = e.keyCode;
		else if (e.which) code = e.which;
		
		if((code >= 48 && code <= 122 )) {
			if(text.length < max) {
			   	return true;
			} else {
				return false;
			}
		} 
		
		if(validateKeyOutOfContext(code)) {
			return true;
		}
		
		if((code == 39 || code == 46 )) {
		   	return true;
		} 
		
		return false;
	}
	
	obj.onkeyup = function () {
		var text = obj.value;
		var tInputLen = document.getElementById("txtLength");
		
		tInputLen.value = text.length + "/" + max;
	}
	
	obj.onkeydown = function () {
		var text = obj.value;
		var tInputLen = document.getElementById("txtLength");
		
		tInputLen.value = text.length + "/" + max;
	}
}

function popWindow(hInstanceName, wURL, wWidth, wHeight, wScrolling, wStatus, wAddressBar, wMenu, wResizable, wToolbar) {
	
	var wPopUpWindow = null;

	var tPosX = (screen.width - parseInt(wWidth)) / 2;
	var tPosY = (screen.height - parseInt(wHeight)) / 2 - 30;	
	
	wPopUpWindow = window.open(wURL, hInstanceName, 'height='+wHeight+',width='+wWidth+',resizable='+wResizable+',location='+wAddressBar+',menubar='+wMenu+',status='+wStatus+',toolbar='+wToolbar+',top='+tPosY+',left='+tPosX+',scrollbars='+wScrolling);
}

// CONSTANTS
var separator = ",";  // use comma as 000's separator
var decpoint = ".";  // use period as decimal point
var percent = "%";
var currency = "$";  // use dollar sign for currency

function formatNumber(number, format, print) {  // use: formatNumber(number, "format")
	if (print) document.write("formatNumber(" + number + ", \"" + format + "\")<br>");
	
	if (number - 0 != number) return null;  // if number is NaN return null
	var useSeparator = format.indexOf(separator) != -1;  // use separators in number
	var usePercent = format.indexOf(percent) != -1;  // convert output to percentage
	var useCurrency = format.indexOf(currency) != -1;  // use currency format
	var isNegative = (number < 0);
	number = Math.abs (number);
	if (usePercent) number *= 100;
	format = strip(format, separator + percent + currency);  // remove key characters
	number = "" + number;  // convert number input to string
	
	 // split input value into LHS and RHS using decpoint as divider
	var dec = number.indexOf(decpoint) != -1;
	var nleftEnd = (dec) ? number.substring(0, number.indexOf(".")) : number;
	var nrightEnd = (dec) ? number.substring(number.indexOf(".") + 1) : "";
	
	 // split format string into LHS and RHS using decpoint as divider
	dec = format.indexOf(decpoint) != -1;
	var sleftEnd = (dec) ? format.substring(0, format.indexOf(".")) : format;
	var srightEnd = (dec) ? format.substring(format.indexOf(".") + 1) : "";
	
	 // adjust decimal places by cropping or adding zeros to LHS of number
	if (srightEnd.length < nrightEnd.length) {
		var nextChar = nrightEnd.charAt(srightEnd.length) - 0;
		nrightEnd = nrightEnd.substring(0, srightEnd.length);
		if (nextChar >= 5) nrightEnd = "" + ((nrightEnd - 0) + 1);  // round up
		
		// patch provided by Patti Marcoux 1999/08/06
		while (srightEnd.length > nrightEnd.length) {
			nrightEnd = "0" + nrightEnd;
		}
		
		if (srightEnd.length < nrightEnd.length) {
			nrightEnd = nrightEnd.substring(1);
			nleftEnd = (nleftEnd - 0) + 1;
		}
	} else {
		for (var i=nrightEnd.length; srightEnd.length > nrightEnd.length; i++) {
			if (srightEnd.charAt(i) == "0") nrightEnd += "0";  // append zero to RHS of number
			else break;
		}
	}
	
	 // adjust leading zeros
	sleftEnd = strip(sleftEnd, "#");  // remove hashes from LHS of format
	while (sleftEnd.length > nleftEnd.length) {
		nleftEnd = "0" + nleftEnd;  // prepend zero to LHS of number
	}
	
	if (useSeparator) nleftEnd = separate(nleftEnd, separator);  // add separator
	var output = nleftEnd + ((nrightEnd != "") ? "." + nrightEnd : "");  // combine parts
	output = ((useCurrency) ? currency : "") + output + ((usePercent) ? percent : "");
	if (isNegative) {
		// patch suggested by Tom Denn 25/4/2001
		output = (useCurrency) ? "(" + output + ")" : "-" + output;
	}
	return output;
}

function strip(input, chars) {  // strip all characters in 'chars' from input
	var output = "";  // initialise output string
	for (var i=0; i < input.length; i++)
		if (chars.indexOf(input.charAt(i)) == -1)
			output += input.charAt(i);
	return output;
}

function separate(input, separator) {  // format input using 'separator' to mark 000's
	input = "" + input;
	var output = "";  // initialise output string
	for (var i=0; i < input.length; i++) {
		if (i != 0 && (input.length - i) % 3 == 0) output += separator;
		output += input.charAt(i);
	}
	return output;
}

function setChecked(formId,val,chkId) {
	doc =document.forms[formId];
	len = doc.elements.length;
	var i=0;
	for( i=0 ; i<len ; i++) {
		if (doc.elements[i].id==chkId) {
			doc.elements[i].checked=val;
		}
	}
}

/**
 * HTML Request / AJAX
 */
function setContents(httpRequest) 
{
    if (httpRequest.readyState == 4) {
        if (httpRequest.status == 200) {

            //alert(httpRequest.responseText);
            try {
	            eval("var decoded_data = "+httpRequest.responseText+";");
	        } catch(err) {
				txt="There was an error on this page.\n\n";
			  	txt+="Error description: " + err.description + "\n\n";
				txt+="Your PHP error is going appear at the bottom of the page.\n\n";
				txt+="Click OK to continue.\n\n";
				alert(txt);
				window.document.body.innerHTML+= httpRequest.responseText;
				//alert(httpRequest.responseText); 
				clearTimeout(t);
			}
			
            /*
            try {
            	decoded_data= decoded_data;
	        } catch(err) {
				txt="There was an error on this page.\n\n";
			  	txt+="Error description: " + err.description + "\n\n";
				txt+="Your PHP error is going appear at the bottom of the page.\n\n";
				txt+="Click OK to continue.\n\n";
				alert(txt);
				window.document.body.innerHTML+= httpRequest.responseText;
	        }*/
	        
			for(i=0; i < decoded_data.length; i++) {
		    	if(decoded_data[i].html_id) {
			    	elt= document.getElementById(decoded_data[i].html_id);
				    if(elt == null) {
				    	alert(decoded_data[i].html_id);
				    	alert(decoded_data[i].html);
				    } 
				    
				    // Verify if keep the old data or just replace-it.
				    if(decoded_data[i].add_data) {
				    	elt.innerHTML= decoded_data[i].html + elt.innerHTML;
				    } else {
	   				    if(!decoded_data[i].execute_js) {
	   				    	elt.innerHTML= decoded_data[i].html;
	   				    } 
				    }
	
				    if(decoded_data[i].change_class != undefined) {
				    	elt.className= decoded_data[i].change_class;
				    }
				    
				} else {
					if(decoded_data[i].execute_js) {
			            // if execute_js yes eval the javascript code in the index html
			            try {
				            eval(decoded_data[i].html);
				        } catch(err) {
							txt="There was an error on this page.\n\n";
						  	txt+="Error description: " + err.description + "\n\n";
							txt+="Click OK to continue.\n\n";
							alert(txt);
							window.document.body.innerHTML+= decoded_data[i].html;
							clearTimeout(t);
						}
					}
				}
			}

			clearTimeout(t);
			
        } else {
            alert('There was a problem with the request. ready state ' + httpRequest.readyState + ' status ' + httpRequest.status + ' obj ' + httpRequest + ' response ' + httpRequest.responseText);
            clearTimeout(t);
        }
    }
}

function AjaxRequest(url, parameters)
{
	var httpRequest;

    if (window.XMLHttpRequest) { // Mozilla, Safari, ...
        httpRequest = new XMLHttpRequest();
        if (httpRequest.overrideMimeType) {
            httpRequest.overrideMimeType('text/xml');
            // See note below about this line
        }
    } else if (window.ActiveXObject) { // IE
        try {
            httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
        	try {
                httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }

    if (!httpRequest) {
        alert('Cannot create an XMLHTTP instance');
        return false;
    }
    
    httpRequest.onreadystatechange = function() { setContents(httpRequest); };
    if(parameters != null) {
    	//alert(parameters);
    	//httpRequest.open('GET', url + parameters, true);
		
		//Remove the first &
    	parameters= parameters.substr(1);
		
		httpRequest.open('POST', url, true);
		
		httpRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		httpRequest.setRequestHeader("Content-length", parameters.length);
		httpRequest.setRequestHeader("Connection", "close");		
		
		//alert(parameters);
		httpRequest.send(parameters);
    } else {
    	//alert(url);
    	httpRequest.open('GET', url, true);
		httpRequest.send('');
    }
}

function GetSubmit(obj) {
  var getstr = ""; // "?"

  if(obj != null) {

  for(i=0; i < obj.elements.length; i++) {
    
     if (obj.elements[i].tagName == "INPUT") {
        if (obj.elements[i].type == "text") {
           getstr += "&" + obj.elements[i].name + "=" + obj.elements[i].value;
        }
        if (obj.elements[i].type == "hidden") {
           getstr += "&" + obj.elements[i].name + "=" + obj.elements[i].value;
        }
        if (obj.elements[i].type == "password") {
           getstr += "&" + obj.elements[i].name + "=" + obj.elements[i].value;
        }
        if (obj.elements[i].type == "checkbox") {
           if (obj.elements[i].checked) {
              getstr += "&" + obj.elements[i].name + "=" + obj.elements[i].value;
           } else {
              getstr += "&" + obj.elements[i].name + "=";
           }
        }
        if (obj.elements[i].type == "radio") {
           if (obj.elements[i].checked) {
              getstr += "&" + obj.elements[i].name + "=" + obj.elements[i].value;
           }
        }
     }   

	if (obj.elements[i].tagName == "TEXTAREA") {
	    getstr += "&" + obj.elements[i].name + "=" + obj.elements[i].value;
	}
	
     if (obj.elements[i].tagName == "SELECT") {
        var sel= obj.elements[i];
        if(sel.type != "select-multiple") {
	        if(sel.selectedIndex >= 0 && typeof(sel.options[sel.selectedIndex]) != "unknown") {
	            //alert(typeof(sel) + ' - ' + typeof(sel.options[sel.selectedIndex]) + ' - ' + sel.options[sel.selectedIndex].value);
		        getstr += "&" + sel.name + "=" + sel.options[sel.selectedIndex].value;
		    }    
		} else {
			if(sel.selectedIndex >= 0 && typeof(sel.options[sel.selectedIndex]) != "unknown") {
				var j= 0;
				for (j=0; j < sel.options.length; j++) {
					if(sel.options[j].selected) {
					  getstr+= "&" + sel.name + "=" + sel.options[j].value;
					}
				}
			}
		}
     }
    }
  }
  
  return getstr;
}

var begin= 0;
var t= 0;

function displayTimeCounter()
{ 
	var d = new Date();
	window.status= "Ajax execution time: " + Math.round(((((d.getMinutes() * 60) + d.getSeconds()) + '.' + d.getMilliseconds())  - begin) * 10000) / 10000 + " seconds";
	t= setTimeout("displayTimeCounter()",100); 
} 


function get(lnk, obj, processing, processing_lit, display_time_counter) 
{
	var d = new Date();
	begin= ((d.getMinutes() * 60) + d.getSeconds()) + '.' + d.getMilliseconds();
	if(typeof(display_time_counter) == 'undefined' || display_time_counter) {
		displayTimeCounter();
	}
	
	var getstr = ""; // "?"
	
	if(obj != '') {
		getstr += GetSubmit(obj);
	}
	
	if(processing && processing_lit) {
		Elt= document.getElementById(processing);
		Elt.innerHTML= processing_lit;
	}
	
	AjaxRequest(lnk, getstr);
}

function SetDivInfo(sp_div_id, sp_info) 
{
	document.getElementById(sp_div_id).innerHTML= sp_info;
}

