/*bbcode*/
var newwindow='';

function pickerPopup202(ifn,sam){
	var bl=screen.width/2-102;
	var bt=screen.height/2-104;
	var page="/includes/fcp202.html"+"?ifn="+escape(ifn)+"&sam="+escape(sam);
	if(!newwindow.closed&&newwindow.location){newwindow.location.href=page;
	}else{
		newwindow=window.open(page,"CTRLWINDOW","help=no,status=no,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,dependent=yes,width=250,height=250,left="+bl+",top="+bt+",");
		if (!newwindow.opener)newwindow.opener=self;};
			if (window.focus){
				newwindow.focus()
			}
		}
													var tips = new Array();
						var tags = new Array();
						tips[0] = 'Bold text: [b]text[/b]';
						tips[1] = 'Italic text: [i]text[/i]';
						tips[2] = 'Insert Link: [url=http://url]URL text[/url]';
						tips[3] = 'Insert Image: [img width=500 height=200]http://image_url[/img]';
						tips[4] = 'Display Code: [code]code[/code]';
						tips[5] = 'Flash Clip: [flash width=* height=*]http://flash_url[/flash]';
						tips[6] = 'Colored Text: <b>[color=#CCCCCC]text[/color]</b> <br /> If you dont know any color codes use the color chart below to find <br />out some color codes just replace the current color code "#CCCCCC".';
						tips[7] = 'Font Size: [size=15px]text[/size]';
						tips[8] = 'Start New Page: [page /]';
						tips[9] = 'This is for Quicktime .mov [mov]URL of film[/mov]';
						tips[10] = 'For Utube Videos [utube]You tube URL[/utube]';
						tags[0] = '[b]';
						tags[1] = '[/b]';
						tags[2] = false;
						tags[3] = '[i]';
						tags[4] = '[/i]';
						tags[5] = false;
						tags[6] = '[url=]';
						tags[7] = '[/url]';
						tags[8] = false;
						tags[9] = '[img width=500 height=200]';
						tags[10] = '[/img]';
						tags[11] = false;
						tags[15] = '[code]';
						tags[16] = '[/code]';
						tags[17] = false;
						tags[18] = '[flash width= height=]';
						tags[19] = '[/flash]';
						tags[20] = false;
						tags[21] = '[color=#CCCCCC]';
						tags[22] = '[/color]';
						tags[23] = false;
						tags[24] = '[size=]';
						tags[25] = '[/size]';
						tags[26] = false;
						tags[27] = '[page /]';
						tags[28] = '[mov]';
						tags[29] = '[/mov]';
						tags[30] = '[utube]';
						tags[31] = '[/utube]';
							tags[32] = false;
						
						var formNAMES = ".$formNames.";
						
						var agt = navigator.userAgent.toLowerCase();
						var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
						function show_tooltips(num) {
							document.getElementById('tooltips').innerHTML = tips[num];	
						}

							
							function OnTagButtonClick(number) {
								if(number == 27) {
									AddTag(tags[27]);
									return;
								}
								var closetag = number + 1;
								var current_state = number + 2;
								if(!is_ie) {
									if (document.form.field.selectionEnd && (document.form.field.selectionEnd - document.form.field.selectionStart > 0)) {
										Wrap(tags[number], tags[closetag]);
										return;
									}
								}
								
								if(tags[current_state] == false) {
									AddTag(tags[number]);
									tags[current_state] = true;
								}else{
									AddTag(tags[closetag]);
									tags[current_state] = false;
									
								}
							}
							function AddTag(tag) {
	
								 document.form.field.value += tag;
							}
							function Wrap(lft, rgt) {
								if (document.all) {
									strSelection = document.selection.createRange().text;
									if (strSelection!="") {
									document.selection.createRange().text = lft + strSelection + rgt;
									}
								}
								else if (document.getElementById) {
									var selLength = document.form.field.textLength;
									var selStart = document.form.field.selectionStart;
									var selEnd = document.form.field.selectionEnd;
									if (selEnd==1 || selEnd==2) selEnd=selLength;
									var s1 = (document.form.field.value).substring(0,selStart);
									var s2 = (document.form.field.value).substring(selStart, selEnd)
									var s3 = (document.form.field.value).substring(selEnd, selLength);
									document.form.field.value = s1 + lft + s2 + rgt + s3;
								}
							}
							
