var OS,browser,version,total,thestring;

function getUserInfo()
{
	var detect = navigator.userAgent.toLowerCase();

	if (checkIt(detect, 'konqueror'))
	{
		browser = "Konqueror";
		OS = "Linux";
	}
	else if (checkIt(detect, 'safari')) browser = "Safari"
	else if (checkIt(detect, 'omniweb')) browser = "OmniWeb"
	else if (checkIt(detect, 'opera')) browser = "Opera"
	else if (checkIt(detect, 'webtv')) browser = "WebTV";
	else if (checkIt(detect, 'icab')) browser = "iCab"
	else if (checkIt(detect, 'msie')) browser = "Internet Explorer"
	else if	(checkIt(detect, 'firefox')) browser = "Firefox"
	else if (!checkIt(detect, 'compatible'))
	{
		browser = "Netscape Navigator"
		version = detect.charAt(8);
	}
	else browser = "An unknown browser";

	if (!version) version = detect.charAt(place + thestring.length);

	if (!OS)
	{
		if (checkIt(detect, 'linux')) OS = "Linux";
		else if (checkIt(detect, 'x11')) OS = "Unix";
		else if (checkIt(detect, 'mac')) OS = "Mac"
		else if (checkIt(detect, 'win')) OS = "Windows"
		else OS = "an unknown operating system";
	}
}

function checkIt(obj, string)
{
	place = obj.indexOf(string) + 1;
	thestring = string;
	return place;
}

function checkForCharacters(inputString, checkString, startingIndex)
{
	if (!startingIndex) startingIndex = 0;
	return inputString.indexOf(checkString);
}

function PopupWindow(Popup_Url, Popup_Height, Popup_Width, Popup_Unique)
{
	getUserInfo();

	try
	{
		var WindowArguments = null;
		var WindowArguments_IE = null;
		var newwindow = null;
		var Window_Left = 0;
		var Window_Top = 0;
//		var Dependent = 'dependent=1,';
		var Dependent = '';
//		var Modal = 'modal=yes,';
		var Modal = '';


		if(browser != 'Internet Explorer')
		{
			Window_Left=(screen.availWidth/2)-(Popup_Width/2);
			Window_Top=(screen.availHeight/2)-(Popup_Height/2);
	
			WindowArguments = 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,'+ Dependent + Modal +'height=' + Popup_Height + ',width=' + Popup_Width + ',left = ' + Window_Left + ',top = ' + Window_Top;

			newwindow = window.open(Popup_Url, Popup_Unique, WindowArguments);
		
			if (!newwindow.opener)
				newwindow.opener = self;
		
			if (window.focus)
				newwindow.focus();


		}
		else
		{
			Window_Left=(screen.availWidth/2)-(Popup_Width/2);
			Window_Top=(screen.availHeight/2)-(Popup_Height/2);
	
			WindowArguments_IE = 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,'+ Dependent + Modal +'height=' + Popup_Height + ',width=' + Popup_Width + ',left = ' + Window_Left + ',top = ' + Window_Top;


			newwindow = window.open(Popup_Url, Popup_Unique, WindowArguments_IE);

			if (!newwindow.opener)
				newwindow.opener = self;

			if (window.focus)
				newwindow.focus();


		}


	}
	catch(myError)
	{
		alert('An error occured!\n\n' + myError.name + ': ' + myError.message );
	}
	
	return newwindow;

}

function IsEmail()
{
	document.frmSend.btnSkicka.disabled=true;

	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(document.frmSend.email.value)))
	{
		alert("Du har inte fyllt i en korrekt email-adress!");
		document.frmSend.btnSkicka.disabled=false;
		document.frmSend.email.focus();
		return false;
	}
}