

function adToBasket(articleId,qty) {
	
	if(isNaN(qty)) {
		window.alert("Du kan endast ange heltal i antal!");
		return false;
	} else {
	
		loadAjax("shoppingbag.asp", "articleId="+ articleId +"&qty="+ qty, "shoppingbag");
		return false;
	}
}



function cc()
{
 /* check for a cookie */
  if (document.cookie == "") 
  {
    /* if a cookie is not found - alert user -
     change cookieexists field value to false */
    alert("COOKIES need to be enabled!");

    /* If the user has Cookies disabled an alert will let him know 
        that cookies need to be enabled to log on.*/ 

    document.Form1.cookieexists.value ="false"  
  } else {
   /* this sets the value to true and nothing else will happen,
       the user will be able to log on*/
    document.Form1.cookieexists.value ="true"
  }
}

/* Set a cookie to be sure that one exists.
   Note that this is outside the function*/
document.cookie = 'killme' + escape('nothing')









function chkOrderForm() {

	var actionUrl = "shoppingcart.asp";

	if (((document.forms["PAY"].PAY[0].checked) == false) && ((document.forms["PAY"].PAY[1].checked) == false) && ((document.forms["PAY"].PAY[2].checked) == false))  {
		alert("Du har inte anget betalalternativ!");
		document.getElementById("PF-div").style.backgroundColor = "#CCCCCC";
		return false; } 

	else if ((document.forms["orderForm"].customerName.value) == "")  {
		alert("Du har inte anget namn!");
		document.forms["orderForm"].customerName.focus();
		return false; }
		
	else if ((document.forms["orderForm"].customerAddress.value) == "")  {
		alert("Du har inte anget adress!");
		document.forms["orderForm"].customerAddress.focus();
		return false; }
		
	else if ((document.forms["orderForm"].customerZip.value) == "")  {
		alert("Du har inte anget postnummer!");
		document.forms["orderForm"].customerZip.focus();
		return false; }
		
	else if ((document.forms["orderForm"].customerCity.value) == "")  {
		alert("Du har inte anget postadress!");
		document.forms["orderForm"].customerCity.focus();
		return false; }
		
	else if ((document.forms["orderForm"].customerPhone.value) == "")  {
		alert("Du har inte anget telefonnummer!");
		document.forms["orderForm"].customerPhone.focus();
		return false; }
		
	else if ((document.forms["orderForm"].customerEmail.value) == "")  {
		alert("Du har inte anget e-postadress!");
		document.forms["orderForm"].customerEmail.focus();
		return false; }
		
	else {
	    document.getElementById("orderForm").action = actionUrl;
	    document.getElementById("orderForm").submit();
	}
	
}


function confirmBox(msg,url) {
	if (confirm(msg)) {
    		document.location.href=(url);
    		//window.location.reload();
    		return true;
    	} else {
    		return false;
    	}
}



function countChar(field, maxlimit, spanId) {
	if (field.value.length > maxlimit)
		field.value = field.value.substring(0, maxlimit); 
	else 
		document.getElementById(spanId).innerHTML = " " + (maxlimit - field.value.length) + " left ";
}



function chkUpload() {

	var koll = (document.frmSend.file1.value);
	koll = koll.toLowerCase(koll);
	
	var pattern = /.jpg|.gif|.pdf|.coc|.xls|.ppt/
	
	if (pattern.test(koll) == false || (koll == "")) {
		window.alert("File format is not valid!");
		document.frmSend.file1.focus();
		return false;
	}  
}



function chkUploadLogo() {

	var koll = (document.frmUpl.file1.value);
	koll = koll.toLowerCase(koll);
	
	var pattern = /.jpg|.gif/
	
	if (pattern.test(koll) == false || (koll == "")) {
		window.alert("File format is not valid!");
		document.frmUpl.file1.focus();
		return false;
	}  
}


