	
var winarr = new Array(2);
var current_image = 0;
	function get_old_file_data(fid)
	{
if(!fid) get_by_id('old_data').innerHTML = '<i>Data from the file you are replacing</i>';
 $.ajax({
   type: "POST",
   url: "http://www.staredit.net/ajax/ajaxs.php",
   data: "p=getOldFileData&id="+fid,
   success: function(msg){
	get_by_id('old_data').innerHTML = msg;
   }
 });
	}
	function sc2_gallery_move(pos)
	{
		if(pos == 'forward')
			current_image++;
		if(pos == 'back')
			current_image--;
		if(max_images == current_image) current_image = 0;
		if(current_image == -1) current_image = max_images - 1;
		get_by_id('popup_img').src = images[current_image];
		get_by_id('popup_max').innerHTML  = max_images;
		get_by_id('popup_current').innerHTML  = current_image+1;
		get_by_id('popup_desc').innerHTML  = images_desc[current_image];
	}
	function sc2_gallery(title)
	{
		in_popup_mode=1;
		create_popup();
		get_by_id('popup_header').innerHTML = title + ' images';;
		get_by_id('popup_img').src = images[0];
		get_by_id('popup_max').innerHTML  = max_images;
		get_by_id('popup_current').innerHTML  = current_image+1;
		get_by_id('popup_desc').innerHTML  = images_desc[0];

	}
	function create_popup()
	{
		realign_popup();
		$("#popup").css({"z-index": 99});
		
		$("#blackout").css({"z-index":95,"left":document.documentElement.scrollLeft,"height":total_doc_height,"width":"100%"});
		$("#popup").fadeIn("slow");
		$("#blackout").fadeIn();
	}
	function realign_popup()
	{
		get_window_dimensions();
		get_total_document_height();
		$("#popup").css({"width":winarr[0]-200,"height":winarr[1]-100,"-moz-border-radius":"10px"});
		popup_height = $("#popup").height();
		popup_width = $("#popup").width();
		$("#popup").css({"top":document.documentElement.scrollTop+winarr[1]/2-popup_height/2,"left":winarr[0]/2-popup_width/2});
		$("#popup_content").css({"height":winarr[1]-150});
	}
	function get_window_dimensions(){winarr[0]=document.documentElement.clientWidth;winarr[1]=document.documentElement.clientHeight;}
	function popup_close(){in_popup_mode=0;$("#popup").fadeOut("slow");$("#blackout").fadeOut();}
	function get_total_document_height(){total_doc_height=Math.max(Math.max(document.body.scrollHeight, document.documentElement.scrollHeight),Math.max(document.body.offsetHeight, document.documentElement.offsetHeight),Math.max(document.body.clientHeight, document.documentElement.clientHeight));}


var fav_open=0;
var rep_open=0;
function sc2map_favorite()
{
	if(!fav_open)
	{
		fav_open = 1;
	box_offset = $('#s2m_favorites').offset();
		$("#favorite_popup").css({"top":box_offset.top+25,"left":box_offset.left-20});
		$("#favorite_popup").fadeIn('fast');
	}
	else
		{
		fav_open = 0;
		$("#favorite_popup").fadeOut('fast');
	}
}
function sc2map_report()
{
	if(!rep_open)
	{
		rep_open = 1;
		box_offset = $('#s2m_report').offset();
		$("#small_popup").css({"top":box_offset.top+25,"left":box_offset.left-30});
		get_by_id('small_popup').innerHTML = 'Report';
		$("#small_popup").fadeIn('fast');
	}
	else
		{
		$("#small_popup").fadeOut('fast');
		rep_open = 0;
	}
}

function clear_quicksearch()
{
if (get_by_id('quicksearch').value == 'Quick Search')
{
get_by_id('quicksearch').value = '';
get_by_id('quicksearch').style.fontStyle = 'normal';
get_by_id('quicksearch').style.color = '#FFF';
get_by_id('quicksearch').style.width = '125px';
}
}


function sc2map_page(page, fid)
{
//get_by_id('sc2map_content').innerHTML = '<div class="box"><br />Loading new content.  You shouldn&#39;t see this message for long.</div>';
 $.ajax({
   type: "POST",
   url: "http://www.staredit.net/ajax/jajax.php",
   data: "p=sc2maps&id="+fid+"&sub="+page,
   success: function(msg){
get_by_id('sc2map_content').innerHTML = msg;
   }
 });
}



function sc2map_edit(page, fid)
{
 $.ajax({
   type: "POST",
   url: "http://www.staredit.net/ajax/jajax.php",
   data: "p=sc2mapsedit&id="+fid+"&t="+page,

   success: function(msg){
get_by_id('sc2map_content').innerHTML = msg;
   }
 });
}

