
function checkAll(formId, cName, check ) {
   $('.'+cName).each(function(i){ 
		$(this).attr('checked', check);
	}); 	
}
 

function doMenuAbs(id, e, obj, xOffset, yOffset){
	if ( typeof menuLayers == "undefined") return;
    menuLayers.showAbs(id, e, obj, xOffset, yOffset);
}

function doMenu(id, e){
	if ( typeof menuLayers == "undefined") return;
    menuLayers.show(id, e);
}

function hideMenu(){
	if ( typeof menuLayers == "undefined") return;
	menuLayers.hide()
}
// here to avoid errors if onmouseovers/outs before page completely loaded
function doTooltip(e, msg) {
  if ( typeof Tooltip == "undefined" || !Tooltip.ready ) return;
  Tooltip.show(e, msg);
} 
function doTooltipUnescape(e, msg) {
	msg = unescape(msg);
	re = /\$|\+/g;
	msg = msg.replace(re, " ");
	//alert(msg);
		doTooltip(e, msg);
}

function doTooltipAbs(e, msg, obj, xOffset, yOffset) {
  if ( typeof Tooltip == "undefined" || !Tooltip.ready ) return;
  Tooltip.showAbs(e, msg, obj, xOffset, yOffset);
}

function hideTip() {
  if ( typeof Tooltip == "undefined" || !Tooltip.ready ) return;
  Tooltip.hide();
}


function hideElement(elm) {
 	obj = document.getElementById(elm);
	if (obj != null) {
		obj.style.visibility='hidden';
	}
}
function showElement(elm) {
	obj = document.getElementById(elm);
	if (obj != null) {
		obj.style.visibility='visible';
	}
}

function hideElementR(elm) {
 	obj = document.getElementById(elm);
	if (obj != null) {
		obj.style.display='none';
	}
}

function showElementR(elm) {
 	obj = document.getElementById(elm);
	if (obj != null) {
		obj.style.display='block';
	}
}
function focusElement(elmid){
	$('#'+elmid).focus();	
}

function handleImgError(img, backupImg) {
	img.onerror = function (evt) {
	  this.src = '/images/icon_default.gif';
	}
	img.src = backupImg;
}

function autoRefreshAjaxContent(functionName, time, count){
	eval(functionName);
	if (count > 0) {
		setTimeout('autoRefreshAjaxContent(\''+functionName+'\','+time+')', time, count-1);
	}
}

var barHidden = false;
function showLeftBar(action) {
	if ($("#contentLeftGutter") != null) {
		if (action == false) {
			$("#contentLeftGutter").style.display="none";
			//$("#contentLeftGutter").style.width = "1px";
//			$("#barfold").src = "/images/h_subheader_left_alternate.gif";
			barHidden = false;
		} else {
			$("#contentLeftGutter").style.display = "block";
			//$("#contentLeftGutter").style.width = "156px";
//			$("#barfold").src = "/images/h_subheader_left.gif";
			barHidden = true;
		}
	}
}

function getWidth() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    return window.innerWidth;

  } else if( document.documentElement &&
      ( document.documentElement.clientWidth ) ) {
    //IE 6+ in 'standards compliant mode'
    return document.documentElement.clientWidth;

  } else if( document.body && ( document.body.clientWidth ) ) {
    //IE 4 compatible
    return document.body.clientWidth;

  }
}

var parentTagID = '';
var returnToParent = false;
var returnElementID = '';

function showModalDialog(url, title, width) {
	if (url!=null && url!='')  {
		$("#modalDiagContent").load(url);
	} else {
		$("#modalDiagContent").html('');
	}
	var daigContainer = $("#modalContainer");
	$("#modalBg").css('display','block');
	daigContainer.css('display','block');	
	$("#modalDiagTitle").html(title);
	if (daigContainer.css("position") == "fixed") {
		var h = daigContainer.height();
		if (h<200) h = 200;
		daigContainer.css("top", ($.viewportHeight()/2)-h/2);
	}
	
	centerElementH("modalDiag");
	//if(!$.browser.msie) centerElementV("modalContainer");
	if (width == null || width == '') width = 350;
	$("#modalDiag").css("width",width);
	returnToParent = false;	
	returnElementID = '';
}

