tinyMCE.init({
	// General options
	mode : "exact",
	elements : "tiny1,tiny2,tiny3",
	theme : "advanced",
	plugins : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordcount,advlist,autosave",
	
	// Theme options
	theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
	theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
	theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
	theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak,restoredraft",
	theme_advanced_toolbar_location : "top",
	theme_advanced_toolbar_align : "left",
	theme_advanced_statusbar_location : "bottom",
	theme_advanced_resizing : true,
	content_css : "<?php echo $this->baseurl ?>/templates/<?php echo $this->template;?>/css/style.css",
	theme_advanced_font_sizes: "10px,12px,13px,14px,16px,18px,20px",
	font_size_style_values : "10px,12px,13px,14px,16px,18px,20px",
	
	// Drop lists for link/image/media/template dialogs
	template_external_list_url : "lists/template_list.js",
	external_link_list_url : "lists/link_list.js",
	external_image_list_url : "lists/image_list.js",
	media_external_list_url : "lists/media_list.js",
	
	// Style formats
	style_formats : [
		{title : 'Bold text', inline : 'b'},
		{title : 'Red text', inline : 'span', styles : {color : '#ff0000'}},
		{title : 'Red header', block : 'h1', styles : {color : '#ff0000'}},
		{title : 'Example 1', inline : 'span', classes : 'example1'},
		{title : 'Example 2', inline : 'span', classes : 'example2'},
		{title : 'Table styles'},
		{title : 'Table row 1', selector : 'tr', classes : 'tablerow1'}
	],
	
	// Replace values for the template plugin
	template_replace_values : {
		username : "Some User",
		staffid : "991234"
	}
	});
