var gifGifMakerURL;
var gelatubeURL;

var AS_GATEWAY;

function showGelatinas() {
	clearGateway();
	mostraModal('gelatinas/gelatinas.php', 446, 442);
}

function showGifMaker() {
	clearGateway();
	mostraModal('gifmaker/gifmaker.php', 784, 490);
}

function showGelatube() {
	clearGateway();
	mostraModal('gelatube/gelatube.php', 880, 498);
}

function showFaq(){

}


function setGifURL(url){
	gifGifMakerURL = url;
	console.debug(gifGifMakerURL);
    fechaModal();
    
    AS_GATEWAY = 'GIFMAKER';
}


function setFlvURL(url){
	gelatubeURL = url;
	console.debug(gelatubeURL);
    fechaModal();
    
    AS_GATEWAY = 'GELATUBE';
}


function sendToGallery(){
    console.debug('sendToGallery');
	fechaModal();
	AS_GATEWAY = 'GALERIA_GIFS';
}

function sendToGalleryVideos(){
	fechaModal();
	AS_GATEWAY = 'GALERIA_VIDEOS';
}





/**

***/
function jsTempGateway(){
	if (AS_GATEWAY == 'GALERIA_GIFS'){
		return 'GALERIA_GIFS';
	} else if (AS_GATEWAY == 'GALERIA_VIDEOS'){
		return 'GALERIA_VIDEOS';
	} else if (AS_GATEWAY == 'GIFMAKER'){
		return gifGifMakerURL;
	} else if (AS_GATEWAY == 'GELATUBE'){
		return gelatubeURL;
	}
}

/**

***/
function clearGateway(){
	gifGifMakerURL = null;
	gelatubeURL = null;
	AS_GATEWAY = null;
}







var height = 900;
function resizeFlashTo(valor) {
	if (valor != null && valor != '' && valor != 'undefined') {
		height = valor;
		document.getElementById("flash").height = height;
	}
}



/**

***/
function mostraModal(url, largura, altura) {
	console.log('teste');
    try {
        janela.dialog('destroy');
    } catch (ex) { }
    $('body').append('<div id="modalDialog"></div>');
    var w = 800;
    var h = 600;

    if (largura != null && largura != undefined && largura != "")
        w = parseInt(largura) + 40;
    if (altura != null && altura != undefined && altura != "")
        h = parseInt(altura) + 65;
	
	var hackNotIE = ' style="padding-left: 0 !important;" ';
	if( $.browser.msie )
		hackNotIE = ' style="padding-left: 12px !important;" ';

    var elementoDialog = '<iframe id="externalSite" class="externalSite" frameBorder="0" border="0" ' + hackNotIE +' src="' + url + '" />';
    janela = $(elementoDialog).dialog({
        title: '',
        autoOpen: true,
        width: w,
        height: h,
        modal: false,
        resizable: true,
        autoResize: true,
		draggable: true,
        closeText: 'Fechar',
		dialogClass: 'dialogWithDropShadow',
        close: fechaModal
    })
}


/**

***/
function fechaModal(ev, ui) {
	$(janela).remove();
	$('body').append('<div id="modalDialog"></div>');
}



