
$(document).ready(function() {

	$('#fptopbox .tabs a').click(function(e) {
	
		$('#fptopbox .tabs a.active').removeAttr('class');
		$('#fptopbox .tabs a').eq($("#fptopbox .tabs a").index(this)).attr('class','active');
		$('#fptopbox table').hide();
		$('#fptopbox table').eq($("#fptopbox .tabs a").index(this)).show();
		e.preventDefault();
	});

	$('#searchfield').val($('#searchfield').attr('hover')).click(function(){if($(this).attr('value') == $('#searchfield').attr('hover')){$(this).val('')}}).blur(function(){if($(this).attr('value') == ''){$(this).val($('#searchfield').attr('hover'))}})

	positionSub('sub1', 'dd_forum');
	positionSub('sub2', 'dd_om');
	positionSub('sub3', 'dd_events');
	$(window).resize(function() {
		positionSub('sub1', 'dd_forum');
		positionSub('sub2', 'dd_om');
		positionSub('sub3', 'dd_events');
	});

	var thatMenu;
	var timeout = false;
	$('#CTmenu .sub1').hover(function() {
			if (thatMenu) {
				$(thatMenu).hide();
			}
		clearTimeout(timeout);
		timeout = false;
		thatMenu = $('#CTmenu #dd_forum');
		thatMenu.show();
	}, function() {
		timeout = setTimeout(function() {
			$('#CTmenu #dd_forum').hide();
		}, 500);
		
	});


	$('#CTmenu .sub2').hover(function() {
			if (thatMenu) {

				$(thatMenu).hide();
			}
		clearTimeout(timeout);
		timeout = false;
		thatMenu = $('#CTmenu #dd_om');
		thatMenu.show();
	}, function() {
		timeout = setTimeout(function() {
			$('#CTmenu #dd_om').hide();
		}, 500);
		
	});

	$('#CTmenu .sub3').hover(function() {
			if (thatMenu) {
				$(thatMenu).hide();
			}
		clearTimeout(timeout);
		timeout = false;
		thatMenu = $('#CTmenu #dd_events');
		thatMenu.show();
	}, function() {
		timeout = setTimeout(function() {
			$('#CTmenu #dd_events').hide();
		}, 500);
		
	});
	
	$("#CTmenu #dd_om").hover( 
		function () {
			clearTimeout(timeout);
			timeout = false;
		},  
		function () { 
			var thatMenu = this;
			timeout = setTimeout(function() {
				$(thatMenu).hide();
			}, 500);
		} 
	); 
	
	$("#CTmenu #dd_events").hover( 
		function () {
			clearTimeout(timeout);
			timeout = false;
		},  
		function () { 
			var thatMenu = this;
			timeout = setTimeout(function() {
				$(thatMenu).hide();
			}, 500);
		} 
	); 
	
	$("#CTmenu #dd_forum").hover( 
		function () {
			clearTimeout(timeout);
			timeout = false;
		},  
		function () { 
			var thatMenu = this;
			timeout = setTimeout(function() {
				$(thatMenu).hide();
			}, 500);
		} 
	); 
	/*
	$('#profile_dd_click').click(function() {
		var ddmenu = $('#profile_dd_menu');
		if (ddmenu.is(':visible')) {
			ddmenu.hide();
		} else {
			ddmenu.show();		
		}

	});
	*/
});

function positionSub(parentClass, subId) {
	var subOffset = $('.'+parentClass).offset();
	$('#CTmenu #'+subId).css({
		'top': subOffset.top-15 +'px',
		'left': subOffset.left-20 +'px'
	});
}