/*

CUSTOM FORM ELEMENTS

Created by Ryan Fait
www.ryanfait.com

The only things you may need to change in this file are the following
variables: checkboxHeight, radioHeight and selectWidth (lines 24, 25, 26)

The numbers you set for checkboxHeight and radioHeight should be one quarter
of the total height of the image want to use for checkboxes and radio
buttons. Both images should contain the four stages of both inputs stacked
on top of each other in this order: unchecked, unchecked-clicked, checked,
checked-clicked.

You may need to adjust your images a bit if there is a slight vertical
movement during the different stages of the button activation.

The value of selectWidth should be the width of your select list image.

Visit http://ryanfait.com/ for more information.

*/

var checkboxHeight = "25";
var radioHeight = "25";
var selectWidth = "190";


/* No need to change anything after this */


document.write('<style type="text/css">input.styled { display: none; } select.styled { position: relative; width: ' + selectWidth + 'px; opacity: 0; filter: alpha(opacity=0); z-index: 5; } .disabled { opacity: 0.5; filter: alpha(opacity=50); }</style>');

var Custom = {
	init: function() {
		var inputs = document.getElementsByTagName("input"), span = Array(), textnode, option, active;
		for(a = 0; a < inputs.length; a++) {
			if((inputs[a].type == "checkbox" || inputs[a].type == "radio") && inputs[a].className == "styled") {
				span[a] = document.createElement("span");
				span[a].className = inputs[a].type;

				if(inputs[a].checked == true) {
					if(inputs[a].type == "checkbox") {
						position = "0 -" + (checkboxHeight*2) + "px";
						span[a].style.backgroundPosition = position;
					} else {
						position = "0 -" + (radioHeight*2) + "px";
						span[a].style.backgroundPosition = position;
					}
				}
				inputs[a].parentNode.insertBefore(span[a], inputs[a]);
				inputs[a].onchange = Custom.clear;
				if(!inputs[a].getAttribute("disabled")) {
					span[a].onmousedown = Custom.pushed;
					span[a].onmouseup = Custom.check;
				} else {
					span[a].className = span[a].className += " disabled";
				}
			}
		}
		inputs = document.getElementsByTagName("select");
		for(a = 0; a < inputs.length; a++) {
			if(inputs[a].className == "styled") {
				option = inputs[a].getElementsByTagName("option");
				active = option[0].childNodes[0].nodeValue;
				textnode = document.createTextNode(active);
				for(b = 0; b < option.length; b++) {
					if(option[b].selected == true) {
						textnode = document.createTextNode(option[b].childNodes[0].nodeValue);
					}
				}
				span[a] = document.createElement("span");
				span[a].className = "select";
				span[a].id = "select" + inputs[a].name;
				span[a].appendChild(textnode);
				inputs[a].parentNode.insertBefore(span[a], inputs[a]);
				if(!inputs[a].getAttribute("disabled")) {
					inputs[a].onchange = Custom.choose;
				} else {
					inputs[a].previousSibling.className = inputs[a].previousSibling.className += " disabled";
				}
			}
		}
		document.onmouseup = Custom.clear;
	},
	pushed: function() {
		element = this.nextSibling;
		if(element.checked == true && element.type == "checkbox") {
			this.style.backgroundPosition = "0 -" + checkboxHeight*3 + "px";
		} else if(element.checked == true && element.type == "radio") {
			this.style.backgroundPosition = "0 -" + radioHeight*3 + "px";
		} else if(element.checked != true && element.type == "checkbox") {
			this.style.backgroundPosition = "0 -" + checkboxHeight + "px";
		} else {
			this.style.backgroundPosition = "0 -" + radioHeight + "px";
		}
	},
	check: function() {
		element = this.nextSibling;
		if(element.checked == true && element.type == "checkbox") {
			this.style.backgroundPosition = "0 0";
			element.checked = false;
		} else {
			if(element.type == "checkbox") {
				this.style.backgroundPosition = "0 -" + checkboxHeight*2 + "px";
			} else {
				this.style.backgroundPosition = "0 -" + radioHeight*2 + "px";
				group = this.nextSibling.name;
				inputs = document.getElementsByTagName("input");
				for(a = 0; a < inputs.length; a++) {
					if(inputs[a].name == group && inputs[a] != this.nextSibling) {
						inputs[a].previousSibling.style.backgroundPosition = "0 0";
					}
				}
			}
			element.checked = true;
		}
	},
	clear: function() {
		inputs = document.getElementsByTagName("input");
		for(var b = 0; b < inputs.length; b++) {
			if(inputs[b].type == "checkbox" && inputs[b].checked == true && inputs[b].className == "styled") {
				inputs[b].previousSibling.style.backgroundPosition = "0 -" + checkboxHeight*2 + "px";
			} else if(inputs[b].type == "checkbox" && inputs[b].className == "styled") {
				inputs[b].previousSibling.style.backgroundPosition = "0 0";
			} else if(inputs[b].type == "radio" && inputs[b].checked == true && inputs[b].className == "styled") {
				inputs[b].previousSibling.style.backgroundPosition = "0 -" + radioHeight*2 + "px";
			} else if(inputs[b].type == "radio" && inputs[b].className == "styled") {
				inputs[b].previousSibling.style.backgroundPosition = "0 0";
			}
		}
	},
	choose: function() {
		option = this.getElementsByTagName("option");
		for(d = 0; d < option.length; d++) {
			if(option[d].selected == true) {
				document.getElementById("select" + this.name).childNodes[0].nodeValue = option[d].childNodes[0].nodeValue;
			}
		}
	}
}
window.onload = Custom.init;
/* 
 * Auto Expanding Text Area (1.2.2)
 * by Chrys Bader (www.chrysbader.com)
 * chrysb@gmail.com
 *
 * Special thanks to:
 * Jake Chapa - jake@hybridstudio.com
 * John Resig - jeresig@gmail.com
 *
 * Copyright (c) 2008 Chrys Bader (www.chrysbader.com)
 * Licensed under the GPL (GPL-LICENSE.txt) license. 
 *
 *
 * NOTE: This script requires jQuery to work.  Download jQuery at www.jquery.com
 *
 */
 
