function GP_popupConfirmMsg(msg) 
{
  document.MM_returnValue = confirm(msg);
}

function imgopen(id)
{
		image = window.open("navigate/xtra/gallery/image_detail.php?pid="+id,"Bildinfo","scrollbars=no,resizable=no,width=680,height=430,screenX=100px,screenY=100px");
		image.focus();
}

function statopen(year, month, type)
{
		image = window.open("navigate/member/stats/arrows.php?year="+year+"&month="+month+"&type="+type,"Statestik","scrollbars=no,resizable=no,width=680,height=480,screenX=100px,screenY=100px");
		image.focus();
}
/*function img2open(id)
{
		image = window.open("image_detail.php?pid="+id,"Redigera","scrollbars=no,resizable=no,width=680,height=430,screenX=100px,screenY=100px");
		image.focus();
}*/

////

var smf_formSubmitted = false;

// Define document.getElementById for Internet Explorer 4.
if (typeof(document.getElementById) == "undefined")
	document.getElementById = function (id)
	{
		// Just return the corresponding index of all.
		return document.all[id];
	}

// Remember the current position.
function storeCaret(text)
{
	// Only bother if it will be useful.
	if (typeof(text.createTextRange) != 'undefined')
		text.caretPos = document.selection.createRange().duplicate();
}

// Replaces the currently selected text with the passed text.
function replaceText(text, textarea)
{
	// Attempt to create a text range (IE).
	if (typeof(textarea.caretPos) != "undefined" && textarea.createTextRange)
	{
		var caretPos = textarea.caretPos;

		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
		caretPos.select();
	}
	// Mozilla text range replace.
	else if (typeof(textarea.selectionStart) != "undefined")
	{
		var begin = textarea.value.substr(0, textarea.selectionStart);
		var end = textarea.value.substr(textarea.selectionEnd);
		var scrollPos = textarea.scrollTop;

		textarea.value = begin + text + end;

		if (textarea.setSelectionRange)
		{
			textarea.focus();
			textarea.setSelectionRange(begin.length + text.length, begin.length + text.length);
		}
		textarea.scrollTop = scrollPos;
	}
	// Just put it on the end.
	else
	{
		textarea.value += text;
		textarea.focus(textarea.value.length - 1);
	}
}

// Surrounds the selected text with text1 and text2.
function surroundText(text1, text2, textarea)
{
	// Can a text range be created?
	if (typeof(textarea.caretPos) != "undefined" && textarea.createTextRange)
	{
		var caretPos = textarea.caretPos;

		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text1 + caretPos.text + text2 + ' ' : text1 + caretPos.text + text2;
		caretPos.select();
	}
	// Mozilla text range wrap.
	else if (typeof(textarea.selectionStart) != "undefined")
	{
		var begin = textarea.value.substr(0, textarea.selectionStart);
		var selection = textarea.value.substr(textarea.selectionStart, textarea.selectionEnd - textarea.selectionStart);
		var end = textarea.value.substr(textarea.selectionEnd);
		var newCursorPos = textarea.selectionStart;
		var scrollPos = textarea.scrollTop;

		textarea.value = begin + text1 + selection + text2 + end;

		if (textarea.setSelectionRange)
		{
			if (selection.length == 0)
				textarea.setSelectionRange(newCursorPos + text1.length, newCursorPos + text1.length);
			else
				textarea.setSelectionRange(newCursorPos, newCursorPos + text1.length + selection.length + text2.length);
			textarea.focus();
		}
		textarea.scrollTop = scrollPos;
	}
	// Just put them on the end, then.
	else
	{
		textarea.value += text1 + text2;
		textarea.focus(textarea.value.length - 1);
	}
}

// Only allow form submission ONCE.
function submitonce(theform)
{
	smf_formSubmitted = true;
}
function submitThisOnce(item)
{
	// Hateful, hateful fix for Safari 1.3 beta.
	if (navigator.userAgent.indexOf('AppleWebKit') != -1)
		return !smf_formSubmitted;

	for (var i = 0; i < item.form.length; i++)
		if (typeof(item.form[i]) != "undefined" && item.form[i].tagName.toLowerCase() == "textarea")
			item.form[i].readOnly = true;

	return !smf_formSubmitted;
}

////

///// Bildpopup


//***---Detta visas då musen dras över bilden
PreviewText="Tryck för förstoring";

//***---Ruvriken av det nya fönster som innehåller den förstorade bilden
NewWindowTitle="Förstoring av bilden";

//***---Visas då musen förs över den förstorade bilden i det nya fönstret
ClickToCloseText="Tryck för att stänga fönstret";

function visaBild(imageURL, showFullSize, width, height)
{
newHeight=Math.round((height*showFullSize/width)/(height*showFullSize/width));
document.write("<A HREF=\"javascript:showFullSize('"+imageURL+"', "+width+", "+height+");\"><IMG SRC='"+imageURL+"' WIDTH='"+showFullSize+"' HEIGHT='"+newHeight+"' BORDER='0' ALT='"+PreviewText+"'></A>")
}


function showFullSize(imageURL, width, height)
{
NewImageWindow=window.open("", Math.round(Math.random()*10000000000), "width="+width+",height="+height);
NewImageWindow.document.open();
NewImageWindow.document.write("<HTML><HEAD>");
NewImageWindow.document.write("<TITLE>"+NewWindowTitle+"</TITLE>");
NewImageWindow.document.write("</HEAD>");
NewImageWindow.document.write("<BODY MARGINHEIGHT='0' TOPMARGIN='0' LEFTMARGIN='0' RIGHTMARGIN='0' MARGINWIDTH='0'>");
NewImageWindow.document.write("<TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0><TR><TD><A HREF='javascript:top.close();'><IMG SRC='"+imageURL+"' WIDTH='"+width+"' HEIGHT='"+height+"' ALT='"+ClickToCloseText+"' BORDER='0' HSPACE=0 VSPACE=0></A></TD></TR></TABLE>");
NewImageWindow.document.write("</BODY></HTML>");
}
////

/*
function insertValueQuery() {
    var myQuery = document.the_form.besk;
    var myListBox = document.the_form.dummy;

    if(myListBox.options.length > 0) {
        var chaineAj = "";
        var NbSelect = 0;
        for(var i=0; i<myListBox.options.length; i++) {
            if (myListBox.options[i].selected){
                NbSelect++;
                if (NbSelect > 1)
                    chaineAj += ", ";
                chaineAj += myListBox.options[i].value;
            }
        }

        //IE support
        if (document.selection) {
            myQuery.focus();
            sel = document.selection.createRange();
            sel.text = chaineAj;
            document.the_form.insert.focus();
        }
        //MOZILLA/NETSCAPE support
        else if (document.the_form.besk.selectionStart || document.the_form.besk.selectionStart == "0") {
            var startPos = document.the_form.besk.selectionStart;
            var endPos = document.the_form.besk.selectionEnd;
            var chaineSql = document.the_form.besk.value;

            myQuery.value = chaineSql.substring(0, startPos) + chaineAj + chaineSql.substring(endPos, chaineSql.length);
        } else {
            myQuery.value += chaineAj;
        }
    }
}
*/