/**
 * SWFObject v1.4.4: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * **SWFObject is the SWF embed script formerly known as FlashObject. The name was changed for
 *   legal reasons.
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}
if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}
if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}
deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b){if(!document.getElementById){return;}
this.DETECT_KEY=_b?_b:"detectflash";
this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);
this.params=new Object();
this.variables=new Object();
this.attributes=new Array();
if(_1){this.setAttribute("swf",_1);}
if(id){this.setAttribute("id",id);}
if(w){this.setAttribute("width",w);}
if(h){this.setAttribute("height",h);}
if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}
this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();
if(c){this.addParam("bgcolor",c);}
var q=_8?_8:"high";
this.addParam("quality",q);
this.setAttribute("useExpressInstall",_7);
this.setAttribute("doExpressInstall",false);
var _d=(_9)?_9:window.location;
this.setAttribute("xiRedirectUrl",_d);
this.setAttribute("redirectUrl","");
if(_a){this.setAttribute("redirectUrl",_a);}};
deconcept.SWFObject.prototype={setAttribute:function(_e,_f){
this.attributes[_e]=_f;
},getAttribute:function(_10){
return this.attributes[_10];
},addParam:function(_11,_12){
this.params[_11]=_12;
},getParams:function(){
return this.params;
},addVariable:function(_13,_14){
this.variables[_13]=_14;
},getVariable:function(_15){
return this.variables[_15];
},getVariables:function(){
return this.variables;
},getVariablePairs:function(){
var _16=new Array();
var key;
var _18=this.getVariables();
for(key in _18){_16.push(key+"="+_18[key]);}
return _16;},getSWFHTML:function(){var _19="";
if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){
if(this.getAttribute("doExpressInstall")){
this.addVariable("MMplayerType","PlugIn");}
_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\"";
_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";
var _1a=this.getParams();
for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}
var _1c=this.getVariablePairs().join("&");
if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";
}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");}
_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\">";
_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";
var _1d=this.getParams();
for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}
var _1f=this.getVariablePairs().join("&");
if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}
return _19;
},write:function(_20){
if(this.getAttribute("useExpressInstall")){
var _21=new deconcept.PlayerVersion([6,0,65]);
if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){
this.setAttribute("doExpressInstall",true);
this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));
document.title=document.title.slice(0,47)+" - Flash Player Installation";
this.addVariable("MMdoctitle",document.title);}}
if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){
var n=(typeof _20=="string")?document.getElementById(_20):_20;
n.innerHTML=this.getSWFHTML();return true;
}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}
return false;}};
deconcept.SWFObjectUtil.getPlayerVersion=function(){
var _23=new deconcept.PlayerVersion([0,0,0]);
if(navigator.plugins&&navigator.mimeTypes.length){
var x=navigator.plugins["Shockwave Flash"];
if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}
}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}
catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}
catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}
catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}
return _23;};
deconcept.PlayerVersion=function(_27){
this.major=_27[0]!=null?parseInt(_27[0]):0;
this.minor=_27[1]!=null?parseInt(_27[1]):0;
this.rev=_27[2]!=null?parseInt(_27[2]):0;
};
deconcept.PlayerVersion.prototype.versionIsValid=function(fv){
if(this.major<fv.major){return false;}
if(this.major>fv.major){return true;}
if(this.minor<fv.minor){return false;}
if(this.minor>fv.minor){return true;}
if(this.rev<fv.rev){
return false;
}return true;};
deconcept.util={getRequestParameter:function(_29){
var q=document.location.search||document.location.hash;
if(q){var _2b=q.substring(1).split("&");
for(var i=0;i<_2b.length;i++){
if(_2b[i].substring(0,_2b[i].indexOf("="))==_29){
return _2b[i].substring((_2b[i].indexOf("=")+1));}}}
return "";}};
deconcept.SWFObjectUtil.cleanupSWFs=function(){if(window.opera||!document.all){return;}
var _2d=document.getElementsByTagName("OBJECT");
for(var i=0;i<_2d.length;i++){_2d[i].style.display="none";for(var x in _2d[i]){
if(typeof _2d[i][x]=="function"){_2d[i][x]=function(){};}}}};
deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};
__flash_savedUnloadHandler=function(){};
if(typeof window.onunload=="function"){
var _30=window.onunload;
window.onunload=function(){
deconcept.SWFObjectUtil.cleanupSWFs();_30();};
}else{window.onunload=deconcept.SWFObjectUtil.cleanupSWFs;}};
if(typeof window.onbeforeunload=="function"){
var oldBeforeUnload=window.onbeforeunload;
window.onbeforeunload=function(){
deconcept.SWFObjectUtil.prepUnload();
oldBeforeUnload();};
}else{window.onbeforeunload=deconcept.SWFObjectUtil.prepUnload;}
if(Array.prototype.push==null){
Array.prototype.push=function(_31){
this[this.length]=_31;
return this.length;};}
var getQueryParamValue=deconcept.util.getRequestParameter;
var FlashObject=deconcept.SWFObject;
var SWFObject=deconcept.SWFObject;






resize_confMaxDim = 560; // pixels

function resize_resize(obj) {

   thisWidth = obj.width;
   thisHeight = obj.height;
   
   if(thisWidth > thisHeight) thisMaxDim = thisWidth;
   else thisMaxDim = thisHeight;
   
   if(thisMaxDim > resize_confMaxDim) {
      thisMinDim = Math.round((((thisWidth > thisHeight)?thisHeight:thisWidth) * resize_confMaxDim) / thisMaxDim); 
      
      if(thisWidth > thisHeight) {
         thisWidth = resize_confMaxDim;
         thisHeight = thisMinDim;
      } else {
         thisHeight = resize_confMaxDim;
         thisWidth = thisMinDim;
      }
   } 
   
   if(thisMaxDim > resize_confMaxDim) {
   obj.height = thisHeight;
   obj.width = thisWidth;
   }
}

var ori_pic_width = [];
function final_resize() {
// x.length
	var x=getElementsByClass("postlink");
	max_length = 85;
	for (var i = 0; i < x.length; i++){
		x[i].target = "_blank";
		link_value = x[i].innerHTML;
		has_images = 0;
		
		if (link_value.length > max_length) {
			var children = x[i].childNodes;
			for (var j=0; j<children.length; j++) {
			 	if (children[j].nodeName == "IMG") {
			 		has_images = 1;
			 	}
			}
			if (has_images == 0) {
				x[i].title = link_value;
				x[i].innerHTML = link_value.substring(0, max_length-3) + "...";
			}
		}
	}
	var x=getElementsByClass("postlink-local");
	for (var i = 0; i < x.length; i++){
		x[i].target = "_blank";
		//alert(x[i].href);
	}
	//alert(c);


 var x=document.getElementsByName("thread_pic");
 for (i=0; i < x.length; i++) {
obj = x[i];

   thisWidth = obj.width;
   thisHeight = obj.height;
   
   
   if(thisWidth > thisHeight) thisMaxDim = thisWidth;
   else thisMaxDim = thisHeight;
   
   thisSrc = obj.src;
   ori_pic_width[thisSrc] = thisWidth;
   
   if(thisMaxDim > resize_confMaxDim) {
      
      thisMinDim = Math.round((((thisWidth > thisHeight)?thisHeight:thisWidth) * resize_confMaxDim) / thisMaxDim); 
      
      if(thisWidth > thisHeight) {
         thisWidth = resize_confMaxDim;
         thisHeight = thisMinDim;
      } else {
         thisHeight = resize_confMaxDim;
         thisWidth = thisMinDim;
      }
      
      
      obj.height = thisHeight;
      obj.width = thisWidth;
   }
  }
 
 var cont=document.getElementById("containerCenter");
 if (cont) {
 x = cont.getElementsByTagName('img');
 for (i=0; i < x.length; i++) {
	 obj = x[i];

	    thisWidth = obj.width;
	    thisHeight = obj.height;
	    
	    
	    if(thisWidth > thisHeight) thisMaxDim = thisWidth;
	    else thisMaxDim = thisHeight;
	    
	    thisSrc = obj.src;
	    ori_pic_width[thisSrc] = thisWidth;
	    
	    if(thisMaxDim > resize_confMaxDim) {
	       
	       thisMinDim = Math.round((((thisWidth > thisHeight)?thisHeight:thisWidth) * resize_confMaxDim) / thisMaxDim); 
	       
	       if(thisWidth > thisHeight) {
	          thisWidth = resize_confMaxDim;
	          thisHeight = thisMinDim;
	       } else {
	          thisHeight = resize_confMaxDim;
	          thisWidth = thisMinDim;
	       }
	       
	       
	       obj.height = thisHeight;
	       obj.width = thisWidth;
	    }
	   }
 }
}

function normal_size(obj) {

	thisSrc = obj.src;
	new_resize_width = ori_pic_width[thisSrc];
      
   thisWidth = obj.width;
   thisHeight = obj.height;
   
   
   if(thisWidth > thisHeight) thisMaxDim = thisWidth;
   else thisMaxDim = thisHeight;
   
   
   if(thisMaxDim != new_resize_width) {
   	   
	      ori_pic_width[thisSrc] = thisMaxDim;	      
	      thisMinDim = Math.round((((thisWidth > thisHeight)?thisHeight:thisWidth) * new_resize_width) / thisMaxDim); 
	      	      
	      if(thisWidth > thisHeight) {
	         thisWidth = new_resize_width;
	         thisHeight = thisMinDim;
	      } else {
	         thisHeight = new_resize_width;
	         thisWidth = thisMinDim;
	      }
	      
	      
	      obj.height = thisHeight;
	      obj.width = thisWidth;
  }
}


function resize_setLink(obj) {
   thisInnerHtml = obj.innerHTML;
   tmpArray = thisInnerHtml.split(' src=\"');
   tmpArray = tmpArray[1].split('"');
   obj.href = tmpArray[0];
}


function changeContent(div_id) 
{ 
document.getElementById(div_id).innerHTML = window.frames['iframe-'+div_id].document.getElementsByTagName('html')[0].innerHTML; 
}

var loaded_images = [];
var ran_num = [];
var tag_data = [];
var my_images_divs = [];
var t;
function changeMyImages(div_id) { 
	my_num = my_images_divs.length;
	my_images_divs[div_id] = div_id;
	clearTimeout(t);
	t = setTimeout('genTags()',750);
} 

my_images_last = [];
my_images_data = [];
function genTags() {
	my_images_ids = "";
	for (var i in my_images_divs) {
		all_divs = $('div[name='+i+'_tags]');
		$(all_divs).each(function(id){
			new_id = i+'_'+id;
			$(this).attr("id",new_id);
			my_images_last[new_id] = i;
		});
		my_images_ids += i+',';
		
	}
	//alert(my_images_ids);
	$.get("my_images_iframe.php?t="+Math.random(), { ids: my_images_ids}, function(data){
		all_data = data.split("|||");
		for (var i in all_data) {
			small_data = [];
			small_data = all_data[i].split("||");
			my_images_data[small_data[0]] = small_data[1]+'|||'+small_data[2];
		}
		
		createTags();
	});
}

function createTags() {
	for (var i in my_images_last) {
		my_data = my_images_data[my_images_last[i]].split("|||");
		$('#'+i).html('<img id="'+i+'_image" src="/my_images/images/'+my_data[0]+'" onload="insertTags(\''+i+'\');">');
		$('#'+i).after('<div id="'+i+'_imagetags" class="tags">&nbsp;</div>');
	}
}

function insertTags(id) {
	my_data = my_images_data[my_images_last[id]].split("|||");
	json_obj = eval(my_data[1]);
	$('#'+id).imgNotes(json_obj, id);
	$('#'+id).updateTags(id);
	
}


function SelectedPosts() {

var x = document.getElementsByName("check_posts");
boxes = document.getElementsByName("check_posts").length;
values = ""
do_value = ""
for (i = 0; i < boxes; i++) {
if (x[i].checked) {

if (do_value != "") do_value = "-"+x[i].value;
else do_value = x[i].value;

values = values + do_value;
}
}

var y = document.getElementsByName("do_check_posts");
y[0].value = values;

if (values == "") {
alert("Du har ikke valgt nogle indlęg!");
return false;
} else {
return true;
}
}

function getElementsByClass( searchClass, domNode, tagName) {
	if (domNode == null) domNode = document;
	if (tagName == null) tagName = '*';
	var el = new Array();
	var tags = domNode.getElementsByTagName(tagName);
	var tcl = " "+searchClass+" ";
	for(i=0,j=0; i<tags.length; i++) {
		var test = " " + tags[i].className + " ";
		if (test.indexOf(tcl) != -1)
			el[j++] = tags[i];
	}
	return el;
}





/**
 * imgnotes jQuery plugin
 * version 0.1
 *
 * Copyright (c) 2008 Dr. Tarique Sani <tarique@sanisoft.com>
 *
 * Dual licensed under the MIT (MIT-LICENSE.txt) 
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * @URL      http://www.sanisoft.com/blog/2008/05/26/img-notes-jquery-plugin/
 * @Example  example.html
 *
 **/


