$.cookie=function(name,value,options){
	if(typeof value!='undefined'){
		options=options||{};
		var expires='';
		if(typeof options.expires=='number'||(options.expires&&options.expires.getTime)){var maxAge;if(typeof options.expires=='number'){maxAge=options.expires*24*60*60}else{var now=new Date();maxAge=parseInt((options.expires.getTime()-now.getTime())/1000);if(maxAge>0&&maxAge<1){maxAge=1}}if(maxAge<=0){expires='; expires='+new Date(0).toGMTString()}
		else{expires='; max-age='+maxAge}}var path=options.path?'; path='+options.path:'';
		var domain=options.domain?'; domain='+options.domain:'';
		var secure=options.secure?'; secure':'';
		document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');
	}else{
		var cookieValue=null;
		if(document.cookie&&document.cookie!=''){
			var cookies=document.cookie.split(';');
			for(var i=0;i<cookies.length;i++){
				var cookie=jQuery.trim(cookies[i]);
				if(cookie.substring(0,name.length+1)==(name+'=')){
				cookieValue=decodeURIComponent(cookie.substring(name.length+1));
				break;
				}
			}
		}
	return cookieValue;
	}
};

function EmbedMan(){
	if($(document).getUrlParam("top")!=null&&self!=top){
		top.window.location.href=self.location.href;
		return
	}
	var uemb=$(document).getUrlParam('emb');
	if(self!=top&&uemb==null){
		if($.cookie('emb')!='1')self.location.href=addQryParam('emb','1');
		return;
	}
	if(self==top&&uemb==null){
		if($.cookie('emb')!='0')self.location.href=addQryParam('emb','0');
		return;
	}
}

$(function(){$("select.jump").change(
	function(){
		var gin=$(this).attr('value');
		var tonic=$(this).attr('title');
		Jump(gin,tonic);
	})
});

function Jump(URL,SCRIPT){if(URL!="")self.location.href=SCRIPT+URL;return true}

$(function(){
	$("div.icons p").hide();
	$("div.titleBar").hover(function(){$(this).find("div.icons p").show()},function(){$(this).find("div.icons p").hide()});
	
//	$(".stripeMe tr").addClass("ui-state-default");
	$(".stripeMe tr").mouseover(function(){$(this).addClass("ui-state-hover")}).mouseout(function(){$(this).removeClass("ui-state-hover")});
	$(".stripePh tr").mouseover(function(){$(this).addClass("ui-state-highlight")}).mouseout(function(){$(this).removeClass("ui-state-highlight")});
//	$(".stripeMe th").addClass("ui-state-focus");

    $(".stripeMe tr a.toggle").click(function(){$(this).closest('tr').toggleClass("ui-state-highlight")});

	$("dl.smCalendar dd.day").hover(function(){$(this).addClass("hoverDay")},function(){$(this).removeClass("hoverDay")});
	
	var oldId=$('body').attr('id');
	$("a.switch").toggle(function(){$('body').attr("id","oneCol");$('a.hide').css({display:'none'})},function(){$('body').attr("id",oldId);$('a.hide').css({display:''})});
});


$(document).ready(function(){
	$('#checkboxToggle').click(function(){
		var checkedValue=$('#checkboxToggle').attr('checked')?'checked':'';
		$(':checkbox').attr('checked',checkedValue)
	})

	$(this).submit(function(e){
		if(e.target.length==0){
			var submitButton=$(this).find("input[type='submit']");
			//$(submitButton).attr("disabled","true");
		}
	});
	return false;
});

