<?php

defined('_JEXEC') or die;
if(!defined('DS')){
    define('DS',DIRECTORY_SEPARATOR);
}

require (JPATH_ROOT.DS.'components' .DS.'com_wishlogue'. DS . 'layouts/wishlogue.php');


JHtml::_('behavior.framework', true);
//create instance for the class
$thumb = new thumb();
$fthumb = $thumb->fthumb();

//for show request approval
$showRequest= $thumb->showRequest();

if(count($fthumb)!=0){
 if($fthumb[0]->link_type=='youtube' || $fthumb[0]->link_type=='vimeo')
    {     
    $srcPath = $fthumb[0]->pin_image;
    }
    else{
        $srcPath = JURI::base()."images/wishlogue/wish_original/" . $fthumb[0]->pin_image;
    }
}
$pinId = JRequest::getVar('pinid');
$app= JFactory::getApplication();
$doc= JFactory::getDocument();
$templateparams	= $app->getTemplate(true)->params;
$config=JFactory::getConfig();
$site_name = $config->get('sitename');
$logo= $this->params->get('logo');

$facebook_url = $templateparams->get('facebook_url');
$twitter_url = $templateparams->get('twitter_url');
$googleplus_url = $templateparams->get('googleplus_url');

?>


	<?php echo '<!DOCTYPE html>'; ?>

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>" >
    <head>
         <script>
    var loading_next_pins="<?php echo JTEXT::_('COM_WISHLOGUE_HEADER_LOADING_NEXT_PINS'); ?>";
    </script>
        <?php if(count($fthumb)!=0){ ?>
                <link rel="image_src" href="<?php echo $srcPath; ?>"/>
    <link rel="canonical" href="<?php echo JURI::base() .JRoute::_('index.php?option=com_wishlogue&view=wish&pinid='.$pinId);?>"/>
         <meta property="fb:app_id" content="<?php echo $showRequest;?>"/>
    <meta property="og:site_name" content="<?php echo $site_name; ?>"/>
    <meta property="og:type" content="website"/>
    <meta property="og:url" content="<?php echo JURI::base() .JRoute::_('index.php?option=com_wishlogue&view=wish&pinid='.$pinId);?>"/>
    <meta property="og:title" content="<?php echo $fthumb[0]->pin_description; ?>"/>
    <meta property="og:description" content="<?php echo $fthumb[0]->pin_description; ?>"/>
    <meta property="og:image" content="<?php echo $srcPath; ?>"/>
         <?php } ?>
            <jdoc:include type="head" />
            <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0">
            <meta name="viewport" content="width=device-width, initial-scale=1.0">
            <link href='http://fonts.googleapis.com/css?family=Oswald' rel='stylesheet' type='text/css'/>
            
                <link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/wishlogue/css/media-queries.css" type="text/css" />
            <!--[if IE]>
                <link rel="stylesheet" type="text/css" href="<?php echo $this->baseurl ?>/templates/wishlogue/css/ie.css" />
            <!--<![endif]-->
         <?php
            $headerstuff=$this->getHeadData();
            reset($headerstuff['scripts']);
            foreach($headerstuff['scripts'] as $key=>$value){ 

            if (strstr($key,"/media/system/js/mootools-core.js") || strstr($key,"/media/system/js/mootools-more.js") )
            {
            unset($headerstuff['scripts'][$key]);
            }        }
            $this->setHeadData($headerstuff);
        ?>   
        <?php
            $files = JHtml::_('stylesheet','templates/wishlogue/css/template.css',null,false,true);
            if ($files):
            if (!is_array($files)):
            $files = array($files);
            endif;
            foreach($files as $file):
        ?>
            <link rel="stylesheet" href="<?php echo $file;?>" type="text/css" />
            <link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/wishlogue/css/reset.css" type="text/css" />
        <?php
            endforeach;
            endif;
        
            $document = JFactory::getDocument();
            $document->addScript('https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js');
            $document->addScript( 'templates/wishlogue/js/socialpinboard.js' );
            $document->addScript( 'templates/wishlogue/js/scrolldown.js' );

