<?
session_name('portal_absa');
session_start();

if(!isset($_SESSION['usuario_p_prov_absa']) || trim($_SESSION['usuario_p_prov_absa']) == "" || trim(strtoupper($_SESSION["URL_PORTAL"]."admin.php")) != trim(strtoupper($_SERVER['HTTP_REFERER']))){
	?><script>window.location.href="<?=$_SESSION["URL_PORTAL"]."index.php"?>"</script><?
	exit;
}

$directorio=opendir("Imagenes/imgLogin");
$arrImg=array();
$col=0;
while ($archivo = readdir($directorio)){
	if(trim($archivo) != "." && trim($archivo) != ".."){
                $ext = strtoupper(trim(end(explode('.',$archivo))));
		if($ext != "DB" && ($ext=="JPG" || $ext=="PNG" || $ext=="GIF")){
			$arrImg[$col].=$archivo;
			$col++;
		}
	}
}
closedir($directorio); 

?>

<script>
$j_6(document).ready(function() {
        $j_6('#config_general_show').hide();
        $j_6('#config_login_show').hide();
        $j_6('#fondo_img_show').hide();
		$j_6('#fondo_img_2_show').hide();
		$j_6('#fondo_img_3_show').hide();
		$j_6('#fondo_img_4_show').hide();
	$j_6('#loading').hide();
    $j_6().ajaxStart(function() {
        $j_6('#loading').show();
    }).ajaxStop(function() {
        $j_6('#loading').hide();
    });
	
	$j_6('#form, #fat, #frmConfig').submit(function() {
        $j_6.ajax({
            type: 'POST',
            url: $j_6(this).attr('action'),
            data: $j_6(this).serialize(),
            success: function(data) {
					$j_6('#resultConfig').html(data);
            }
        })
        
        return false;
    });
    
$j_6('#tema_general').change(function(){
    $j_6('#tema_general').each(function(){
        var tema = $j_6(this).val();
        document.getElementById('img_tema_general').src='Imagenes/'+tema+'.png';
    });
});

$j_6('#login_img').change(function(){
    $j_6('#login_img').each(function(){
        var tema = $j_6(this).val();
        document.getElementById('tema_login_img').src='Imagenes/imgLogin/'+tema;
    });
});

$j_6('#fondo_img_img').click(function(){
    $j_6('#fondos_img').load('load_fondos.php');
    $j_6('#fondos_img').show();
});

$j_6('#fondo_img_img_3').click(function(){
    $j_6('#fondos_img_3').load('load_fondos_bannerS.php');
    $j_6('#fondos_img_3').show();
});

$j_6('#fondo_img_img_4').click(function(){
    $j_6('#fondos_img_4').load('load_fondos_bannerC.php');
    $j_6('#fondos_img_4').show();
});

$j_6('#fondo_img_img_2').click(function(){
    $j_6('#fondos_img_2').load('load_fondos_2.php');
    $j_6('#fondos_img_2').show();
});
    
    
});

$j_6('#color_fondo').ColorPicker({
	color: '<?=$_SESSION['color_fondo']?>',
	onShow: function (colpkr) {
		$j_6(colpkr).fadeIn(500);
		return false;
	},
	onHide: function (colpkr) {
		$j_6(colpkr).fadeOut(500);
		return false;
	},
	onChange: function (hsb, hex, rgb) {
                $j_6('#color_fondo').val('#'+hex);
		$j_6('#color_fondo').css('backgroundColor', '#' + hex);
	}
});

$j_6('#color_fondo_2').ColorPicker({
	color: '<?=$_SESSION['color_fondo_2']?>',
	onShow: function (colpkr) {
		$j_6(colpkr).fadeIn(500);
		return false;
	},
	onHide: function (colpkr) {
		$j_6(colpkr).fadeOut(500);
		return false;
	},
	onChange: function (hsb, hex, rgb) {
                $j_6('#color_fondo_2').val('#'+hex);
		$j_6('#color_fondo_2').css('backgroundColor', '#' + hex);
	}
});

