// Common Js functions 

function help_appear(popup)
{
	var object = $(popup);
	new Effect.Appear(object, { duration: 1.0, from: 0.0, to: 1.0 });
}
function hide_help (popup)
{
	var object = $(popup);
	new Effect.Fade(object, { duration: 1.0 });
}

// refresh_cart_content() - Refresh Cart Summary
function refresh_cart_content() {

	if($('refresh_cart_ajax_box')) { // if the side bar app for the cart content is showing on this page, then...
	
		new Ajax.Updater('refresh_cart_ajax_box', 'apps/sidebar_apps/cart_summar_refreshy.inc.php', { method: 'get' });
	 }
}


var myfunc;

/* Function that allows you to add onload events with ease 
 */
function addNewOnload(myfunc) {

	if(window.addEventListener)
		 window.addEventListener('load', myfunc, false);
	else if(window.attachEvent)
		 window.attachEvent('onload', myfunc);
}
//addNewOnload(alert('a'));


/* Function that allows you to add functions to different events on the go
 */
function addNewEvent(e, myfunc) {  
	 
	 var old_event = this[e];  
	 if (old_event) {  
		 this[e] = function(e) {  
			 old_event();  
			 myfunc();  
		 };  
	 }  
	 else this[e] = myfunc();  
} 
//addNewEvent(onload,alert('b'));


/* Function that tests if another function exists
 */
 function functionPreExists(myfunc) {
 
	if (typeof myfunc == "function") return true;
	else return false;
 }
//if(functionPreExists(addNewEvent)) { addNewEvent(onload,alert('b')); }	


// Highlight product 
function highlightProduct(productId,newColor,newBorder) {
	
	var newID = $(productId);
	newID.style.background = newColor;
	newID.style.borderTop = newBorder;
}


/**
 * AJAX 
 */	
function makeObject(){ 
	var x; 
	if (window.ActiveXObject) { 
		x = new ActiveXObject("Microsoft.XMLHTTP"); 
	}else if (window.XMLHttpRequest) { 
		x = new XMLHttpRequest(); 
	} 
	return x; 
} 
var request = makeObject(); 

var the_content; 
<!--// 1st //-->
function check_content(the_content){ 
	request.open('get', the_content); 
	request.onreadystatechange = parseCheck_content; 
	request.send(''); 
} 
function parseCheck_content(){ 
	if(request.readyState == 1){ 
	$('recently_used').innerHTML = "<img src='images/4-1.gif' alt='loading...' title='loading...' />"; 
	} 
	if(request.readyState == 4){ 
		var answer = request.responseText; 
		$('recently_used').innerHTML = answer; 
	}
} 


// Contact form functions  
function pleasewait()
{
	$('submit').value = 'Sending, Please wait...';
}

// Callback function that will update the response_form1 div with the response that comes from the server

function updateResponseDiv(req) 
{
	$('submit').value = 'Re-send';
	Spry.Utils.setInnerHTML('response_form1', req.xhRequest.responseText);
}

