var xmlHttp
var tmpTarget

function Exempel(){
	
	}
	
function newCourseName(){
	document.getElementById("NewCourse").innerHTML=" <input name='txtArtHeadline' id='txtArtHeadline' type='text' class='textsmall' value='' size='42'>"
}
	
function checkDate(inDate,target){
	var flag=true;
	// As in 070902
	if (inDate.length==6){
			var tmpDate = "20" + Left(inDate,2) + "-" + Mid(inDate,2,2) + "-" + Right(inDate,2)
	}
	// As in 20070902
	if (inDate.length==8){
			var tmpDate = Left(inDate,4) + "-" + Mid(inDate,4,2) + "-" + Right(inDate,2)
	}
	// As in 2007-09-02
	if (inDate.length==10){
			var tmpDate = inDate
	}
	
	document.getElementById(target).value = tmpDate;
}

function checkTime(inTime,target){
	var flag=true;
	// As in 1810
	if (inTime.length==4){
			var tmpTime = Left(inTime,2) + ":" + Right(inTime,2);
	}
	// As in 18
	if (inTime.length==2){
			var tmpTime = inTime + ":00";
	}
	// As in 9
	if (inTime.length==1){
			var tmpTime = "0" + inTime + ":00";
	}
	
	document.getElementById(target).value = tmpTime;
}

	
function cleanSearchCust(){
	if (document.getElementById('searchCust').value=="Minst tre tecken"){
	document.getElementById('searchCust').value="";
	}
}

function showSearchResultCust(){
	var searchCust = document.getElementById('searchCust').value;			
	if (searchCust.length>2) {
		url = "invoice_customer.asp?f=SearchFor&searchCust=" + searchCust;
		location.href=url;
		}
}


function delCourse(ArtID){
	document.getElementById("delArtContainer").innerHTML="Är du säker? [<a href='javascript:delArtYes(" + ArtID + ")'>JA</a>] [<a href='javascript:delArtNo(" + ArtID + ")'>NEJ]</a>";	
}



function delArtNo(ArtID){
	var url = "chCourse.asp?ArtID=" + ArtID;
	location.href=url;
	}
	
function delArtYes(ArtID){
	var url = "delArt.asp?ArtID=" + ArtID + "&f=listCourse";
	location.href=url;
	}
	
function delSchemeNo(ArtID){
	var url = "course.asp";
	location.href=url;
	}
	
function delSchemeYes(ArtID){
	var url = "delArt.asp?ArtID=" + ArtID + "&f=listCourse";
	location.href=url;
	}

function updateSuperField(FieldID,FieldIDName,PaintTarget,FrieldName,ChangeToValue,tblName){ 
	var flagChecked = null;
	flagChecked = document.getElementById(PaintTarget).checked;
	//alert(flagChecked)
	tmpTarget = PaintTarget;
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	// Update value in field
	var url="http://www.neurodynamik.se/admPage/updateSuperField.asp?tblName=" + tblName + "&FieldID=" + FieldID + "&FieldIDName=" + FieldIDName + "&FrieldName=" + FrieldName + "&ChangeToValue=" + ChangeToValue + "&flagChecked=" + flagChecked;
	//location.href=url;
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=infoUpdated; 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function openChScheme(ArtID){
	location.href="chScheme.asp?ArtID=" + ArtID;
	}


function QuickNewArt(){
	document.getElementById("artName").innerHTML="<input type='text' name='newArt' size='50' id='newArt' value='Namnge den nya artikeln'> ";
	}


// ============================= ADM artiklar & PG
function insertHTML(startTag, stopTag,TargetName){ 

var textarea = document.getElementById(TargetName);

//alert(typeof(textarea.selectionStart));

// get selection in firefox, safari, opera, ...
if (typeof(textarea.selectionStart) == 'number')

{
	//alert("firefox, safari");

  // get start and end points of selected text

  textarea.sel_start = textarea.selectionStart;

  textarea.sel_end = textarea.selectionEnd;
  
 	//alert(textarea.sel_start);
 	//alert(textarea.sel_end);
	//alert(textarea.value);  

  // get selected and surrounding text

  textarea.sel_text = textarea.value.substring(textarea.sel_start, textarea.sel_end);

  textarea.sel_text_pre = textarea.value.substring(0, textarea.sel_start);

  textarea.sel_text_post = textarea.value.substring(textarea.sel_end, textarea.value.length);
  
//  alert(textarea.sel_text);
//  alert(textarea.sel_text_pre);
//  alert(textarea.sel_text_post);
  
   // inserting TAGS
 
  var txtTextAreaUpdated
 
  textarea.sel_text_pre = textarea.sel_text_pre + startTag;
  textarea.sel_text_post = stopTag + textarea.sel_text_post;
  txtTextAreaUpdated = textarea.sel_text_pre + textarea.sel_text + textarea.sel_text_post;
  
//  alert(textarea.sel_text_pre);
//  alert(textarea.sel_text_post);
 
 document.getElementById(TargetName).value = txtTextAreaUpdated;
}

// get selection in IE

else if (document.selection)

{

  // make sure it's the textarea's selection

  var range = document.selection.createRange();

  if (range.parentElement().id == TargetName)

  {

     // create a selection of the whole textarea

     var range_all = document.body.createTextRange();

     range_all.moveToElementText(textarea);

     // calculate selection start point by moving beginning of range_all to beginning of range

     for (var sel_start = 0; range_all.compareEndPoints('StartToStart', range) < 0; sel_start ++)

       range_all.moveStart('character', 1);

     // get number of line breaks from textarea start to selection start and add them to sel_start

     for (var i = 0; i <= sel_start; i ++)

     {

       if (textarea.value.charAt(i) == '\n')

         sel_start ++;

     }

     textarea.sel_start = sel_start;

     // create a selection of the whole textarea

     var range_all = document.body.createTextRange();

     range_all.moveToElementText(textarea);

     // calculate selection end point by moving beginning of range_all to end of range

     for (var sel_end = 0; range_all.compareEndPoints('StartToEnd', range) < 0; sel_end ++)

       range_all.moveStart('character', 1);

     // get number of line breaks from textarea start to selection end and add them to sel_end

     for (var i = 0; i <= sel_end; i ++)

     {

       if (textarea.value.charAt(i) == '\n')

         sel_end ++;

     }

     textarea.sel_end = sel_end;

     // get selected and surrounding text

     textarea.sel_text = range.text;

     textarea.sel_text_pre = textarea.value.substring(0, textarea.sel_start);

     textarea.sel_text_post = textarea.value.substring(textarea.sel_end, textarea.value.length);
	 
//	 alert(textarea.sel_text_pre);
//	 alert(textarea.sel_text);
//	 alert(textarea.sel_text_post);

 // inserting TAGS
 
  var txtTextAreaUpdated
 
 textarea.sel_text_pre = textarea.sel_text_pre + startTag;
 textarea.sel_text_post = stopTag + textarea.sel_text_post;
 txtTextAreaUpdated = textarea.sel_text_pre + textarea.sel_text + textarea.sel_text_post;
 
 document.getElementById(TargetName).value = txtTextAreaUpdated;
}

}

// this browser doesn't support javascript selections

else

{

  // ...

}

}



// ============================= EKONOMI

function moveInvoiceList(OrderID,f,f2,intOrderStatus){ 
	var url="invoice_moveInvoiceList.asp?OrderID=" + OrderID + "&f=" + f + "&f2=" + f2 + "&intOrderStatus=" + intOrderStatus ;	
	location.href=url;
} 

function printThis(mName) {
	var url =  "invoice_List_print.asp?mName='" + mName + "'";
	mywindow = window.open (url , "mywindow","resizable=1,location=0,status=0,scrollbars=0, width=800,height=1000");
  	mywindow.moveTo(0,0);
}


function FindOrder(searchID,typeOfAction){
	////Skapa extra rader
//	var tbl = document.getElementById('tblFindOrder');
//	var lastRow = tbl.rows.length;
//	// if there's no header row in the table, then iteration = lastRow + 1
//	var row = tbl.insertRow(lastRow-2); 
//	// Setting the rows unique id
//	row.id = "findOrder";
//	// cell 
//	var cellOne = row.insertCell(0);
//	cellOne.innerHTML="<div id='ShowOrder'>&nbsp;</div>";
////	cellEight.setAttribute("align", "left");
//
	// Placing found order
	var intOrderID = document.getElementById("intOrderID").value;
	var txtCustName = document.getElementById("txtCustName").value;
	var txtCustPhone = document.getElementById("txtCustPhone").value;
	tmpTarget="ShowInvoice"
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
	alert ("Your browser does not support AJAX!");
	return;
	} 
	var url="invoice_info.asp?intOrderID=" + intOrderID + "&txtCustName=" + txtCustName + "&txtCustPhone=" + txtCustPhone + "&searchID=" + searchID + "&typeOfAction=" + typeOfAction;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=updatedTarget;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);	
	
}