(function(jQuery) {
		  
	var self = null;
 
	jQuery.fn.autogrow = function(o)
	{	
		return this.each(function() {
			new jQuery.autogrow(this, o);
		});
	};
	

    /**
     * The autogrow object.
     *
     * @constructor
     * @name jQuery.autogrow
     * @param Object e The textarea to create the autogrow for.
     * @param Hash o A set of key/value pairs to set as configuration properties.
     * @cat Plugins/autogrow
     */
	
	jQuery.autogrow = function (e, o)
	{
		this.options		  	= o || {};
		this.dummy			  	= null;
		this.interval	 	  	= null;
		this.line_height	  	= this.options.lineHeight || parseInt(jQuery(e).css('line-height'));
		this.min_height		  	= this.options.minHeight || parseInt(jQuery(e).css('min-height'));
		this.max_height		  	= this.options.maxHeight || parseInt(jQuery(e).css('max-height'));;
		this.textarea		  	= jQuery(e);
		
		if(this.line_height == NaN)
		  this.line_height = 0;
		
		// Only one textarea activated at a time, the one being used
		this.init();
	};
	
	jQuery.autogrow.fn = jQuery.autogrow.prototype = {
    autogrow: '1.2.2'
  };
	
 	jQuery.autogrow.fn.extend = jQuery.autogrow.extend = jQuery.extend;
	
	jQuery.autogrow.fn.extend({
						 
		init: function() {			
			var self = this;			
			this.textarea.css({overflow: 'hidden', display: 'block'});
			this.textarea.bind('focus', function() { self.startExpand() } ).bind('blur', function() { self.stopExpand() });
			this.checkExpand();	
		},
						 
		startExpand: function() {				
		  var self = this;
			this.interval = window.setInterval(function() {self.checkExpand()}, 400);
		},
		
		stopExpand: function() {
			clearInterval(this.interval);	
		},
		
		checkExpand: function() {
			
			if (this.dummy == null)
			{
				this.dummy = jQuery('<div></div>');
				this.dummy.css({
												'font-size'  : this.textarea.css('font-size'),
												'font-family': this.textarea.css('font-family'),
												'width'      : this.textarea.css('width'),
												'padding'    : this.textarea.css('padding'),
												'line-height': this.line_height + 'px',
												'overflow-x' : 'hidden',
												'position'   : 'absolute',
												'top'        : 0,
												'left'		 : -9999
												}).appendTo('body');
			}
			
			// Strip HTML tags
			var html = this.textarea.val().replace(/(<|>)/g, '');
			
			// IE is different, as per usual
			if ($.browser.msie)
			{
				html = html.replace(/\n/g, '<BR>new');
			}
			else
			{
				html = html.replace(/\n/g, '<br>new');
			}
			
			if (this.dummy.html() != html)
			{
				this.dummy.html(html);	
				
				if (this.max_height > 0 && (this.dummy.height() + this.line_height > this.max_height))
				{
					this.textarea.css('overflow-y', 'auto');	
				}
				else
				{
					this.textarea.css('overflow-y', 'hidden');
					if (this.textarea.height() < this.dummy.height() + this.line_height || (this.dummy.height() < this.textarea.height()))
					{	
						this.textarea.animate({height: (this.dummy.height() + this.line_height) + 'px'}, 100);	
					}
				}
			}
		}
						 
	 });
})(jQuery);
$(document).ready(function() {
	$('#adminContainer tr:even').css('background-color', '#333333');
/*	var count = $("#msgHidden").size();
	alert(count)
	for (i=0; i<count; i++){
	$('#msgHidden'.i).css('display', 'none');
	}*/
});
$(document).ready(function() {
	$('.FRContainer:even').css('background-color', '#060606');
});
$('textarea').autogrow();
$('textarea.expanding').autogrow();