var i
var iLabel = 0
var iArk = 1
var checkflag = "false";

function check(field) {
	if (checkflag == "false") {
		for (i = 0; i < field.length; i++) {
			field[i].checked = true;
			checkflag = "true";
			iLabel = field.length;
		}
		}	else {
		for (i = 0; i < field.length; i++) {
			field[i].checked = false;
			checkflag = "false";
			iLabel = 0;
		}
		}
	//document.getElementById("etikett").innerHTML = iLabel;
}

function checkSelected() {

var i
var iCount = 0

		for (i = 0; i < document.frm.categoryId.length; i++) {
			if ((document.frm.categoryId[i].checked) == true) {
				iCount = iCount + 1;
			}
		}
	document.getElementById("label").innerHTML = iCount;
}

function openWin(url,w,h) {
	var setWidth = w;
	var setHeight = h;
	var setScroll = 1;
	var setStatus = 1;
	var setMenu = 0;
	var setResiz = 0;
	var setLeft=(screen.width/2)-(setWidth/2);
	var setTop=(screen.height/2)-(setHeight/2);
	var myWin = window.open(url, 'PopUp', 'height=' + setHeight + ',width=' + setWidth + ',left=' + setLeft + ',top=' + setTop + ',scrollbars=' + setScroll +',status= '+ setStatus +',menubar='+setMenu+',resizable='+setResiz+',', true );
}



function confirmBoxRedirect(msg,url) {
	if (confirm(msg)) {
    		document.location.href=(url);
    		this.location.reload(1);
    		return true;
    	} else {
    		return false;
    	}
}



function confirmBoxSubmit(msg) {
	if (confirm(msg)) {
    		this.form.submit();
    		return true;
    	} else {
    		return false;
    	}
}



function chkOffert() {

	if ((document.forms["offert"].company.value) == "Företag/Kontaktperson")  {
		alert("Du har ej anget företag/kontaktperson");
		document.forms["offert"].company.focus();
		return false; } 
		
	else if ((document.forms["offert"].mail.value) == "E-postadress")  {
		alert("Du har ej anget E-postadress");
		document.forms["offert"].mail.focus();
		return false; } 
		
	else if ((document.forms["offert"].message.value) == "Skriv ner dina funderingar!")  {
		alert("Du har ej skriv ner dina funderingar!");
		document.forms["offert"].message.focus();
		return false; } 
		
	else {
	    document.getElementById("offert").action = "offert.asp";
	    document.getElementById("offert").submit();
	}
	
}

function chkWebQuestAds() {

	if ((document.forms["webQuest"].mail.value) == "E-postadress och/eller telefonnummer")  {
		alert("Du har ej anget E-postadress och/eller telefonnummer");
		document.forms["webQuest"].mail.focus();
		return false; } 
		
	else if ((document.forms["webQuest"].loadContact.value) == "Skriv ner dina funderingar!")  {
		alert("Du har ej skriv ner dina funderingar!");
		document.forms["webQuest"].loadContact.focus();
		document.getElementById("loadContact").style.height="120px";
		return false; } 
		
	else {
	    document.getElementById("webQuest").action = "loadContact.asp";
	    document.getElementById("webQuest").submit();
	}
	
}

function chkWebQuestCom() {

	if ((document.forms["webQuest"].mail.value) == "E-postadress och/eller telefonnummer")  {
		alert("Du har ej anget E-postadress och/eller telefonnummer");
		document.forms["webQuest"].mail.focus();
		return false; } 
		
	else if ((document.forms["webQuest"].loadContact.value) == "Skriv ner dina funderingar!")  {
		alert("Du har ej skriv ner dina funderingar!");
		document.forms["webQuest"].loadContact.focus();
		document.getElementById("loadContact").style.height="120px";
		return false; } 
		
	else {
	    document.getElementById("webQuest").action = "loadContact.asp";
	    document.getElementById("webQuest").submit();
	}
	
}



