<?php

/**
* @version 2.8.14
* @package Joomla 2.5
* @subpackage DT Register
* @copyright Copyright (C) 2006 DTH Development
* @copyright contact dthdev@dthdevelopment.com
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/

    jimport('joomla.html.pane');

	jimport('joomla.html.select');

	//$pane =& JPane::getInstance('tabs');

	$editor =& JFactory::getEditor();

    //$editor->_loadEditor();
   $document =& JFactory::getDocument();
   $document->addScript( JURI::root(true).'/components/com_dtregister/assets/js/dt_jquery.js');
   $document->addStyleSheet(JURI::root(true).'/components/com_dtregister/assets/css/south-street/jquery-ui.css');
   $document->addScript( JURI::root(true).'/components/com_dtregister/assets/js/addmore.js');
?>

<form action="index.php" method="post" name="adminForm" autocomplete="off">

  <table width="100%">

 			<tr>

 				<td width="100%">
                    <div id="tabs">
                        <ul>
                            <li>
                            <a href="#general">
							<?php echo JText::_( 'DT_REGISTER_GENERAL' ); ?></a></li>
                            
                            <li>
                            <a href="#event_listing">
							<?php echo JText::_( 'DT_EVENT_LISTING' ); ?></a></li>
                            <li>
                            <a href="#calendar">
							<?php echo JText::_( 'DT_CALENDAR' ); ?></a></li>
                            <li><a href="#dtregister_message"><?php echo JText::_( 'DT_REGISTER_EMAIL' );  ?></a></li>
                            
                            <li><a href="#dtregister_email"><?php echo JText::_( 'DT_EMAILS' ); ?></a></li>
                            <li><a href="#dtregister_registrant"><?php echo JText::_( 'DT_REGISTER_REGISTRANTS' ); ?></a></li>
                            <li><a href="#dtregister_userpanel"><?php echo JText::_( 'DT_USER_PANEL' );  ?></a></li>
                            
                            <li>
                            <a href="#fieldmap">
							<?php echo JText::_( 'DT_PROFILE_SYNC' ); ?></a></li>
                            
                            <li>
                            <a href="#barcode">
							<?php echo JText::_( 'DT_BARCODE' ); ?></a></li>
							
							<li>
                            <a href="#frontend_mgmt">
							<?php echo JText::_( 'DT_FRONTEND_MGMT' ); ?></a></li>
                            
                        </ul>
                        <div id="general" class="dtTabs">
                        </div>
                        <div id="event_listing" class="dtTabs">
                        </div>
                        <div id="calendar" class="dtTabs">
                        </div>
                        <div id="dtregister_message">
                             <?php
 include(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_dtregister'.DS.'views'.DS.'config'.DS.'tmpl'.DS.'tab.message.php');

		 ?>
                        </div>
                        <div id="dtregister_email">
                             <?php
 include(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_dtregister'.DS.'views'.DS.'config'.DS.'tmpl'.DS.'tab.email.php');

		 ?>
                        </div>
                        <div id="dtregister_registrant">
                             <?php
 include(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_dtregister'.DS.'views'.DS.'config'.DS.'tmpl'.DS.'tab.registrant.php');

		 ?>
                        </div>
                        <div id="dtregister_userpanel">
                             <?php
 include(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_dtregister'.DS.'views'.DS.'config'.DS.'tmpl'.DS.'tab.userpanel.php');

		 ?>
                        </div>
                        
                        <div id="fieldmap" class="dtTabs">
                        </div>
                        <div id="barcode" class="dtTabs">
                        </div>

						<div id="frontend_mgmt" class="dtTabs">
                        </div>

                    </div>

	 				</td>

	 			</tr>

	 		</table>

  <input name="task" type="hidden" value="edit" />

  <input type="hidden" name="controller" value="config" />

  <input name="option" type="hidden" value="<?php echo DTR_COM_COMPONENT; ?>" />

</form>

 <?php  

           $document =& JFactory::getDocument();

		   JHTML::script('dt_jquery.js','components/com_dtregister/assets/js/');

    ?>

   <script type="text/javascript">

      DTjQuery(function(){
		   DTjQuery(".colorbox").live('click',function(e){		

		e.preventDefault();

		var horizontalPadding = 30;

		var verticalPadding = 30;

		DTjQuery('<iframe id="externalSite" class="externalSite" src="'+DTjQuery(this).attr('href')+'" />').dialog({

			title:  '<?php echo JText::_('DT_TAG_DETAILS')?>',

			autoOpen: true,

			width: 800,

			height: 500,

			modal: true,

			resizable: true,

			autoResize: true,

			overlay: {

				opacity: 0.5,

				background: "black"

			}

		}).width(800 - horizontalPadding).height(500 - verticalPadding);

			     });
		  DTjQuery.ajaxSetup({
			
			 sync: true
		  
		   });

        var config_tabs = DTjQuery("#tabs").tabs();
		
		
		  DTjQuery(document.adminForm).validate({
                        success: function(label) {
                            label.addClass("success");
                        },
						invalidHandler:function(event, validator) {
							                 DTjQuery("#tabs").find(".dt_tab_error").removeClass("dt_tab_error")
						                     // console.log(validator.numberOfInvalids());
											  //console.log(validator.invalidElements());
											  DTjQuery.each(validator.invalidElements() , function(k,v){
												  
												 var tabpanel = DTjQuery(v).closest(".ui-tabs-panel");
												 //console.log(tabpanel[0]);
												 var index = DTjQuery(".ui-tabs-panel").index(tabpanel[0]) ;
												// console.log(index);
										         var tab = DTjQuery("li.ui-state-default").get(index).addClass('dt_tab_error');
												 //console.log(tab);
												 //DTjQery(tab).addClass('dt_tab_error');
												 
												 
												  
											  });
											
											}
              
                });
		 
         var nohtml;

	     DTjQuery('.dtTabs').each(function(){

			   nohtml = '&no_html=1';
             DTjQuery(this).load("index.php?option=com_dtregister&controller=config"+nohtml+"&task=loadtab&type="+DTjQuery(this).attr('id'));

		 });

	  });

     Joomla.submitbutton = function (pressbutton){
    		
			DTjQuery('.taberror').removeClass('taberror');
			
			if(pressbutton == "cancel"){
				submitform(pressbutton);
				
				return false;
			}
			
			if(DTjQuery(document.adminForm).valid()){
				
				submitform(pressbutton);
				
			}else{
			  
			  var index = DTjQuery('.error:input').parents('#tabs').children('div').index(DTjQuery('.error:input').parents('.ui-tabs-panel')[0]);
			  index++;
			  
			  DTjQuery('#tabs li:nth-child('+index+')').addClass('taberror');
			  DTjQuery('#tabs li:nth-child('+index+')').css({'background':'#ff0000'});
			  
			}	
			  
			return false;
		
		}

	  function loadeditor(){

		 <?php

		// include(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_dtregister'.DS.'view'.DS.'config'.DS.'tab.loadeditor.php');

		 ?>

	  }
     
   </script>