function display_tag(notenum) {
	$("#note_"+notenum).css('border', '2px solid rgb(255, 255, 255)');
	$("#notep_"+notenum).show();
}
function hide_tag(notenum) {
	$("#note_"+notenum).css('border', '0px');
	$("#notep_"+notenum).hide();
			
}

//Wrap in a closure
(function($) {

	$.fn.imgNotes = function(n, div_id) {
		
		if(undefined != n){
			notes = n;
		} 
				
		if (!$.noteNumber) {
			$.noteNumber = 0;
		}
		
		if (!$.allNotes) {
			$.allNotes = [];
		}
		if (!$.divTags) {
			$.divTags = [];
		}
		if (!$.allTags) {
			$.allTags = [];
			$.allTagsRemove = [];
		}
				
		$.disable_hover = 0;
		
		image = this;
		
		imgOffset = $(image).offset();
		
		$(notes).each(function(){
			if (this.width != undefined) {
				appendnote(this, div_id);
			}
		});

		addnoteevents();
		
		$(window).resize(function () {

			$('.note').remove();

			imgOffset = $(image).offset();

			$(notes).each(function(){
				appendnote(this);				
			});

			addnoteevents();

		});
	} 
	
	function addnoteevents() {
	
	}


	function appendnote(note_data, div_id){
		
		$.allNotes[$.noteNumber] = note_data;
		
		//alert(note_data);
		
		note_left  = parseInt(imgOffset.left) + parseInt(note_data.x1);
		note_top   = parseInt(imgOffset.top) + parseInt(note_data.y1);
		note_p_left = note_left + (parseInt(note_data.width)/2)-15;
		note_p_top = note_top + (parseInt(note_data.height)/2)-6;

		//alert(div_id);
		
		note_tag = note_data.note;
		var note_tag=note_tag.split("|"); 
		
		note_overlay = note_tag[1];
		if (note_tag[0] == 0) {
			note_tag_final = note_tag[1];
		} else {
			note_tag_final = '<a href="/memberlist.php?mode=viewprofile&u='+note_tag[0]+'" target="_blank">'+note_tag[1]+'</a>';
		}
		
		note_area_div = $("<div class='note' onmouseover='display_tag(\""+$.noteNumber+"\")' onmouseout='hide_tag(\""+$.noteNumber+"\")' id='note_"+$.noteNumber+"'></div>").css({ left: note_left + 'px', top: note_top + 'px', width: note_data.width + 'px', height: note_data.height + 'px' });	
		note_text_div = $('<div class="notep" name="'+div_id+'_notep" id="notep_'+$.noteNumber+'">'+note_overlay+'</div>').css({ left: note_p_left + 'px', top: note_p_top + 'px'});
	
		$('body').append(note_area_div);
		$('body').append(note_text_div);
		
		
		// Append note text below img

		if ($.allTags[div_id] == undefined) {
			comma_sep = ""; 
			$.allTags[div_id] = "";
		}
		if ($.allTagsRemove[div_id] == undefined) {
			$.allTagsRemove[div_id] = "";
		}
		else comma_sep = ", ";
		$.allTags[div_id] += comma_sep+'<span id="tag_'+$.noteNumber+'"><span onmouseover="display_tag(\''+$.noteNumber+'\')" onmouseout="hide_tag(\''+$.noteNumber+'\')">'+note_tag_final+'</span></span>';
		$.allTagsRemove[div_id] += comma_sep+'<span id="tag_'+$.noteNumber+'"><span onmouseover="display_tag(\''+$.noteNumber+'\')" onmouseout="hide_tag(\''+$.noteNumber+'\')">'+note_tag_final+'</span> (<a href="#" onclick="noteRemove('+$.noteNumber+'); return false;">fjern</a>)</span>';
		//$.divTags[]
		
		$.noteNumber++;
	}
	
	// Public methods
	var newMethods = {
		hoverDisable : function() {
			$.disable_hover = 1;
		},
		hoverEnable : function() {
			$.disable_hover = 0;
		},
		getData : function() {
			return $.allNotes;
		},
		updateTags : function(div_id) {
			//$('#'+div_id+'_imagetags').html('');
			//alert($.allTags);
			if ($.allTags[div_id] != undefined) {
				$('#'+div_id+'_imagetags').html($.allTags[div_id]);
			}
		},
		updateTagsRemove : function(div_id) {
			//$('#'+div_id+'_imagetags').html('');
			//alert($.allTags);
			if ($.allTagsRemove[div_id] != undefined) {
				$('#'+div_id+'_imagetags').html($.allTagsRemove[div_id]);
			}
		},
		resetTags : function() {
			$.disable_hover = 1;
			$.allTags = [];
			$.allTagsNoRemove = [];
		}
	};
	// Load public methods
	jQuery.each(newMethods, function(i) {
		jQuery.fn[i] = this;
	});

// End the closure
})(jQuery);





