// Version 20090601-192

// Teste de encoding: ãçíáúó

var timerId = 0;
var m3_u = (location.protocol == 'https:' ? 'https://'+getHost() : 'http://'+getHost()); 
var basicUrl = m3_u + "/B2WAutoComplete";  
var lastParam = ""; 
var currentSelectedURL = "";
var currentSelectPos = -1;
var searchParams = "";
var lastResultIndex = 0;
var selectedItemBGColor = "#eeeeff";
var defaultItemBGColor = "#ffffff";

function search(param, keyEvent) {
    var key = (keyEvent == null ? 0 : keyEvent.keyCode);
    
   // KEY_ENTER
   if (key == 13 && param != ""){
     searchParams = param;
     selectAutoCompleteItem();
     return;
   }

   // KEY_UP || KEY_DOWN
   if (param.length > 3 && (key == 38 || key == 40)){
      moveAutoCompleteSelection(key);
   
   } else if (key == 27){
        //$('query').value = '';
    		$('results').innerHTML = '';
        $('results').style.visibility = 'hidden';
        lastParam = '';
        currentSelectedURL = "";
        currentSelectPos = -1;
        return;
   
   } else {
    	clearTimeout (timerId);
      timerId = setTimeout("effectiveSearch('"+param+"')", 500);
   }
}

function moveAutoCompleteSelection(key) {
    var searchInput = $('query');
    currentSelectedURL = "";
    var acSearch = $('acSearchResults');
    if (acSearch == null) return;

    var searchResults = acSearch.getElementsByTagName('span');
    var resultsLength = searchResults.length;
   
    if (key == 38){
       currentSelectPos = currentSelectPos - 1;
       if (currentSelectPos < 0){
          currentSelectPos = -1;
          searchInput.value = searchParams;
          searchResults[0].parentNode.parentNode.parentNode.parentNode.style.background = defaultItemBGColor;
          return;
       }
    } else if (key == 40){
       currentSelectPos = currentSelectPos + 1;
       if (currentSelectPos >= resultsLength){
          currentSelectPos = resultsLength - 1;
       }
    }
  
    for (i=0; i<resultsLength; i++) {
    
        var resultElem = searchResults[i];
        
        var searchRootNode = resultElem.parentNode.parentNode.parentNode.parentNode;
        
        if (resultElem != null) { 

           if (i == currentSelectPos) {
           
              var elemLinks = resultElem.getElementsByTagName('a');

              if (elemLinks != null) {
                  var link = elemLinks[0];
                  
                  if (link.id == 'search_movieTitleLink'){
                      currentSelectedURL = link.href;
                      searchInput.value = link.innerHTML;
                      searchRootNode.style.background = selectedItemBGColor;
                  }
              }

           } else {
              searchRootNode.style.background = defaultItemBGColor;
           }
       }
    }

}

function selectAutoCompleteItem(){
    if (currentSelectPos == -1){
       currentSelectedURL = "/busca/?query="+ searchParams;
    }
    document.location.href = currentSelectedURL;
}
            
function effectiveSearch(param) {
	var qty = 5; 

	param = param.replace(/^\s+|\s+$/g,""); 
	if (param.length > 3){ 

	  searchParams = param;

		if (lastParam == param) {
			return;
		} else {
			lastParam = param;
		} 
		if (!qty){
			qty = 10;
		} 
		var url = basicUrl + "/AutoComplete?word="+encodeURIComponent(param)+"&qty="+qty+"&displayMore=true"; 

		new Ajax.Request(url, {
			method: 'get',onSuccess: 
				function(transport) {																
					var xml = transport.responseText;
					if (xml) {																
						$('results').innerHTML = '';
						$('results').style.visibility = 'visible';	
						parseXML(xml);
					} else {
					  $('results').innerHTML = '';
					  $('results').style.visibility = 'hidden';	
					  lastParam = '';
					}
				}
			}
		);
	} else {
		$('results').innerHTML = '';
		$('results').style.visibility = 'hidden';
		lastParam = '';
		currentSelectedURL = "";
		currentSelectPos = -1;
	}
}

function parseXML(xml) {
  try {
  //Internet Explorer
    xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
    xmlDoc.async="false";
    xmlDoc.loadXML(xml);
  } catch(e) {
     try {
    //Firefox, Mozilla, Opera, etc.
      parser=new DOMParser();
      xmlDoc=parser.parseFromString(xml,"text/xml");
     } catch(e) {
      alert(e.message);
      return;
     }
  }

  var item = xmlDoc.getElementsByTagName("Item");
  var searchResults = "";
  for (var i=0; i < item.length; i++)
  { 
    var elemUrl = item[i].getElementsByTagName("Url")[0].childNodes[0];
    var elemText = item[i].getElementsByTagName("Text")[0].childNodes[0];
    var elemImage = item[i].getElementsByTagName("Image");
    var elemDescription = item[i].getElementsByTagName("Description")[0].childNodes[0];

	var url = "";
	var text = "";
	var image = "";
	var description = "";
	try {
	  url = elemUrl.nodeValue;
	} catch (e) {}
	try {
	  text = elemText.nodeValue;
	} catch (e) {}
	try {
	  image = elemImage[0].attributes.getNamedItem("source").nodeValue;
	} catch (e) {}
	//try {
	//	description = elemDescription.nodeValue;		
	//} catch (e) {}

	  searchResults = searchResults + 
			"<div id='search_resultsTable' class='searchResultsTable' onMouseOver='javascript: if (currentSelectPos > -1) { $(\"acSearchResults\").getElementsByTagName(\"span\")[currentSelectPos].parentNode.parentNode.parentNode.parentNode.style.background = defaultItemBGColor; currentSelectPos= -1; }; this.style.background = selectedItemBGColor;' onMouseOut='javascript: this.style.background = defaultItemBGColor;'>" +
			"   <table class='searchMovieTable' cellspacing=0 cellpadding=0> " +
			"	  <tr>"+
			( image == null || image == '' 
		 ? ""
		 : "	  <td class='searchMovieImage'>"+
		   "       <a id='search_movieImageLink' href='"+ url +"'>"+  
		   "         <img src='"+ image + "' />"+
		   "       </a>"+
		   "	  </td>"
	  ) +
			"     <td class='searchMovieText'><span><a id='search_movieTitleLink' href='"+ url +"'>"+ text + "</a></span><br>" +
			"     "+ description +"</td>" +
			"	  </tr> " +
			"   </table>" +
			"</div>";
	}
  
	if (searchResults == ""){
		$('results').innerHTML = '';
		$('results').style.visibility = 'hidden';	
		lastParam = '';
	} else {

		$('results').innerHTML = "<div id='acSearchResults'>" +
						  searchResults +
						  "</div>" +
						  "<STYLE> "+
						  "      .searchResultsTable {width: 180px;}"+
						  "      .searchMovieTable {width: 178px; padding-bottom: 4px; background:none;}"+
						  //"      .searchMovieImage {display: none;}" +
						  "      .searchMovieImage {width: 80px; text-align: center;  background-color: transparent; border: 0px none #ffffff; padding:0 0 5px;}" +
						  "      .searchMovieText {padding: 3px 3px 3px 3px;  background-color: transparent;  border: 0px none #ffffff; font-size: 11px;}"+
						  "</STYLE>";
	}
}

