var gOs 					=			navigator.platform;					// client running on ( Win, Mac, Linux, SunOS )..

var gBrowser				=			( document.all ) ? 'IE' : 'NN'; 	// client browser

var gVersion				=			navigator.appVersion;



function incolor(id)

{

	document.all[id].style.backgroundColor = "#AACCCC";

}



function outcolor(id)

{

	document.all[id].style.backgroundColor = "#F4F4F4";

}

function mincolor(id)

{

	document.all[id].style.backgroundColor = "#AACCCC";

}



function moutcolor(id)

{

	document.all[id].style.backgroundColor = "";

}



function NewWin(sURL, height, width) {
	properties="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=YES,resizable=yes,";
	properties=properties + ",width=" + width;
	properties=properties + ",height=" + height;
	objWin = window.open(sURL,"proVISTA",properties);
	objWin.focus();
}

function echeck(str) {
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Ej korrekt e-postadress angiven")
		   return false
		}



		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Ej korrekt e-postadress angiven")
		   return false
		}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Ej korrekt e-postadress angiven")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Ej korrekt e-postadress angiven")
            	    return false

		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Ej korrekt e-postadress angiven")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Ej korrekt e-postadress angiven")
		    return false
		 }

		 if (str.indexOf(" ")!=-1){
		    alert("Ej korrekt e-postadress angiven")
		    return false
		 }
		 return true
	}



function ValidateForm(){
	var emailID=document.medlem.epost
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Ni måste ange er e-post!")
		emailID.focus()
		return false
	}

	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }



function hl(row, color) {
 if (typeof(row.style) == 'undefined' || typeof(row.cells) == 'undefined') {
 return false;
}

row.style.backgroundColor = color;
}
function LimitInput(control, outputCtrl, e)
{
	//
	if(control.value.length > control.attributes["maxLength"].value)
	{
		control.value = control.value.substring(0,control.attributes["maxLength"].value);
	}
	outputCtrl.innerHTML =  control.attributes["maxLength"].value - control.value.length;
	if( !e )
	{
		//if the browser did not pass the event information to the
		//function, we will have to obtain it from the event register
		if( window.event )
		{
			//Internet Explorer
			e = window.event;
		}
		else
		{
			//total failure, we have no way of referencing the event
			return;
		}
	}
	if( typeof( e.keyCode ) == '46'  )
	{
		//DOM
		e = e.keyCode;
		outputCtrl.innerHTML =  control.attributes["maxLength"].value - control.value.length;
	}
	else if( typeof( e.which ) == '46' )
	{
		//NS 4 compatible
		e = e.which;
		outputCtrl.innerHTML =  control.attributes["maxLength"].value - control.value.length;
	}
	else if( typeof( e.charCode ) == '46'  )
	{
		//also NS 6+, Mozilla 0.9+
		e = e.charCode;
		outputCtrl.innerHTML =  control.attributes["maxLength"].value - control.value.length;
	}
	else
	{
		//total failure, we have no way of obtaining the key code
		return;
	}
}


function doPaste(control, outputCtrl)
{
   maxLength = control.attributes["maxLength"].value;
   value = control.value;
   if(maxLength)
   {
		event.returnValue = false;
		maxLength = parseInt(maxLength);
		var o = control.document.selection.createRange();
		var iInsertLength = maxLength - value.length + o.text.length;
		var sData = window.clipboardData.getData("Text").substr(0,iInsertLength);
		o.text = sData;
	}

	outputCtrl.innerHTML =  control.attributes["maxLength"].value - control.value.length;
}

function doBeforePaste(control)
{
   maxLength = control.attributes["maxLength"].value;
   if(maxLength)
   {
	   event.returnValue = false;
   }
}
function sf(){document.f.q.focus();}