function oblitOrder(OrderID){
	var url="invoice_updateStatus.asp?OrderID=" + OrderID + "&intOrderStatus=4&f=oblit";
	location.href=url;
}

function creditOrder(OrderID){
	var url="invoice_updateStatus.asp?OrderID=" + OrderID + "&intOrderStatus=5&f=credit";
	location.href=url;
}

function paid(OrderID,intOrderStatus) {
	var url =  "invoice_paidConfirm.asp?OrderID=" + OrderID + "&intOrderStatus=" + intOrderStatus + "";
	mywindow = window.open (url , "Fakturabetald","toolbar=no,directories=no,resizable=no,location=no,status=no,scrollbars=no,menubar=no,width=190,height=120");
	mywindow.moveTo(500,0);
	
	if (!mywindow.closed && mywindow.location) {
		mywindow.location.href = url;
	}
	else {
		mywindow=window.open(url,'Fakturabetald','toolbar=no,directories=no,resizable=no,location=no,status=no,scrollbars=no,menubar=no,width=230,height=120');
		if (!mywindow.opener) mywindow.opener = self;
	}
//	if (window.focus) {newwindow.focus()}
//	return false;

}


function paidGo(OrderID,intOrderStatus) {
	var dtmOrderPayedDate = frmPayed.dtmOrderPayedDate.value;
	if (frmPayed.txtOrderPayedTo1.checked==true){
		var txtOrderPayedTo = "PG"
	}
	if (frmPayed.txtOrderPayedTo2.checked==true){
		var txtOrderPayedTo = "BG"
	}
	var url="invoice_updateStatus.asp?OrderID=" + OrderID + "&intOrderStatus=" + intOrderStatus + "&dtmOrderPayedDate=" + dtmOrderPayedDate + "&txtOrderPayedTo=" + txtOrderPayedTo;
	location.href=url;
}

// FUNKTIONER FÖR UTSKRIFT ==================================================

//printInvoice('new',1,'printList')

function printInvoice(f,intOrderStatus,f2){
	if (f=='new'){
	//	var dtmToDay = frmInvoice.dtmToDay.value;
	//		var dtmDueToPay = frmInvoice.dtmDueToPay.value;
	// NO OrderID becuase its new...
		url="invoice_custInvoice_print.asp?OrderID=f=" + f + "&intOrderStatus=" + intOrderStatus + "&f2=" + f2;
	}
	else {
		var remaind=document.getElementById("remaidInv").checked;
		url="invoice_custInvoice_print.asp?f=old&f2=" + f2 + "&intOrderStatus=" + intOrderStatus + "&remaind=" + remaind;
	}
	day = new Date();
	id = day.getTime();
	url = url + "&pageid=" + id;
	eval("page" + id + " = window.open(url, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=700,height=700,left = 320,top = 162');");
}

// FUNKTIONER FÖR E-POSTA FAKTURA ===========================================

function showEmailForm(intOrderStatus){ 
	tmpTarget="ecoAssignment"
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
	alert ("Your browser does not support AJAX!");
	return;
	} 
	if (intOrderStatus==1){
//		var dtmEventFromDate = document.getElementById("dtmToDay").value;
//		var dtmEventToDate = document.getElementById("dtmDueToPay").value;
//		var intInvitation = document.getElementById("intInvitation").value;
//		var intCompendium = document.getElementById("intCompendium").value;
//		var intOther = document.getElementById("intOther").value;
		//var url="invoice_All.asp?f=new&f2=emailInvoice&dtmEventFromDate=" + dtmEventFromDate + "&dtmEventToDate=" + dtmEventToDate+ "&intInvitation=" + intInvitation + "&intCompendium=" + intCompendium + "&intOther=" + intOther;
		//var url="invoice_mailInvoice.asp?f=new&dtmEventFromDate=" + dtmEventFromDate + "&dtmEventToDate=" + dtmEventToDate+ "&intInvitation=" + intInvitation + "&intCompendium=" + intCompendium + "&intOther=" + intOther;
	var url="invoice_mailInvoice.asp?intOrderStatus=1&remaind=false";
	}
	if (intOrderStatus>1){
		var remaind=document.getElementById("remaidInv").checked;
		//var url="invoice_got_All.asp?f=old&f2=emailInvoice"
		var url="invoice_mailInvoice.asp?fintOrderStatus=2&remaind=" + remaind;
	}
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=updatedTarget;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function hideEmailForm(intOrderStatus){
	tmpTarget="ecoAssignment"
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
	alert ("Your browser does not support AJAX!");
	return;
	} 
	if (intOrderStatus==1){
		var url="/adm/invoice/invoice_All.asp?f2=none";
	}
	if (intOrderStatus>1){
		var url="/adm/invoice/invoice_got_All.asp?f2=none"
	}
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=updatedTarget;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function sendInvoiceByEMail(intOrderStatus,remind){ 
	tmpTarget="ecoAssignment"
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
	alert ("Your browser does not support AJAX!");
	return;
	} 
	if (intOrderStatus==1){
		var dtmToDay = document.getElementById("dtmToDay").value;
		var dtmDueToPay = document.getElementById("dtmDueToPay").value;
		var intInvitation = document.getElementById("intInvitation").value;
		var intCompendium = document.getElementById("intCompendium").value;
		var intOther= document.getElementById("intOther").value;
	}
	var txtHeadline = document.getElementById("txtHeadline").value;
	var txtMailMess = document.getElementById("txtMailMess").value;

	if (intOrderStatus==1){
		var url="invoice_sendinvoice.asp?intOrderStatus=" + intOrderStatus + "&txtHeadline=" + txtHeadline + "&txtMailMess=" + txtMailMess + "&intInvitation=" + intInvitation + "&intCompendium=" + intCompendium + "&intOther=" + intOther + "&dtmToDay=" + dtmToDay + "&dtmDueToPay=" + dtmDueToPay;
	}
	if (intOrderStatus>1){
		var url="invoice_sendinvoice.asp?intOrderStatus=" + intOrderStatus + "&txtHeadline=" + txtHeadline + "&txtMailMess=" + txtMailMess + "&remind=" + remind;
	}
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=updatedTarget;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function popUp(URL){
	var dtmToDay = frmInvoice.dtmToDay.value;
	var dtmDueToPay = frmInvoice.dtmDueToPay.value;
	var day = new Date();
	var id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=640,height=700,left = 320,top = 162');");
}

// FUNKTIONER FÖR ATT SKAPA EGEN FAKTURA ===========================================

function newOrder_addInvoiceRow(){
	//Skapa extra rader
	var tbl = document.getElementById('tblOrder');
	var lastRow = tbl.rows.length;
	// if there's no header row in the table, then iteration = lastRow + 1
	var row = tbl.insertRow(lastRow-8); 
	// Setting the rows unique id
	row.id = "invRow" + (lastRow-10);
	// cell 
	var cellOne = row.insertCell(0);
	cellOne.innerHTML="<input name='btnAddRow" + (lastRow-10) + "' type='button' class='textSmall' id='btnAddRow" + (lastRow-10) + "' value=' + ' onclick='newOrder_addInvoiceRow()' />";
	var cellTwo = row.insertCell(1);
	cellTwo.innerHTML="<input name='freeform_objid_" + (lastRow-10) + "' id='freeform_objid_" + (lastRow-10) + "' type='text' class='textSmall' size='5'/>";
	var cellThree = row.insertCell(2);
	cellThree.innerHTML="<input name='freeform_description_" + (lastRow-10) + "' id='freeform_description_" + (lastRow-10) + "' type='text' class='textSmall'  size='60' ondblclick='fetchProduct(" + (lastRow-10) + ")' />";
	var cellFour = row.insertCell(3);
	cellFour.innerHTML="<input name='freeform_quantity_" + (lastRow-10) + "' id='freeform_quantity_" + (lastRow-10) + "' type='text' class='textSmall' size='4' value='1' onblur='newOrder_setSum(" + (lastRow-10) + ")'/>";
	var cellFive = row.insertCell(4);
	cellFive.innerHTML="<input name='freeform_price_NOVAT_" + (lastRow-10) + "' id='freeform_price_NOVAT_" + (lastRow-10) + "' type='text' class='textSmall' size='7' onblur='newOrder_setSum(" + (lastRow-10) + ")' />";
	var cellSix = row.insertCell(5);
	cellSix.innerHTML="<select name='freeform_vat_" + (lastRow-10) + "' id='freeform_vat_" + (lastRow-10) + "' class='textSmall' onblur='newOrder_setSum(" + (lastRow-10) + ")'><option value='25' selected='selected'>25%</option><option value='12'>12%</option><option value='6'>6%</option></select>";
	var cellSeven = row.insertCell(6);
	cellSeven.innerHTML="<input name='freeform_sum_" + (lastRow-10) + "' id='freeform_sum_" + (lastRow-10) + "' type='text' class='textSmall' size='9' />";
	var cellEight = row.insertCell(7);
	cellEight.innerHTML="<input name='" + (lastRow-10) + "' type='button' class='textSmall' id='" + (lastRow-10) + "' value=' - ' onclick='newOrder_delInvoiceRow(this.id)' />&nbsp;<input name='freeform_type_" + (lastRow-10) + "' id='freeform_type_" + (lastRow-10) + "' type='hidden' value='2' class='textSmall' size='2' /><input name='freeform_card_" + (lastRow-10) + "' id='freeform_card_" + (lastRow-10) + "' type='hidden' class='textSmall' size='2' />";
	cellEight.setAttribute("align", "left");

	//Assign rowvalue to a field	
	document.getElementById('loopid').value=(lastRow-10);
	//Hide + button in the row above
	document.getElementById('btnAddRow'+(lastRow-11)).style.visibility="hidden";
}