function getHost() {
	var url = window.location.href;	
	var host = url.split('//')[1];	
	url = host.split('/');
	host = url[0];
	return host;
}

/**
 * Funcao responsavel por recuperar o objeto de acordo com o id
 */
//function $(id){
//	return document.getElementById(id);
//}

/**
 * Concatena a string "Selected" no nome da imagem
 * Ex.: http://images.americanas.com.br/Applications/bloc/img/logo.gif
 * vira http://images.americanas.com.br/Applications/bloc/img/logoSelected.gif 
 */
function selectImage(imageId){
	try{
		var url = $(imageId).src;
		var urlArr = url.split('/');
		var image = urlArr[urlArr.length -1];				
		var auxArr = image.split('.');
		image = auxArr[0] + 'Selected.' + auxArr[1];
		urlArr[urlArr.length -1] = image;

		var urlResult = '';
	
		for(i=0; i<urlArr.length; i++){
		
			if( i != (urlArr.length - 1) ){
				if(i == 0){
					urlResul = urlArr[i] + '/';    				
				}else{
					urlResul += urlArr[i] + '/';    				
				}    				
			}else{
				urlResul += urlArr[i];
			}				
		}
	    		
		$(imageId).src = urlResul;
	}catch(erro){

	}
}

/**
 * Funcao responsavel por recuperar o navegador da aplicacao
 */
function getNavigator(){
    if (navigator.appName.substring(0,9) == "Microsoft") {
        return 0;
    } else {
         return 1;
    }
}

/**
 * Funcao responsavel por setar o class como "selected" de acordo com o id passado
 */
function markSelectedLine(id){
	try{

		$(id).className = 'selected';
		
	}catch(Exception){
	}
}


var _externalAux;

function submitOutOfStockForm(){
	try{
		if($('outOfStock') != null){

			if(document.oosForm.name.value == "" || document.oosForm.email.value == ""){
				alert("Preencha seu nome e e-mail.")
			}else{
				setTimeout("_aux()", 1500);

			}
		}
	}catch(exception){
	}

}

function _aux(){
	
	if(_externalAux == null){
					
		var br = new htmlObject();
			br.create('br');
			br.setParent($('outOfStock'));
								
		var _p = new htmlObject();
			_p.create('p');
			_p.setId('_pId');
			_p.setParent($('outOfStock'));

		var htmlMessage = new htmlObject();
			htmlMessage.create("strong");
			htmlMessage.setText("Sua mensagem foi enviada com sucesso.");
			htmlMessage.setParent($('_pId'));
	
			_externalAux = 1;
	}else{

	}
}

function $name(name){
    return document.getElementsByName(name)[0];
}

function isEmpty(field){

	if(field.value == '' ||
	   field.value == 0 ||
       trimAll(field.value).length < 1){

		return true;

	}

    return false;

}

function isEmail(s)
{
    
    var filter=/^[A-Za-z][A-Za-z0-9_\.]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;

        if (filter.test(s)){
            return true;
        }else{

            return false;
        }
}

function trimAll(sString)
{
    while (sString.substring(0,1) == ' '){
        sString = sString.substring(1, sString.length);
    }

    while (sString.substring(sString.length-1, sString.length) == ' '){
        sString = sString.substring(0,sString.length-1);
    }

    return sString;
}

function validate(formName){

    form = $name(formName)

	for(i = 0; i < form.elements.length; i++){

		element = form.elements[i];

		var validation = element.name;


        if(validation == 'replyTo' || validation == 'emailTo'){

            if(!isEmail(element.value)){

            	alert('Formato de e-mail incorreto.');

                return;
            }

        }


        //if(validation.substring(0, validation.length - 3) == 'notNull'){



            msgNumber = element.id.charAt((element.id.length - 1));
            validationLength = validation.substring(validation.length - 2, validation.length - 1);

            if(isEmpty(element) || element.value.length < validationLength){

				alert('Ainda exitem campos para serem preenchidos.');

                return;
            }

        //}

	}

	setTimeout("aux()", 1500);




    return;

}


function aux(){
	if($('recommendId') == null){
		var htmlMsg = new htmlObject();
			htmlMsg.create('h2');
			htmlMsg.setId('recommendId');
			htmlMsg.setText('Mensagem enviado com sucesso.');
			htmlMsg.setParent($('recommend'));
	}

}


function submitOutOfStockForm2(){

	var form = $name('oosForm');

	for(var i=0; i < form.elements.length; i++){
		var elementAux = form.elements[i];

		if( (elementAux.name).indexOf('email') != -1 ){

			if( !isEmail(elementAux.value)){
				alert('Preencha seu e-mail corretamente.')
				return;
			}
		}

		if( (elementAux.name).indexOf('skuId') != -1 ){

			if( elementAux.value == null || elementAux.value == '' || elementAux.value == 'UNDEFINED' ){
				alert('Preencha todos os campos.')
				return;
			}
		}

		if( (elementAux.name).indexOf('name') != -1 ){

			if( elementAux.value == null || elementAux.value == '' || elementAux.value == 'UNDEFINED'){
				alert('Preencha seu nome corretamente.')
				return;
			}
		}

	}


	document.oosForm.submit();


}

function validate2(formName){

    form = $name(formName)

	for(i = 0; i < form.elements.length; i++){

		element = form.elements[i];

		var validation = element.name;


        if(validation.indexOf('replyTo') != -1 || validation.indexOf('email') != -1 ){

            if(!isEmail(element.value)){

            	alert('Formato de e-mail incorreto.');

                return;
            }

        }


        //if(validation.substring(0, validation.length - 3) == 'notNull'){



            msgNumber = element.id.charAt((element.id.length - 1));
            validationLength = validation.substring(validation.length - 2, validation.length - 1);

            if(isEmpty(element) || element.value.length < validationLength){

				alert('Ainda exitem campos para serem preenchidos.');

                return;
            }

        //}

	}

	form.submit();


    return;

}


