function getArgument(name)
{
    var arguments = window.location.search;
    var start_pos = arguments.indexOf("?"+name+"=");

    if( start_pos < 0 )
    {
        start_pos = arguments.indexOf("&"+name+"=");
    }

    if( start_pos < 0 )
    {
        return "";
    }

    arguments = arguments.substr( start_pos + name.length + 2, arguments.length );

    var end_pos = arguments.indexOf("&");

    if(end_pos != -1)
    {
        arguments = arguments.substr( 0, end_pos );
    }

    return arguments;

}


var open_window = null;

function popUpSmall(url)
{
    //open_window = window.open(url,'small_popup','width=360 height=160 menu=no resizable=yes scrollbars=no');
    popUp(url,360,160,'menu=no, resizable=yes, scrollbars=no')
}

function popUpLarge(url)
{
    //open_window = window.open(url,'question_library_popup','width=500 height=500 menu=no resizable=yes scrollbars=yes');
    popUp(url,500,600,'menu=yes, resizable=yes, scrollbars=yes')
}

function popUp(url,w,h,attrib)
{
    if (w>0 && (parseInt(navigator.appVersion)) >= 4)
    {
		winX = (screen.availWidth - w)/2;
		winY = (screen.availHeight - h)/2;
	}

	if(w>0)
	{
		open_window = window.open(url,'PopupWindow','width=' + w + ',height=' + h + ',left=' + winX + ',top=' + winY + ',dependent '+attrib);
	    open_window.opener = window;
	    open_window.opener.name = "opener"
	}
	else
	{
		//open_window = window.open(url,'PopupWindow','menu=no resizable=yes scrollbars=yes');
    }
}

function closePopUp()
{
    if( open_window != null )
    {
        open_window.close();
    }
}

// ---------------------------------------

function testIfResized() {
	
	var str="" + window.location;
	var posAction=str.indexOf("id="); // The first page that use extra_index.xslt
	var posResized=str.indexOf("resized=true"); // Check if already resized.
	
	if (posAction>0) {
		if (posResized>0) {
			resized=true;
		} else {
			resized=false;
		}
	
		if (!resized) {
			url = str + "&resized=true";
			popUp(url,500,600,'toolbar=yes, directories=no, status=yes, menubar=no, scrollbars=yes, resizable=yes');
			open_window.opener.location="http://www.collecta.nu/survey/surveywasopened.html";
			open_window.focus();
			// open_window.opener.close();
		}
	}
}