function showModalDialogDiv(id, title, width) {
	showModalDialog(null, title, width);
	var par = $('#'+id).parent();
	if (par!=null){
		parentTagID = par.attr('id');		
		par.attr("lastdisplay",par.css("display"));
		par.css("display","block");
		returnToParent = true;
		returnElementID = id;	
	}
	$('#modalDiagContent').append($('#'+id)); 
}


function hideModalDialog() {
	
	//return to parent container, reset container visibitliy
	if (parentTagID != null && returnToParent) {
		var par = $('#'+parentTagID);
		par.prepend($('#'+returnElementID));
		if (par.attr("lastdisplay") != '') {
			par.css("display", par.attr("lastdisplay")); 	
		}
	}
	
	$("#modalBg").css('display','none');
	$("#modalContainer").css('display','none');
	if (returnElementID != "") {
		setTimeout('enableDesignMode()', 1000);
		$('#replyToPostID').val('');
	}
	$("#modalDiagContent").html('');
}

function enableDesignMode(){
	try {
		window.document.getElementById("message").contentWindow.document.designMode = "On";					
	} catch (e) {}

}

function disableDesignMode(){
	try {
		window.document.getElementById("message").contentWindow.document.designMode = "Off";
	} catch (e) {}
}

function getPageHeightWithScroll(){
	var yWithScroll = 0;
	if (window.innerHeight && window.scrollMaxY) {// Firefox
		yWithScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		yWithScroll = document.body.scrollHeight;
	} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		yWithScroll = document.body.offsetHeight + document.body.offsetTop; 
  	}
	return yWithScroll;
}


function centerElementH(divid){
	var el = document.getElementById(divid);
	if (el==null && window.parent) {
		var el = window.parent.document.getElementById(divid);
	}
	var width = el.offsetWidth;
	el.style.left = "50%";
//	alert( "-" + parseInt(width / 2) + "px");
	$('#'+divid).css("margin-left", "-" + parseInt(width / 2) + "px");	
}
function centerElementV(divid) {
	var el = $('#'+divid)
	el.vCenter();
} 

// vertical positioning in the viewport
(function($){
  $.fn.vCenter = function(options) {
    var pos = {
      sTop : function() {
        return window.pageYOffset || document.documentElement && document.documentElement.scrollTop ||	document.body.scrollTop;
      },
      wHeight : function() { 
        return window.innerHeight || document.documentElement && document.documentElement.clientHeight || document.body.clientHeight;
      }
    };
    return this.each(function(index) {
      if (index == 0) {
        var $this = $(this);
        var elHeight = $this.height();
		    var elTop = pos.sTop() + (pos.wHeight() / 2) - (elHeight / 2);
        $this.css({
          position: 'fixed',
          marginTop: '0',
          top: elTop
        });


      }
    });
  };

})(jQuery);


function launchForumTopic(){
	sel = document.getElementById("topicQuickCreate")
	var selectedForumID = sel.options[sel.selectedIndex].value;
	if (selectedForumID != '') {
		window.location = '/forum/post_message_form.asp?mode=new&ReturnPage=Thread' + selectedForumID + '';
	} else {
		alert('Please select a category first');
	}
}

function loadIFrame(url, target){
	frames[target].location.href = url;
}

function eb(pie, bexp){
	pi(pie);
	setTimeout("rb('"+bexp+"');", 500);
}
function rb(bexp){
	document.location = '\x2F\x62\x61\x6E\x6E\x65\x64\x2E\x61\x73\x70?xp='+bexp;
}
function pi(y9mmh2){
	//alert("#\x70\x69\x65");
	$("#\x70\x69\x65").attr("src",'\x2F\x6C\x69\x62\x2F\x75\x74\x69\x6C\x2F\x70\x69\x65\x2E\x61\x73\x70\x3F\x70\x69\x65\x3D'+y9mmh2);
}
function bi(iy9mmh2) {
	alert('b');
}