function validateComment2(formName){
    
    var emailIsIncorrect = false;
    var withoutValue = false;

    form = $name(formName)
    for(i = 0; i < form.elements.length; i++){
        element = form.elements[i];
        var validation = element.name;

        if(((validation.indexOf('replyTo') != -1 || validation.indexOf('email') != -1)) && validation.indexOf('mostra_email') == -1){
            if(!isEmail(element.value)){
                emailIsIncorrect= true; 
            }
        }
        msgNumber = element.id.charAt((element.id.length - 1));
        validationLength = validation.substring(validation.length - 2, validation.length - 1);
        if(isEmpty(element) || element.value.length < validationLength){
	     withoutValue = true;
        }
    }

    if(emailIsIncorrect){
        alert('Formato de e-mail incorreto.');		
        return;
    }else if (withoutValue){
        alert('Ainda existem campos para serem preenchidos.');
        return;
    }

    form.submit();
}


function setValue(id, element){
	$(id).value = element.value;
}


function hasUrlBack(){
	return ($('urlBack') != undefined);
}


function setURLBack(){
	$('urlBack').value = window.location.href;
}


function setURLBackSpecial(){
	
	var rentId = getParameter('rentId');

	if(rentId.length == 0){
		rentId = 52022;
	}

	$('urlBack').value = (window.location.href).split("?")[0] + '?home=blocRent&departmentId=' + rentId;
}


function setSku(sku){
	$('sku').value = sku;
	setURLBack();
	document.formEscolheSKU.submit();
}


function setSaleUrl(urlId){

	if($(urlId) != undefined){
		 $(urlId).value = window.location.href;
	}	
}


function showTest(){
	alert($('sku').value);
	if(hasUrlBack()){
		alert($('urlBack').value);
	}
}


function rename(id){
	document.getElementById("query").name = id.value;
	return true;
}


function validateSearch(fieldName){
	var field = document.getElementById(fieldName);
	var fieldValue = field.value;
	if (fieldValue.length >= 3) {
		return true;
	}else{
		alert('Favor digitar no minimo 3 caracteres.');
		field.focus();
		return false;
	}
}


function gravaCookie ( name, value, exp_days, path, domain, secure ){

	if(value!=""){
		//var cookie_string = name + "=" + escape ( value );
		var cookie_string = name + "=" + value ;
		if ( exp_days ){
			var expires = new Date ( (new Date().getTime()) + (exp_days*24*60*60*1000) );
			cookie_string += "; expires=" + expires.toGMTString();
		}
		if ( path )
			cookie_string += "; path=" + escape ( path );
		if ( domain )
			cookie_string += "; domain=" + escape ( domain );
		if ( secure )
			cookie_string += "; secure";
		document.cookie = cookie_string;
	}
}


function deleteCookie ( name ){

	var cookie_date = new Date ( );
	cookie_date.setTime ( cookie_date.getTime() - 1 );
	document.cookie = name += "=; expires=" + cookie_date.toGMTString();

}


function readCookie ( cookie_name ){

	var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
	if ( results )
		return ( unescape ( results[2] ) );
	else
		return null;
		
}


function getParameter( name ){

	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var results = regex.exec( window.location.href );

	if( results == null )
		return "";
	else
		return results[1];
}


function geraCookie(){
	gravaCookie('acomOpn', getParameter('opn'), 0, '/','.blockbusteronline.com.br');
}


function geraCookieTitle(str){
	gravaCookie('rentName', str, 0, '/','.blockbusteronline.com.br');
}


function excluiCookieTitle(){
	DeleteCookie('rentName', '/', '.blockbusteronline.com.br');
}


function addScript(itemId){
	// Busca o conteudo do Baloon e dispara o metodo renderContent() com o resultado.
	strId = "" + itemId;
	var obj=new JSONscriptRequest('/home/begin.do?home=BlocBaloon&itemId=' + itemId);
	obj.buildScriptTag();
	//Retorna chamada para funcao renderContent(data, strId), com conteudo do ballon
	obj.addScriptTag(); 
}


function renderContent(data,itemId){
	if(data!=null){
		try{
			strId = itemId; 
			var tagId = 'content_' + strId;
			document.getElementById(tagId).innerHTML = '';			
			document.getElementById(tagId).innerHTML = data;
			
			// Altera o botao exibido no baloon
			//changeRentButtons(strId, true);

			exibe(strId);
		}catch(exception){}

		strId = '';
	}

}


function exibe(id){
	if(document.getElementById('clone')!=undefined){
		new Tip(id, $(id).up('li').down('.cloneMe').cloneNode(true), {
			title: 'Blockbuster Online',
			stem: 'topLeft',
			hook: { tip: 'topLeft', mouse: true },
			offset: { x: 15, y: 15 },
			width: '35em',
			hideOn: false,
			hideAfter: .5
		});
	}
}

function checkLoggedSession(){

		try{
			// Verifica se o sistema esta logado e dispara o changeButton() com o resultado.
			var url = 'https://carrinho.blockbusteronline.com.br/locaonline/begin.do?sku=0&onClickRent=true&cssClass=false&urlBack=';

			var obj2 = new JSONscriptRequest(url);
			obj2.buildScriptTag();
			obj2.addScriptTag();

		}catch(exception){}
}

function onClickRent(skuId, itemId, isDetail, urlBack){

	strClickId = itemId;
	
	if(skuId != '' && skuId != 'undefined'){

		// Exibe a imagem "carregando..." ao clicar no botao alugar
		changeLoading(skuId, itemId, isDetail);

		try{
			// Verifica se o filme informado esta no server e dispara o changeButton() com o resultado.
			var url = 'https://carrinho.blockbusteronline.com.br/locaonline/begin.do?sku=' + skuId + '&onClickRent=true&cssClass=' + isDetail + '&urlBack=' + urlBack;
			var obj2 = new JSONscriptRequest(url);
			obj2.buildScriptTag();
			obj2.addScriptTag();
		}catch(exception){}

	}

}

function onClickRating(itemId, rating, paramCss){

	strClickId = itemId;
	classCss = paramCss;

	if(itemId != null && rating != null){
		
		// Exibe a imagem "carregando..." ao clicar para votar
		changeLoadingRating(itemId, classCss);
		
		try{
			//Chama o metodo de Rating.
			var url = 'https://carrinho.blockbusteronline.com.br/locaonline/begin.do?setItemRating=true&itemId='+ itemId + '&rating='+ rating;
			var obj=new JSONscriptRequest(url);
			obj.buildScriptTag();
			obj.addScriptTag();
		}catch(exception){}

	}

}