?>

        <script type="text/javascript">var scr = jQuery.noConflict(); </script>
    </head>

    <?php
    $user = JFactory::getUser();
    if($user->id){
        $style = '.banner_box {display: none; height: 0;}';
$document->addStyleDeclaration($style);
        }else{
            $style = '#wrapper {margin: 25px auto !important;}';
$document->addStyleDeclaration($style);
        }
    ?>

    <?php 
flush();
?>

	<body id="CategoriesBarPage">
            <?php  $view = JRequest::getVar('view');
            if($view != 'people'  &&  $view != 'inviterequest'  && $view != 'userfollow'){
//                if($view != 'people' && $view != 'inviterequest') {
            ?>
        <div id="header_container" class="clearfix">
            <div id="Header" class="">

               <ul id="solcial_links">
                   <li><a href="<?php echo $facebook_url; ?>" target="_blank" class="fbicon" title="FaceBook"></a></li>
                   <li><a href="<?php echo $twitter_url; ?>" target="_blank" class="tweeticon" title="Twitter"></a></li>
                   <li><a href="<?php echo $googleplus_url; ?>" target="_blank" class="gplus-icon" title="Google+"></a></li>
                   <li><a class="rssicon my_modal_open" title="RSS"></a></li>
               </ul>

			   <div id="my_modal" class="well" style="display:none;margin:1em;">
					<a href="#" class="my_modal_close"></a>
                                        <p>
                                            <input type="radio" id="optt1" name="optt" value="top10" checked>
                                            <span onclick="document.getElementById('optt1').checked = 'true';">Top 10 Wishes</span>
					</p>
                                        <p>
                                            <input type="radio" id="optt2" name="optt" value="wwya">
                                            <span onclick="document.getElementById('optt2').checked = 'true';">Articles from We Wish You A… page</span>
                                        </p>
					<input type="button" onclick="rssfeed();" value="Show RSS Feed" >
                           </div>

                <div class="logoheader">
                        <h1 id="logo">
                            <a href="<?php echo JURI::base(); ?>" >
                            <?php if ($logo != null ): ?>
                                <img src="<?php echo $this->baseurl ?>/<?php echo htmlspecialchars($logo); ?>" alt="<?php echo htmlspecialchars($templateparams->get('sitetitle'));?>" />
                            <?php else: ?>
                            <img src="<?php echo JURI::base(); ?>/templates/wishlogue/images/logo.png" alt="" />
                            <?php endif; ?>
                            </a>
                        </h1>
                </div>
                
                <!-- <div class="logo_search_mobile">
                    <div class="logoheader">
                        <h1 id="mobile_logo"> <a href="<?php echo JURI::base(); ?>" >
                            <?php if ($logo != null ): ?>
                                <img src="<?php echo $this->baseurl ?>/<?php echo htmlspecialchars($logo); ?>" alt="<?php echo htmlspecialchars($templateparams->get('sitetitle'));?>" />
                            <?php else: ?>
                            <img src="<?php echo JURI::base(); ?>/templates/wishlogue/images/logo.png" alt="" />
                            <?php endif; ?>
                             </a>
                        </h1>
                    </div>
                    <div id="mobile_Search">
                            <jdoc:include type="modules" name="wishlogue_search" />
                    </div>
                </div> -->
                <div id="header_top_right">
                    <jdoc:include type="modules" name="wishlogue_menu" />
                </div>
                
            </div>
        </div>


        <div id="CategoriesBar_content" class="clearfix">
            <div class="innercategories">
            <jdoc:include type="modules" name="wishlogue_header" />
            
            <div id="Search">
                <jdoc:include type="modules" name="wishlogue_search" />
            </div>
            </div>
        </div>
        <?php } ?>