</script>
<center>
<div id="resultConfig"></div>

 
<form action="altaConfig.php" name="frmConfig" id="frmConfig">
<table width="600px" style="margin-left: 8px">
    <tr>
        <td class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" onClick="collapseMenuLeft('config_login');">
            Login
        </td>
    </tr>
    <tr>
        <td height="0px">
            <div id="config_login_show">
					<table valign="top" class="ui-accordion-header ui-helper-reset ui-state-default ui-accordion-header-active ui-state-active ui-corner-top ui-accordion-icons" width="100%">
						<tr>
                                                    <td valign="top">
                                                        <table>
                                                        <tr>
                                                            <td width="15" valign="top">
                                                            &nbsp;Seleccione la imagen del login<br/>
                                                            <select name="login_img" id="login_img">
																<?for($i=0; $i < count($arrImg); $i++){?>
																	<option value="<?=$arrImg[$i]?>" <?if($_SESSION['login_img'] == $arrImg[$i]){?>selected<?}?>><?=$arrImg[$i]?></option>
																<?}?>
                                                            </select>
                                                            <br/>
                                                            <img id="tema_login_img" src="Imagenes/imgLogin/<?=$_SESSION['login_img']?>" style="border: 1px solid"/>
                                                            </td>
                                                        </tr>
                                                        </table>
                                                    </td>
                                                </tr>
                                        </table>
    
            </div>
            
        </td>
    </tr>
    
    
    <tr>
        <td class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" onClick="collapseMenuLeft('config_general');">
            Tema General
        </td>
    </tr>
    <tr>
        <td height="0px">
            <div id="config_general_show">
					<table valign="top" class="ui-accordion-header ui-helper-reset ui-state-default ui-accordion-header-active ui-state-active ui-corner-top ui-accordion-icons" width="100%">
						<tr>
                                                    <td valign="top">
                                                        <table>
                                                        <tr>
                                                            <td width="15" valign="top">
                                                            &nbsp;Seleccione el tema general de la aplicacion<br/>
                                                            <select name="tema_general" id="tema_general">
                                                                <option value="redmond" <?if($_SESSION['tema_general'] == 'redmond'){?>selected<?}?>>Redmond</option>
                                                                <option value="pepper-grinder" <?if($_SESSION['tema_general'] == 'pepper-grinder'){?>selected<?}?>>Pepper Grinder</option>
                                                                <!--<option value="overcast" <?if($_SESSION['tema_general'] == 'overcast'){?>selected<?}?>>Overcast</option>-->
                                                                <option value="flick" <?if($_SESSION['tema_general'] == 'flick'){?>selected<?}?>>Flick</option>
                                                                <option value="dark-hive" <?if($_SESSION['tema_general'] == 'dark-hive'){?>selected<?}?>>Dark Hive</option>
                                                            </select>
                                                            <br/>
                                                            <img src="Imagenes/<?=$_SESSION['tema_general']?>.png" style="border: 1px solid" id="img_tema_general"/>
                                                            </td>
                                                        </tr>
                                                        </table>
                                                    </td>
                                                </tr>
                                        </table>
    
            </div>
            
        </td>
    </tr>
    
    <tr>
        <td class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" onClick="collapseMenuLeft('fondo_img');">
            Fondo de Login
        </td>
    </tr>
    <tr>
        <td height="0px">
            <div id="fondo_img_show">
					<table valign="top" class="ui-accordion-header ui-helper-reset ui-state-default ui-accordion-header-active ui-state-active ui-corner-top ui-accordion-icons" width="100%">
						<tr>
                                                    <td valign="top">
                                                        <table>
                                                        <tr>
                                                            <td width="300" valign="top">
                                                            &nbsp;Color de fondo
                                                                <input readOnly="true" type="text" size="10" style="background-color: <?=$_SESSION['color_fondo']?>" id="color_fondo" name="color_fondo" value="<?=$_SESSION['color_fondo']?>"/>
                                                                <br/>
                                                                &nbsp;Imagen de Fondo <input type="checkbox" value="1" name="fondo_img_check" <?if($fondo_img_check==1){?>checked<?}?> /><br/>
                                                                &nbsp;<img style="cursor: pointer" src="Imagenes/imgFondo/<?=$_SESSION['fondo_img']?>" width="300" height="75" id="fondo_img_img" name="fondo_img_img"/>
                                                                <input type="hidden" name="fondo_img" id="fondo_img" value="<?=$_SESSION['fondo_img']?>"/>
                                                                <div id="fondos_img"></div>
                                                            </td>
                                                        </tr>
                                                        </table>
                                                    </td>
                                                </tr>
                                        </table>
    
            </div>
            
        </td>
    </tr>
	
	<tr>
        <td class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" onClick="collapseMenuLeft('fondo_img_2');">
            Fondo General
        </td>
    </tr>
    <tr>
        <td height="0px">
            <div id="fondo_img_2_show">
					<table valign="top" class="ui-accordion-header ui-helper-reset ui-state-default ui-accordion-header-active ui-state-active ui-corner-top ui-accordion-icons" width="100%">
						<tr>
                                                    <td valign="top">
                                                        <table>
                                                        <tr>
                                                            <td width="300" valign="top">
                                                            &nbsp;Color de fondo
                                                                <input readOnly="true" type="text" size="10" style="background-color: <?=$_SESSION['color_fondo_2']?>" id="color_fondo_2" name="color_fondo_2" value="<?=$_SESSION['color_fondo_2']?>"/>
                                                                <br/>
                                                                &nbsp;Imagen de Fondo <input type="checkbox" value="1" name="fondo_img_2_check" <?if($fondo_img_2_check==1){?>checked<?}?> /><br/>
                                                                &nbsp;<img style="cursor: pointer" src="Imagenes/imgFondo/<?=$_SESSION['fondo_img_2']?>" width="300" height="75" id="fondo_img_img_2" name="fondo_img_img_2"/>
                                                                <input type="hidden" name="fondo_img_2" id="fondo_img_2" value="<?=$_SESSION['fondo_img_2']?>"/>
                                                                <div id="fondos_img_2"></div>
                                                            </td>
                                                        </tr>
                                                        </table>
                                                    </td>
                                                </tr>
                                        </table>
    
            </div>
            
        </td>
    </tr>
	
	<tr>
        <td class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" onClick="collapseMenuLeft('fondo_img_3');">
            Fondo Banner Superior
        </td>
    </tr>
    <tr>
        <td height="0px">
            <div id="fondo_img_3_show">
					<table valign="top" class="ui-accordion-header ui-helper-reset ui-state-default ui-accordion-header-active ui-state-active ui-corner-top ui-accordion-icons" width="100%">
						<tr>
                                                    <td valign="top">
                                                        <table>
                                                        <tr>
                                                            <td width="300" valign="top">
                                                            &nbsp;Movible: <input type="checkbox" value="1" name="slide_superior_check" <?if($_SESSION['slide_superior_check']==1){?>checked<?}?> />
																Alineacion: 
																<select name="alineacion_slide_superior">
																	<option value="left" <?if($_SESSION['alineacion_slide_superior'] == "left"){?>selected<?}?>>Izquierda</option>
																	<option value="right" <?if($_SESSION['alineacion_slide_superior'] == "right"){?>selected<?}?>>Derecha</option>
																	<option value="center" <?if($_SESSION['alineacion_slide_superior'] == "center"){?>selected<?}?>>Centro</option>
																</select>
                                                                <br/>
                                                                &nbsp;Imagen Fija: <br/>
                                                                &nbsp;<img style="cursor: pointer" src="Imagenes/imgBannerS/<?=$_SESSION['fondo_img_3']?>" width="300" height="75" id="fondo_img_img_3" name="fondo_img_img_3"/>
                                                                <input type="hidden" name="fondo_img_3" id="fondo_img_3" value="<?=$_SESSION['fondo_img_3']?>"/>
                                                                <div id="fondos_img_3"></div>
                                                            </td>
                                                        </tr>
                                                        </table>
                                                    </td>
                                                </tr>
                                        </table>
    
            </div>
        </td>
    </tr>
	
	<tr>
        <td class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" onClick="collapseMenuLeft('fondo_img_4');">
            Fondo Banner Centro
        </td>
    </tr>
    <tr>
        <td height="0px">
            <div id="fondo_img_4_show">
					<table valign="top" class="ui-accordion-header ui-helper-reset ui-state-default ui-accordion-header-active ui-state-active ui-corner-top ui-accordion-icons" width="100%">
						<tr>
                                                    <td valign="top">
                                                        <table>
                                                        <tr>
                                                            <td width="300" valign="top">
                                                            &nbsp;Movible <input type="checkbox" value="1" name="slide_centro_check" <?if($_SESSION['slide_centro_check']==1){?>checked<?}?> />
															&nbsp;Sin banner <input type="checkbox" value="1" name="banner_centro_check" <?if($_SESSION['banner_centro_check']==1){?>checked<?}?> />
                                                                <br/>
                                                                &nbsp;Imagen Fija <br/>
                                                                &nbsp;<img style="cursor: pointer" src="Imagenes/imgBannerC/<?=$_SESSION['fondo_img_4']?>" width="300" height="75" id="fondo_img_img_4" name="fondo_img_img_4"/>
                                                                <input type="hidden" name="fondo_img_4" id="fondo_img_4" value="<?=$_SESSION['fondo_img_4']?>"/>
                                                                <div id="fondos_img_4"></div>
                                                            </td>
                                                        </tr>
                                                        </table>
                                                    </td>
                                                </tr>
                                        </table>
    
            </div>
        </td>
    </tr>
    
    <tr><td><input type="submit" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" value="Guardar"></td></tr>
</table>
</form>
</center>