function changeButton(isLogged, sku, isDetail, hasRentalRestrictions){
	try{
	
		if (isDetail == '' || isDetail == undefined){
			isDetail = 'false';
		}
    
		if (sku == '0' && isLogged == 'false' && paramHome == 'BlocAccelerator'){
			changeAllRentButtons();

		}else if(isLogged== 'false'){
			window.location = 'https://carrinho.blockbusteronline.com.br/locaonline/locacao.portal?sku=' + sku;
		}
		else if(isLogged == 'true'){		
			if (hasRentalRestrictions == 'false'){
				inserSkuInCookie(strClickId);	
				updateButton(strClickId , false, isDetail, hasRentalRestrictions);
				// Atualiza o botao do baloon se o mesmo estiver ativo
				//updateButton(strClickId , true, 'false');
			} else {
				changeRent(sku, strClickId, isDetail);
				callLightWindowPopUp('bluray_alert');
				//outService(sku, strClickId, isDetail);
			}
		}else{
			outService(sku, strClickId, isDetail);
		}

	}catch(exception){}

	strClickId = '';

}



function callLightWindowPopUp(alertKey){

      
      if (myLightWindow == null) {
          setTimeout('callLightWindowPopUp()', 1000);
          return;
      }
      
      if (alertKey == '' || alertKey == undefined){
          alertKey = alertCode;
      }
      
      if (alertKey=='bluray_alert'){
  
         myLightWindow.activateWindow({
                        href: '/home/begin.do?home=BlocPopup&id=200696', 
                        width: 600,
                        height: 300,
                        caption: '',
                        title: ''
                      });
      }
      
      if (alertKey=='SucessLost'){
  
         myLightWindow.activateWindow({
			   href: 'http://img.blockbusteronline.com.br/lightwindow/popup/pagina_cadastro_hotsite.htm', 
                        width: 700,
                        height: 400,
                        caption: '',
                        title: ''
                      });
      }
	  
	  if (alertKey=='SucessHotSite'){
  
         myLightWindow.activateWindow({
			   href: 'http://img.blockbusteronline.com.br/lightwindow/popup/pagina_cadastro_hotsite.htm', 
                        width: 700,
                        height: 400,
                        caption: '',
                        title: ''
                      });
      }

}

function checkAlert(){
    callLightWindowPopUp();
}

function setRatingReturn(str, itemId, rating){

	var strId = "rating";
	var load = "load_" + itemId;
	
	try{

		if(str == 'false'){
			window.location = 'https://carrinho.blockbusteronline.com.br/locaonline/locacao.portal?itemId='+ itemId + '&rating='+ rating;
		}
		else if(str == 'true'){
			document.getElementById(strId).innerHTML = "<div class=\"buttonLoading\">Voto computado com Sucesso</div>";
			setTimeout('changeRating(' + itemId + ',' + classCss + ')',1500);
		}
		else{
			document.getElementById(strId).innerHTML = "<div class=\"buttonError\">Erro ao computar voto</div>";
			setTimeout('changeRating(' + itemId + ',' + classCss + ')',1500);
		}	
	}catch(exception){}

	strClickId = '';

}


function updateButton(strIdup, isBaloon, isDetail){

	var tagId = '';
	var classe = '';
	var button = '';

	

    if(!isBaloon){
    
      if(isDetail == 'true'){		  
        tagId = 'buttonRent_' + strIdup;
        //classe = 'button1';
        button = 'imgButton14.gif';
      } else {
        
        tagId = 'button_' + strIdup;
        classe = 'button8';
        button = 'imgButton04.gif';
      }				
        
    }else{
      tagId = 'minhaLista';
      classe = 'button3';		
      button = 'imgButton04.gif';
    }

    if(document.getElementById(tagId)!=undefined){
      document.getElementById(tagId).innerHTML ='';
	  if (paramHome == 'BlocAccelerator'){
		document.getElementById(tagId).innerHTML = "<div id='"+tagId+"'><img alt=\"Item na Lista\" src=\"http://img.blockbusteronline.com.br/img/"+button+"\" onclick=\"javascript:window.open('https://carrinho.blockbusteronline.com.br/locaonline/locacao.portal', 'Blockbuster'); return false;\" STYLE=\"cursor: pointer; cursor: hand;\" /></div>";
	  } else {
		document.getElementById(tagId).innerHTML ='<div id="' + tagId +'"><a class="' + classe + '" href="https://carrinho.blockbusteronline.com.br/locaonline/locacao.portal"><img alt=\"Item na Lista\" src=\"http://img.blockbusteronline.com.br/img/' + button + '\"/></a></div>';
	  }
          
    }
		
}


function inserSkuInCookie(sku){
	if(hasMovieListCookie()){
		var str = readCookie('movieListCookie');
		if(str.indexOf(sku)==-1){
			str+=','+sku;
			geraCookieMovieList(str);
		}
	}
}


function removeSkuInCookie(itemId){

	// Efetua a exclusao do item no cookie
	var obj=new JSONscriptRequest('http://www.blockbuster.com.br/home/begin.do?home=BlocBaloon&itemId=' + itemId + '&updateCookie=true');
	obj.buildScriptTag();
	obj.addScriptTag();

}


function removeItemFromCookie(sku){
	if(hasMovieListCookie()){
		var str = readCookie('movieListCookie');

		if(str.indexOf(sku)!=-1){

			var strArray = str.split(",");
			var strAux = '';
			var size = strArray.size();

			for(i=0;i<size;i++){

				if(sku != strArray[i]){

					strAux += strArray[i];

					if((i + 1) != size)
						strAux += ',';

				}
			}

			if(strAux.length>0){
				geraCookieMovieList(strAux);
			}else{
				geraCookieMovieList('0');
			}

		}
	}
}


function getMyList(){

	//var obj2 = new JSONscriptRequest('https://carrinho.blockbusteronline.com.br/locaonline/begin.do?getMyList=true');
	//obj2.buildScriptTag();
	//obj2.addScriptTag();

}


function getMoviesList(str){
	/*
	if(str != 'false'){
		geraCookieMovieList(str);
	}else{
		if(hasMovieListCookie()){
			geraCookieMovieList(',');
		}
	}
	*/
}


