﻿// JScript File

function addFav(){
    var url        = "http://www.probitas.pt";
    var title    = "::PROBITAS::";
    if (window.sidebar) window.sidebar.addPanel(title, url,"");
    else if(window.opera && window.print){
        var mbm = document.createElement('a');
        mbm.setAttribute('rel','sidebar');
        mbm.setAttribute('href',url);
        mbm.setAttribute('title',title);
        mbm.click();
    }
    else if(document.all){window.external.AddFavorite(url, title);}
}

function mostrarDIV(el) {

        document.getElementById("DadosProduto").style.display='none';
        document.getElementById("CaracteristicasTecnicas").style.display='none';
        document.getElementById("OutrasCaracteristicas").style.display='none';
        document.getElementById("D").style.color="#666666";
        document.getElementById("CT").style.color="#666666";
        document.getElementById("O").style.color="#666666";
        
              
        document.getElementById(el).style.display='inline';
         switch(el)
        {
            case "DadosProduto":
                document.getElementById("D").style.color="#FD9711";
                break;
                
             case "CaracteristicasTecnicas":
                document.getElementById("CT").style.color="#FD9711";
                break;
                
             case "OutrasCaracteristicas":
                document.getElementById("O").style.color="#FD9711";
                break;
         }          
            
}
        
        
        function mostrarFotos(ctrl, el) {
        document.getElementById(ctrl).src=el;
        }
        
           function swapimage (id, url, alt) {
		      imagem = document.getElementById(id);
		       imagem.src = url;
		   imagem.alt = alt;
       }

function ValidatePais(source, arguments)
{
var idSource = source.selectedIndex;
//alert(arguments.Value.id);
	var list = document.getElementById("ctl00_contentPlaceHolder1_ddlPais");
	if (null != list)
	{
		var iValue = new Number(list.selectedIndex);
//alert(list.selectedIndex);
		arguments.IsValid=(iValue > 0);
	}
	else
	{
		arguments.IsValid = false;
	}
}
function ValidatePaisInvoice(source, arguments)
{
	var list = document.getElementById("ctl00_contentPlaceHolder1_ddlPaisInvoice");
	if (null != list)
	{
		var iValue = new Number(list.selectedIndex);
		arguments.IsValid=(iValue > 0);
	}
	else
	{
		arguments.IsValid = false;
	}
}

function ValidatePaisDelivery(source, arguments)
{
	var list = document.getElementById("ctl00_contentPlaceHolder1_ddlPaisDelivery");
	if (null != list)
	{
		var iValue = new Number(list.selectedIndex);
		arguments.IsValid=(iValue > 0);
	}
	else
	{
		arguments.IsValid = false;
	}
}

function ValidateMetodosPagamento(source, arguments)
{
	var list = document.getElementById("ctl00_contentPlaceHolder1_ddlMetodosPagamento");
	if (null != list)
	{
		var iValue = new Number(list.selectedIndex);
		arguments.IsValid=(iValue > 0);
	}
	else
	{
		arguments.IsValid = false;
	}
}

function ValidateMetodosEntrega(source, arguments)
{
	var list = document.getElementById("ctl00_contentPlaceHolder1_ddlMetodosEntrega");
	if (null != list)
	{
		var iValue = new Number(list.selectedIndex);
		arguments.IsValid=(iValue > 0);
	}
	else
	{
		arguments.IsValid = false;
	}
}

function ValidateChecked(oSrc, args)
{
    var check = document.getElementById("ctl00_contentPlaceHolder1_ckbTermos");
    if(null != check)
    {
        if (check.checked == false)
        {
            args.IsValid = false;
        }
        else
        {
            args.IsValid = true;
        }
    }
    else
    {
        args.IsValid = false;
    }
}

function redirect(url)
{
    window.location = url
}

function setActiveTab(activeTab, activeImage, alt)
{
    var tab = document.getElementById(activeTab);
    if (tab)
    {
        swapimage (activeTab, activeImage, alt)
    }
}

function setTabLink(idTab, urlTab)
{
    var tab = document.getElementById(idTab);
    if (tab)
    {
        tab.href = urlTab;
    }
}