// JavaScript Document
function switchRowColor(row, rowColor){
        if(document.all){
                row.style.backgroundColor = rowColor;
        }
}

function validateOrder(that){
	if(that.name.value == ''){
		alert('Du måste ange ett namn!\nVar god försök igen.');
		that.name.focus();
		that.name.select();
		return false;
	}
	if(that.address.value == ''){
		alert('Du måste ange en adress!\nVar god försök igen.');
		that.address.focus();
		that.address.select();
		return false;
	}
	if(that.postcode.value == ''){
		alert('Du måste ange en postadress!\nVar god försök igen.');
		that.postcode.focus();
		that.postcode.select();
		return false;
	}
	if(that.town.value == ''){
		alert('Du måste ange en stad!\nVar god försök igen.');
		that.town.focus();
		that.town.select();
		return false;
	}
	if(that.phone.value == ''){
		alert('Du måste ange ett telefonnummer!\nVar god försök igen.');
		that.phone.focus();
		that.phone.select();
		return false;
	}
	if(that.email.value == ''){
		alert('Du måste ange en e-post adress!\nVar god försök igen.');
		that.email.focus();
		that.email.select();
		return false;
	}
	else{
        if(window.RegExp){
			var reg1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)");
			var reg2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
			if (reg1.test(that.email.value) == true || reg2.test(that.email.value) == false){
				alert("Ange en korrekt e-post adress");
				that.email.focus();
				that.email.select();
				return false;
	         }
		}
		else{
			if(str.indexOf("@")<0){
				alert("Ange en korrekt e-post adress");
				that.email.focus();
				that.email.select();
				return false;
			}
		 }
	}

	//return confirm('Beställa Markettrends?\nKontrollera dina uppgifter.\n \nBeställningen är bindande!');
}


function validateAdminSettings(that){
	if(that.customer_pwd.value == ''){
		alert('Användarnas löseord får inte vara tomt!\nVar god försök igen.');
		that.customer_pwd.focus();
		that.customer_pwd.select();
		return false;
	}
	if(that.admin_username.value == ''){
		alert('Du måste ha ett användarnamn till admin kontot!\nVar god försök igen.');
		that.admin_username.focus();
		that.admin_username.select();
		return false;
	}
	if(that.admin_pwd.value == ''){
		alert('Du måste ha ett lösenord till admin kontot!\nVar god försök igen.');
		that.admin_pwd.focus();
		that.admin_pwd.select();
		return false;
	}
	if(that.admin_pwd2.value == ''){
		alert('Du måste ange ditt nuvarande lösenord för att uppdatera!\nVar god försök igen.');
		that.admin_pwd2.focus();
		that.admin_pwd2.select();
		return false;
	}
	return confirm('Är du säker på att du vill uppdatera?');
}

function validateAdmin(that){
	if(that.user.value == ''){
		alert('Du måste ange ett användarnamn!\nVar god försök igen.');
		that.user.focus();
		that.user.select();
		return false;
	}
	if(that.pwd.value == ''){
		alert('Du måste ange ett lösenord!\nVar god försök igen.');
		that.pwd.focus();
		that.pwd.select();
		return false;
	}
	return true;
}

function validateMarket(that){
	if(that.pwd.value != '')
		return true;
	else{
		alert('Du måste ange ett lösenord!\nVar god försök igen.');
		that.pwd.focus();
		that.pwd.select();
		return false;
	}
}

function ow(page, w, h) {
	prop='toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+w+',height='+h;
	window.open(page,'NewWindow',prop);
}

function linkselect (url) {
        if (url == "nochoice") {
        }
        else top.location = url
}   
//end hide it-->

function linkselect_self (url) {
        if (url == "nochoice") {
        }
        else self.location = url
}   

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}