//Uploader
jQuery.noConflict();
(function($) { 
	$(function() {
	var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
	$('#timeDownload').html($('#timeDat').html());
	$("a.thumbnail").fancybox({
		'titleShow'     : false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'easingIn'      : 'easeOutBack',
		'easingOut'     : 'easeInBack'
	});
	$('#save').click(function(){
		$('#clubForm').submit();
	});
	$('#close').click(function(){
		window.location.href = 'index.php?option=com_clubsmanagement&task=manage';
	});
	$('#24hrs').click(function(){
		for(i=0; i<7; i++){
			if ($(this).attr('checked') == true){
				$('#hours').find('input[type=text]:eq('+i+')').val('24 hours');
			}else{
				$('#hours').find('input[type=text]:eq('+i+')').val('');
			}
		}
	});
	var dockOptions = { align: 'middle', size: 50, labels: 'tl', distance: 110, fadeIn: 500, coefficient: 1 };
	$('#menu').jqDock(dockOptions);
	//Enq Form Validation
	$('#enqForm').submit(function(){
		var error = 0;
		var fname = $(this).find('input[type=text]').eq(0);
		var sname = $(this).find('input[type=text]').eq(1);
		var email = $(this).find('input[type=text]').eq(2);
		var number = $(this).find('input[type=text]').eq(3);
		if(fname.val() == null || fname.val() == ''){
			error = 1;
			fname.css({'background': '#fff4f4', 'border': '1px solid #ff5858'});
		}else{
			fname.css({'background': '#FFF', 'border': '1px solid #CCC'});
		}
		if(sname.val() == null || sname.val() == ''){
			error = 1;
			sname.css({'background': '#fff4f4', 'border': '1px solid #ff5858'});
		}else{
			sname.css({'background': '#FFF', 'border': '1px solid #CCC'});
		}
		if(email.val() == null || email.val() == ''){
			error = 1;
			email.css({'background': '#fff4f4', 'border': '1px solid #ff5858'});
		}else if(!pattern.test(email.val())){
			error = 1;
			email.css({'background': '#fff4f4', 'border': '1px solid #ff5858'});
		}else{
			email.css({'background': '#FFF', 'border': '1px solid #CCC'});
		}
		if(number.val() == null || number.val() == ''){
			error = 1;
			number.css({'background': '#fff4f4', 'border': '1px solid #ff5858'});
		}else if (isNaN(number.val())){
			error = 1;
			number.css({'background': '#fff4f4', 'border': '1px solid #ff5858'});
		}else{
			number.css({'background': '#FFF', 'border': '1px solid #CCC'});
		}
		if (error == 1){
			return false;
		}
	});
	//Enq Form Validation
	$('#enqFormE').submit(function(){
		var error = 0;
		var fname = $(this).find('input[type=text]').eq(0);
		var sname = $(this).find('input[type=text]').eq(1);
		var email = $(this).find('input[type=text]').eq(2);
		var number = $(this).find('input[type=text]').eq(3);
		if(fname.val() == null || fname.val() == ''){
			error = 1;
			fname.css({'background': '#fff4f4', 'border': '1px solid #ff5858'});
		}else{
			fname.css({'background': '#FFF', 'border': '1px solid #CCC'});
		}
		if(sname.val() == null || sname.val() == ''){
			error = 1;
			sname.css({'background': '#fff4f4', 'border': '1px solid #ff5858'});
		}else{
			sname.css({'background': '#FFF', 'border': '1px solid #CCC'});
		}
		if(email.val() == null || email.val() == ''){
			error = 1;
			email.css({'background': '#fff4f4', 'border': '1px solid #ff5858'});
		}else if(!pattern.test(email.val())){
			error = 1;
			email.css({'background': '#fff4f4', 'border': '1px solid #ff5858'});
		}else{
			email.css({'background': '#FFF', 'border': '1px solid #CCC'});
		}
		if(number.val() == null || number.val() == ''){
			error = 1;
			number.css({'background': '#fff4f4', 'border': '1px solid #ff5858'});
		}else if (isNaN(number.val())){
			error = 1;
			number.css({'background': '#fff4f4', 'border': '1px solid #ff5858'});
		}else{
			number.css({'background': '#FFF', 'border': '1px solid #CCC'});
		}
		if (error == 1){
			return false;
		}
	});
	//Enq Form Validation - 1
	$('#enqFormF').submit(function(){
		var error = 0;
		var fname = $(this).find('input[type=text]').eq(0);
		var sname = $(this).find('input[type=text]').eq(1);
		var email = $(this).find('input[type=text]').eq(4);
		var number = $(this).find('input[type=text]').eq(2);
		if(fname.val() == null || fname.val() == ''){
			error = 1;
			fname.css({'background': '#fff4f4', 'border': '1px solid #ff5858'});
		}else{
			fname.css({'background': '#FFF', 'border': '1px solid #CCC'});
		}
		if(sname.val() == null || sname.val() == ''){
			error = 1;
			sname.css({'background': '#fff4f4', 'border': '1px solid #ff5858'});
		}else{
			sname.css({'background': '#FFF', 'border': '1px solid #CCC'});
		}
		if(email.val() == null || email.val() == ''){
			error = 1;
			email.css({'background': '#fff4f4', 'border': '1px solid #ff5858'});
		}else if(!pattern.test(email.val())){
			error = 1;
			email.css({'background': '#fff4f4', 'border': '1px solid #ff5858'});
		}else{
			email.css({'background': '#FFF', 'border': '1px solid #CCC'});
		}
		if(number.val() == null || number.val() == ''){
			error = 1;
			number.css({'background': '#fff4f4', 'border': '1px solid #ff5858'});
		}else if (isNaN(number.val())){
			error = 1;
			number.css({'background': '#fff4f4', 'border': '1px solid #ff5858'});
		}else{
			number.css({'background': '#FFF', 'border': '1px solid #CCC'});
		}
		if (error == 1){
			return false;
		}
	});
	$('#franchisee-form').submit(function(){
		var error = 0;
		$(this).find('input[type=text]:eq(0), input[type=text]:eq(1), input[type=text]:eq(2), input[type=text]:eq(3), input[type=text]:eq(4), input[type=text]:eq(7), input[type=text]:eq(8), input[type=text]:eq(9), input[type=text]:eq(10),input[type=text]:eq(11), select:first,').each(function(){
			if ($(this).val() == ''){
				error = 1;
				$(this).addClass('ferror');
			}else{
				$(this).removeClass('ferror');
			}			
		});
		/*var questions = ['bankruptcy', 'judgements','pending_action','misdemeanour'];
		for(var i = 0; i < questions.length; i++) {alert($('input[name=' + questions[i] + ']:checked').length)
			if ($('input[name=' + questions[i] + ']:checked').length == 0) {
					error = 1;
					$('#span-' + questions[i]).addClass('Rerror');
			}else{
				$('#span-' + questions[i]).removeClass('Rerror');
			}			
		}*/
		if (error == 1){
			return false;
		}
	});
	
	
	$('#franchisee-finance-form').submit(function(){
		var error = 0;
		$(this).find('input[type=text]:eq(0)').each(function(){
			if ($(this).val() == ''){
				error = 1;
				$(this).addClass('ferror');
			}else{
				$(this).removeClass('ferror');
			}			
		});
		
		if (error == 1){
			return false;
		}
	});
	//Tabs
	var TopTabs = new Array('allclubs|tabDiv-1', 'hltclubs|tabDiv-2', '247clubs|tabDiv-3');
	jQuery.fn.extend({
		Tabs : function(array, options){
			var nCls = options.norCls;
			var sCls = options.selCls;
			for(i=0; i<TopTabs.length; i++){
				var tabArr = TopTabs[i].split('|');
				if (i != 0){
					$('#'+tabArr[0]).attr('class', nCls);
					$('#'+tabArr[1]).hide();
				}else{
					$('#'+tabArr[0]).attr('class', sCls);
					$('#'+tabArr[1]).fadeIn();
				}
			}
			$(this).click(function(){
				for(i=0; i<TopTabs.length; i++){
					var tabArr = TopTabs[i].split('|');
					if ($(this).attr('id') == tabArr[0]){
						$('#'+tabArr[0]).attr('class', sCls);
						$('#'+tabArr[1]).fadeIn();
					}else{
						$('#'+tabArr[0]).attr('class', nCls);
						$('#'+tabArr[1]).hide();
					}
				}
			});
		},
		Pagination : function(maX, CurrClass, pagerO, pagerI){
			if ($(this).length > 0){
				var iniHei = $('#'+pagerI).find('li:first').height();
				var Outer = $(this);
				var Inner = $(this).find('div');
				var Size = Inner.find('span').size();
				var eachW = Inner.find('span').outerWidth();
				var liSize = $('#'+pagerI).find('li').size();
				var liEach = $('#'+pagerI).find('li:first').outerWidth();
				var maxWid = (Size < maX) ? Size*eachW : maX*eachW;
				var currPos = 0;
				var currPPos = 0;
				$('#'+pagerI).width(liSize*liEach+100);
				Outer.width(maxWid+10);
				Inner.find('span').each(function(){
					$(this).click(function(){
						Inner.find('span').each(function(){
							$(this).find('a').removeClass(CurrClass);
						});
						$(this).find('a').addClass(CurrClass);
						var currInd = Outer.find('span').index($(this))+1;
						if ((currInd-currPos) == maX){
							if (currInd < Size){
								if (currInd <= (Size - maX)){
									currPos = currPos+(maX-1);
								}else{
									currPos = currPos+(Size-currInd);
								}
								Inner.animate({marginLeft: '-'+eachW*currPos+'px'});
							}
						}else if((currInd-currPos) == 1){
							if (currInd > 1){
								if (currInd >= maX){
									currPos = currPos-(maX-1);
								}else{
									currPos = currPos-(currInd-1);
								}
								Inner.animate({marginLeft: '-'+eachW*currPos+'px'});
							}
						}
						$('#'+pagerI).animate({marginLeft: '-'+liEach*(currInd-1)+'px'}, "slow");
						var currHei = $('#'+pagerI).find('li:eq('+(currInd-1)+')').outerHeight();
						if ((iniHei - 10) > currHei || (iniHei - 10) < currHei){
							//setTimeout(function(){
								$('#'+pagerO).animate({height: currHei+'px'}, 1000);
							//}, 1000);
						}
						return false;
					});
				});
			}
		}
	});
	$('#pagi-outer1').Pagination(5, 'activePage', 'clubsOut1', 'pager1');
	$('#pagi-outer2').Pagination(5, 'activePage', 'clubsOut2', 'pager2');
	$('#pagi-outer3').Pagination(5, 'activePage', 'clubsOut3', 'pager3');
	$('#allclubs').Tabs(TopTabs, {norCls: 'normal', selCls: 'selected'});
	$('#hltclubs').Tabs(TopTabs, {norCls: 'normal', selCls: 'selected'});
	$('#247clubs').Tabs(TopTabs, {norCls: 'normal', selCls: 'selected'});
});
})(jQuery);
function downloadPDF(id){
	var pdfURL = document.getElementById(id).value;
	if (pdfURL != ''){
		window.location.href = '/ttable/'+pdfURL;
	}
}