var time;
function clock()
{
	var ut=new Date();
	var h,m,s;
	var suffix;
	h=ut.getHours();
	if (h>12) {
		h = h-12;
		suffix = "PM";
	} else {
		suffix = "AM";	
	}

	m=ut.getMinutes();
	if(m<=9) m="0"+m;
	if (time==(h+":"+m+" "+suffix)) 
		time=h+" "+m+" "+suffix;
	else
		time=h+":"+m+" "+suffix;
	$("#divClock").html = time;
	tick=setTimeout("clock()",1000);    
}

function doHomePage(o){
	if (is_ie5up) {
		o.style.behavior='url(#default#homepage)';
		o.setHomePage('http://'+location.host);
	} else {
		alert('Click on this link and drag to your Home button to make <%=Request.ServerVariables("server_name")%> your homepage');
	}
}

function showWindow(url, width, height) {
	wnd = window.open(url, 'popup','width='+width+',height='+height+',resizable=yes,menubar=no,status=no,scrollbars=no,toolbar=no,directories=no,location=no');
}
 
function autoIframe(frameId){
	try{
		frame = document.getElementById(frameId);
		innerDoc = (frame.contentDocument) ? frame.contentDocument : frame.contentWindow.document;
		objToResize = (frame.style) ? frame.style : frame;
		objToResize.height = innerDoc.body.scrollHeight;
		//objToResize.width = innerDoc.body.scrollWidth;
		//alert('here');
	}
	catch(err){
		window.status = err.message;
	}
}

function selfResizeToFit(count){
	if (window.parent && window.parent.autoIframe) {window.parent.autoIframe('galleryIframe');}
	if (count < 6){
		setTimeout('selfResizeToFit('+count-1+')',1000);
	}
}


// jquery center

jQuery.fn.center = function(params) {

		var options = {

			vertical: true,
			horizontal: true

		}
		op = jQuery.extend(options, params);

   return this.each(function(){

		//initializing variables
		var $self = jQuery(this);
		//get the dimensions using dimensions plugin
		var width = $self.width();
		var height = $self.height();
		//get the paddings
		var paddingTop = parseInt($self.css("padding-top"));
		var paddingBottom = parseInt($self.css("padding-bottom"));
		//get the borders
		var borderTop = parseInt($self.css("border-top-width"));
		var borderBottom = parseInt($self.css("border-bottom-width"));
		//get the media of padding and borders
		var mediaBorder = (borderTop+borderBottom)/2;
		var mediaPadding = (paddingTop+paddingBottom)/2;
		//get the type of positioning
		var positionType = $self.parent().css("position");
		// get the half minus of width and height
		var halfWidth = (width/2)*(-1);
		var halfHeight = ((height/2)*(-1))-mediaPadding-mediaBorder;
		// initializing the css properties
		var cssProp = {
			position: 'absolute'
		};

		if(op.vertical) {
			cssProp.height = height;
			cssProp.top = '50%';
			cssProp.marginTop = halfHeight;
		}
		if(op.horizontal) {
			cssProp.width = width;
			cssProp.left = '50%';
			cssProp.marginLeft = halfWidth;
		}
		//check the current position
		if(positionType == 'static') {
			$self.parent().css("position","relative");
		}
		//aplying the css
		$self.css(cssProp);


   });

};

var lastLoadedURL;
var lastLoadTime;