function newOrder_delInvoiceRow(rid){
	//Delete row
	document.getElementById('tblOrder').deleteRow(document.getElementById("invRow" + rid).rowIndex);
	var tbl = document.getElementById('tblOrder');
	var lastRow = tbl.rows.length;	
	//Assign rowvalue to a field	
	document.getElementById('loopid').value=(lastRow-11);
	//Make plus-button visible
	
	//alert(document.getElementById("invRow" + rid).rowIndex;
	document.getElementById('btnAddRow' + document.getElementById('loopid').value).style.visibility="visible";
//	alert(rid);
//	alert(document.getElementById('loopid').value);
}

function newOrder_getProduct(rowID){
//	alert("Hämtar produkt till rad " + rowID)
	var url =  "/adm/invoice/invoice_productList.asp?rowID=" + rowID;
	if (!newwindow.closed && newwindow.location) {
		newwindow.location.href = url;
	}
	else {
		newwindow=window.open(url,'Produkter','toolbar=no,directories=no,resizable=no,location=no,status=no,scrollbars=yes,menubar=no,width=385,height=120');
		if (!newwindow.opener) newwindow.opener = self;
	}
}

function newOrder_setSum(rowID){
	document.getElementById('freeform_sum_' + rowID).value=document.getElementById('freeform_quantity_' + rowID).value * document.getElementById('freeform_price_NOVAT_' + rowID).value;	
	var tmpSum=0;
	var tmpVat0=0;
	var tmpVat6=0;
	var tmpVat12=0;
	var tmpVat25=0;
	for (var i=0;i <= document.getElementById('loopid').value;i++){
		tmpSum = tmpSum + (document.getElementById('freeform_quantity_' + i).value * document.getElementById('freeform_price_NOVAT_' + i).value);	
		if (document.getElementById('freeform_vat_' + i).value=="0"){
		tmpVat0 = tmpVat0 + 0;	
		}
		if (document.getElementById('freeform_vat_' + i).value=="6"){
		tmpVat6 = tmpVat6 + ((document.getElementById('freeform_quantity_' + i).value * document.getElementById('freeform_price_NOVAT_' + i).value)*1.06)-(document.getElementById('freeform_quantity_' + i).value * document.getElementById('freeform_price_NOVAT_' + i).value);	
		}
		if (document.getElementById('freeform_vat_' + i).value=="12"){
		tmpVat12 = tmpVat12 + ((document.getElementById('freeform_quantity_' + i).value * document.getElementById('freeform_price_NOVAT_' + i).value)*1.12)-(document.getElementById('freeform_quantity_' + i).value * document.getElementById('freeform_price_NOVAT_' + i).value);	
		}
		if (document.getElementById('freeform_vat_' + i).value=="25"){
		tmpVat25 = tmpVat25 + ((document.getElementById('freeform_quantity_' + i).value * document.getElementById('freeform_price_NOVAT_' + i).value)*1.25)-(document.getElementById('freeform_quantity_' + i).value * document.getElementById('freeform_price_NOVAT_' + i).value);	
		}
	}
	document.getElementById('freeform_SumExVat').value=Math.round(tmpSum);
	document.getElementById('freeform_Vat0').value=Math.round(tmpVat0);
	document.getElementById('freeform_Vat6').value=Math.round(tmpVat6);
	document.getElementById('freeform_Vat12').value=Math.round(tmpVat12);
	document.getElementById('freeform_Vat25').value=Math.round(tmpVat25);
	document.getElementById('freeform_SumIncVat').value=Math.round(tmpSum+tmpVat0+tmpVat6+tmpVat12+tmpVat25);
}



// ===============================================================================

