<?php

/*

  FILE STRUCTURE:

- LAYOUT BUILDER CLASS

*/

/* LAYOUT BUILDER CLASS (writes the layout.css file) */
/*------------------------------------------------------------------*/

class Bizz_CSS {	
	function build() {
		$this->layout();
	}
		
	function layout() {
		global $optd;
	    $saved_design = get_option('bizzthemes_design');
		if (!empty($saved_design)){
		    $optd = $saved_design;
		}
		$font_stacks = bizz_get_fonts();
		$font_stacks = bizz_get_fonts();

		// Build CSS output.
$this->css .= '/*
File:			layout.css
Description:	Custom layout styles for Your Theme
Author:         You ;)

        IMPORTANT NOTE:
	
	    If you wish to make custom changes to your theme, DO NOT EDIT THIS FILE. 
	    Instead, use the Theme Design Options in your theme administration to 
	    define custom layout styles or EDIT CUSTOM.CSS file also included in this directory.
*/';
	foreach ( (array) $optd as $option => $value ) {
		$this->css .= ($value['css'] != '' && $option != 'themeid') ? $value['css'].'{ ' : '';
		foreach ( (array) $value as $css => $selector ) {
		    if($css != 'css' && $value['css'] != '' && $selector != ''){
			    $this->css .= $css;
				$this->css .= ':';
				$this->css .= ($css == 'background-image') ? 'url("' : '';
				$this->css .= ($css == 'font-family') ? $font_stacks[$selector]['family'] : $selector;
				$this->css .= ($css == 'background-image') ? '")' : '';
				$this->css .= '; ';
			}
		}
		$this->css .= ($value['css'] != '' && $option != 'themeid') ? ' }'.'' : '';
		$this->css .= '
';
	}

        // end css output

	} // end layout (function)
		
} // end Bizz_CSS (class)

function bizz_generate_css() {
	if (is_writable(BIZZ_LAYOUT_CSS)) {
		$bizz_css = new Bizz_CSS;
		$bizz_css->build();
		$lid = @fopen(BIZZ_LAYOUT_CSS, 'w');
		@fwrite($lid, $bizz_css->css);
		@fclose($lid);
	}
}