function getUniqueId()
{
	var stamp = new Date();
	var id = stamp.getMonth().toString() + stamp.getDay() + stamp.getHours() + stamp.getMinutes() + stamp.getSeconds() + stamp.getMilliseconds() ;
	return id;
}

function ajaxPost(url, container, postParams, encoding)
{
	var xmlObj = createXMLRequest();
	if( url.indexOf('?') == -1 )
	{
		url += '?noCache=' + getUniqueId();
	}
	else
	{
		url += '&noCache=' + getUniqueId();
	}
	xmlObj.open('POST', url, false);
	if(encoding)
		xmlObj.setRequestHeader('Content-Type', encoding);
	else 
		xmlObj.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
		
	xmlObj.send(postParams);
}

function ajaxLoad(url, container, callBack, imageLoading)/*THIS FUNCTION LOADS A PAGE INTO A DIV*/
{
	var xmlObj = createXMLRequest();
	
	if( imageLoading && imageLoading.length > 0 && $(container) )
	{
		$(container).innerHTML = imageLoading;
	}
	
	xmlObj.onreadystatechange=function(){
			loadPage(xmlObj, container, callBack)
	}
	if( url.indexOf('?') == -1 )
	{
		url += '?noCache=' + getUniqueId();
	}
	else
	{
		url += '&noCache=' + getUniqueId();
	}
	xmlObj.open('GET', url, true) // asignamos los métodos open y send
	xmlObj.send(null)
}

function ajaxLoadSync(url, container)/*THIS FUNCTION LOADS A PAGE INTO A DIV*/
{
	
	var xmlObj = createXMLRequest();
	
	if( url.indexOf('?') == -1 )
	{
		url += '?noCache=' + getUniqueId();
	}
	else
	{
		url += '&noCache=' + getUniqueId();
	}
	
	xmlObj.open('GET', url, false);
	xmlObj.send(null);
	
	if(container)container.innerHTML=xmlObj.responseText;
	return xmlObj.responseText;
}

function loadPage(request, container, callBack){
	if(request.readyState == 4)
	{
		if (container)container.innerHTML=request.responseText
		if(callBack){eval(callBack);}
	}
}

function createXMLRequest(){
var XMLObj;
if(window.XMLHttpRequest) {XMLObj = new XMLHttpRequest()} 
else if(window.ActiveXObject){
	try
	{XMLObj = new ActiveXObject("Msxml2.XMLHTTP")} 
	catch(e){try{XMLObj = new ActiveXObject("Microsoft.XMLHTTP")}catch (e){}}}
else
{
	return false
}
return XMLObj;
}

function loadAjaxFile(nameFile, nameDiv, callBack, ajaxLoading) {
	var div_pointer = $(nameDiv);
	ajaxLoad(nameFile,div_pointer,callBack, ajaxLoading);
}

function loadContent(nameFile, nameDiv, callBack, ajaxLoading) {
	if(ajaxLoading != "")
		ajaxLoading = "<img src='" + shop.url + "/ecommerce/images/icons/"+ajaxLoading+"'>";
	if($(nameDiv+'Floater'))$(nameDiv+'Floater').style.top = 30+ (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + 'px';
	loadAjaxFile(nameFile, nameDiv, callBack, ajaxLoading);
}

function closeContent(){
	$('informationBox').innerHTML = '';
	$('informationBox').style.visibility = 'hidden';
}

function submitForm(form, divId, callBack, imageLoading){
	if(imageLoading)
			document.getElementById(divId).innerHTML = "<img src='" + shop.url + "/ecommerce/images/icons/"+imageLoading+"'>";
	Spry.Utils.submitForm(form, function(req){document.getElementById(divId).innerHTML = req.xhRequest.responseText; eval(callBack);} );
}


function changeClass(obj, nameClass, nameClass2){
	if(obj.className == nameClass){obj.className = nameClass2;}
	else {obj.className = nameClass;}
}

function restartShadowbox(){
	Shadowbox.clearCache(); Shadowbox.setup(); 
}

function playMusic(file){
	ajaxLoadSync(shop.url + '/ajaxTemplates/common/checkoutActions.cfm?action=sound_open')
	$('audioDiv').innerHTML = '<embed src="'+file+'" hidden="true" autostart="true" loop="true" type="audio/wav">';
}
function stopMusic(){
	ajaxLoadSync(shop.url + '/ajaxTemplates/common/checkoutActions.cfm?action=sound_close')	
	$('audioDiv').innerHTML = '';
}

function getStyleObject(objectId) {
    // cross-browser function to get an object's style object given its
    if(document.getElementById && document.getElementById(objectId)) {
	// W3C DOM
	return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
	// MSIE 4 DOM
	return document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
	return document.layers[objectId];
    } else {
	return false;
    }
} // getStyleObject