(function($){
	$.fn.checkgroup=function(options){
		settings=$.extend({groupSelector:null,groupName:'group_name',enabledOnly:false},options||{});
		var ctrl_box=this;
		var grp_slctr=(settings.groupSelector==null)?'input[name='+settings.groupName+']':settings.groupSelector;
		if(settings.enabledOnly){grp_slctr+=':enabled'}
		ctrl_box.click(function(e){
			chk_val=(e.target.checked);
			$(grp_slctr).attr('checked',chk_val);
			ctrl_box.attr('checked',chk_val)
		});
		$(grp_slctr).click(function(){
			if(!this.checked){ctrl_box.attr('checked',false)}
			else{
				if($(grp_slctr).size()==$(grp_slctr+':checked').size()){ctrl_box.attr('checked','checked')}
			}
		});
		return this
	};
	$.fn.vAlign=function(){
		return this.each(function(i){
			var ah=$(this).eq(i).height();
			var ph=$(this).eq(i).parent().height();
			var mh=(ph-ah);
			$(this).eq(i).css('margin-top',mh)
			})
		}
	})
(jQuery);

function isArray(obj) {
	if (obj.constructor.toString().indexOf("Array") == -1) return false;
	else return true;
};

$(document).ready(function(){

	// Link

	$('a.preview').hover(
	function(){
		var relparam=$(this).attr('rel');
		var hrefparam=$(this).attr('href');
		if(relparam!=null&&relparam.length>0&&hrefparam.indexOf('=')>0){
			var topic_post=(hrefparam.split('?')[1]);
			topic_post=escape(hrefparam.split('#')[0]);
			
	$('body').append('<div id="dialog" title="Preview"><div style="text-align:center"><img border=0 src="'+ cor_sSkinPath +'imgages/loading.gif" alt="" /></div></div>');

//	$.fx.speeds._default = 2500;
	$('#dialog').dialog({
			autoOpen: false,
			draggable: false,
			resizable: false,
//			show: 'explode',
//			hide: 'explode',
			//height: 500,
			width: 600
		});
		$('#dialog').dialog('open');
		$('#dialog').empty().load(
			'fora_lookup.asp?'+relparam+'='+topic_post
		)
		return false;
		}
	},
	
	function(){
		$('#dialog').dialog('close');
		$('#dialog').remove();
	});
});


$(document).ready(function(){

	$('div.show h4').add('div.show2 h4').hover(
		function(){$(this).addClass('hover')},
		function(){$(this).removeClass('hover')}
	)

	$('div.show:eq(0) > div').hide();
	$('div.show:eq(0) > h4').click(function(){$(this).next().slideToggle('fast')});

	$('div.show:eq(1) > div:gt(0)').hide();
	$('div.show:eq(1) > h4').click(function(){$(this).next('div:hidden').slideDown('fast').siblings('div:visible').slideUp('fast')});

	$('div.show2:eq(0) > div').hide();$('div.show2:eq(0) > h4').click(function(){$(this).next('div').slideToggle('fast').siblings('div:visible').slideUp('fast')});

	$('div.show2:eq(1) > div').hide();$('div.show2:eq(1) > h4').click(function(){
		var $nextDiv=$(this).next();var $visibleSiblings=$nextDiv.siblings('div:visible');
		if($visibleSiblings.length){$visibleSiblings.slideUp('fast',function(){$nextDiv.slideToggle('fast')})}
		else{$nextDiv.slideToggle('fast')}
	});
});

$(function(){
	$('a.toggle').SoopToggle("div.modular","toggle","toggle","togglehide","show","hide","365","0");
	$('a.help').SoopToggle(".helpDiv","show","help","help","show","hide","365","0");
	$('a.togTree').SoopToggle("#treemenu1 ul.subMenu","tog","hide_max","hide_min","show","hide","365","1");
	$('a.togMen').SoopToggle("#treeMenu ul.subMenu","tog","hide_max","hide_min","show","hide","365","1");
	$('#vertMenu a.togMen').SoopToggle("#vertMenu ul.subMenu","tog","hide_max","hide_min","peek","aboo","365","1");
});