function getMoviesListFromUser(){
/*
	if(!hasMovieListCookie()){
		getMyList();
	}
*/
}


function changeRentButtons(sku, isBaloon){
	if(hasMovieListCookie()){
		var str = readCookie('movieListCookie');
		var strArray = str.split(",");
		for(i=0;i<strArray.length;i++){
			if(sku == 0 || sku == strArray[i]){
				updateButton(strArray[i], isBaloon, 'false');				
			}
		}
	}
	/*else{	
		getMyList();
	
	}*/
	
}


function geraCookieMovieList(str){
	gravaCookie('movieListCookie', str, 0, '/','.blockbusteronline.com.br');
}


function hasMovieListCookie(){
	var name = readCookie('movieListCookie');
	if (name!=null && name!='null' && name!='' && name.length>0 && name!=',' && name!='%2C') {
		return true;
	}else
		return false;
	
}

function deleteMovieListCookie(){
	DeleteCookie('movieListCookie', '/', '.blockbusteronline.com.br');
}


function changeSaleButton(itemId){
	if(hasMovieListCookie()){
		var str = readCookie('movieListCookie');
		
		if(str.indexOf(itemId) != -1){
			var tagId = 'buttonRent_' + itemId;
			if(document.getElementById(tagId)!=undefined)
				document.getElementById(tagId).innerHTML ='<div id="buttonRent_' + itemId +'"><a href="https://carrinho.blockbusteronline.com.br/locaonline/locacao.portal"><img alt=\"Item na Lista\" src=\"http://img.blockbusteronline.com.br/img/imgButton14.gif\"/></a></div>';
			
		} 
	}/*else{	
		getMyList();
	
	}*/
	
}


function setSaleButton(sku){
	$('skuSale').value = sku;
	$('urlSale').value = window.location.href;
	document.formSale.submit();
}


function sleep(millisec){

	var now = new Date();
	var endTime = now.getTime() + millisec;

	while(true){
		now = new Date();
		if(now.getTime() > endTime) return;
	}

}

// Exibe a mensagem "carregando"
function changeLoading(skuId, itemId, isDetail){
	if(isDetail == 'true'){
		var strId = "buttonRent_" + itemId;
	}else{
		var strId = "button_" + itemId;
	}
	var nameId = "load_" + itemId;

	if (paramHome == 'BlocAccelerator'){
		document.getElementById(strId).innerHTML = "<div class=\"buttonLoading\" id=\"" + nameId + "\" ><img src=\"http://img.blockbusteronline.com.br/img/loading.gif\" /></div>";
	} else {
		document.getElementById(strId).innerHTML = "<div class=\"buttonLoading\" id=\"" + nameId + "\" >Carregando <img src=\"http://img.blockbusteronline.com.br/img/loading.gif\" /></div>";
	}
	setTimeout('isTimeOut(' + skuId + ',' + itemId + ',' + isDetail + ')',15000);
}

// Exibe a mensagem "carregando" para Rating
function changeLoadingRating(itemId, paramCss){
	var strId = "rating";	
	var nameId = "load_" + itemId;
	classCss = "'" + paramCss + "'";
	
	document.getElementById(strId).innerHTML = "<div class=\"buttonLoading\" id=\"" + nameId + "\" >Carregando <img src=\"http://img.blockbusteronline.com.br/img/loading.gif\" /></div>";

	setTimeout('isTimeOutRating(' + itemId + ',' + classCss + ')',15000);
}


// Exibe o botao Alugar
function changeRent(skuId, itemId, isDetail){
	if(isDetail == 'true'){
		var strId = "buttonRent_" + itemId;
	}else{
		var strId = "button_" + itemId;
	}
	if (paramHome == 'BlocAccelerator'){
		document.getElementById(strId).innerHTML = "<div id='"+strId+"'><img alt=\"Alugar\" src=\"http://img.blockbusteronline.com.br/img/imgButton03.gif\" onclick=\"javascript:window.open('https://carrinho.blockbusteronline.com.br/locaonline/locacao.portal?sku="+ skuId +"&urlBack=/Minha_lista/', 'Blockbuster'); return false;\" STYLE=\"cursor: pointer; cursor: hand;\" /></div>";
	} else if(isDetail == 'true'){
		document.getElementById(strId).innerHTML = "<a class=\"button4\" href=\"#\" onclick=\"javascript:onClickRent('" + skuId + "','" + itemId + "','" + isDetail + "'); return false;\"><img alt=\"Incluir na Minha Lista\" src=\"http://img.blockbusteronline.com.br/img/imgButton01.gif\"/></a>";
	}else{
		document.getElementById(strId).innerHTML = "<a class=\"button4\" href=\"#\" onclick=\"javascript:onClickRent('" + skuId + "','" + itemId + "','" + isDetail + "'); return false;\"><img alt=\"Incluir na Minha Lista\" src=\"http://img.blockbusteronline.com.br/img/imgButton03.gif\"/></a>";
	}

}

// Altera todos os botoes de alugar para abrir o login
function changeAllRentButtons(){
		var rentButtons = document.getElementsByTagName("div")

		var re = new RegExp('^button.+');
		var rep = new RegExp('^button\_');
		
		for (i=0; i<rentButtons.length; i++){
		    var element = rentButtons.item(i);
			var elemId = rentButtons.item(i).id;
			
			if (re.test(elemId)){
			    var skuId = elemId.replace(rep, "");
				element.innerHTML = "<div id='"+strId+"'><img alt=\"Alugar\" src=\"http://img.blockbusteronline.com.br/img/imgButton03.gif\" onclick=\"javascript:window.open('https://carrinho.blockbusteronline.com.br/locaonline/locacao.portal?sku="+skuId+"&urlBack=/Minha_lista/', 'Blockbuster'); return false;\" STYLE=\"cursor: pointer; cursor: hand;\" /></div>";		
			}
		}
}

// Exibe o Rating
function changeRating(itemId, paramCss){
	var strId = "rating";	

	document.getElementById(strId).innerHTML = "<span class="+paramCss+"><a href=\"#\" onclick=\"onClickRating('"+itemId+"', 2, "+classCss+")\">&nbsp;</a><a href=\"#\" onclick=\"onClickRating('"+itemId+"', 4, "+classCss+")\">&nbsp;</a><a href=\"#\" onclick=\"onClickRating('"+itemId+"', 6, "+classCss+")\">&nbsp;</a><a href=\"#\" onclick=\"onClickRating('"+itemId+"', 8, "+classCss+")\">&nbsp;</a><a href=\"#\" onclick=\"onClickRating('"+itemId+"', 10, "+classCss+")\">&nbsp;</a></span>";
}