<!--        <div id="content_banner">
            <jdoc:include type="modules" name="wishlogue_banner" />
        </div>-->
        <div id="content_color">
            
        </div>
           <div id="wrapper" >
                <div id="ColumnContainer" >
                   <div id="login_error_msg">
                       <jdoc:include type="message" />
                   </div>

            <!-- rgs. -->
			<?php
				if( JRequest::getVar( 'option' ) == 'com_wishlogue' && JRequest::getVar( 'view' ) != 'wwya'  )
				{
					// if( JRequest::getVar( 'view' ) == 'grantedwishes' || JRequest::getVar( 'view' ) == 'wishdisplay' || JRequest::getVar( 'view' ) == 'sectiondisplay' || JRequest::getVar( 'view' ) == 'search' || JRequest::getVar( 'view' ) == 'popular' || JRequest::getVar( 'view' ) == 'likes' || JRequest::getVar( 'view' ) == 'home' )
					// if( JRequest::getVar( 'view' ) == 'popular' || JRequest::getVar( 'view' ) == 'home' )
					$category_name = rawurldecode(JRequest::getVar('category'));
					$category_id = JRequest::getInt('cat_id', '0', 'default');

					if( $category_name == '' && $category_id == '0' && JRequest::getVar( 'wishes' ) != 'topten' && JRequest::getVar( 'wishers' ) != 'youfollow' && JRequest::getVar( 'view' ) == 'home' )
					{
			?>
						<input type='hidden' id='minushun'>
                                                     <div class="maincontent clearfix">
						<div id="wishlogue_left_wishes">
							<jdoc:include type="modules" name="wishlogue_left_wishes" />
						</div> 
                        <div class="wishlogue_center_pins">
			<?php
					}
				}
			?>
			<!-- rgs.. -->

         
                                
                <?php $pageoption = JRequest::getVar( 'option');
                        if($pageoption !='com_wishlogue'){ ?>
                            <div class="template_wrapper">
                                <jdoc:include type="component" />
                            </div>
                       <?php }else{ ?>
                            <jdoc:include type="component" />
                        <?php } ?>
            
             
            <?php
				if( JRequest::getVar( 'option' ) == 'com_wishlogue' && JRequest::getVar( 'view' ) != 'wwya'  )
				{
					if( $category_name == '' && $category_id == '0' && JRequest::getVar( 'wishes' ) != 'topten' && JRequest::getVar( 'wishers' ) != 'youfollow' && JRequest::getVar( 'view' ) == 'home' )
					{
			?> 
                        </div>
						<div id="wishlogue_right_wishes">
							<jdoc:include type="modules" name="wishlogue_right_wishes" />
						</div> 
                          </div>
			<?php
					}
				}
			?>
          
               
                </div>
               <!-- #ColumnContainer -->  
           </div><!-- #wrapper -->
            <!-- <input type='hidden' value='top' id='whereScroll'>
            <input type='hidden' value='enable' id='EnablewhereScroll'> -->

			<script src="components/com_wishlogue/javascript/jquery.popupoverlay.js"></script>
			<script type="text/javascript">
				function rssfeed()
				{
					var radios = document.getElementsByName('optt');
					if (radios[0].checked) {
						val = radios[0].value;
					}
					else if (radios[1].checked) {
						val = radios[1].value;
					}

					if (val == 'top10') {
						var url = "<?php echo JRoute::_('index.php?option=com_wishlogue&view=ajaxcontrol&tmpl=component&task=getWishesRSS'); ?>";
						window.open(url, '_blank');
					}
					else if (val == 'wwya') {
						var url = "<?php echo JRoute::_('index.php?option=com_wishlogue&view=ajaxcontrol&tmpl=component&task=getArticlesRSS'); ?>";
						window.open(url, '_blank');		
					}
					else {
						alert("Please select a option..");
					}
				}
			</script>
			<script>
				jQuery(document).ready(function() {
					jQuery('.my_modal_open').click(function() {
						jQuery('#my_modal').popup({
							'autoopen': true
						});
					});
				});
			</script>
</body>
</html>