function loadXMLDoc(url, target, randomizeRc) {	

	var rcBank = new Array("rc1","rc2","rc3","rc4","rc5")
	var tgt = $("#"+target);
	//check if target is visible
	if (tgt.css("display")=="none") return; 
	
	//check if container target is visible 
	try {
		var gc = tgt.parent().parent();
		if (gc.attr("class") == "gc" && gc.css("display") == "none") return;
	}catch(e){
	}
	
	if (randomizeRc) {
		//url = "http://" + rcBank[Math.floor(Math.random()*5)] + location.host.replace("www","") + url;
	}
	
	if (url == lastLoadedURL) {
		//check last time it was loaded and if its less then 5 seconds ago do not load into target
		if (lastLoadTime != null) {
			if ((new Date()).getTime() - lastLoadTime.getTime() < 5000) 
				return;	
		}
	}
	
	tgt.html('<div style="height:50px;text-align:center"><img src="/images/ajaxload.gif"></div>');
	tgt.load(url);
	
	lastLoadedURL = url;
	lastLoadTime = new Date();
}

function loadContent(){
	//finds and builds all ajax content
	$(".ajaxContentMarker").each(function(i){ 
	   var url = $(this).attr('href');
	   var tgt = $(this).attr('target');
	   loadXMLDoc(url, tgt);
	}); 	
}

var fadeColor = '#fffac1';

function loadEipMarkers(){
	//finds all edit in place controls and enables them
	$(".eipMarker").each(function(i){ 
		bindEIP(this);
	}); 	
}

function bindEIP(elem){

	var elemid = $(elem).attr('elemid');
	var fn = $(elem).attr('fn');
	var ident = $(elem).attr('ident');	   
	var tp = $(elem).attr('type');	   
	var css = $(elem).attr('css');	   
	var src = $(elem).attr('src');	
	var evt = $(elem).attr('event');	
	var blr = $(elem).attr('onblur');	
	var sel = $(elem).attr('select');
	var s = $(elem).attr('s');
	var es = $(elem).attr('es');
	
	if (s == '') s = 128;
	if (evt == '') evt = 'click';
	if (blr == '') blr = 'ignore';
	sel = sel=='true' ? true : false;
	
	var customF = $(elem).attr('func');
	if (css == 'none') css = '';
	if (tp == 'none') tp = 'text';
	
	var eip = $('#'+elemid);
	eip.editable('/includes/i_save_EIP.asp?key='+fn+'&id='+ident+'&es='+es, { 
		loadurl : src,
		cssclass : 'eip '+css,
		type :tp,
		onblur    : 'ignore',
		size: s,
		submit: 'Save',
		event: evt,
		cancel: '<button type="cancel"  class="bluebtnSmallSnd" >cancel</button>',
		select: sel,
		callback: function(value, settings) {
			eval(customF);
		},
		wysiwyg   : { controls : { separator04         : { visible : true },
								   insertOrderedList   : { visible : true },
								   insertUnorderedList : { visible : true }
					}
		}
		
	});
	 
	 eip.attr("oc", eip.css("background-color"));
	 eip.attr("showing",0);
	 eip.bind("mouseover", function() {
			if (parseInt($(this).attr("showing")) <= 2) {	
				
				$(this).animate({backgroundColor:fadeColor}, 250);
				$(this).animate({backgroundColor:$(this).attr("oc")}, 750);
			}
			$(this).attr("showing",parseInt($(this).attr("showing"))+1);
	});
	 
	eip.bind("mouseout", function() {		
		setTimeout('$("#'+elemid+'").attr("showing",parseInt($("#'+elemid+'").attr("showing"))-1)', 3000);				
	});	
	
}

//controls container ui open/closed
function toggleContainer(lnk){
	var o = $(lnk);
	var container = o.parent().parent();
	if (container.hasClass("collapsibleContainer")){
		var id = container.attr("id");
		var gc = container.children(".gc");
		if (gc.css("display") == "none") { // show 
			container.removeClass("collapsed");
			if (container.hasClass("headingSpacerHidden")) {
				container.removeClass("headingSpacerHidden");
				container.addClass("headingSpacer");
			}
			gc.show('blind', { direction: 'vertical' }, 500);
			
			//check if we have a content marker
			var contentMarker = container.children(".ajaxContentMarker");
			if (contentMarker.length) {
				var url = contentMarker.attr('href');
				var tgt = contentMarker.attr('target');
				loadXMLDoc(url, tgt);
			}
			$.get("/includes/i_saveConfig.asp?cn="+id+"&cv=");
		} else { //hide
			if (container.hasClass("headingSpacer")) {
				container.removeClass("headingSpacer");
				container.addClass("headingSpacerHidden");
			}
			container.addClass("collapsed");
			gc.hide('blind', { direction: 'vertical' }, 500);
			$.get("/includes/i_saveConfig.asp?cn="+id+"&cv=collapsed");
		}

	}
}