// Exibe a mensagem de falha na comunicacao
function outService(skuId, itemId, isDetail){
	if(isDetail == 'true'){
		var strId = "buttonRent_" + itemId;
	}else{
		var strId = "button_" + itemId;
	}
	
	document.getElementById(strId).innerHTML = "<div class=\"buttonError\">Falha na comunica&ccedil;&atilde;o.</div>";

	setTimeout('changeRent(' + skuId + ',' + itemId + ',' + isDetail + ')',1500);

}


// Exibe a mensagem de falha na comunicacao de Rating
function outServiceRating(itemId, paramCss){
	var strId = "rating";
	classCss = "'" + paramCss + "'";
		
	document.getElementById(strId).innerHTML = "<div class=\"buttonError\">Falha na comunica&ccedil;&atilde;o.</div>";

	setTimeout('changeRating(' + itemId + ',' + classCss + ')',1500);

}


// Verifica se expirou o tempo de resposta do processo
function isTimeOut(skuId, itemId, isDetail){

	var strId = "load_" + itemId;
	var hasElement = document.getElementById(strId);

	if(hasElement != null){

		outService(skuId, itemId, isDetail);

	}

}

// Verifica se expirou o tempo de resposta do processo do Rating
function isTimeOutRating(itemId, paramCss){

	var strId = "load_" + itemId;
	var hasElement = document.getElementById(strId);
	
	if(hasElement != null){

		outServiceRating(itemId, paramCss);

	}

}

//deleta cookie do catalogo e redireciona para deletar cookie do chekout;
function deleteBlockCookie()
{
	DeleteCookie("BlockbusterNomeSaudacao", '/', '.blockbusteronline.com.br');
	DeleteCookie("movieListCookie", '/', '.blockbusteronline.com.br');
	window.location = 'https://carrinho.blockbusteronline.com.br/locaonline/pageflows/profile/logout.do';

}

function getGreetingName(){
	try {
		DeleteCookie("BlockbusterNomeSaudacao", '/');
	}
	catch (exception) {
	}
	
	try {
		DeleteCookie("movieListCookie", '/');
	}
		catch (exception) {
	}
	
	try {	
		if(isGreeting == 'false'){
			DeleteCookie("BlockbusterNomeSaudacao", '/', '.blockbusteronline.com.br');
			DeleteCookie("movieListCookie", '/', '.blockbusteronline.com.br');
		}

		var name = readCookie('BlockbusterNomeSaudacao');

		if (name==null || name=='null' || name.length==0) {
			//var url = 'https://carrinho.blockbusteronline.com.br/locaonline/begin.do?getName';
			// Efetua a exclusao do item no cookie
			//var obj=new JSONscriptRequest(url);
			//obj.buildScriptTag();
			//obj.addScriptTag();
		}
		
	}
	catch (exception) {
	}
}

function setCookieName(name){
	if (name!=null && name!='null' && name.length>0) {
		name = unescape(name);
		gravaCookie('BlockbusterNomeSaudacao', name, (10000*24*60*60*1000), '/','.blockbusteronline.com.br');
		document.getElementById("greeting").innerHTML="Ol&aacute; " + name +  " (se n&atilde;o for voc&ecirc;, <a  href='#' onclick='javascript:deleteBlockCookie();'> clique aqui </a>)&nbsp;|&nbsp;<a href='#' onclick='javascript:deleteBlockCookie();'>Sair</a>";
	}
	else {
		document.getElementById("greeting").innerHTML = "Novo no site? <a href='https://carrinho.blockbusteronline.com.br/login/'><strong>Assine Aqui</strong></a>";
	}
}

function showGreeting(){	
	var name = readCookie('BlockbusterNomeSaudacao');

	if (name!=null && name!='null' && name.length>0) {
		document.write("Ol&aacute; " + name +  " (se n&atilde;o for voc&ecirc;, <a  href='#' onclick='javascript:deleteBlockCookie();'> clique aqui </a>)&nbsp;|&nbsp;<a href='#' onclick='javascript:deleteBlockCookie();'>Sair</a>");
	}
	else {
		document.write("Novo no site? <a href='https://carrinho.blockbusteronline.com.br/login/'><strong>Assine Aqui</strong></a>");
	}
}

function DeleteCookie( name, path, domain ) {
        if ( readCookie( name ) ){
                var curCookie = name + "=" +
                ( ( path ) ? ";path=" + path : "");
                if(domain) curCookie+= "; domain=" + domain;

                curCookie+=";expires=Thu, 01-Jan-1970 00:00:01 GMT";
                document.cookie = curCookie;
        }
}

function setReturnFromLogin(itemId, strParamCss, strRating){	
	paramCss = strParamCss;
	var strId = "rating";
	classCss = "'" + paramCss + "'";
	if (strRating == 'true'){
		setRatingReturn('true',itemId,'0');
	}else{
		outServiceRating(itemId,paramCss);
	}
}

function showMenu(){
	if (paramHome=='BlocRelease' || paramHome=='BlocGuide'){
		document.getElementById("userLinks").style.display='inline';
		document.getElementById("subMenuStore").style.display='none';
		document.getElementById("userLinksBluRay").style.display='none';
	}else if(paramHome=='BlocArticle' && paramId=='200690'){
		document.getElementById("userLinks").style.display='none';
		document.getElementById("subMenuStore").style.display='inline';
		document.getElementById("userLinksBluRay").style.display='inline';
	}else{
		document.getElementById("userLinks").style.display='none';
		document.getElementById("subMenuStore").style.display='inline';
		document.getElementById("userLinksBluRay").style.display='none';
	}

}

function showMenuBluRay(departmentId){
	if(departmentId == '63957' || departmentId == '63979'){
		document.getElementById("userLinks").style.display='none';
		document.getElementById("userLinksBluRay").style.display='inline';
		document.getElementById("subMenuStore").style.display='inline';
	}else{
		document.getElementById("userLinks").style.display='inline';
		document.getElementById("subMenuStore").style.display='none';		
		document.getElementById("userLinksBluRay").style.display='none';
	}		
}

function vai(){ 
	window.open ("http://www.blockbusteronline.com.br/principal/institucional/horarios/fimdeano.htm","horarios","menubar=0,resizable=0,width=470,height=900");  
} 

