var Site = {
    Init: function() {

        //Busca por todos os links que possuem a classe '.external-modal' para abrir janela modal
        $('.external-modal').click(function() {
            var id = $(this).attr('id');
            var source = $(this).attr('href');
            var dimensoes = $(this).attr('rel');
            dimensoes = dimensoes.split('x');
            var w = dimensoes[0];
            var h = dimensoes[1];
            Site.Generics.OpenExternalModal(id, source, w, h);
            return false;
        });

        $('.internal-modal').click(function() {
            var id = $(this).attr('href');
            var openmodal = function(hash) { hash.o.fadeIn('700', function() { hash.w.fadeIn('300'); }); };
            var closemodal = function(hash) { hash.w.fadeOut('300', function() { hash.o.fadeOut('700'); }); };
            $(id).jqm({ toTop: true, onShow: openmodal, onHide: closemodal });
            Site.Generics.OpenInternalModal(id);
            return false;
        });
    },
    Generics: {
        OpenExternalModal: function(id, source, w, h) {
            ModalWindow.windowId = id;
            ModalWindow.width = w;
            ModalWindow.height = h;
            ModalWindow.content = '<iframe width=\"' + w + '\" height=\"' + h + '\" frameborder=\"0\" scrolling=\"no\" allowtransparency=\"true\" src=\"' + source + '\"></iframe>';
            ModalWindow.Open();
        },
        OpenInternalModal: function(id) {
            $(id).jqmShow({ toTop: true });
        }
    }
}

function trim(vString){
	return vString.replace(/^\s+|\s+$/ig, '');
}
function clickInText(obj){
	var valorinicial = trim(obj.getAttribute('valorInicial'));
	if ( trim(obj.value) == valorinicial ) {
		obj.value = '';					
	}
}
function clickOutText(obj){
	var valorinicial = trim(obj.getAttribute('valorInicial'));
	if ( trim(obj.value) == '' ) {
		obj.value = valorinicial;
	}
}
function clickInPass(obj1, obj2){
	var valorinicial = trim(obj1.getAttribute('valorInicial'));
	if ( trim(obj1.value) == valorinicial ) {
		obj1.style.display = 'none';
		obj2.style.display = 'inline';
		obj2.value = '';
		obj2.focus();
	}
}
function clickOutPass(obj1, obj2){
	var valorinicial = trim(obj1.getAttribute('valorInicial'));
	if ( trim(obj2.value) == '' ) {
		obj2.style.display = 'none';
		obj1.value = valorinicial;
		obj1.style.display = 'inline';
	}
}
function acessaMarca(){
    url = document.forms[0].ctl00$ddlSelecioneMarca.value;
    if (url != "#"){
        window.open(url, "marca");
    }
} 
function bancoImagensImageBig(id)
{
    window.open('banco_imagens_big.aspx?id=' + id, null,'height = 300, width = 700, left= 200, top = 200,status=0,toolbar=0,menubar=0,location=0,resizable=1');

}