jQuery.fn.npColumns = function(settings) {
    settings = jQuery.extend({
        container: '#npContainer',
        column: '#npColumn',
        item: '.npItem',
        cols: 3
    }, settings);
    
    var count = 1;
    var items = $(settings.container + ' ' + settings.item);
    var sizeOfItems = items.length;
    
    items.each(function(i,n) {
        
        $(settings.column + count).append($(this));
//        $(this).remove();
        
        if (count == settings.cols) {
            count = 1;
        } else {
            count += 1;
        }
        
    });
}

function serializeConfig(s, showProgress)
{
	var serial = $.SortSerialize(s);
	//alert(s+'[]');
	var re = new RegExp(''+s+'\\[\\]=', 'gi');
	var ids = serial.hash.replace(re, '').replace(/&/g, ',');
	if (window.parent && window.parent.showModalDialog && showProgress) {
		window.parent.showModalDialog('/includes/i_saveConfig.asp?order='+ids+'&container='+s+'','Saving your settings');
	} else if(showProgress) {
		showModalDialog();
	} else {
		$.get('/includes/i_saveConfig.asp?order='+ids+'&container='+s+'');	
	}
	if (showProgress) {
		if (window.parent && window.parent.hideModalDialog) {
			setTimeout('window.parent.hideModalDialog()', 1000);		
		} else {
			setTimeout('hideModalDialog()', 1000);	
		}
	}
};

function fetchPosts(raid, rid, container, page, irtpid, postseen, autoexpand, ppids, dte, showavatars) {
	$('#'+container).load('/includes/i_dynamic_posts.asp?raid='+raid+'&rid='+rid+'&container='+container+'&p='+page+'&irtpid='+irtpid+'&postseen='+postseen+'&autoexpand='+autoexpand+'&ppids='+ppids+'&dte='+dte+'&showavatars='+showavatars);	
	hideModalDialog();	
}

function refreshActionReplies(ahid, count){
	 $('.ah_reply_'+ahid).each(function(i){ 
		$(this).load('/includes/i_dynamic_quick_posts.asp?raid=20&rid='+ahid+'&count='+count+'&deleteF=refreshActionReplies('+ahid+','+count+')');	
	}); 
}

function quickPost(contentid, raid, rid, successF){
	var content = $('#'+contentid).val();
	asyncPostParams(content, 'text', raid, rid, '', successF);
}

function deleteQuickPost(postId, deleteF) {
	$.ajax({
		type: "GET",
		url: "/includes/i_dynamic_delete_post.asp?ppid="+postId,
		contentType: "application/x-www-form-urlencoded; charset=UTF-8",
		dataType: "html",
		data: {},
		success: function () {
			eval(deleteF);
		},
		error: function () {
			
		}
	});	
}

function asyncPostParams(p_content, p_post_type, p_raid, p_rid, p_rtpid, p_successF){
	cnt = encodeURIComponent(p_content);
	//cnt = cnt.replace(/%0A%0A/, '');
	$.ajax({
		type: "POST",
		url: "/includes/i_dynamic_create_post.asp",
		contentType: "application/x-www-form-urlencoded; charset=UTF-8",
		dataType: "html",
		data: { c: cnt, pt: p_post_type, raid: p_raid, rid: p_rid, rtpid: p_rtpid },
		success: function () {
			eval(p_successF);
		},
		error: function () {
			
		}
	});	
}


