<!-- http://www.codingforums.com/archive/index.php/t-184602.html -->
function ajax_Start(url, target,value_data) {
		
if(value_data != "Nothing" && url.match("txtQuickShareLookup") == "txtQuickShareLookup"  ){
	 document.getElementById('txtQuickShareLookup').value = value_data;
     document.getElementById('txtQuickShareLookup').style.fontSize='14px';
     document.getElementById('txtQuickShareLookup').style.fontFamily='arial, verdana, helvetica';
     document.getElementById('txtQuickShareLookup').style.color ='white';
	 document.getElementById('left_body').style.background = 'white';

}

else {
document.getElementById('txtQuickShareLookup').style.color ='white';
}//end else

if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
}
if (req != undefined) {
req.onreadystatechange = function() {
ajax_Done(url, target);};
req.open("GET",url, true);
req.send("");
}
}

function ajax_Done(url, target) {
if (req.readyState == 4) { // only if req is "loaded"
if (req.status == 200) { // only if "OK"
if(req.responseText.length == "2"){
	document.getElementById('txtQuickShareLookup').value = "Invalid code or company name";
     document.getElementById('txtQuickShareLookup').style.fontSize='14px';
     document.getElementById('txtQuickShareLookup').style.fontFamily='arial, verdana, helvetica';
     document.getElementById('txtQuickShareLookup').style.color ='red';
}else{
document.getElementById(target).innerHTML = req.responseText;
}
} else {
document.getElementById(target).innerHTML=" Error:\n"+ req.status + "\n" +req.statusText;
}
}
}

function zoomSearch(form_name,div,value_data){
	var value_length = value_data.length;
	var regex = /\w/gi;
	if(value_length < 3 || value_data == "Minimum 3 characters." ){
		document.getElementById('txtQuickShareLookup').value = "Minimum 3 characters.";
		document.getElementById('txtQuickShareLookup').style.fontSize='14px';
		document.getElementById('txtQuickShareLookup').style.fontFamily='arial, verdana, helvetica';
		document.getElementById('txtQuickShareLookup').style.color ='red';
	}
	else if(!regex.test(value_data) || value_data == "Invalid characters." ){
		document.getElementById('txtQuickShareLookup').value = "Invalid characters.";
		document.getElementById('txtQuickShareLookup').style.fontSize='14px';
        document.getElementById('txtQuickShareLookup').style.fontFamily='arial, verdana, helvetica';
        document.getElementById('txtQuickShareLookup').style.color ='red';		
	}
	else{
		document.getElementById('txtQuickShareLookup').style.color ='black';
		ajax_Start(form_name,div,value_data);
	}//end if value_data
	
}//end zoomSearch
//http://www.sitepoint.com/forums/php-34/display-form-result-same-div-651773.html
function post_displ(name,div){
	ajax_Start(name,div);
	return false;
}	


var prev_code="0";
function graph_image(code,form_name){
	if(prev_code == "0" || prev_code ==""){
		prev_code = 'J203';
	}//end if code
	if(code == ""){
		form_name += '&code='+prev_code;
		
	}//end code 
	else{
		document.getElementById('code_'+code).style.color = "red";
		 document.getElementById('code_'+prev_code).style.color = "black";
	}//end else
	document.getElementById('graph_frame').innerHTML = "<img src='"+form_name+"' />";

	if(code == "" && prev_code !=""){
		prev_code = prev_code;
	}else{
		prev_code = code;
	}//end else
}//end graph_frame

var prev_content_id =0;
function displ_content(content_id,basket_id,mode){
	var image_val = "container/image.php?content_id="+content_id+"&basket_id="+basket_id+"&mode="+mode;
	var newImg = new Image();
	//make chrome detect heigh
	//http://stackoverflow.com/questions/623172/how-to-get-image-size-height-width-using-javascript
	
	var img_height;
	var img_width;

	newImg.onload = function(){
		 img_height = this.height;
		img_width = this.width;
		if(mode !=""){
			if(img_height <= '290' && img_width <= '300'  ){
			 	document.getElementById('image_displ_'+basket_id).innerHTML = "<img src='"+image_val+"'  />";
        	}
			else if(img_width > '300'){
				document.getElementById('image_displ_'+basket_id).innerHTML = "<img src='"+image_val+"' width='300px' />";
			}//end else if img_width
			else if (img_height > '290'){
            	if(img_width < '300'){
                	document.getElementById('image_displ_'+basket_id).innerHTML = "<img src='"+image_val+"' height='290px'  />";
            	}else{
                	document.getElementById('image_displ_'+basket_id).innerHTML = "<img src='"+image_val+"'  width='300px' />";
            	}//end else img_width
        	}//end img_heigh >
		 }//end if not mode
		
	}//end newImg.onload
	if((mode =="0" || mode =="") && basket_id !="374" ){
	
		document.getElementById('image_displ_'+basket_id).innerHTML = "<img src='images/NewsImage_Generic.jpg'  height='290px' />";
	}//end if mode is empty
	
		 newImg.src = image_val;
		
}//end displ_content_load