function FillOutForm(CustomerID,HitCounter){
	var tmpTotalHitCounter = document.getElementById("TotalHitCounter").value;
	for (var x = 1; x <= tmpTotalHitCounter; x++){
	document.getElementById("rowName" + x).style.background ="#666";
	document.getElementById("rowPhone" + x).style.background="#666";
	}
	document.getElementById("rowName" + HitCounter).style.background ="#CCC";
	document.getElementById("rowPhone" + HitCounter).style.background="#CCC";
	tmpTarget = "UserInfoForm";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="UserInfoForm.asp?CustomerID=" + CustomerID;
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=updatedTarget 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function checkForOldUserInfo(){
	var txtCustFirstName= document.getElementById("txtCustFirstName").value;
	var txtCustLastName = document.getElementById("txtCustLastName").value;
	tmpTarget = "FindOldUserInfo";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="FindOldUserInfo.asp?txtCustFirstName=" + txtCustFirstName + "&txtCustLastName=" + txtCustLastName;
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=updatedTarget 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}


function addOnlyJoiner(ArtID){
	var txtCustInvoiceName = document.getElementById("txtCustInvoiceName"+ ArtID).value;
	var txtCustInvoiceAddress = document.getElementById("txtCustInvoiceAddress"+ ArtID).value;
	var txtCustInvoiceZip = document.getElementById("txtCustInvoiceZip"+ ArtID).value;
	var txtCustInvoiceCity = document.getElementById("txtCustInvoiceCity"+ ArtID).value;
	var txtCustPhone = document.getElementById("txtCustPhone"+ ArtID).value;
	var txtCode = document.getElementById("txtCode"+ ArtID).value;
	var txtCustEmail = document.getElementById("txtCustEmail").value;
	var txtCustFirstName = document.getElementById("txtCustFirstName"+ ArtID).value;
	var txtCustLastName = document.getElementById("txtCustLastName"+ ArtID).value;
//	url="addJoinerList.asp?ArtID=" + ArtID + "&txtCustInvoiceName=" + txtCustInvoiceName + "&txtCustInvoiceAddress=" + txtCustInvoiceAddress + "&txtCustInvoiceZip=" + txtCustInvoiceZip + "&txtCustInvoiceCity=" + txtCustInvoiceCity + "&txtCustPhone=" + txtCustPhone + "&txtCode=" + txtCode + "&txtCustEmail=" + txtCustEmail + "&txtCustFirstName=" + txtCustFirstName + "&txtCustLastName=" + txtCustLastName;
//	location.href=url;
	
	tmpTarget = "AreaJoiners" + ArtID;
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="addJoinerList.asp?ArtID=" + ArtID + "&txtCustInvoiceName=" + txtCustInvoiceName + "&txtCustInvoiceAddress=" + txtCustInvoiceAddress + "&txtCustInvoiceZip=" + txtCustInvoiceZip + "&txtCustInvoiceCity=" + txtCustInvoiceCity + "&txtCustPhone=" + txtCustPhone + "&txtCode=" + txtCode + "&txtCustEmail=" + txtCustEmail + "&txtCustFirstName=" + txtCustFirstName + "&txtCustLastName=" + txtCustLastName;
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=updatedTarget 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	}
	
function addJoinerAndOrder(ArtID){
	var txtCustInvoiceName = document.getElementById("txtCustInvoiceName"+ ArtID).value;
	var txtCustInvoiceAddress = document.getElementById("txtCustInvoiceAddress"+ ArtID).value;
	var txtCustInvoiceZip = document.getElementById("txtCustInvoiceZip"+ ArtID).value;
	var txtCustInvoiceCity = document.getElementById("txtCustInvoiceCity"+ ArtID).value;
	var txtCustPhone = document.getElementById("txtCustPhone"+ ArtID).value;
	var txtCode = document.getElementById("txtCode"+ ArtID).value;
	var txtCustEmail = document.getElementById("txtCustEmail").value;
	var txtCustFirstName = document.getElementById("txtCustFirstName"+ ArtID).value;
	var txtCustLastName = document.getElementById("txtCustLastName"+ ArtID).value;

	var url="addNEWJoinerList.asp?ArtID=" + ArtID + "&txtCustInvoiceName=" + txtCustInvoiceName + "&txtCustInvoiceAddress=" + txtCustInvoiceAddress + "&txtCustInvoiceZip=" + txtCustInvoiceZip + "&txtCustInvoiceCity=" + txtCustInvoiceCity + "&txtCustPhone=" + txtCustPhone + "&txtCode=" + txtCode + "&txtCustEmail=" + txtCustEmail + "&txtCustFirstName=" + txtCustFirstName + "&txtCustLastName=" + txtCustLastName;
	window.location.href=url;
	}
	
function delJoiner(OrderDetailID,rowID){
	document.getElementById("delCell" + rowID).bgColor="#ff3333";
	document.getElementById("delCell" + rowID).innerHTML="Är du säker? <a href='delJoiner.asp?OrderDetailID=" + OrderDetailID + "' class='whiteLink'>Ja</a>&nbsp;&nbsp;<a href='start.asp' class='whiteLink'>Nej</a>"
}
	
		
function addJoiner(txtArtHeadline,ArtID){ 
tmpTarget = "AreaJoiners" + ArtID;
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
var url="newJoiner.asp?ArtID=" + ArtID + "&f=null";
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=updatedTarget 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function fetchCourseMaterial(CustomerID){
	url="courseMaterial.asp?CustomerID=" + CustomerID;
	location.href=url;
}

function ClearMe(targetID){
	document.getElementById(targetID).value="";
}

function LoggInVideo(){
	var txtCode = document.getElementById("txtCode").value;
	url="/Kursvideos/checkInlogg.asp?txtCode=" + txtCode;
	location.href=url;
}

function searchPerson(){
	var txtWho = document.getElementById("txtWho").value;	
	var txtWhere = document.getElementById("txtWhere").value;
	var txtArt = document.getElementById("txtArt").value;
	var url = "searchResult.asp?txtWho=" + txtWho + "&txtWhere=" + txtWhere + "&txtArt=" + txtArt;
	location.href = url;
}

function store_basket(){
	document.location.href="store/store_basket.asp?f=course"	
}

function store_basket_fromStore(){
	parent.location.href="store_basket.asp?f=store"	
}

function copyInvAdress(){
	document.getElementById("txtCustAddress2").value=document.getElementById("txtCustInvoiceDepart").value;
	document.getElementById("txtCustAddress").value=document.getElementById("txtCustInvoiceAddress").value;
	document.getElementById("txtCustZip").value=document.getElementById("txtCustInvoiceZip").value;
	document.getElementById("txtCustCity").value=document.getElementById("txtCustInvoiceCity").value;
}

function addTeacherRow(){
	document.getElementById("connLeaderID2").style.visibility="visible";
	document.getElementById("btnTecherRow2").style.visibility="visible";
}
				
function delTeacherRow(){
	document.getElementById("connLeaderID2").style.visibility="hidden";
	document.getElementById("btnTecherRow2").style.visibility="hidden";
}

function addDateRow(strRowNumb){
	var rowNumb = Right(strRowNumb,1);
	rowNumb = parseFloat(rowNumb) + 1;
	if(rowNumb<10){
		if (document.getElementById("dtmRow"+rowNumb).innerHTML.length==0){
			strContent = "<div style='float:left; width:100px; text-align:center; padding:3px;'><input name='dtmProdFromDate" + rowNumb + "' type='text' class='text' id='dtmProdFromDate" + rowNumb + "' size='13' onChange='javascript:addDateRow(" + rowNumb + ")'></div>"
			strContent = strContent + "<div style='float:left; width:100px; text-align:center; padding:3px;'><input name='dtmProdFromTime" + rowNumb + "' type='text' class='text' id='dtmProdFromTime" + rowNumb + "' size='13'></div>"
			strContent = strContent + "<div style='float:left; width:100px; text-align:center; padding:3px;'><input name='dtmProdToDate" + rowNumb + "' type='text' class='text' id='dtmProdToDate" + rowNumb + "' size='13'></div>"
			strContent = strContent + "<div style='float:left; width:100px; text-align:center; padding:3px;'><input name='dtmProdToTime" + rowNumb + "' type='text' class='text' id='dtmProdToTime" + rowNumb + "' size='13'></div>"
			strContent = strContent + "<div style='float:left; width:50px; text-align:left; padding:2px;'><input name='button' type='button' class='textSmall' id='button' value=' X ' onclick='javascript:delDateRow(" + rowNumb + ")'></div>"
			document.getElementById("dtmRow"+rowNumb).innerHTML=strContent;
			document.getElementById("intNumbOfDates").value=parseFloat(document.getElementById("intNumbOfDates").value) + 1;
		}
	}
	else
	{
		alert("Det går tyvär inte att ha fler än nio olika datum till varje kurs");
	}
}

function delDateRow(strRowNumb){
	var rowNumb = Right(strRowNumb,1);
	rowNumb = parseFloat(rowNumb);
	document.getElementById("dtmRow"+rowNumb).innerHTML="";
	if (document.getElementById("intNumbOfDates").value<1)
		{
		document.getElementById("intNumbOfDates").value=0
		}
	else{
		document.getElementById("intNumbOfDates").value=parseFloat(document.getElementById("intNumbOfDates").value) - 1;
		}
	}


function printFIL(txtArtHeadline,StrLeader,ArtID){
var tmpF = document.getElementById("btnF").checked;
var tmpI = document.getElementById("btnI").checked;
var tmpL = document.getElementById("btnL").checked;
var NumbOf = document.getElementById("NumbOf" + ArtID).value;
url="admin_printFIL.asp?ArtID=" + ArtID + "&txtArtHeadline=" + txtArtHeadline + "&StrLeader=" + StrLeader + "&NumbOf=" + NumbOf + "&tmpF=" + tmpF + "&tmpI=" + tmpI + "&tmpL=" + tmpL;
top.location.href = url;
//alert(tmpF)
//alert(tmpI)
//alert(tmpL)
//alert(NumbOf)
}


function correctDate(dtmStr){
	var tmpDateStr
	if(dtmStr.length==8){
		tmpDateStr = Left(dtmStr,4) + "-" +  Mid(dtmStr,4,2) + "-" + Right(dtmStr,2)
		document.getElementById("dtmAttractionDate").value = tmpDateStr;
		}
}

function readMore(pageURL){
	var url= pageURL
	location.href=url;
}

function printCourse(ArtID){
	var url =  "/adm/participant.asp?ArtID=" + ArtID;
	mywindow = window.open (url , "mywindow","resizable=1,location=0,status=0,scrollbars=0, width=700,height=800");
	mywindow.moveTo(0,0);
}

function printDiploma(ArtID){
	var url =  "/adm/admin_diploma.asp?ArtID=" + ArtID;
	mywindow = window.open (url , "mywindow","resizable=1,location=0,status=0,scrollbars=0, width=700,height=800");
	mywindow.moveTo(0,0);
}

// Funtioner för tidsangivelse

//function addList(x,iRowCount){
//	var cell_name=x.insertCell(0)
//	var sScript="<select name='connLeaderID"+iRowCount+"' class='text'>";
//	<% 
//	Dim arrTeatcher(50)
//	Dim arrTeatcherID(50)
//	Dim arrNumb
//	arrNumb=0
//	Set Connect = Server.CreateObject("ADODB.Connection")
//	Connect.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & _
//	Server.MapPath("../../data/neuro_db.mdb") & ";pwd=neurodb;"
//	Set RecSet = Server.CreateObject("ADODB.Recordset")
//	strSQL = "SELECT * FROM tblLeader " & _
//			 " ORDER BY txtLeaderName"
//	RecSet.Open strSQL, Connect
//	Do Until RecSet.EOF
//		Response.Write("sScript = sScript + '<option value=" & RecSet("LeaderID") & ">" & RecSet("txtLeaderName") & "</option>';")
//		'---------------------------------
//		' For use further down in the code
//		'---------------------------------
//		arrNumb = arrNumb + 1
//		arrTeatcher(arrNumb)=RecSet("txtLeaderName")
//		arrTeatcherID(arrNumb)=RecSet("LeaderID")
//	RecSet.MoveNext
//	Loop
//	RecSet.Close
//	Connect.Close
//	Set RecSet = nothing
//	Set Connect = nothing
//	%>
//	sScript = sScript + "</select>";
//	cell_name.innerHTML=sScript;
//}

//function insRow()
//  {
//	var oRows = addScheme.document.getElementById('MyTable').getElementsByTagName('tr');
//	var iRowCount = oRows.length + 1;
//	
//	var x=addScheme.document.getElementById('myTable').insertRow(1)
//	
//	addList(x,iRowCount);
//	
//	var cell_btn=x.insertCell(1)
//	var cell_empty=x.insertCell(2)
//	
//	
//	
//	cell_btn.innerHTML="<input type='button' name='btnDel' class='text' value='&nbsp;X&nbsp;' onclick='deleteRow(this," + iRowCount + ")' onkeypress='return noenter()'/>";
//	cell_empty.innerHTML="b" + iRowCount + "<input name='b" + iRowCount + "' type='button' class='text' id='b" + iRowCount + "' onclick='insRow()' value='Fler f&ouml;rel&auml;sare' />";
//
//	tmpBtn = document.getElementById('b1');
//	tmpBtn.style.visibility="hidden";
//	
//	// fungerar
//	if (iRowCount>2) {
//	tmpStr="b" + iRowCount;
//	tmpBtn = document.getElementById(tmpStr);
//	tmpBtn.style.visibility="hidden";
//	}
//	
//	//Setting rowvalue
//	document.addScheme.intRowsTeatcher.value=iRowCount;
//}

//function deleteRow(t,r){
//	// Counting
//	var oRows = addScheme.document.getElementById('MyTable').getElementsByTagName('tr');
//	var iRowCount = oRows.length;
//	//Delete row
//	var i=t.parentNode.parentNode.rowIndex
//	document.getElementById('myTable').deleteRow(i)
//	//get value of row above
//	var table = document.getElementById("MyTable");
//	var row = table.rows[iRowCount-2];
//	var cell = row.cells[2];
//	var content = cell.firstChild.nodeValue;
//	if (iRowCount>2) {
//		//Set button to Visible
//		tmpBtn = document.getElementById(content);
//		tmpBtn.style.visibility="visible";
//	}
//	else
//	{
//	//if there is only one row left
//	tmpBtn = document.getElementById('b1');
//	tmpBtn.style.visibility="visible";
//	}
//	//Setting rowvalue
//	document.addScheme.intRowsTeatcher.value=iRowCount-1;
//}
//
function insRow_date()
  {
	var oRows = frmNewArt.document.getElementById('MyTable_date').getElementsByTagName('tr');
	var iRowCount = oRows.length + 1;
	
	var x=frmNewArt.document.getElementById('myTable_date').insertRow(1)
	
	var cell_fromdate=x.insertCell(0)
	var cell_todate=x.insertCell(1)
	var cell_btn=x.insertCell(2)
	var cell_empty=x.insertCell(3)
	var cell_index=x.insertCell(4)
		
	cell_fromdate.innerHTML="<span class='text'>Från </span><input name='dtmProdFromDate" + iRowCount + "' type='text' class='text' id='dtmProdFromDate" + iRowCount + "' size='12'><input name='dtmProdFromTime" + iRowCount + "' type='text' class='text' id='dtmProdFromTime" + iRowCount + "' size='6'>";
	cell_todate.innerHTML="<span class='text'>till </span><input name='dtmProdToDate" + iRowCount + "' type='text' class='text' id='dtmProdToDate" + iRowCount + "' size='12'><input name='dtmProdToTime" + iRowCount + "' type='text' class='text' id='dtmProdToTime" + iRowCount + "' size='6'>";
	cell_btn.innerHTML="<input type='button' name='btnDel' class='text' value='&nbsp;X&nbsp;' onclick='deleteRow_date(this," + iRowCount + ")' onkeypress='return noenter()'/>";
	cell_empty.innerHTML="<input name='c" + iRowCount + "' type='button' class='text' id='c" + iRowCount + "' onClick='insRow_date()' value='Fler datum' />";
	cell_index.innerHTML="c" + iRowCount;
	
	tmpBtn = document.getElementById('c1');
	tmpBtn.style.visibility="hidden";
	
	// fungerar
	if (iRowCount>3) {
	tmpStr="c" + iRowCount;
	tmpBtn = document.getElementById(tmpStr);
	tmpBtn.style.visibility="hidden";
	}	 
	//Setting rowvalue
	document.frmNewArt.intRowsDate.value=iRowCount;
}

//
//function deleteRow_date(t,r){
//	// Counting
//	var oRows = addScheme.document.getElementById('MyTable_date').getElementsByTagName('tr');
//	var iRowCount = oRows.length;
//	//Delete row
//	var i=t.parentNode.parentNode.rowIndex
//	document.getElementById('MyTable_date').deleteRow(i)
//	//get value of row above
//	var table = document.getElementById("MyTable_date");
//	var row = table.rows[iRowCount-3];
//	var cell = row.cells[4];
//	var content = cell.firstChild.nodeValue;
//	if (iRowCount>2) {
//		//Set button to Visible
//		tmpBtn = document.getElementById(content);
//		tmpBtn.style.visibility="visible";
//	}
//	else
//	{
//	//if there is only one row left
//	tmpBtn = document.getElementById('c1');
//	tmpBtn.style.visibility="visible";
//	}
//		//Setting rowvalue
//	document.addScheme.intRowsDate.value=iRowCount-1;
//}
  
function checkMailCopy(){
	document.addScheme.blnMailCopy.checked = true;
}

function AddFinnishDate(x) {
	n=Right(x, 1);
	switch(n)
	{
	case "2":
  	document.addScheme.dtmToDate2.value=document.addScheme.dtmFromDate2.value;
  	break;
	case "3":
  	document.addScheme.dtmToDate3.value=document.addScheme.dtmFromDate3.value;
  	break;
	case "4":
  	document.addScheme.dtmToDate4.value=document.addScheme.dtmFromDate4.value;
  	break;
	case "5":
  	document.addScheme.dtmToDate5.value=document.addScheme.dtmFromDate5.value;
  	break;
	case "6":
  	document.addScheme.dtmToDate6.value=document.addScheme.dtmFromDate6.value;
  	break;
	case "7":
  	document.addScheme.dtmToDate7.value=document.addScheme.dtmFromDate7.value;
  	break;
	case "8":
  	document.addScheme.dtmToDate8.value=document.addScheme.dtmFromDate8.value;
  	break;
	case "9":
  	document.addScheme.dtmToDate9.value=document.addScheme.dtmFromDate9.value;
  	break;
	case "10":
  	document.addScheme.dtmToDate10.value=document.addScheme.dtmFromDate10.value;
  	break;
	}
}

// --------------------------- EKONOMI FUNKTIONER -----------------------------------

function openAdmCust(){
	url="invoice_customer.asp";
	location.href=url;
}

function openInvoiceList(){
	url="invoice_invoiceList.asp?f=none";
	location.href=url;
}

function openNoInvoice(){
	url="invoice_All.asp?f=none";
	location.href=url;
}

function openGotInvoice(){
	url="invoice_got_All.asp?f=none";
	location.href=url;
}

function openOblitiration(){
	url="invoice_obliterate.asp?f=none";
	location.href=url;
}

function openCredit(){
	url="invoice_credit.asp?f=none";
	location.href=url;
}

function openCreateorder(){
	url="invoice_newOrder.asp?f=none";
	location.href=url;
}

function openAdmin(){
	url="invoice_adm.asp?f=none";
	location.href=url;
}

function viewInvoice(OrderID,intOrderStatus) {
	var url =  "/adm/invoice/invoice_custInvoice.asp?OrderID=" + OrderID + "&intOrderStatus=" + intOrderStatus;
	mywindow = window.open (url , "mywindow","resizable=1,location=0,status=0,scrollbars=0, width=700,height=800");
  	mywindow.moveTo(0,0);
 }


function filterSub(CatID){
	tmpTarget = "SubCat";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="filterSubCat.asp?CatID=" + CatID;
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=updatedTarget 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function chArtSub(ArtID,CatID){
		tmpTarget = "SubCatID" + ArtID;
		xmlHttp=GetXmlHttpObject() 
		if (xmlHttp==null)
		 {
		 alert ("Browser does not support HTTP Request")
		 return
		 }
		var url="showSubCat.asp?ArtID=" + ArtID + "&CatID=" + CatID;
		url=url+"&sid="+Math.random()
		xmlHttp.onreadystatechange=updatedTarget;
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}

function chCatForArt(ArtID,CatID,SubCatID){
	tmpTarget = "SubCatID" + ArtID;
	xmlHttp=GetXmlHttpObject() 
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="updateCatForArt.asp?ArtID=" + ArtID + "&CatID=" + CatID + "&SubCatID=" + SubCatID;;
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=updatedTarget;
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	}
	

function loadNewCourse(connArtID){
	// Fast värde 2, betyder att det är förvalt som Kurs
	url="newArt_course.asp?connArtID=" + connArtID+ "&CatID=2";
	location.href=url;
}

function loadNewArt(connArtID){
	url="newArt_article.asp?connArtID=" + connArtID;
	location.href=url;
}

function SendInv(){
	alert("Beställning mot faktura är igång senast den 18 augusti")
	document.getElementById("radio3").checked=false; 
	document.getElementById("radio1").checked=true; 
}

// ================================================== KEYPRESSED FUNCTIONS

function EnterPressed(e) {
// Code adapted from Jennifer Madden
// http://jennifermadden.com/162/examples/stringEnterKeyDetector.html

  var characterCode
  if(e && e.which){           // NN4 specific code
    e = e
    characterCode = e.which
  }
  else {
    e = event
    characterCode = e.keyCode // IE specific code
  }
  if (characterCode == 13) return true   // Enter key is 13
  else return false
}

// INLOGGNING ==============================================

function CheckInlogg(){
	document.frmLoggIn.submit();
}

function forgotAdminPW(){
	tmpTarget = "sendMess";
	xmlHttp=GetXmlHttpObject() 
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="sendPW.asp?f=null";
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=updatedTarget;
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

// ================================================== CHANGE BACKGROUND
		
function resetBg_left (loc) 
{
loc.style.backgroundColor = activetrcolor;
}

function changeBg (loc) 
{
activetrcolor = loc.style.backgroundColor;
loc.style.backgroundColor = '#e0e9f3';
}
function resetBg (loc) 
{
loc.style.backgroundColor = activetrcolor;
}

// =============================================================== Admin

function searchArtClear(searchArt){
	if (searchArt=="Minst tre tecken"){
		document.getElementById("txtSearch").value="";
		}
	}


function searchArtDirect(searchArt){
	var checkLength = searchArt.length;
	if(checkLength>2){
		location.href="article.asp?f=searchArt&searchArt=" + searchArt;
		}
	}
	
function searchCourseDirect(searchArt){
	var checkLength = searchArt.length;
	if(checkLength>2){
		location.href="course.asp?f=searchArt&searchArt=" + searchArt;
		}
	}

function admFilterCat(CatID){
	location.href="article.asp?f=filter&CatID=" + CatID;
}

function admFilterSubCat(SubCatID){
	var CatID = document.getElementById("filterCat").value;
	location.href="article.asp?f=filter&CatID=" + CatID + "&SubCatID=" + SubCatID;
}

function moveSubFocus(target){
	document.getElementById(target).focus();	
}

function showArtText(ArtID){
	document.getElementById("artTextBtn" + ArtID).innerHTML="<A HREF='javascript:void(0)' onClick='hideArtText(" + ArtID + ")'><img src='../images/dblUp.gif' alt='Visa all text' width='15' height='16' border='0' align='absmiddle'></a>";
	tmpTarget = "art" + ArtID;
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="artTextFrame.asp?connArtID=" + ArtID;
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=updatedTarget 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function hideArtText(ArtID){
	document.getElementById("artTextBtn" + ArtID).innerHTML="<A HREF='javascript:void(0)' onClick='showArtText(" + ArtID + ")'><img src='../images/dblDown.gif' alt='Visa all text' width='15' height='16' border='0' align='absmiddle'></a>";
	document.getElementById("art" + ArtID).innerHTML="";
}

function closeNewArt(){
	document.getElementById("filterCat").focus();
	document.getElementById("NewArticle").innerHTML="";
}

function createSizeGuide(ArtSizeGrpID,connArtID){
	url="artCreateSizeTable.asp?ArtSizeGrpID=" + ArtSizeGrpID + "&connArtID=" + connArtID;
	location.href = url;
}

function updateStockPerSize(ArtStockID,intArtStock,connArtID){
	tmpTarget = ArtStockID;
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	// Update value in field
	var url="updateVarStock.asp?ArtStockID=" + ArtStockID + "&intArtStock=" + intArtStock + "&connArtID=" + connArtID;
	xmlHttp.onreadystatechange=infoUpdated; 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function showArtExtras(ArtID){
	document.getElementById("artExtrasBtn" + ArtID).innerHTML="<A HREF='javascript:void(0)' onClick='hideArtExtras(" + ArtID + ")'><img src='../images/minus.gif' width='18' height='18' border='0'></A>";
	tmpTarget = "art" + ArtID;
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="artExtrasFrame.asp?ArtID=" + ArtID;
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=updatedTarget 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function hideArtExtras(ArtID){
	document.getElementById("artExtrasBtn" + ArtID).innerHTML="<A HREF='javascript:void(0)' onClick='showArtExtras(" + ArtID + ")'><img src='../images/plus.gif' width='18' height='18' border='0' align='absmiddle'></a>";
	document.getElementById("art" + ArtID).innerHTML="";
}

function showScheme(ArtID){
	document.getElementById("artSchemeBtn" + ArtID).innerHTML="<A HREF='javascript:void(0)' onClick='hideScehme(" + ArtID + ")'><img src='../images/minus.gif' width='18' height='18' border='0'></A>";
	tmpTarget = "art" + ArtID;
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="showCourseScheme.asp?connArtID=" + ArtID;
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=updatedTarget 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function hideScehme(ArtID){
	document.getElementById("artSchemeBtn" + ArtID).innerHTML="<A HREF='javascript:void(0)' onClick='showScheme(" + ArtID + ")'><img src='../images/plus.gif' width='18' height='18' border='0'></A>";
	document.getElementById("art" + ArtID).innerHTML="";
}



function showArtImage(ArtID){
	document.getElementById("artImgBtn" + ArtID).innerHTML="<A HREF='javascript:void(0)' onClick='hideArtImage(" + ArtID + ")'><img src='../images/minus.gif' width='18' height='18' border='0'></A>";
	tmpTarget = "art" + ArtID;
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="uploadArtImageFrame.asp?ArtID=" + ArtID;
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=updatedTarget 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function hideArtImage(ArtID){
	document.getElementById("artImgBtn" + ArtID).innerHTML="<A HREF='javascript:void(0)' onClick='showArtImage(" + ArtID + ")'><img src='../images/plus.gif' width='18' height='18' border='0'></A>";
	document.getElementById("art" + ArtID).innerHTML="";
}


function newArticle(CatID){ 
	if (CatID>0){
	var SubCatID = document.getElementById("filterSubCat").value;
	}
	else
	{
	SubCatID=0;	
	}
	tmpTarget = "NewArticle";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="newArtFrame.asp?CatID=" + CatID + "&SubCatID=" + SubCatID;
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=updatedTarget 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function newCourse(){ 
	tmpTarget = "NewArticle";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="newCourse.asp?f=fromList";
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=updatedTarget 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function delScheme(ArtID){
	document.getElementById("delScheme" + ArtID).style.backgroundColor="#F00";
	document.getElementById("delScheme" + ArtID).innerHTML="Är du säker? [<a href='javascript:delSchemeYes(" + ArtID + ")'>JA</a>] [<a href='javascript:delSchemeNo(" + ArtID + ")'>NEJ]</a>";	
}

function checkDate(inDate,target){
	var flag=true;
	// As in 070902
	if (inDate.length==6){
			var tmpDate = "20" + Left(inDate,2) + "-" + Mid(inDate,2,2) + "-" + Right(inDate,2)
	}
	// As in 20070902
	if (inDate.length==8){
			var tmpDate = Left(inDate,4) + "-" + Mid(inDate,4,2) + "-" + Right(inDate,2)
	}
	// As in 2007-09-02
	if (inDate.length==10){
			var tmpDate = inDate
	}
	
	// As in 0902
	if (inDate.length==4){
		now = new Date
		theYear=now.getYear()
		var tmpDate = theYear + "-" + Left(inDate,2) + "-" + Right(inDate,2)
	}
	
	document.getElementById(target).value = tmpDate;
}

function checkTime(inTime,target){
	var flag=true;
	// As in 1810
	if (inTime.length==4){
			var tmpTime = Left(inTime,2) + ":" + Right(inTime,2);
	}
	// As in 18
	if (inTime.length==2){
			var tmpTime = inTime + ":00";
	}
	
	// As in 9
	if (inTime.length==1){
			var tmpTime = "0" + inTime + ":00";
	}
	
	document.getElementById(target).value = tmpTime;
}

// =============================================================== Open pages

function openStart(){ 
	url="http://www.neurodynamik.se/index.asp?f=null";
	document.location.href = url;
}

function openFmt(){ 
	url="http://www.neurodynamik.se/fmt.asp?f=null";
	document.location.href = url;
}
		
function openCourse(){ 
	url="http://www.neurodynamik.se/course.asp?f=null";
	document.location.href = url;
}

function openNeurodynamit(){
	url="http://www.neurodynamik.se/neurodynamit.asp?f=null";
	document.location.href = url;
}

function openStore(comingFrom){ 
	if (comingFrom==2){
		var url="http://www.neurodynamik.se/store/store_basket.asp?f=null";
		}
	else{
		var url="http://www.neurodynamik.se/store/store_page.asp?f=null&lvl=2";
		}
	document.location.href = url;
}

function openForum(){ 
	url="http://www.neurodynamik.se/forum.asp?f=null";
	document.location.href = url;
}

function openContact(){ 
	url="http://www.neurodynamik.se/contact.asp?f=null";
	document.location.href = url;
}

function openBooking(){ 
	url="http://www.neurodynamik.se/timebooking/index.asp?f=inbedded";
	document.location.href = url;
}

function openExtra(){ 
	url="http://www.neurodynamik.se/extra.asp?f=null";
	document.location.href = url;
}

function openDownload(){ 
	url="http://www.neurodynamik.se/extra.asp?f=null";
	document.location.href = url;
}

function openLinks(){ 
	url="http://www.neurodynamik.se/extra_links.asp?f=null";
	document.location.href = url;
}

function openPG(EventID){ 
	url="http://www.neurodynamik.se/event.asp?intEventCat=1&EventID=" + EventID;
	document.location.href = url;
}

function openArt(EventID){ 
	url="http://www.neurodynamik.se/event.asp?intEventCat=2&EventID=" + EventID;
	document.location.href = url;
}

function openResult(){ 
	tmpTarget = "pageMain";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="result.asp?f=null";
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=updatedTarget 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function openResult_ex2(){ 
	tmpTarget = "pageMain";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="result_ex2.asp?f=null#Res2";
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=updatedTarget 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function openMembers(){ 
	tmpTarget = "pageMain";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="members.asp?f=null";
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=updatedTarget 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function openOverview(){ 
	var url="courseOverview.asp?f=null";
	location.href=url;
}

function openPrice(){ 
	var url="coursePrice.asp?f=null";
	document.location = url;
}

function openArrange(){ 
	var url="courseArrange.asp?f=null";
	document.location = url;}

function openLeader(){ 
	var url="courseLeader.asp?f=null";
	document.location = url;}

function showCV(pageCV){ 
	tmpTarget = "pageMain";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url=pageCV + ".asp?f=null";
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=updatedTarget 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function openTestimonial(){ 
	var url="courseTestimonial.asp?f=null";
	location.href = url;
}

function openRoom(){ 
	tmpTarget = "pageMain";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="room.asp?f=null";
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=updatedTarget 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function openCons(){ 
	var url="consultation.asp?f=null";
	document.location = url;
}

function openPG_hint(){ 
	tmpTarget = "pageMain";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="pg_hint.asp?f=null"
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=updatedTarget 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function adminEvent(EventID, intEventCat){ 
	url="changeEvent.asp?EventID=" + EventID + "&intEventCat=" + intEventCat;
	location.href=url;
}

function adminTechDemo(CaseID){ 
	url="changeTechDemo.asp?CaseID=" + CaseID;
	location.href=url;
}

function delEvent(EventID){ 
	document.getElementById("event" + EventID).innerHTML="Säker? <a href='javascript:delEventYes(" + EventID + ")'>JA</a>"
}

function delTechDemo(CaseID){ 
	document.getElementById("techDemo" + CaseID).innerHTML="Säker? <a href='javascript:delTechDemoYes(" + CaseID + ")'>JA</a>"
}

function delEventYes(EventID){ 
	url="updateEvent.asp?f=delYes&EventID=" + EventID;
	location.href=url;
}

function delTechDemoYes(CaseID){ 
	url="delTechDemo.asp?CaseID=" + CaseID;
	location.href=url;
}

function adminCitat(WordID){ 
	url="changeCitat.asp?WordID=" + WordID;
	location.href=url;
}

function delCitat(WordID){ 
	document.getElementById("word" + WordID).innerHTML="Säker? <a href='javascript:delCitatYes(" + WordID + ")'>JA</a>"
}

function delCitatYes(WordID){ 
	url="updateCitat.asp?f=delYes&WordID=" + WordID;
	location.href=url;
}


// =============================================================== BILDER

function showPict(EventID){
	tmpTarget = "showPict" + EventID;
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	var url="showPict.asp?EventID=" + EventID;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=updatedTarget;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	return;	
}

// =============================================================== SHOP

function openTerms(){ 
	tmpTarget = "showTerms";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="store_terms.asp?f=null";
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=updatedTarget 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function ShowArtDetail(ArtID){ 
	var url="/store/store_artDetail.asp?ArtID=" + ArtID;
	location.href=url;
}

function addToBasket(ADID,ArtID,CatID,SubCatID,txtArtHeadline,intArtPrice,intArtVat,intArtWeight,comingFrom){

	//Type of text
	//if (CatID==1){
		//var tmpBasketText = "Antal beställda varor: "
		//var tmpBasketTextLength = 23;
		//document.getElementById("subStoreMenu").innerHTML="<input name='btnBasket' type='button' onclick='javascript:openBasket(2);' value='Visa korgen >>' class='text'/>"
	//}
//	if (CatID==2){
//		var tmpBasketText = "Antal bokade kurser: "
//		var tmpBasketTextLength = 21;
//		document.getElementById("subStoreMenu").innerHTML="<input name='btnBasket' type='button' onclick='javascript:openBasket(1);' value='Visa korgen >>' class='text'/>"
//	}

	// Add to database
	
	//xmlHttp=GetXmlHttpObject()
//	if (xmlHttp==null)
//	 {
//	 alert ("Browser does not support HTTP Request")
//	 return
//	 }
	var url="/store/store_addToBasket.asp?ADID=" + ADID + "&ArtID=" + ArtID + "&CatID=" + CatID + "&SubCatID=" + SubCatID + "&txtArtHeadline=" + txtArtHeadline + "&intArtPrice=" + intArtPrice + "&intArtVat=" + intArtVat + "&intArtWeight=" + intArtWeight + "&intArtQuantity=1&ArtStockID=0";
	location.href = url;
//	url=url+"&sid="+Math.random()
//	xmlHttp.onreadystatechange=confirmAddToBasket; 
//	xmlHttp.open("GET",url,true)
//	xmlHttp.send(null)
	
	// Add to textinfo
	//var tmpValue = document.getElementById("sumBasket").innerHTML;
	//document.getElementById("subStoreMenu").style.backgroundColor="#00ff00";
	//document.getElementById("sumBasket").style.backgroundColor="#00ff00";
	
	//var lengthTmpValue = tmpValue.length;
	
	//if (lengthTmpValue>16){
		//var tmpNumb = (lengthTmpValue - tmpBasketTextLength) - 3;
	
		//tmpValue = parseFloat(Mid(tmpValue, tmpBasketTextLength, tmpNumb))
		//tmpValue = tmpValue + 1;
		//document.getElementById("sumBasket").innerHTML = tmpBasketText + tmpValue + " st"
	//}
	//else
	//{
		//document.getElementById("sumBasket").innerHTML = tmpBasketText + "1 st"
	//}
	//openBasket(comingFrom);
}

function openBasket(comingFrom){ 
	if (comingFrom==1){
	document.getElementById("subMenuContainer").innerHTML = "";
	}
	tmpTarget = "pageMain";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="/store/store_basket.asp?comingFrom=" + comingFrom;
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=updatedTarget 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function delFromBasket(connArtID,tmpID,intArtPrice,intArtQuantity,connArtCatID){ 
	var url="/store/store_basket.asp?f=del&connArtID=" + connArtID + "&tmpID=" + tmpID + "&connArtCatID=" + connArtCatID;
	var txtCustFirstName=document.getElementById("txtCustFirstName").value;
	var txtCustLastName=document.getElementById("txtCustLastName").value;
	var txtCustAddress=document.getElementById("txtCustAddress").value;
	var txtCustZip=document.getElementById("txtCustZip").value;
	var txtCustCity=document.getElementById("txtCustCity").value;
	var txtCustInvoiceName=document.getElementById("txtCustInvoiceName").value;
	var txtCustInvoiceDepart=document.getElementById("txtCustInvoiceDepart").value;
	var txtCustInvoiceAddress=document.getElementById("txtCustInvoiceAddress").value;
	var txtCustInvoiceZip=document.getElementById("txtCustInvoiceZip").value;
	var txtCustInvoiceCity=document.getElementById("txtCustInvoiceCity").value;
	var txtCustInvoiceCountry=document.getElementById("txtCustInvoiceCountry").value;
	var txtCustOrgNumb=document.getElementById("txtCustOrgNumb").value;
	var txtCustInvoiceVatNumb=document.getElementById("txtCustInvoiceVatNumb").value;
	var txtOrderRefNumb=document.getElementById("txtOrderRefNumb").value;
	var txtCustEmail=document.getElementById("txtCustEmail").value;
	var txtCustPhone=document.getElementById("txtCustPhone").value;
	url = url + "&txtCustFirstName=" + txtCustFirstName;
	url = url + "&txtCustLastName=" + txtCustLastName;
	url = url + "&txtCustAddress=" + txtCustAddress;
	url = url + "&txtCustZip=" + txtCustZip;
	url = url + "&txtCustCity=" + txtCustCity;
	url = url + "&txtCustInvoiceName=" + txtCustInvoiceName;
	url = url + "&txtCustInvoiceDepart=" + txtCustInvoiceDepart;
	url = url + "&txtCustInvoiceAddress=" + txtCustInvoiceAddress;
	url = url + "&txtCustInvoiceZip=" + txtCustInvoiceZip;
	url = url + "&txtCustInvoiceCity=" + txtCustInvoiceCity;
	url = url + "&txtCustInvoiceCountry=" + txtCustInvoiceCountry;
	url = url + "&txtCustOrgNumb=" + txtCustOrgNumb;
	url = url + "&txtCustInvoiceVatNumb=" + txtCustInvoiceVatNumb;
	url = url + "&txtOrderRefNumb=" + txtOrderRefNumb;
	url = url + "&txtCustEmail=" + txtCustEmail;
	url = url + "&txtCustPhone=" + txtCustPhone;
	location.href=url;
}

function showMyInfo(CustomerID){ 
	tmpTarget = "LoggIn";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="/store/store_inLoggCheck.asp?f=showInfo&CustomerID=" + CustomerID;
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=updatedTarget 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function hideMyInfo(txtCustName,CustomerID){ 
	strContent = "<div id='storeBasketINLOGGHeadline'>Dina uppgifter</div>"
	strContent = strContent + "Inloggad som <strong>" + txtCustName + "</strong>  [<a href='javascript:showMyInfo(" + CustomerID + ")'>Visa mina uppgifter</a>]"
	document.getElementById("LoggIn").innerHTML = strContent;
}

function blnConfirmOrder(){ 
	document.getElementById("btnRegisterContainer").innerHTML = "&nbsp;&nbsp;&nbsp;<input name='btnRegister' type='button' class='textsmall' id='btnRegister' value='BEKR&Auml;FTA ORDER' onClick='javascript:validate();' />"
}


function updateFieldCustomer(CustomerID,FieldID,FieldName,ChangeToValue){ 
	tmpTarget = FieldID;
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	// Update value in field
	var url="../adm/updateCust.asp?CustomerID=" + CustomerID + "&FieldName=" + FieldName + "&ChangeToValue=" + ChangeToValue;
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=infoUpdated 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

//----------------------------------
// Update basket
//----------------------------------
function updateBasket(intArtQuantity,rowID,connArtID,intArtPrice,tmpID){
	var url="/store/store_basket.asp?f=update&connArtID=" + connArtID + "&tmpID=" + tmpID + "&intArtQuantity=" + intArtQuantity;
	location.href=url;
}


//----------------------------------
// Logg in customer
//----------------------------------
function LoggInBasket(typeOfCust){
	if (typeOfCust=="regCust"){
		tmpTarget = "LoggIn";
		xmlHttp=GetXmlHttpObject() 
		if (xmlHttp==null)
		 {
		 alert ("Browser does not support HTTP Request")
		 return
		 }
		var url="/store/store_inLogg.asp?f=null"
		url=url+"&sid="+Math.random()
		xmlHttp.onreadystatechange=updatedTarget;
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}
	
	
	if (typeOfCust=="regCust")
	{
	document.getElementById('LoggIn').innerHTML="<iframe src ='http://www.neurodynamik.se/store/store_inLogg.asp' width='100%' height='300' frameborder='0' scrolling='No'></iframe>"
	}
	else
	{
	document.getElementById('LoggIn').innerHTML="<iframe src ='http://www.neurodynamik.se/store/store_newCust.asp' width='100%' height='450' frameborder='0' scrolling='No'></iframe>"
	}
}

//----------------------------------
// Check inlogg of customer
//----------------------------------
function checkInloggBasket(){
	var txtMemberID = document.getElementById("txtMemberID").value
	var txtMemberPW = document.getElementById("txtMemberPW").value
	tmpTarget = "LoggIn";
	xmlHttp=GetXmlHttpObject() 
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="/store/store_inLoggCheck.asp?txtMemberID=" + txtMemberID + "&txtMemberPW=" + txtMemberPW;
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=updatedTarget;
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

//----------------------------------
// Forgot password
//----------------------------------
function forgotPW(){
	tmpTarget = "LoggIn";
	xmlHttp=GetXmlHttpObject() 
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="/store/store_forgotPW.asp?f=null";
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=updatedTarget;
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

//----------------------------------
// Send password
//----------------------------------
function sendPW(){
	var txtCustEmail = document.getElementById("txtCustEmail").value
	tmpTarget = "LoggIn";
	xmlHttp=GetXmlHttpObject() 
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="/store/store_sendPW.asp?txtCustEmail=" + txtCustEmail;
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=updatedTarget;
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

// =========== Mall

function demo(variabelA,variabelB){ 
tmpTarget = VadSomSkaUppdateras;
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
var url="sida.asp?variabelA=" + variabelA + "&variabelB=" + variabelB + "";
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=updatedTarget 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

// =========== Funktioner för uppdatering

function infoUpdated() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 	// Update value in field
	document.getElementById(tmpTarget).style.borderWidth = "2px"
	document.getElementById(tmpTarget).style.borderStyle = "solid"
	document.getElementById(tmpTarget).style.borderColor = "#00cc00"
 } 
}

function markRead(thisTarget) 
{ 
 	// Mark as read
	document.getElementById(thisTarget).style.borderWidth = "2px"
	document.getElementById(thisTarget).style.borderStyle = "solid"
	document.getElementById(thisTarget).style.borderColor = "#ff0000"
}

function markNeutral(thisTarget) 
{ 
 	// Mark as gree
	document.getElementById(thisTarget).style.borderWidth = "2px"
	document.getElementById(thisTarget).style.borderStyle = "solid"
	document.getElementById(thisTarget).style.borderColor = "#33ff00"
}


function updatedTarget() 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById(tmpTarget).innerHTML=xmlHttp.responseText;
}
}

function confirmAddToBasket() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 	// Update value in field
	//document.getElementById(tmpTarget).style.borderWidth = "2px"
	//document.getElementById(tmpTarget).style.borderStyle = "solid"
	//document.getElementById(tmpTarget).style.borderColor = "#00cc00"
 } 
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}

// ================================================== ACTIONS

function validate(){
	// Check if there is someone logged
	var passFlag=true
	if (document.getElementById("txtCustFirstName").value.length==0){
		markRead("txtCustFirstName");					
		passFlag=false;
		}
		else
		{
		markNeutral("txtCustFirstName");
		}
	
	if (document.getElementById("txtCustLastName").value.length==0){
		markRead("txtCustLastName");						
		passFlag=false;						
		}
		else
		{
		markNeutral("txtCustLastName");
		}
	if (document.getElementById("txtCustInvoiceAddress").value.length==0){
		markRead("txtCustInvoiceAddress");						
		passFlag=false;
		}
		else
		{
		markNeutral("txtCustInvoiceAddress");
		}
								
	if (document.getElementById("txtCustInvoiceZip").value.length==0){
		markRead("txtCustInvoiceZip");						
		passFlag=false;
		}
		else
		{
		markNeutral("txtCustInvoiceZip");
		}
		
	if (document.getElementById("txtCustInvoiceCity").value.length==0){
		markRead("txtCustInvoiceCity");						
		passFlag=false;
		}
		else
		{
		markNeutral("txtCustInvoiceCity");
		}
								
	if (document.getElementById("txtCustEmail").value.length==0){
		markRead("txtCustEmail");						
		passFlag=false;
		}
		else
		{
		markNeutral("txtCustEmail");
		}
								
	if (document.getElementById("txtCustPhone").value.length==0){
		markRead("txtCustPhone");						
		passFlag=false;
		}
		else
		{
		markNeutral("txtCustPhone");
		}
								
	if (passFlag==true){
		document.MyBasket.submit();
	}
}

function NOvalidate(){
	alert("Markera att ni läst Neurodynamiks försäljningsvillkor först");
}

function NOprod(){
	alert("Det måste finnas en artikel i korgen först.");
	document.getElementById("blnConfirmTerms").checked=false;
}

function blnConfirmTerms(){ 
	document.getElementById("btnRegisterContainer").innerHTML = "&nbsp;&nbsp;&nbsp;<input name='btnRegister' type='button' class='textsmall' id='btnRegister' value='BEKR&Auml;FTA ORDER' onClick='javascript:validate();' />"
}

function noenter() {
  return !(window.event && window.event.keyCode == 13); }



// ================================================== STRING FUNCTIONS

function Left(str, n)
        /***
                IN: str - the string we are LEFTing
                    n - the number of characters we want to return

                RETVAL: n characters from the left side of the string
        ***/
        {
                if (n <= 0)     // Invalid bound, return blank string
                        return "";
                else if (n > String(str).length)   // Invalid bound, return
                        return str;                // entire string
                else // Valid bound, return appropriate substring
                        return String(str).substring(0,n);
        }
		

function Mid(str, start, len)
        /***
                IN: str - the string we are LEFTing
                    start - our string's starting position (0 based!!)
                    len - how many characters from start we want to get

                RETVAL: The substring from start to start+len
        ***/
        {
                // Make sure start and len are within proper bounds
                if (start < 0 || len < 0) return "";

                var iEnd, iLen = String(str).length;
                if (start + len > iLen)
                        iEnd = iLen;
                else
                        iEnd = start + len;

                return String(str).substring(start,iEnd);
        }


// Keep in mind that strings in JavaScript are zero-based, so if you ask
// for Mid("Hello",1,1), you will get "e", not "H".  To get "H", you would
// simply type in Mid("Hello",0,1)

// You can alter the above function so that the string is one-based.  Just
// check to make sure start is not <= 0, alter the iEnd = start + len to
// iEnd = (start - 1) + len, and in your final return statement, just
// return ...substring(start-1,iEnd)


function Right(str, n)
        /***
                IN: str - the string we are RIGHTing
                    n - the number of characters we want to return

                RETVAL: n characters from the right side of the string
        ***/
        {
                if (n <= 0)     // Invalid bound, return blank string
                   return "";
                else if (n > String(str).length)   // Invalid bound, return
                   return str;                     // entire string
                else { // Valid bound, return appropriate substring
                   var iLen = String(str).length;
                   return String(str).substring(iLen, iLen - n);
                }
        }
		
		