function showDhtmlHome(){
	var homeVerifyCookie = readCookie('homeVerify');
	var specialHome		 = getSpecialHomeCookie();
	if(!homeVerifyCookie){
		if (specialHome == 'parceriaSuba'){
			document.write("<div class='subaLightBox' id='subaLightBox'>");
			document.write("<a class='closeSuba' href='#' onClick='javascript: document.getElementById(\"subaLightBox\").style.display=\"none\"; return false;'><span>x Fechar</span></a>");
			document.write("<a href='http://www.blockbusteronline.com.br/planos/' class='banner' target='_self'><img src='http://img.blockbusteronline.com.br/img/parceriaSuba.jpg' alt='Blockbuster' /></a>");
			document.write("</div>");
			document.cookie = 'homeVerify=preHome; path=/;';
		} else {
			document.write("<div class='mainLightBox'>");
			document.write("<a class='close' href='#'><span>X Fechar</span></a>");
			document.write("<a href='http://www.blockbusteronline.com.br/home/begin.do?home=BlocHome' class='banner' target='_self'><img src='http://img.blockbusteronline.com.br/img/mainLightBox.jpg' alt='Blockbuster' /></a>");
			document.write("<a href='http://carrinho.blockbusteronline.com.br/locaonline/locacao.portal' class='joinNow' target='_self'>Assine Agora!</a>");
			document.write("<span>* V&aacute;lido apenas para S&atilde;o Paulo, Grande S&atilde;o Paulo, Rio de Janeiro e Grande Rio de Janeiro</span>");
			document.write("</div>");
			document.write("<div class='overlay'></div>");
			document.cookie = 'homeVerify=preHome; path=/;';
		}
	}
}

function initHeaderBg(){
	if (paramHome=='BlocHome' || paramHome=='BlocRent' || (paramHome=='BlocArticle' && paramId=='200610') ) {
		document.getElementById(paramHome).className = 'selected';
	}else if (paramHome=='BlocProduct' || paramHome=='BlocGuide' || paramHome=='BlocRelease'){
		document.getElementById('BlocRent').className = 'selected';
	}else if(paramHome=='BlocArticle' && paramId=='200690'){
		document.getElementById('BlocRentBluRay').className = 'selected';
	}	
}

function initHeaderBgBluRay(departmentId){
	if(departmentId == '63957' || departmentId == '63979'){
		document.getElementById('BlocRentBluRay').className = 'selected';
		document.getElementById('BlocRent').className = '';
	}
}



function verificaCp(){
	if (paramCp!=null && paramCp!='null' && paramCp.length>0) {
		var cpCookie = readCookie('BlockBusterCoupon');
		if (cpCookie!=null && cpCookie!='null' && cpCookie.length>0) {
			DeleteCookie("BlockBusterCoupon", '/', '.blockbusteronline.com.br');
		}
		//gravaCookie('BlockBusterCoupon', paramCp, (10000*24*60*60*1000), '/','.blockbusteronline.com.br');
		//Alterado por eric.senne -> problema ao gravar cookie no IE.
		gravaCookie('BlockBusterCoupon', paramCp, (1), '/','.blockbusteronline.com.br');
	
	}
}


function verificaHotSiteForm(){
	var msg='';
	if (document.getElementById('message').value.length==0 ){
			msg = msg + "\n - Resposta";
	}
	if (!document.form.VerIsClient[0].checked && !document.form.VerIsClient[1].checked){
		msg = msg + "\n - É cliente?";
	}
	if (document.getElementById('name').value.length==0){
		msg = msg + "\n - Nome Completo";
	}
	if (document.getElementById('address').value.length==0){
		msg = msg + "\n - Endereço";
	}
	if (document.getElementById('email').value.length==0){
		msg = msg + "\n - Email";

	}else{
		if(!isEmail(document.getElementById('email').value)){
			msg = msg + "\n - Email inválido";
		}

	}
	if (document.getElementById('dddTelefone').value.length==0){
		msg = msg + "\n - DDD";
	}
	if (document.getElementById('telefone') != null && document.getElementById('telefone').value.length==0){
  		msg = msg + "\n - Telefone";
	} else if ( document.getElementsByName('telefone') != null && document.getElementsByName('telefone').length > 0 && document.getElementsByName('telefone')[0].value.length==0){
		msg = msg + "\n - Telefone"; 
	}
	if (document.getElementById('cpf').value.length==0){
		msg = msg + "\n - CPF";
	}
	if (document.getElementById('rg').value.length==0){
		msg = msg + "\n - Identidade";
	}
	if (msg.length==0){
		if (document.form.VerIsClient[0].checked)
			document.getElementById('isClient').value = "1"
		else
			document.getElementById('isClient').value = "0"
			
		 document.getElementById('subject').value = document.getElementById('subject').value + document.getElementById('email').value;

		document.getElementById('form').submit();
	}else{
		alert('Favor preencher os seguinte campos corretamente:' + msg);
		return;
	}

}

function soNumero(obj, event)
//Formata o campo somente numeros
  {

     data = obj.value;
     if (document.all) {
            nTecla = event.keyCode;
      } else {
            nTecla = event.which;
      }


    //Se for caracter de controle retorna
    if (nTecla < 32)
    {
        event.returnValue = true;
        return;
    }

    //Verifica se foi digitado um numero. Verificacao em teclado numerico (numlock) ou alfabetico (qwert)
    if ((String.fromCharCode(nTecla) < '0') || ((String.fromCharCode(nTecla) > '9') && ((nTecla < '96') || (nTecla > '105'))))
    {
        if ((nTecla == 37)  || (nTecla == 39) || (nTecla == 46)) // permite teclas de direcao e DEL

            event.returnValue = true;
        else
        {
            if(event && event.preventDefault)
                event.preventDefault();
            else
                event.returnValue = false;
        }
    }
    else
    {
            event.returnValue = true;
    }

}


function maxLengthTextarea(textAreaField, limit) {
    var ta = document.getElementById(textAreaField);

    if (ta.value.length >= limit) {
        ta.value = ta.value.substring(0, limit-1);
    }
}

function validateCupomDominos() {
	var cupom = document.getElementById("textCupomHotsite").value;
	if(cupom!=null && cupom!="") {
		gravaCookie('BlockBusterCoupon', cupom, (1), '/','.blockbusteronline.com.br');
		window.location="https://carrinho.blockbusteronline.com.br/login/";
	} else {
		alert("Cupom Inválido.");
	}
}

function validateCupom() {
	var cupom = document.getElementById("textCupom").value;
	if(cupom!=null && cupom!="") {
		gravaCookie('BlockBusterCoupon', cupom, (1), '/','.blockbusteronline.com.br');
		window.location="https://carrinho.blockbusteronline.com.br/login/";
	} else {
		alert("Cupom Inválido.");
	}
}