function show_note(e) {
	var xOffset = 10;
	var yOffset = 30;
	
	var t = $(e).attr('tooltiptitle');
	var my_offset = $(e).offset();
		
	$("<p id='tooltip'>"+ t +"</p>")
		.css("top", (my_offset.top - xOffset) + "px")
		.css("left", (my_offset.left + yOffset) + "px")
		.fadeIn("fast")
		.appendTo(document.body);
}
function remove_note() {
	$("#tooltip").remove();
}

/**
* phpBB3 forum functions
*/

/**
* Window popup
*/
function popup(url, width, height, name)
{
	if (!name)
	{
		name = '_popup';
	}

	window.open(url.replace(/&amp;/g, '&'), name, 'height=' + height + ',resizable=yes,scrollbars=yes, width=' + width);
	return false;
}

/**
* Jump to page
*/
function jumpto()
{
	var page = prompt(jump_page, on_page);

	if (page !== null && !isNaN(page) && page > 0)
	{
		document.location.href = base_url.replace(/&amp;/g, '&') + '&start=' + ((page - 1) * per_page);
	}
}

/**
* Mark/unmark checklist
* id = ID of parent container, name = name prefix, state = state [true/false]
*/
function marklist(id, name, state)
{
	var parent = document.getElementById(id);
	if (!parent)
	{
		eval('parent = document.' + id);
	}

	if (!parent)
	{
		return;
	}

	var rb = parent.getElementsByTagName('input');
	
	for (var r = 0; r < rb.length; r++)
	{	
		if (rb[r].name.substr(0, name.length) == name)
		{
			rb[r].checked = state;
		}
	}
}