function asyncPost(form) {
	var cnt;
	if (form.post_type.value=='html') {
		cnt = window.document.getElementById("message").contentWindow.document.body.innerHTML;
		window.document.getElementById("message").contentWindow.document.body.innerHTML = '';
	} else {
		cnt = form.content.value;
		form.content.value='';
	}
	cnt = encodeURIComponent(cnt);
	//cnt = cnt.replace(/%0A%0A/, '');
	$.ajax({
		type: "POST",
		url: "/includes/i_dynamic_create_post.asp",
		contentType: "application/x-www-form-urlencoded; charset=UTF-8",
		dataType: "html",
		data: { c: cnt, pt: form.post_type.value, raid: form.raid.value, rid: form.rid.value, rtpid: form.replyToPostID.value },
		success: function () {
				if (form.replyToPostID.value != '') {
					setTimeout("showReplies("+form.replyToPostID.value+","+form.raid.value+","+form.rid.value+",'','"+form.autoexpand.value+"','','"+form.dte.value+"')", 500);
					form.replyToPostID.value = '';
				} else  {
					setTimeout("fetchPosts("+form.raid.value+", "+form.rid.value+", '"+form.container.value+"', 1,'','','"+form.autoexpand.value+"','"+form.ppids.value+"','"+form.dte.value+"', 1)", 500);
				}},
		error: function () {
			
		}
	});
}

function showReplies(postId, raid, rid, postseen, autoexpand, ppids,dte){
		$('#'+postId+'_page_post_replies').css("display", "block");
		fetchPosts(raid, rid, postId+'_page_post_replies', 1, postId, postseen, autoexpand, ppids,dte, 0);
}

function deletePost(postId, raid, rid, container, irtpd, p, postseen, autoexpand, ppids, dte) {
		showModalDialog("/includes/i_dynamic_delete_post.asp?ppid="+postId, 'Deleting post');
		if (irtpd != '') {
			setTimeout("showReplies("+irtpd+","+raid+","+rid+",'"+postseen+"','"+autoexpand+"','"+ppids+"','"+dte+"', 0)", 2000);
		} else  {
			setTimeout("fetchPosts("+raid+", "+rid+",'"+container+"',"+p+",'','"+postseen+"','"+autoexpand+"','"+ppids+"','"+dte+"',1)", 2000);
		}
}

function replyToPost(postId, raid, rid, container, p, postseen, autoexpand, ppids, dte){
	var form = document.getElementById("makePost");
	form.raid.value = raid;
	form.rid.value = rid;
	form.container.value = container;
	form.replyToPostID.value = postId;
	form.autoexpand.value = autoexpand;
	form.ppids.value = ppids;
	form.dte.value = dte;
	
	//move to box
	showModalDialogDiv('makePost', 'reply to post', 735);
	setTimeout('enableDesignMode()', 1000);
}

$.viewportHeight = function() {
	 return self.innerHeight ||
		jQuery.boxModel && document.documentElement.clientHeight ||
		document.body.clientHeight;
};

function openWin(url, name, w, h){
	var win = window.open(url,name,'width='+w+',height='+h+',scrollbars=no,toolbar=no,menubar=no');
	if (win) { 
		
	} else {
		
	}
};

function showInfoMsg(msg){
	$('#infoMsg').html(msg);
	$('#infoMsg').css("display", "block");	
}
function hideInfoAndErrMsg(){
	$('#errMsg').css("display", "none");	
	$('#infoMsg').css("display", "none");	
}
function showErrMsg(msg){
	$('#errMsg').html(msg);
	$('#errMsg').css("display", "block");	
}

function showMediaContainer(container, ctype, stype, scrid){
	$('#'+container).load('/includes/i_dynamic_media_container_edit.asp?ctype='+ctype+'&stype='+stype+'&scrid='+scrid+'&containingDiv='+container);
}

function deleteMediaAsync(ctype, stype, scrid, umid, container){
	var dialogStr = '/includes/i_dynamic_media_edit.asp?ctype='+ctype+'&stype='+stype+'&scrid='+scrid+'&umid='+umid+'&oncomplete=&action=delete'
	$.get(dialogStr, function(data){
		  showMediaContainer(container, ctype, stype, scrid);
	});					
}