function displ_abstr(basket_id,content_id,heading,headline,abstract){
	document.getElementById('abstr_heading_'+basket_id).innerHTML = heading;
	document.getElementById('headline_'+basket_id).innerHTML =headline;
	document.getElementById('abstract1_'+basket_id).innerHTML = abstract;
	document.getElementById('content_id').value = content_id;
}
function hide_content(basket_id){
	document.getElementById('abstract_'+basket_id).style.display="none";
}//end hide_content


 <!--http://www.codeproject.com/KB/aspnet/EnterKeyToButtonClick.aspx-->
function enterOnGo(buttName,e,func){
    var key;
    if(window.event)
        key = window.event.keyCode;
    else
        key = e.which;
	
    if(key == 13){
                	var btn=document.getElementById(buttName);
            	if(btn != null){
		    if(func =='zoomSearch'){
			zoomSearch('quick_search/zoomsearch.php?txtQuickShareLookup='+document.frmQuickShareLookup.txtQuickShareLookup.value,'left_frame',document.frmQuickShareLookup.txtQuickShareLookup.value);
         		e.keyCode = 0;
    		}else{
                	document.getElementById('txtQuickShareLookup').value="";
 	  		}//end if else
		}//end if key
	}//end if key== 13
}//end enterOnGo
<!-- http://www.mediacollege.com/internet/javascript/form/disable-return.html -->
<!--Dont submit when enter key is pressed -->
function stopRKey(evt) {
        var evt  = (evt) ? evt : ((event) ? event : null);
        var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
        if ((evt.keyCode == 13) && (node.type=="text")) { return false; }
}
document.onkeypress = stopRKey;

function clear_txt(txt){
	document.getElementById(txt).value ="";
}//end txt_security
        <!-- http://forrst.com/posts/file_get_contents_in_JavaScript-7bu -->
           function file_get_contents(url)
        {
                if(window.XMLHttpRequest)
                {
                        request = new XMLHttpRequest();
                }
                else if(window.ActiveXObject)
                {
                        request = new ActiveXObject("Microsoft.XMLHTTP");
                }
                request.open("GET", url, false);
                request.send(null);
                return request.responseText;
        }//end file_get_contents
        function embed_jsp_dspl(url,dspl,bckgrnd){
                var left_frame_val = file_get_contents(url);
                	document.getElementById(dspl).innerHTML =left_frame_val;
					 document.getElementById('left_body').style.background = bckgrnd;
					document.getElementById('left_body').style.borderColor='transparent';
        }//end embeded_jsp_dsp


	function embed_frame(url){
		document.getElementById('left_frame').innerHTML = "<iframe src="+url+"  width='715px' height='900px' frameborder='0' scrolling='no'></iframe>";
	}

	function embed_dspl_frame(pg,map_adr){
        document.getElementById('content_lbox').innerHTML ="<iframe src='"+pg+"' width='100%' height='470px' scrolling='no' frameborder='0' ></iframe>";
		document.getElementById('map_adr').innerHTML =document.getElementById(map_adr).innerHTML
	}//end div display
function displ_light_box(url_cont,div_displ){
	var url_val = file_get_contents(url_cont);
	document.getElementById(div_displ).innerHTML = url_val;
	document.getElementById("light").style.display="block";
        document.getElementById("fade").style.display="block";
	scroll(0,0);
}// end displ_light_box

function hide_light_box(){
	document.getElementById('light').style.display='none';
	document.getElementById('fade').style.display='none';	
}//hide_light_box

 function print_art(){
        document.getElementById('content_lbox').style.visibility='visible';
        document.getElementById('content_lbox').style.width='800px';
        document.getElementById('bodyName').style.visibility='hidden';
        window.print();
        setTimeout("window.close()", 500);
        document.getElementById('bodyName').style.visibility='visible';

}
function print_art2(content_id){
	var strid = 'content_lbox';
	var printContent = document.getElementById(strid); 
	var windowUrl = 'about:blank'; 
	var uniqueName = new Date(); 
	var windowName = 'Print' + uniqueName.getTime(); 
	var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;

	printWindow = window.open(windowUrl, windowName, "width=200,height=100"); 

	var strContent = document.getElementById(strid).innerHTML;
	strContent = strContent+"<center>"+document.getElementById('footer_image').innerHTML+"<br>";
	 strContent = strContent+document.getElementById('footer').innerHTML+"</center>";

	if(navigator.appName == 'Opera'){
		printWindow.document.body.innerHTML = strContent;
	}else{
		printWindow.document.write(strContent); 
	}
	printWindow.document.close(); 
	printWindow.focus(); 
	printWindow.print();
	if(is_chrome == 'false'){
		printWindow.window.close();
	}//end is_chrome
}//end print_art2 funvtion


function displ_img(img,locate){
	document.getElementById(locate).innerHTML = "<img src="+img+" />";
}//end displ_img

function getCellPos(cell){
  var cells = cell.parentNode.getElementsByTagName('td');
  for (var i=0; i<cells.length; i++){
    if (cells[i]==cell){
       alert("Position is "+i);
       break;
    }
  }
}//end getCellPos;

