// start create target blank from class="blank"

function addEvent(obj, evType, fn) {
	if (obj.addEventListener) {
		obj.addEventListener(evType, fn, true);
		return true;
	} else if (obj.attachEvent) {
		var r = obj.attachEvent("on"+evType, fn); 
		return r;
	} else {
		return false;
	}
}

function getlinks() {
	var links = document.getElementsByTagName('A');
	for (var i = 0; i < links.length; i++) {
		if (/nolink/.exec(links[i].href)) {
			links[i].onclick = linkinfo;
		}
	}
}
function linkinfo() {
	alert('Denna länk är inte aktiv i prototypen.');
	return false;
}

addEvent(window, 'load', getlinks);



function openBrWindow(theURL,winName,features) { 
	window.open(theURL,winName,features);
	return false;
}

function openPic(imgSrc, wPic, hPic){
		window.open("images/produkter/" + imgSrc + ".jpg", "Agria" + imgSrc, "height="+ eval(hPic + 20) +",width="+ eval(wPic + 20) +",titelbar=0,channelmode=0,screenX=0,left=0,screenY=0,top=0,hotkeys=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,toolbar=0");
		return false;
}

function openFullWindow(theURL) { 
	window.open(theURL);
	return false;
}


function validateContact(thisObj){
  if(thisObj.headline.value==''){
  	alert('Du måste ange en rubrik!');
  	thisObj.headline.focus();
  	return false;
  }
  if(thisObj.msg.value==''){
  	alert('Du måste skriva ett meddelande!');
  	thisObj.msg.focus();
  	return false;
  }
  return true;
}


function validateBroschyr(thisObj){


  if((thisObj.question1.checked == false) && (thisObj.question2.checked == false) && (thisObj.question3.checked == false) && (thisObj.question4.checked == false) && (thisObj.question5.checked == false) && (thisObj.question6.checked == false) && (thisObj.question7.checked == false) && (thisObj.question8.checked == false) && (thisObj.question9.checked == false) && (thisObj.question10.checked == false)){
  	alert('Du måste välja minst en broschyr');
  	return false;
  }
  if(thisObj.name.value==''){
  	alert('Du måste ange ditt namn.');
  	thisObj.name.focus();
  	return false;
  }
  if(thisObj.address.value==''){
  	alert('Du måste ange en adress.');
  	thisObj.address.focus();
  	return false;
  }
  if(thisObj.postalcode.value==''){
  	alert('Du måste ange ett postnummer.');
  	thisObj.postalcode.focus();
  	return false;
  }
  if(thisObj.city.value==''){
  	alert('Du måste ange ort.');
  	thisObj.city.focus();
  	return false;
  }

  return true;
}



function validateNews(thisObj){
		
	if(thisObj.how[0].checked){
    if(thisObj.email.value==''){
    	alert('Du måste ange en e-postadress');
    	thisObj.email.focus();
    	return false;
    }
	}else{
    if(thisObj.name.value==''){
    	alert('Du måste ange ditt namn.');
    	thisObj.name.focus();
    	return false;
    }
    if(thisObj.address.value==''){
    	alert('Du måste ange en adress.');
    	thisObj.address.focus();
    	return false;
    }
    if(thisObj.postalcode.value==''){
    	alert('Du måste ange ett postnummer.');
    	thisObj.postalcode.focus();
    	return false;
    }
    if(thisObj.city.value==''){
    	alert('Du måste ange ort.');
    	thisObj.city.focus();
    	return false;
    }
	}

  return true;
}