/**
* Resize viewable area for attached image or topic review panel (possibly others to come)
* e = element
*/
function viewableArea(e, itself)
{
	if (!e) return;
	if (!itself)
	{
		e = e.parentNode;
	}
	
	if (!e.vaHeight)
	{
		// Store viewable area height before changing style to auto
		e.vaHeight = e.offsetHeight;
		e.vaMaxHeight = e.style.maxHeight;
		e.style.height = 'auto';
		e.style.maxHeight = 'none';
		e.style.overflow = 'visible';
	}
	else
	{
		// Restore viewable area height to the default
		e.style.height = e.vaHeight + 'px';
		e.style.overflow = 'auto';
		e.style.maxHeight = e.vaMaxHeight;
		e.vaHeight = false;
	}
}

/**
* Set display of page element
* s[-1,0,1] = hide,toggle display,show
*/
function dE(n, s)
{
	var e = document.getElementById(n);

	if (!s)
	{
		s = (e.style.display == '' || e.style.display == 'block') ? -1 : 1;
	}
	e.style.display = (s == 1) ? 'block' : 'none';
}

/**
* Alternate display of subPanels
*/
function subPanels(p)
{
	var i, e, t;

	if (typeof(p) == 'string')
	{
		show_panel = p;
	}

	for (i = 0; i < panels.length; i++)
	{
		e = document.getElementById(panels[i]);
		t = document.getElementById(panels[i] + '-tab');

		if (e)
		{
			if (panels[i] == show_panel)
			{
				e.style.display = 'block';
				if (t)
				{
					t.className = 'activetab';
				}
			}
			else
			{
				e.style.display = 'none';
				if (t)
				{
					t.className = '';
				}
			}
		}
	}
}