function ShowHide(){
$("#slidingDiv").animate({"height": "toggle"}, { duration: 1000 }); }

function ShowHide2(){
$("#sliding2Div").animate({"height": "toggle"}, { duration: 1000 }); }

function ShowHideReg(){
$("#slidingRegDiv").animate({"height": "toggle"}, { duration: 1000 }); }

function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=400,left = 440,top = 425');");
}

	function showDiv(divName) {
		var height = $(document).height();
		var width = $(document).width();
		$('#fadedbk').css({'display': 'inline', 'height': height, 'width': width});
		$('#' + divName).fadeIn(2000, function() {
		});
	}
	
	function closeDiv(divName) {
		var height = $(document).height();
		var width = $(document).width();
		$('#fadedbk').css({'display': 'none', 'height': height, 'width': width});
			$('#' + divName).css({'display': 'none'})
	}
	
	$(window).resize(function() {
		var htmlHeight = $('html').css('height');
		var bodyWidth = $('body').css('width');
		var newWindowHeight = $(window).height();
		var newWindowWidth = $(document).width();
			$('#fadedbk').css({'height': htmlHeight, 'width': newWindowWidth });
	});

	
$(document).ready (function() {
   
   $('textarea.expanding').autogrow();
                     
});
function popUp() {
	 $('#popUp').css('visibility', 'visible');
}
function popUpOut() {
	 $('#popUp').css('visibility', 'hidden');
}
function msgHidden(i) {
	 $("#msgHidden"+i).css('display', 'block');
}
function msgHidden2(i) {
	 $('#msgHidden'+i).css('display', 'none');
}
$(document).ready(function() {
  sliderAnyname = new simpleHorizontalSlider('button_left','button_right','myDivItems',2, {moveThisManyOnClick: 1, elementWidth: "120px"} );
});
function popUp2() {
window.open( "http://www.dsclan.org.uk/Player/index.php", "Ds Music Player", 
"status = 1, height = 300, width = 300, resizable = 0" )
}
function simpleHorizontalSlider(leftClick, rightClick, elementClassName, howManyDivsWidth, optionsArray) {
    this.randInt = Math.floor(Math.random() * 500 + 1);
    this.sliderName = eval("'slider" + this.randInt + "'");
    eval("" + this.sliderName + " = this; ");
    eval("$(\"#\" + leftClick).click(function() {" + this.sliderName + ".clickRight();});");
    eval("$(\"#\" + rightClick).click(function() {" + this.sliderName + ".clickLeft();});");
    this.leftClick = leftClick;
    this.rightClick = rightClick;
    this.elementClassName = elementClassName;
    this.howManyDivsWidth = howManyDivsWidth;
    this.options = optionsArray || {};
    if (!this.options.moveThisManyOnClick) { this.options.moveThisManyOnClick = '1'; }
    this.lLocation = 1;
    this.rLocation = howManyDivsWidth;
    this.divBucket = new Array();
    this.totalDivs = 0;
    this.showWidth = 0;
    this.divs = $("." + this.elementClassName);
    this.divBucket = new Array();
    this.divCount = 1;
    this.i = 0;
    for (this.i in this.divs) {
        this.newdiv = this.divs[this.i];
        if (this.newdiv.innerHTML != undefined) {
            if (!this.newdiv.id) {
                this.randomDivID = Math.floor(Math.random() * 9999 + 1);
                this.newdiv.id = 'sliderdiv' + this.randInt + this.randomDivID + this.divCount;
            }
            this.divBucket[this.divCount] = this.newdiv.id;
            if (this.divCount > this.howManyDivsWidth) {
                this.hideBucketDiv(this.newdiv.id);
            }
            this.divCount++;
        }
    }
    this.totalDivs = (this.divCount--);
    this.initialized = true;
}