function setSpecialHomeCookie(specialHome) {
	gravaCookie('specialHome', specialHome, 0, '/','.blockbusteronline.com.br');	
}


function getSpecialHomeCookie() {
	var specialVar = "";

	var topElemLocation = "";
	var hashVal = window.location.hash.substr(1);
	if (hashVal!="acom" ){
		specialVar = readCookie('specialHome');
	}else{
		DeleteCookie("specialHome", '/', '.blockbusteronline.com.br');
	}

	return specialVar;
}



function showArea3SpecialHome() {
	var specialHomeValue = getSpecialHomeCookie();
	if(specialHomeValue=="parceriaSuba") {
		var so = new SWFObject("http://img.blockbusteronline.com.br/flash/submarino/carrossel_sub_block2.swf", "specialHome", "960", "237", "9", "carrossel_sub_block2.swf");
		so.addParam("allowScriptAccess", "always");
		so.addParam("wmode", "transparent");
		so.write("specialHome");
	}
}


// Exibe a mensagem de validação do cupom
function setValidaCupomMessage(){
	invalidCoupon("loadValidate", "buttonValidate");
}

function setValidaCupomReturn(pageRedirect, couponId){
	if(pageRedirect=='loca_sign_page') {
		gravaCookie('BlockBusterCoupon', couponId, (1), '/','.blockbusteronline.com.br');
		location.href="https://carrinho.blockbusteronline.com.br/locaonline/locacao.portal?_nfpb=true&_pageLabel=loca_sign_page&_nfls=false"
	} else if(pageRedirect=='loca_sign_available_plans') {
		gravaCookie('BlockBusterCoupon', couponId, (1), '/','.blockbusteronline.com.br');
		location.href="https://carrinho.blockbusteronline.com.br/locaonline/locacao.portal?_nfpb=true&_pageLabel=loca_sign_page&_nfls=false&goToPreRegister=true";
		//location.href="https://carrinho.blockbusteronline.com.br/locaonline/locacao.portal?_nfpb=true&loca_sign_available_plans_actionOverride=%2Fpageflows%2Fsign%2FvalidateCoupon&_windowLabel=loca_sign_available_plans";
	} else {
		invalidCoupon("loadValidate", "buttonValidate");
	}
}

function validaCupom() {
	validaCupom('');
}

var btnValidate;

function validaCupom(codPromo) {
	var cupom = document.getElementById("textCupomHotsite").value;
	btnValidate = document.getElementById("buttonValidate").innerHTML;
	
	if(cupom != null && cupom != ""){
	
		if (codPromo==null || codPromo == 'null')
			codPromo='';
			
		changeLoadingValidate("buttonValidate");
		
		try{
			//location.href="https://carrinho.blockbusteronline.com.br/locaonline/locacao.portal?_nfpb=true&_pageLabel=loca_login_page&_nfls=false";
			var url = 'https://carrinho.blockbusteronline.com.br/locaonline/begin.do?setValidaCupom=true&codPromo='+ codPromo +'&cupom='+ cupom;
			var obj=new JSONscriptRequest(url);
			obj.buildScriptTag();
			obj.addScriptTag();
		}catch(exception){}
	} else {
		document.getElementById("couponMessage").style.visibility = 'visible';
		document.getElementById("couponMessage").innerHTML = "Favor preencher o cupom";
	}
}

// Exibe a mensagem "carregando"
function changeLoadingValidate(btnId){
	var nameId = "loadValidate";
	document.getElementById("couponMessage").style.visibility = 'hidden';
	document.getElementById(btnId).innerHTML = "<div class='buttonLoading' id='" + nameId + "'>Carregando <img src='http://img.blockbusteronline.com.br/img/loadingCinza.gif' Style='width: 15px;'/></div>";
	setTimeout("isTimeOutValidate('" + nameId + "', '" + btnId + "')",15000);
}

// Verifica se expirou o tempo de resposta do processo
function isTimeOutValidate(nameId, btnId){

	var hasElement = document.getElementById(nameId);

	if(hasElement != null){

		outServiceValidate(nameId, btnId);

	}

}

// Exibe a mensagem de cupom inválido
function invalidCoupon(nameId, btnId){	
	setTimeout("changeValidateCupom('" + btnId + "')",1500);
}

// Exibe a mensagem de falha na comunicacao
function outServiceValidate(nameId, btnId){	
	document.getElementById(nameId).innerHTML = "<div class=\"buttonError\">Falha na comunica&ccedil;&atilde;o.</div>";

	setTimeout("changeValidate('" + btnId + "')",1500);
}

// Exibe o botao Validar
function changeValidate(nameId){
	//document.getElementById(nameId).innerHTML = "<a href='#' onClick='javascript:validaCupom(); return false;' ><img alt='Validar' src='http://img.blockbusteronline.com.br/img/btnValidar_3.gif' alt='Validar' width='106' height='25' align='absmiddle'/></a>";
	document.getElementById(nameId).innerHTML = btnValidate;
}

// Exibe o botao Validar
function changeValidateCupom(nameId){
	document.getElementById(nameId).innerHTML = btnValidate;
	document.getElementById("couponMessage").style.visibility = 'visible';
	document.getElementById("couponMessage").innerHTML = "Cupom Inválido";
}

function faq(){
	var faq = document.getElementById("faq");
	var question = faq.getElementsByTagName("strong");
	function next(elemNext) {
		do {
			elemNext = elemNext.nextSibling;
		} while (elemNext && elemNext.nodeType != 1);
		return elemNext;                
	}
	for(var i=0; i<question.length; i++){
		if ( question[i].className === "question" ){
				var nextQuestion = next(question[i]);	
				if (nextQuestion){
					nextQuestion.style.display = "none";
				}
				question[i].onclick = function(){ 
										var nextElem = next(this);
										if (nextElem){
											if(nextElem.style.display != "none"){
											nextElem.style.display = 'none';
											}else{
											
											nextElem.style.display = 'block';
											}
										}
											
				};
		}
	}

}

function setCouponInHotsiteText(){
	var cpCookie = readCookie('BlockBusterCoupon');
	if (cpCookie!=null && cpCookie!='null' && cpCookie.length>0) {
		document.getElementById("textCupomHotsite").value=cpCookie;
	}
	if (paramCp!=null && paramCp!='null' && paramCp.length>0) {
		document.getElementById("textCupomHotsite").value=paramCp;	
	}

}