/**
* Call print preview
*/
function printPage()
{
	if (is_ie)
	{
		printPreview();
	}
	else
	{
		window.print();
	}
}

/**
* Show/hide groups of blocks
* c = CSS style name
* e = checkbox element
* t = toggle dispay state (used to show 'grip-show' image in the profile block when hiding the profiles) 
*/
function displayBlocks(c, e, t)
{
	var s = (e.checked == true) ?  1 : -1;

	if (t)
	{
		s *= -1;
	}

	var divs = document.getElementsByTagName("DIV");

	for (var d = 0; d < divs.length; d++)
	{
		if (divs[d].className.indexOf(c) == 0)
		{
			divs[d].style.display = (s == 1) ? 'none' : 'block';
		}
	}
}

function selectCode(a)
{
	// Get ID of code block
	var e = a.parentNode.parentNode.getElementsByTagName('CODE')[0];

	// Not IE
	if (window.getSelection)
	{
		var s = window.getSelection();
		// Safari
		if (s.setBaseAndExtent)
		{
			s.setBaseAndExtent(e, 0, e, e.innerText.length - 1);
		}
		// Firefox and Opera
		else
		{
			var r = document.createRange();
			r.selectNodeContents(e);
			s.removeAllRanges();
			s.addRange(r);
		}
	}
	// Some older browsers
	else if (document.getSelection)
	{
		var s = document.getSelection();
		var r = document.createRange();
		r.selectNodeContents(e);
		s.removeAllRanges();
		s.addRange(r);
	}
	// IE
	else if (document.selection)
	{
		var r = document.body.createTextRange();
		r.moveToElementText(e);
		r.select();
	}
}

/**
* Play quicktime file by determining it's width/height
* from the displayed rectangle area
*/
function play_qt_file(obj)
{
	var rectangle = obj.GetRectangle();

	if (rectangle)
	{
		rectangle = rectangle.split(',');
		var x1 = parseInt(rectangle[0]);
		var x2 = parseInt(rectangle[2]);
		var y1 = parseInt(rectangle[1]);
		var y2 = parseInt(rectangle[3]);

		var width = (x1 < 0) ? (x1 * -1) + x2 : x2 - x1;
		var height = (y1 < 0) ? (y1 * -1) + y2 : y2 - y1;
	}
	else
	{
		var width = 200;
		var height = 0;
	}

	obj.width = width;
	obj.height = height + 16;

	obj.SetControllerVisible(true);
	obj.Play();
}
function hide(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}
function show(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}

