function initAjax() {
	var httpRequest;
	try {  // Firefox, Opera 8.0+, Safari
		httpRequest=new XMLHttpRequest();
	} catch (e) {  // Internet Explorer
		try {
			httpRequest=new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			httpRequest=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return httpRequest;
}

function detect_browser() {
	var browser_name = navigator.userAgent;
	// We have to check for Opera first because
	// at the beginning of the userAgent variable
	// Opera claims it is MSIE. 
	
	if (browser_name.indexOf("Opera")!= -1)
		browser_name = "Opera";
	else if (browser_name.indexOf("Firefox")!= -1)
		browser_name = "Firefox";
	else if (browser_name.indexOf("MSIE")!= -1)
		browser_name = "MSIE";
	else if (browser_name.indexOf("Netscape")!= -1)
		browser_name = "Netscape";
	else if (browser_name.indexOf("Chrome")!= -1)
		browser_name = "Chrome";
	else if (browser_name.indexOf("Safari")!= -1)
		browser_name = "Safari";
	
	return browser_name;
} // end function detect_browser()

function openDivHelp(divName) {
	var div = document.getElementById(divName);
	if(div.style.display == 'none') {
		div.style.display = 'block';
	} else {
		div.style.display = 'none';
	}
	scrollValue = 0;
	keepScroll();
}

var scrollValue = 0;
var timer=""

function keepScroll(){
	clearTimeout(timer);

	if(scrollValue == 0) {
		if (document.documentElement && !document.documentElement.scrollTop) {
			scrollValue = document.documentElement.scrollTop;
		} else if (document.documentElement && document.documentElement.scrollTop) {
			scrollValue = document.documentElement.scrollTop;
		} else if (document.body && document.body.scrollTop) {
			scrollValue = document.body.scrollTop;
		}
	}

	var updatedScroll;
	if (document.documentElement && !document.documentElement.scrollTop) {
		updatedScroll = document.documentElement.scrollTop;
	} else if (document.documentElement && document.documentElement.scrollTop) {
		updatedScroll = document.documentElement.scrollTop;
	} else if (document.body && document.body.scrollTop) {
		updatedScroll = document.body.scrollTop;
	}
	
	if((updatedScroll == 0) && (scrollValue != 0)) {
		if (document.documentElement && !document.documentElement.scrollTop) {
			document.documentElement.scrollTop = scrollValue;
		} else if (document.documentElement && document.documentElement.scrollTop) {
			document.documentElement.scrollTop = scrollValue;
		} else if (document.body && document.body.scrollTop) {
			document.body.scrollTop = scrollValue;
		}
		clearTimeout(timer);
	} else {
		timer=setTimeout("keepScroll()",10);
	}
}

function changeAction(action) {
	document.forms[0].action = action;
	document.forms[0].submit();
}

function getVendorDevices(vendorId,devSelect,errorDiv,devImgs,deviceId,urlDevice,imgParams,devList,dummyId) {
	var vendor = document.getElementById(vendorId);
	var opt = 0;
	try{opt = vendor.options.selectedIndex;}catch(e){opt = null;}
	
	var selectedOption;
	try
	{
		if(vendor.options[opt] != null)
		{
			selectedOption = vendor.options[opt].value;
		}
	}catch(e){selectedOption = 0;}

	url="listVendorDevices.action?vendorId="+selectedOption;
		
	var httpRequest=initAjax();
	if (httpRequest==null) {
		alert ("Your browser does not support AJAX!");
		return;
	}

	httpRequest.onreadystatechange = function () {
		reloadListDevicePage(httpRequest,devSelect,errorDiv,devImgs,deviceId,devList,urlDevice,imgParams,dummyId);
	}
	httpRequest.open("GET",url,true);
	httpRequest.send(null);
}

//Callback function
function reloadListDevicePage(httpRequest,devSelect,errorDiv,devImgs,deviceId,devList,urlDevice,imgParams,dummyId){
	var deviceSelect = document.getElementById(devSelect);
	var deviceImages = document.getElementById(devImgs);

	var deviceList = "[";
	for(var d=0; d < devList.length; d++) {
		deviceList += '\'';
		deviceList += devList[d];
		deviceList += '\',';
	}
	deviceList += ']';

	if (httpRequest.readyState == 4) { // Complete
		if (httpRequest.status == 200) { // OK response
			//Split the document
			var textToSplit = httpRequest.responseText;

			//Populate Device Names Select
			deviceSelect.options.length = 0;
			var content = '<ul>'; //Reload Devices Images
			var selectItems=textToSplit.split("||");
			deviceSelect.options[0] = new Option("...",0);
			for ( var i=0; i<selectItems.length-1; i++ ){
				var valueLabelPair = selectItems[i].split("|");
				deviceSelect.options[i+1] = new Option(valueLabelPair[1],valueLabelPair[0]);
				
				content += '<li><a href="#" onclick="updateDeviceId(\'' + errorDiv + '\',\'' + deviceId + '\',\'' + valueLabelPair[1] + '\',' + valueLabelPair[0] + ',' + deviceList + ',' + dummyId + ',\'compativel\')" id="' + valueLabelPair[0] + '">';
				content += '<img src="' + urlDevice + valueLabelPair[2] + '?' + imgParams + '" width="62" height="105" id="device' + deviceId + '" alt="" title="' + valueLabelPair[1] + '" /><p>' + valueLabelPair[1] + '</p></a></li>';
				
				if((i+1) % 6 == 0 && (i-1) > 0) {
					content += '<div class="clear"></div>';
				}
			}		

			content += '</ul>';
			deviceImages.innerHTML=content;
		}
	} else {  
		//alert("Bad response by the server");
	}
}

function selectDevice(devSelect,devImgs,deviceId,deviceError,deviceNames,dummyId) {
	var device = document.getElementById(devSelect);
	var opt = 0;
	try{opt = device.options.selectedIndex;}catch(e){opt = null;}
	
	var selectedOptionValue;
	var selectedOptionLabel;
	try
	{
		if(device.options[opt] != null)
		{
			selectedOptionValue = device.options[opt].value;
			selectedOptionLabel = device.options[opt].text;
		}
	}catch(e){}

	var devSelected = document.getElementById(deviceId);

	for(var i=0; i < document.links.length; i++) {
		if (document.links[i].id == selectedOptionValue) {
			document.links[i].className = 'over';

			var included = false;
			for(var d=0; d < deviceNames.length-1; d++) {
				if(deviceNames[d] == selectedOptionValue) {
					included = true;
				}
			}
			if(deviceNames[deviceNames.length-1] != null) { //bug ie
				if(deviceNames[deviceNames.length-1] == selectedOptionValue) {
					included = true;
				}
			}
			if(deviceNames.length == 0) {
				included = true;
			}
			var divError = document.getElementById(deviceError);
			var devSelected = document.getElementById(deviceId);
			if(!included && deviceNames.length > 0) {
				if(selectedOptionValue == dummyId) {
					divError.style.display = 'none';
					divError.innerHTML = '';
					devSelected.value = selectedOptionValue;
				} else {
					divError.style.display = 'block';
					divError.innerHTML = 'ERRO: Aparelho incompat&iacute;vel com o conte&uacute;do selecionado.';
					devSelected.value = '';
				}
			} else {
				divError.style.display = 'none';
				divError.innerHTML = '';
				devSelected.value = selectedOptionValue;
			}
			
			var devImg = document.getElementById(devImgs);
			
			var lines = Math.floor((opt-1) / 6);
			if (detect_browser() == "Firefox" || detect_browser() == "Netscape") { 
				devImg.scrollTop = (lines * 158); //165 168 170 175 185 pouco
			} else if (detect_browser() == "Chrome") {  //185 190 195pouco
				devImg.scrollTop = (lines * 162);
			} else if (detect_browser() == "Safari") { //148 145 140muito
				devImg.scrollTop = (lines * 171);
			} else if (detect_browser() == "MSIE") { //170 175 178 182 190 210pouco
				lines = Math.floor((opt-1) / 6);
				if (document.documentElement && !document.documentElement.scrollTop) {
					devImg.scrollTop = (lines * 156);
				} else if (document.documentElement && document.documentElement.scrollTop) {
					devImg.scrollTop = (lines * 156);
				} else if (document.body && document.body.scrollTop) {
					devImg.scrollTop = (lines * 156);
				}
			}
		} else if(document.links[i].className == 'over') {
			document.links[i].className = '';
		}
	}
}

function updateDeviceId(deviceError,deviceId,name,id,deviceNames,dummyId,naocompativel) {
	var included = false;
	for(var i=0; i < deviceNames.length-1; i++) {
		if(deviceNames[i] == id) {
			included = true;
		}
	}

	if(deviceNames[deviceNames.length-1] != null) { //bug ie
		if(deviceNames[deviceNames.length-1] == id) {
			included = true;
		}
	}

	if(deviceNames.length == 0) {
		included = true;
	}
	
	var divError = document.getElementById(deviceError);
	var devSelected = document.getElementById(deviceId);
	var naoCompativel = document.getElementById(naocompativel);
	
	if(!included && deviceNames.length > 0) {
		if(id == dummyId) {
			divError.style.display = 'block';
			divError.innerHTML = '';
			devSelected.value = id;
		} else {
			divError.style.display = 'block';
			divError.innerHTML = 'ERRO: Aparelho incompat&iacute;vel com o conte&uacute;do selecionado.';
			devSelected.value = '';
		}
	} else {
		divError.style.display = 'block';
		divError.innerHTML = '';
		devSelected.value = id;
	}

	for(var j=0; j < document.links.length; j++) {
		if (document.links[j].id == id) {
			document.links[j].className = 'over';
		} else if(document.links[j].className == 'over') {
			document.links[j].className = '';
		}
	}
	
	naoCompativel.checked = false;
}

function updateDeviceIdNaoCompativel(deviceError,deviceId,dummyId) {
	var devSelected = document.getElementById(deviceId);
	devSelected.value = dummyId;
	
	var divError = document.getElementById(deviceError);
	divError.style.display = 'block';
	divError.innerHTML = '';

	for(var j=0; j < document.links.length; j++) {
		if(document.links[j].className == 'over') {
			document.links[j].className = '';
		}
	}
}

function getAuthenticatorParams(link,ddd,nro,pass,params) {
	var dddValue = document.getElementById(ddd).value;
	var nroValue = document.getElementById(nro).value;
	var password = document.getElementById(pass).value;
	var loginParams = '&cdDDD=' + dddValue + '&numTelefone=' + nroValue + '&senha=' + password;

	for(var i=0; i < document.links.length; i++) {
		if (document.links[i].id == link) {
			document.links[i].href = '/autenticator.action?' + params + loginParams;
		}
	}
}

function getLoginParams(link,ddd,nro,pass,params) {
	var dddValue = document.getElementById(ddd).value;
	var nroValue = document.getElementById(nro).value;
	var password = document.getElementById(pass).value;
	var loginParams = '&cdDDD=' + dddValue + '&numTelefone=' + nroValue + '&senha=' + password;

	for(var i=0; i < document.links.length; i++) {
		if (document.links[i].id == link) {
			document.links[i].href = '/loginSave.action?' + params + loginParams;
		}
	}
}

function getParamsDedication(link,ddd,nro) {
	var dddValue = document.getElementById(ddd).value;
	var nroValue = document.getElementById(nro).value;
	var dedicationParams = '&numeroCelular=' + dddValue + nroValue;

	for(var i=0; i < document.links.length; i++) {
		if (document.links[i].id == link) {
			document.links[i].href += dedicationParams;
		}
	}
}

function getOffer(button,offer) {
	var radioElem = document.getElementsByName(offer);
	var offerValue = radioElem.value;
	for (var o = 0;o<radioElem.length;o++){
       if (radioElem[o].checked)
          offerValue = radioElem[o].value;
    }
    //alert(offerValue);
	var loginParams = '&offerId=' + offerValue;
 
	for(var i=0; i < document.links.length; i++) {
		if (document.links[i].id == button) {
			var link = document.links[i].href;
			if(link.indexOf('offerId') != -1) {
				var newString = link.substring(0,link.indexOf('&offerId='));
				document.links[i].href = newString + loginParams;
			} else {
				document.links[i].href += loginParams;
			}
			//alert(document.links[i].href);
		}
	}
}

function checkDeviceSelected(deviceId,deviceError,button,linkParams,selectVendor) {
	var devSelected = document.getElementById(deviceId);
	var devId = devSelected.value;

	if(devId == 'null' || devId == '') {
		var divError = document.getElementById(deviceError);
		divError.style.display = 'block';
		divError.innerHTML = 'Selecione um aparelho compat&iacute;vel com o conte&uacute;do selecionado.';
	
		var vendor = document.getElementById(selectVendor);
		var vendorValue;
		var opt = 0;
		try{opt = vendor.options.selectedIndex;}catch(e){opt = 0;}

		try
		{
			if(vendor.options[opt] != null)
			{
				vendorValue = vendor.options[opt].value;
			}
		}catch(e){}
		
		for(var i=0; i < document.links.length; i++) {
			if (document.links[i].id == button) {
				document.links[i].href = '/listDevices.action?vendorId=' + vendorValue + '&deviceId=' +  devId + '&' + linkParams;
			}
		}
	} else {
		for(var i=0; i < document.links.length; i++) {
			if (document.links[i].id == button) {
				document.links[i].href = '/saveDevice.action?deviceId=' + devId + '&' + linkParams;
			}
		}
	}
}

function getDeviceParam(deviceId,deviceError,button,linkParams,selectVendor) {
	var devSelected = document.getElementById(deviceId);
	var devId = devSelected.value;

	if(devId == 'null' || devId == '') {
		var divError = document.getElementById(deviceError);
		divError.style.display = 'block';
		divError.innerHTML = 'Selecione um aparelho.';
	
		var vendor = document.getElementById(selectVendor);
		var vendorValue;
		var opt = 0;
		try{opt = vendor.options.selectedIndex;}catch(e){opt = 0;}

		try
		{
			if(vendor.options[opt] != null)
			{
				vendorValue = vendor.options[opt].value;
			}
		}catch(e){}
		
		for(var i=0; i < document.links.length; i++) {
			if (document.links[i].id == button) {
				document.links[i].href = '/chooseDevice.action';
			}
		}
	} else {
		for(var i=0; i < document.links.length; i++) {
			if (document.links[i].id == button) {
				document.links[i].href = '/saveChooseDevice.action?deviceId=' + devId + '&' + linkParams;
			}
		}
	}
}

function setNext(obj1,obj2){
	var object1 = document.getElementById(obj1);
	if(isNaN(object1.value)) { //false means it is a number
		object1.value = '';
	} else {
		var object2 = document.getElementById(obj2);
		if(object1.value.length == object1.maxLength){
			object2.focus();
			object2.value = '';
		}
	}
}

function changeTopContents(divName, listName, buttonName, tipo, rootType) {
	var topDiv = document.getElementById(divName);
	var faixaHtml = '<table><colgroup><col width="20"/><col width="270"/><col width="90"/>';
	var max = 10;
	if(listName.length < 10)
		max = listName.length;
	for(var i=0; i < max; i++) {
		var faixaPart = listName[i];
		var options = faixaPart.split("|");
	
		faixaHtml += '<tr><td class="posicao">' + options[0] + '.</td><td>';
		
		if(rootType.indexOf('Music') != -1) {
			faixaHtml += '<a href="javascript:void(0)" onclick="open(\'/content.action?folderId=' + options[5] + '&cid=' + options[6] + '\',\'Player\',\'status=no,width=490,height=327,resizable=1\');" style="color:#000;" >';
		} else {
			faixaHtml += '<a href="/content.action?folderId=' + options[5] + '&cid=' + options[6] + '" style="color:#000;" >';
		}
		
		faixaHtml += '<b>' + options[1] + '</b><br />' + options[2] + '</a></td>';
		faixaHtml += '<td class="direita"><div class="star_p_' + options[3] + '"></div>';
		faixaHtml += '<p class="votos txt_centro">';
		faixaHtml += options[4];
		faixaHtml += '</p>';
		faixaHtml += '</td></tr>';
	}
	faixaHtml += '</table>';

	topDiv.innerHTML = faixaHtml;
	
	var buttonDiv = document.getElementById(buttonName);
	var buttonText = buttonDiv.innerHTML;
	var newString = buttonText;
	
	var class_on = "box_botao_top_on";
	var class_off = class_on.substring(0,class_on.indexOf('_on'));

	if(tipo == 0) {
		if(buttonText.indexOf('box_botao_top_on') == -1) {
			newString = buttonText.substring(0,buttonText.indexOf(class_off));
			newString += class_on; 
			newString += buttonText.substring(buttonText.indexOf(class_off)+13,buttonText.length);
			buttonText = newString;
		}

		if(buttonText.indexOf('box_botao_ranking_on') != -1) {
			newString = buttonText.substring(0,buttonText.indexOf('box_botao_ranking_on'));
			newString += 'box_botao_ranking'; 
			newString += buttonText.substring(buttonText.indexOf('box_botao_ranking_on')+20,buttonText.length);
		}
	} else {
		if(buttonText.indexOf('box_botao_ranking_on') == -1) {
			newString = buttonText.substring(0,buttonText.indexOf('box_botao_ranking'));
			newString += 'box_botao_ranking_on'; 
			newString += buttonText.substring(buttonText.indexOf('box_botao_ranking')+17,buttonText.length);
			buttonText = newString;
		}
		
		if(buttonText.indexOf(class_on) != -1) {
			newString = buttonText.substring(0,buttonText.indexOf(class_on));
			newString += class_off; 
			newString += buttonText.substring(buttonText.indexOf(class_on)+16,buttonText.length);
			
		}
	}
	buttonDiv.innerHTML = newString;
	//alert(newString);
}

function saveRank(link,rank,params) {
	var rankElem = document.getElementById(rank);
    var rankValue = rankElem.value 
	var rankParams = '&note=' + rankValue;

	for(var i=0; i < document.links.length; i++) {
		if (document.links[i].id == link) {
			document.links[i].href = '/rankSave.action?' + params + rankParams;
		}
	}
}

function changeHightLightImg(nro, div, listImg, faixa, faixaList,rootType) {
	var highlight = document.getElementById(div);
	var img = '<img src="' + listImg[nro] + '" width="215" height="176" />';
	highlight.innerHTML = img;
	//alert(img);
	var faixaDiv = document.getElementById(faixa);
	var faixaPart = faixaList[nro];
	//alert(faixaList);
	var options = faixaPart.split("|");
	var faixaText = '<div id="faixa-' + options[0] + '" class="faixa"><div class="lancamentos-numero">' + options[0] + '</div>';

	if(rootType.indexOf('Music') != -1) {
		faixaText += '<div class="lancamentos-info"><a href="javascript:void(0)" onclick="open(\'/content.action?folderId=' + options[5] + '&cid=' + options[6] + '\',\'Player\',\'status=no,width=490,height=327,resizable=1\');" ><strong>' + options[1] + '</strong><br />' + options[2] + ' | &Aacute;lbum: ' + options[3] + '</a></div>';
	} else {
		faixaText += '<div class="lancamentos-info"><a href="/content.action?folderId=' + options[5] + '&cid=' + options[6] + '" ><strong>' + options[1] + '</strong><br />' + options[2] + options[3] + '</a></div>';
	}
	
	//faixaText += '<div class="star_p_' + options[4] + ' direita"></div>';
	
	faixaDiv.innerHTML = faixaText;
	//alert(faixaText);
}

function changeHightLightImgTI(nro, div, listImg, faixa, faixaList,rootType) {
	var highlight = document.getElementById(div);
	var img = '<img src="' + listImg[nro] + '" width="166" height="222" />';
	highlight.innerHTML = img;
	//alert(img);
	var faixaDiv = document.getElementById(faixa);
	var faixaPart = faixaList[nro];
	//alert(faixaList);
	var options = faixaPart.split("|");
	var faixaText = '<div id="faixa-' + options[0] + '" class="faixa"><div class="lancamentos-numero">' + options[0] + '</div>';

	if(rootType.indexOf('Music') != -1) {
		faixaText += '<div class="lancamentos-info"><a href="javascript:void(0)" onclick="open(\'/content.action?folderId=' + options[5] + '&cid=' + options[6] + '\',\'Player\',\'status=no,width=490,height=327,resizable=1\');" ><strong>' + options[1] + '</strong><br />' + options[2] + '</a></div>';
	} else {
		faixaText += '<div class="lancamentos-info"><a href="/content.action?folderId=' + options[5] + '&cid=' + options[6] + '" ><strong>' + options[1] + '</strong><br />' + options[2] + '</a></div>';
	}
	
	//faixaText += '<div class="star_g_' + options[4] + ' direita"></div>';
	faixaDiv.innerHTML = faixaText;
	//alert(faixaText);
}

function changeHightLightMusic(nro, div, listImg, faixa, faixaList,rootType) {
	var highlight = document.getElementById(div);
	var img = '<img src="' + listImg[nro] + '" width="284" height="222" />';
	highlight.innerHTML = img;
	//alert(img);
	var faixaDiv = document.getElementById(faixa);
	var faixaPart = faixaList[nro];
	//alert(faixaList);
	var options = faixaPart.split("|");
	var faixaText = '<div id="faixa-' + options[0] + '" class="faixa"><div class="lancamentos-numero">' + options[0] + '</div>';

	if(rootType.indexOf('Music') != -1) {
		faixaText += '<div class="lancamentos-info"><a href="javascript:void(0)" onclick="open(\'/content.action?folderId=' + options[5] + '&cid=' + options[6] + '\',\'Player\',\'status=no,width=490,height=327,resizable=1\');" ><strong>' + options[1] + '</strong><br />' + options[2] + '</a></div>';
	} else {
		faixaText += '<div class="lancamentos-info"><a href="/content.action?folderId=' + options[5] + '&cid=' + options[6] + '" ><strong>' + options[1] + '</strong><br />' + options[2] + '</a></div>';
	}
	
	//faixaText += '<div class="star_g_' + options[4] + ' direita"></div>';
	faixaDiv.innerHTML = faixaText;
	//alert(faixaText);
}

function updateRank(rankId,value) {
	var rankSelected = document.getElementById(rankId);
	rankSelected.value = value;
}

function changeMobileImg(nro, div, listImg) {
	var highlight = document.getElementById(div);
	var img = '<img src="' + listImg[nro] + '" class="screenshot" width="131" height="142" id="content" onerror="changeImgSource(\'content\',\'images/common/jogo_sem_imagem.gif\')"/>';
	highlight.innerHTML = img;
	
	scrollValue = 0;
	keepScroll();
}

var album_display = '';
function changeAlbumCarousel(divName, listName, buttonName, buttonToHighlight) {
	if(album_display.indexOf(buttonToHighlight) == -1) {
		album_display = buttonToHighlight;
		var topDiv = document.getElementById(divName);
		
		var carouselHtml = '';
		for(var i=0; i < listName.length; i++) {
			var faixaPart = listName[i];
			var options = faixaPart.split("|");
			carouselHtml += '<li jcarouselindex="' + (i+1) + '" class="jcarousel-item jcarousel-item-horizontal jcarousel-item-' + (i+1) + ' jcarousel-item-' + (i+1) + '-horizontal"><div>';
			carouselHtml += '<a href="/discovery.action?folderId=' + options[0] + '" class="cb">';
			carouselHtml += '<img src="' + options[1] + '" id="album' + options[0] + '" onerror="changeImgSource(\'album' + options[0] + '\',\'images/common/album_sem_imagem.gif\')" alt="' + options[2] + '" title="' + options[2] + '" width="66" height="66"/><br />'
			carouselHtml += '<b>' + options[2] + '</b><br /><p>' + options[3] + '</p></a>';
			carouselHtml += '</div></li>';
		}
		topDiv.innerHTML = carouselHtml;
		//resetCarousel(listName.length);
		//alert(carouselHtml);
		
		var buttonDiv = document.getElementById(buttonName);
		var buttonText = buttonDiv.innerHTML;
		var newString = buttonText;
		
		var class_on = buttonToHighlight + "_on";
		var class_off = buttonToHighlight;
	
		if(buttonText.indexOf("_on") != -1) { //if there is any active button
			newString = buttonText.substring(0,buttonText.indexOf("_on"));
			newString += buttonText.substring(buttonText.indexOf("_on")+3,buttonText.length);
			buttonText = newString;
		}
	
		if(buttonText.indexOf(class_on) == -1) {
			newString = buttonText.substring(0,buttonText.indexOf(class_off));
			newString += class_on; 
			newString += buttonText.substring(buttonText.indexOf(class_off)+class_off.length,buttonText.length);
		}
		
		buttonDiv.innerHTML = newString;
		//alert(newString);
	}
}

function redirect() {
	var redirectUrl = document.getElementById('redirectUrl1');

	if(redirectUrl != null) {
		var param = document.getElementById('redirectUrl2');
		var reloadUrl = param.innerHTML;
		setTimeout('reloadPage("' + reloadUrl + '")', 2000)
		window.location.href = redirectUrl.innerHTML;
	}
}

function redirectHome() {
	var url = '/home.action';
	window.location.href = url;
}
			
function replaceAll(string, token, newtoken) {
	while (string.indexOf(token) != -1) {
 		string = string.replace(token, newtoken);
	}
	return string;
}
function reloadPage(reloadUrl) {
	var fixedUrl = replaceAll(reloadUrl,"&amp;","&"); 
	window.location.href = fixedUrl;
}
function focusFirst(){
	var object1 = document.getElementById('ddd');
	object1.maxLength = 2;
	object1.value = '';
}
function changeImgSource(imgId,new_source){
	var object1 = document.getElementById(imgId);
	object1.src = new_source;
}

function open_close(divId) {
	var div_name = "#"+divId;
	$(div_name).parent().next().toggle('slow');
	return false;
}

function window_resize(size) {
	if($('#but-mais').is(':hidden')) {
		window.resizeTo(538,400);
	} else window.resizeTo(538,250);
	
}

function openAlbum(divHide, divShow, numberDiv){
	for(var d=0; d < numberDiv; d++) {
		var name = 'album'+ d;
		var div = document.getElementById(name);
		div.style.display = 'none';
	}

	var divToShow = document.getElementById(divShow);
	divToShow.style.display = 'block';
	
	var divToHide = document.getElementById(divHide);
	divToHide.style.display = 'none';
}

function window_increase() {
	if(window.name == 'Player') {
		window.resizeTo(570,600);
	}
}

function window_decrease() {
	if(window.name == 'Player') {
		if (detect_browser() == "MSIE" || detect_browser() == "Netscape") { 
			window.resizeTo(500,360);
		} else if (detect_browser() == "Chrome") {
			window.resizeTo(500,370);
		} else if (detect_browser() == "Safari") {
			window.resizeTo(500,368);
		} else {
			window.resizeTo(500,385);
		}
	}
}

function loading_page(delay) {
	setTimeout('delivery_content();', delay);
	
	tb_show('','/waitDelivery.action?'+'height=410&width=400&modal=true',false);
}

function delivery_content() {
	var bot_baixar = document.getElementById('bot_baixar');
	bot_baixar.style.display = 'block';
	var waiting = document.getElementById('waiting');
	waiting.style.display = 'none';
	var download = document.getElementById('download');
	download.style.display = 'block';
	//window.location.href = redirectUrl.innerHTML;
}