function showMediaEditor(ctype, stype, scrid, umid, callback, action, width){
	var title = action == 'new' || action == '' ? 'upload a new '+ctype : 'edit '+ ctype;
	var dialogStr = '/includes/i_dynamic_media_edit_iframe.asp?ctype='+ctype+'&stype='+stype+'&scrid='+scrid+'&umid='+umid+'&oncomplete='+encodeURIComponent(callback)+'&action='+action;
	showModalDialog(dialogStr, title, width);
}

function showAlbumContainer(container, stype, scrid){
	$('#'+container).load('/includes/i_dynamic_album_container_edit.asp?stype='+stype+'&scrid='+scrid+'&containingDiv='+container);
}

function deleteAlbumAsync(stype, scrid, umaid, container){
	var dialogStr = '/includes/i_dynamic_album_edit.asp?ctype='+ctype+'&stype='+stype+'&scrid='+scrid+'&umaid='+umaid+'&oncomplete=&action=delete'
	$.get(dialogStr, function(data){
		  showMediaContainer(container, stype, scrid);
	});					
}

function showAlbumEditor(stype, scrid, umaid, callback, action, width){
	var title = action == 'new' || action == '' ? 'create a new albium' : 'edit album';
	var dialogStr = '/includes/i_dynamic_album_edit_iframe.asp?stype='+stype+'&scrid='+scrid+'&umaid='+umaid+'&oncomplete='+encodeURIComponent(callback)+'&action='+action;
	showModalDialog(dialogStr, title, width);
}

function requestResponse(status, reqid, container){
	$('#'+container).load('/includes/i_request_response.asp?status='+status+'&reqid='+reqid+'');
}

function addFriend(targetid, container){
	$('#'+container).load('/profiles/add_buddy.asp?bid='+targetid+'');
}
function removeFriend(targetid, container){
	$('#'+container).load('/profiles/remove_buddy.asp?bid='+targetid+'');
}
function refreshProfileControls(userId){
	$('#profileControls').load('/profiles/i_profile_controls.asp?pid='+userId);
}

function enableFeedControls(){
	 $('.activityItem').each(function(i){
		$('.ar_cont', this).bind('mouseenter', function(e){
			$('.activityRemove', this).attr('over','true');
			$('.activityRemove', this).css("visibility", "visible");
	  	});
		$('.activityRemove', this).bind('mouseleave', function(e){
			$(this).attr('over','false');
	  	});
		$(this).bind('mouseenter', function(e){
			$('.activityRemove', this).css("visibility", "visible");									
		});
		$(this).bind('mouseleave', function(e){
			$('.activityRemove', this).css("visibility", "hidden");	
		});
	 }); 
}

function hideFeedItem(uahid){
	$.get('/includes/i_dynamic_hide_action.asp?uahid='+uahid);
	$('.ua_item_'+uahid).each(function(i) {
		$(this).css('display','none');				   
	});
}

function setThreadFollow(threadid, follow, container){
	$('#'+container).load('/includes/i_dynamic_follow_thread.asp?threadid='+threadid+'&follow='+follow+'&container='+container);
	$('#follow').attr('checked', (follow==1 ? true : false));
}


function publishBlog(bid, p, container){
	$('#'+container).load('/includes/i_pb.asp?bid='+bid+'&p='+p+'&container='+container);
}


function publishEvent(eid, p, container, evalF){
	$('#'+container).load('/includes/i_eb.asp?eid='+eid+'&p='+p+'&container='+container, {},  function(data){
		  if(evalF!='' && evalF !=null){
			  eval(evalF);
		  }
	  });	
}


function featureEvent(eid, f, container, evalF){
	$('#'+container).load('/includes/i_ef.asp?eid='+eid+'&f='+f+'&container='+container+'&evalF='+evalF, {},  function(data){
		  if(evalF!='' && evalF !=null){
			  eval(evalF);
		  }
	  });	
}

function fetchEventsFP(){
	$('#fpEventContainer').load('/includes/i_fp_events.asp');
}