$.fn.SoopToggle=function(targetElement,prfx,gr1,gr2,c1,c2,d,toggleType){
	targetElement=targetElement||ul.subMenu;
	prfx=prfx||tog;gr1=gr1||hide_max;gr2=gr2||hide_min;c1=c1||show;c2=c2||hide;d=d||365;
	$(targetElement).each(function(){
		var cutter=$(this).attr("id");
		var biscuit=$.cookie(cutter);
		if(toggleType==1){//image toggle
			if(biscuit=='hide'){
				$("#"+cutter).hide();
				var target="#"+prfx+cutter;
				var targetImg=$(target).find('img').attr("src").replace(gr2,gr1);
				$(target).find('img').attr({src:targetImg});
			}else{}
		}else{//class toggle
			if(biscuit=='hide'){
				$("#"+cutter).hide();
				var target="#"+prfx+cutter;
				$('p').find('a'+target).addClass(gr2);
			}else{
				var target="#"+prfx+cutter;
				$('p').find('a'+target).removeClass(gr2);
			}
		}
	});
	var $this=$(this).toggle(//
	function(){
		var element=$(this).attr("id").replace(prfx,'');
		if($("#"+element).is(':hidden')){
			if(toggleType==1){//image toggle
				var minMaxImg = $('img',this).attr("src").replace(gr1,gr2);
				$('img',this).attr({src:minMaxImg});
			}else{//class toggle
				$("a."+gr2).removeClass(gr2);
			}
			$("#"+element).show();
			$.cookie(element,c1,{expires:d,path:cor_sWebroot});
		}else{
			if(toggleType==1){//image toggle
				var minMaxImg = $('img',this).attr("src").replace(gr2,gr1);
				$('img',this).attr({src:minMaxImg});
			}else{//class toggle
				$("a."+gr1).addClass(gr2);
			}
			$("#"+element).hide();
			$.cookie(element,c2,{expires:d,path:cor_sWebroot})
		}
	},
	function(){
		var element=$(this).attr("id").replace(prfx,'');
		if($("#"+element).is(':visible')){
			if(toggleType==1){//image toggle
				var minMaxImg = $('img',this).attr("src").replace(gr2,gr1);
				$('img',this).attr({src:minMaxImg});
			}else{//class toggle
				$("a."+gr1).addClass(gr2);
			}
			$("#"+element).hide();
			$.cookie(element,c2,{expires:d,path:cor_sWebroot});
		}else{
			if(toggleType==1){//image toggle
				var minMaxImg = $('img',this).attr("src").replace(gr1,gr2);
				$('img',this).attr({src:minMaxImg});
			}else{//class toggle
				$("a."+gr2).removeClass(gr2);
			}
			$("#"+element).show();
			$.cookie(element,c1,{expires:d,path:cor_sWebroot});
		}
	});
	return this;
};

function goback(){
	history.go(-1)};
	$().ready(function(){
		function formatResult(row){return row[0]}
		if($().autocomplete){
			if($("#musers").length)$("#musers").autocomplete('member_lookup.asp',{
				delay:700,
				max: 30,
				scrollHeight: 300,
				selectFirst:false,
				multiple:true,
				matchContains:true
			})
		}
});

// cluetip (better placement and viewing for topics and posts preview system - also handy as tooltips of any kind, including ajaxed ones
$(document).ready(function(){
    $('a.clueview').cluetip({width: '600px'});
});
			
$(document).ready(function() {

//	$('.ui-widget-content,.post').imagefit();
	$('#content').imagefit();
	$('.panel_wrapper,.post').imagefit();

});

$(document).ready(function(){
	$("span#print_content").click(function(){
		$("div#content").printArea( {mode: "popup", popHt: 500, popWd: 700, popTitle: "Print", popClose: true} );
	});
});

$(document).ready(function(){

//	$("#mainmenuh").removeClass("hide");
	
	var windowHeight;
	var contentHeight;
	var footerHeight;
	var headerHeight;
	var contentWidth;
	
//	windowHeight = $(window).height();
//	contentHeight = $("#content").height();
//	contentWidth = $("#content").width();
//	footerHeight = $("#innerWrapper").height();
//	headerHeight = $("#header").height();
		
});