simpleHorizontalSlider.prototype.clickLeft = function() {
    howManyClicks = this.options.moveThisManyOnClick;
    var i=0;
    for (i=0;i<howManyClicks;i++)
    {
        maxlLocation = this.totalDivs - this.howManyDivsWidth;
        newlLocation = this.lLocation + 1;
    
        if (newlLocation <= maxlLocation) {
            this.hideBucketDiv(this.divBucket[this.lLocation]);
            this.lLocation++;
            this.rLocation++;
            this.showBucketDiv(this.divBucket[this.rLocation]);
        }
    }
}
simpleHorizontalSlider.prototype.clickRight = function() {
    howManyClicks = this.options.moveThisManyOnClick;
    var i=0;
    for (i=0;i<howManyClicks;i++)
    {

        maxlLocation = this.totalDivs - this.howManyDivsWidth;
        newrLocation = this.rLocation - 1;
        if (newrLocation >= this.howManyDivsWidth) {
            this.hideBucketDiv(this.divBucket[this.rLocation]);
            this.lLocation--;
            this.rLocation--;
            this.showBucketDiv(this.divBucket[this.lLocation]);
        }
    }
}
simpleHorizontalSlider.prototype.showBucketDiv = function(elementID) {
    $("#" + elementID).animate({
        width: this.options.elementWidth,
        opacity: 1,
        marginLeft: "0"
    },
    500);
}
simpleHorizontalSlider.prototype.hideBucketDiv = function(elementID) {

    $("#" + elementID).animate({
        width: "0%",
        opacity: 0,
        marginLeft: "0"
    },
    500,null,function() { $("#" + elementID).hide();  });
}
// When the document is ready set up our sortable with it's inherant function(s) 
$(document).ready(function() { 
  $("#test-list").sortable({ 
    handle : '.handle', 
    update : function () { 
      var order = $('#test-list').sortable('serialize'); 
      $("#info").load("process-sortable.php?action=SORT&"+order); 
    } 
  });
  $("#new_subcat").validate();
  $("#new_cat").validate();

});
 //Deletion confirmation script
	function confirmation(id) {
        if (confirm('Warning you are a bout to remove this catergory, if you are sure you want to remove this catergory then click ok otherwise click cancel.')) {
			$("#info").load("process-sortable.php?action=DELETE_CAT&id="+id);
			location.reload();
		}else {
			
		}
	}
	
	function display(cat) {
		$('#'+cat).show();
	}
	
	function create(action) {
		$.post("process-sortable.php?action="+action, $('#'+action).serialize()); 
	}
	
/*	function edit(action) {
		$.post("process-sortable.php?action="+action, $('#'+action).serialize()); 
	}*/
	