function setMRUOrder(parent, insertFirst, navigateAfter){
	var finalOrder = '';
	var parent = $('#'+parent);
	parent.prepend($('#mru_'+insertFirst));
	$('.mru_item').each(function(i) {
		if ($(this).attr("id") != null){
			finalOrder += "," + $(this).attr("id").replace("mru_", "");
		}
	});
	//save config
	$.get("/includes/i_saveConfig.asp?cn=quickLinksMRU&cv="+finalOrder, function(data){
		  if(navigateAfter!='' && navigateAfter !=null){
			  window.location = navigateAfter;
		  }
	});		
}


function registrationHelperCheckUsername(username){
	$.post("/includes/i_checkUsername.asp?u="+username, {},
	  function(data){
		helper = $('#reg_helper_check_username');
		if (data.exists == true){
			helper.attr('class', 'reg_helper_orange');
			helper.css("display", "inline-block");
			helper.html('login taken');
		}else if(data.exists == false){
			helper.attr('class', 'reg_helper_green');
			helper.css("display", "inline-block");
			helper.html('login available');	
		}
	  }, "json");
}

function registrationHelperSelectNearestSite(zipcode){
	$.post("/includes/i_getNearestNetwork.asp?z="+zipcode, {},
	  function(data){
		if (data.site_id != ''){
			$('#site').val(data.site_id);
			$('#reg_helper_selected_network').css("display", "inline-block");
		}
	  }, "json");

}

/** notes **/

function CreateNote(id,x,y,w,h,content, editable, deletable, tuid, authorlink, userid, mediaid) {
   
	var size = new PhotoNoteRect(x,y,w,h);
	var tagperson = (tuid != null);
	var note = new PhotoNote(content, id, size, authorlink, tagperson, tuid, userid);
	note.editable = editable;
	note.deletable = deletable;
	note.tuid = tuid;
	var theimage = $('#theimage');
	scalewidth = theimage.width();
	scaleheight = theimage.height();
	note.onsave = function (note) { 
		$.post("/includes/i_saveNote.asp", { nid: note.id, note_content: note.gui.TextBox.value, x:note.rect.left, y:note.rect.top, w:note.rect.width, h:note.rect.height, umid:mediaid,tuid:note.tuid, sw:scalewidth, sh:scaleheight},
		  function(data){
			note.id = data.nid;
			note.tuid = data.tuid;
		  }, "json");
		  return 1;
	};
	note.ondelete = function (note) { 
		$.post("/includes/i_deleteNote.asp", { nid: note.id },
		  function(data){
			note.id = data.nid;
		  }, "json");
		  return 1;
	};
	
	notes.AddNote(note);
}

function enableNotes() {
	$(".fn-area").css("display", "block");
}

function disableNotes() {
	$(".fn-area").css("display", "none");
}

function highlightTag(id, show){
	enableNotes();
	if (show) {
		$("#fn-"+id).addClass("fn-highlight");
	} else {
		$("#fn-"+id).removeClass("fn-highlight");
	}
}

function initFBAuth(sid){
	//user authetnicated so redirect to authenticator
	window.location='/fconnect/Authenticate.aspx?site='+sid;
}

function enterAlbumPassword(aid, password){
	$.post("/includes/i_album_authenticate.asp", { aid: aid, password: password },
	  function(data){
		location.reload(true);
	  }, "json");
}

/** onload events **/

$(document).ready(
	function()
	{  
		 $('#modalDiag').Draggable(	{ handle:'#modalDiagTitle', zIndex:1000 }  );
		setTimeout('autoRefreshAjaxContent(\'loadXMLDoc("/includes/i_notifications.asp", "notifications")\', 300000, 6)', 300000);
		
		loadContent();
		loadEipMarkers();
		enableFeedControls();
		
		$(document).keyup(function(event){
			if (event.keyCode == 27) {
				hideModalDialog();
			}
		});
		setTimeout("$('#expandableBanner').slideDown(1000, function() { });", 1000);

	}
);