// see lazy tabs from mootools
function setCookie(name, value, path, expires, domain, secure){
	document.cookie = name + "=" +escape(value) +
	((expires) ? ";expires=" + expires.toGMTString() : "") +
	((path) ? ";path=" + path : "") +
	((domain) ? ";domain=" + domain : "") +
	((secure) ? ";secure" : "");
}

$(document).ready(function(){

	$("#mainmenuh").removeClass("menuhide");
    $("#mainmenuv").removeClass("menuhide");
    $('#mainmenuh').ptMenu({vertical:false});
    $('#mainmenuv').ptMenu({vertical:true});

//	$('.fix-z-index').bgiframe();
//	$('#mainmenuh').ptMenu().find("ul").bgIframe({opacity:false});
//	$('#headerMenu').ptMenu().find("ul").bgIframe({opacity:false});

});

$(function(){
	//all hover and click logic for buttons
	$(".fg-buttonsmall:not(.ui-state-disabled)")
	.hover(
		function(){
			$(this).addClass("ui-state-hover");
		},
		function(){
			$(this).removeClass("ui-state-hover");
		}
	)
	$(".fg-button:not(.ui-state-disabled)")
	.hover(
		function(){
			$(this).addClass("ui-state-hover");
		},
		function(){
			$(this).removeClass("ui-state-hover");
		}
	)
//	.mousedown(function(){
//			$(this).parents('.fg-buttonset-single:first').find(".fg-button.ui-state-active").removeClass("ui-state-active");
//			if( $(this).is('.ui-state-active.fg-button-toggleable, .fg-buttonset-multi .ui-state-active') ){ $(this).removeClass("ui-state-active"); }
//			else { $(this).addClass("ui-state-active"); }
//	})
//	.mouseup(function(){
//		if(! $(this).is('.fg-button-toggleable, .fg-buttonset-single .fg-button,  .fg-buttonset-multi .fg-button') ){
//			$(this).removeClass("ui-state-active");
//		}
//	});
});

$(function(){
	//all hover and click logic for buttons
	$(".button:not(.ui-state-disabled)")
	.hover(
		function(){
			$(this).removeClass("ui-state-default");
			$(this).addClass("ui-state-highlight");
		},
		function(){
			$(this).addClass("ui-state-default");
			$(this).removeClass("ui-state-highlight");
		}
	)
});

$(document).ready( function() {

//     var mainHeight = $("#wrapper").height();
   var totalHeight = $("body").outerHeight();
//		alert(mainHeight+'-'+totalHeight);

   var myDiv = $('#content');
   myDiv.minSize({height: 460});

});


/*
$(function(){
	//all hover and click logic for lists
	$(".ui-list li:not(.ui-state-disabled)")
	.hover(
		function(){
			$(this).addClass("ui-state-hover");
		},
		function(){
			$(this).removeClass("ui-state-hover");
		}
	)
	$(".ui-listi li:not(.ui-state-disabled)")
	.hover(
		function(){
			$(this).addClass("ui-state-hover");
		},
		function(){
			$(this).removeClass("ui-state-hover");
		}
	)
});
*/

/*
// toggle class ---------------------------------------------------------------------------------------------------------------------
$(document).ready(function() {

	// choose text for the show/hide link - can contain HTML (e.g. an image)
	var showText='Show';
	var hideText='Hide';

	// append show/hide links to the element directly preceding the element with a class of "toggle"
	$('.toggle').prev().append(' (<a href="#" class="toggleLink">'+showText+'</a>)');

	// hide all of the elements with a class of 'toggle'
	$('.toggle').hide();

	// capture clicks on the toggle links
	$('a.toggleLink').click(function() {

	// change the link depending on whether the element is shown or hidden
	$(this).html ($(this).html()==hideText ? showText : hideText);

	// toggle the display - uncomment the next line for a basic "accordion" style
	//$('.toggle').hide();$('a.toggleLink').html(showText);
	$(this).parent().next('.toggle').toggle('slow');

	// return false so any link destination is not followed
	return false;

});
});
*/

