			var DivId;
			var status = true;
			var time = 0;
			var DepIDbefore = 0;
			var TabIDbefore = 1;
			var FirstGo = true;
			var SecondGo = true;
			//var objektai = new Array();
			
			function XmlHttp( ){
                this.CreateXmlHttpObject = CreateXmlHttpObject;
                this.GetUrlContent              = GetUrlContent;
                this.GetResponseText          = GetResponseText;
                this.GetReadyState              = GetReadyState;           
                this.HttpMethod = 'GET'; // default
                this.objXmlHttp = this.CreateXmlHttpObject();
            }

            // Initialize XMLHttpObject
            function CreateXmlHttpObject(){
                var xmlhttp=false;
                try {
                    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
                } catch (e) {
                try {
                    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (E) {
                    xmlhttp = false;
                }
            }
       

            if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                xmlhttp = new XMLHttpRequest();
            }
                return xmlhttp;
            }
            var objXMLHttp =  new XmlHttp();
                   
            function GetReadyState( ){
				return this.objXmlHttp.readyState;
            }
 
            function GetResponseText( ){
                return this.objXmlHttp.responseText;
            }

			function GetResponse(){
				if (objXMLHttp!=null && objXMLHttp.GetReadyState()==4 && tmpDivId != null) {
				var objMyDiv = document.getElementById( tmpDivId );
				var objMyDiv2 = document.getElementById( tmpDivId2 );
				var objMyDiv3 = document.getElementById( tmpDivId3 );
				var objMyDiv4 = document.getElementById( tmpDivId4 );
                    // save response in inner html of result object                       
					//objMyDiv.innerHTML = '<a style="font-size:12px;padding-top:15px;">Please wait...'+DivId+'</a>';
					if (objXMLHttp.GetResponseText( )!=''){
						if (objXMLHttp.GetResponseText( )=='None') {
							objMyDiv.innerHTML = objXMLHttp.GetResponseText();
							objMyDiv2.innerHTML = '<img src="/images/addtobasket.png" alt="add to basket" />';
							objMyDiv3.value = '';
							objMyDiv4.innerHTML = '<img src="/images/addtowishlist.png" alt="Add to wishlist" />';
						} else {
							splitArr = objXMLHttp.GetResponseText().split("@@");
							if (splitArr.length > 0) {
								//activate buttons
								objMyDiv2.innerHTML = '<input type="image" src="/images/addtobasket.png" alt="add to basket" />';
								objMyDiv4.innerHTML = '<a href="#" onclick=" frmDetail.m.value=\'wishlist\'; frmDetail.action=\'/detail.asp/sku='+SKU+'\'; frmDetail.submit();"><img src="/images/addtowishlist.png" alt="Add to wishlist" /></a>';
							}
							
							var splitIds = new Array();
							var splitVals = new Array();
							
							for(i=0;i<splitArr.length;i++) {
								if (i == 0) {
									objMyDiv.innerHTML = splitArr[i];	
								} else if(i == 1) {
									//insert option id to hidden input
									objMyDiv3.value = splitArr[i];
								} else if (i == 2) {
									//get ids
									splitIds = splitArr[i].split(",");
								} else if (i == 3) {
									//split again and assing option values by ids
									splitVals = splitArr[i].split(",");
									for(j=0;j<splitIds.length;j++) {
										if (document.getElementById('optid'+splitIds[j])) {
											document.getElementById('optid'+splitIds[j]).value = splitVals[j];
										}
									}
								}
							}
						}
					}
                }
            }		

			function GetResponse2(){
				if (objXMLHttp!=null && objXMLHttp.GetReadyState()==4 && tmpDivId != null) {
					var objMyDiv = document.getElementById( tmpDivId);
                    // save response in inner html of result object                       
					if (objXMLHttp.GetResponseText( )!='') {
						objMyDiv.innerHTML = objXMLHttp.GetResponseText();
					}
                }
            }			
 
            // Function performs Get request to absolute url(strUrl)
            // using XmlHttp object (asynchroni)
            // Response returned into objResult element using innerHTML.
            // When state of XmlHttp object is changed - objOnReadyStateChangeFunction called
            function GetUrlContent( strUrl, toSend ,objOnReadyStateChangeFunction, filename){
			if (objXMLHttp.HttpMethod == "GET") {
				this.objXmlHttp.open(this.HttpMethod, strUrl, true);
                this.objXmlHttp.setRequestHeader('Content-Type', 'text/xml; charset=UTF-8');
				strUrl = null;
			} else if (objXMLHttp.HttpMethod == "POST"){
					this.objXmlHttp.open(this.HttpMethod, filename, true);
	                this.objXmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	                this.objXmlHttp.setRequestHeader("Content-length", strUrl.length);
	                this.objXmlHttp.setRequestHeader("Connection", "close");
			}
                if(objOnReadyStateChangeFunction){
					this.objXmlHttp.onreadystatechange=function(){
                        objOnReadyStateChangeFunction();
                    }
                }
                this.objXmlHttp.send(strUrl);
				status = true;
            }
           
            //This function is called when we get the data back from the server.       
            
			var tmpDivId = null;
			var tmpDivId2 = null;
			var tmpDivId3 = null;
			var tmpDivId4 = null;
			var SKU = null;
            function UpdateDiv( DivId,DivId2,DivId3,DivId4,sku2,Page ){
				Page = Page.replace(/&amp;/g,"&");
				objXMLHttp.HttpMethod = "GET";
				if (FirstGo==false && objXMLHttp.GetReadyState()!=4){
					UpdateDivByTimeOut(DivId, DivId2, DivId3, DivId4, sku2, Page);
				} else {
					FirstGo = false;
					status = false;
					SKU = sku2;
					tmpDivId = DivId;
					tmpDivId2 = DivId2;
					tmpDivId3 = DivId3;
					tmpDivId4 = DivId4;
					if( Page !='' ){
						var objMyDiv = document.getElementById( DivId );
						var objMyDiv2 = document.getElementById( DivId2 );
						var objMyDiv3 = document.getElementById( DivId3 );
						var objMyDiv4 = document.getElementById( DivId4 );
						objMyDiv.innerHTML = '<img src="/images/ajax-loader.gif" alt="" />';
						objXMLHttp.GetUrlContent( Page, null ,GetResponse, '');				
					}
				}
				return true;
            }		

			function UpdateOptTable(tableID,Page,filename,method) {
				Page = Page.replace(/&amp;/g,"&");
				objXMLHttp.HttpMethod = method;
				if (FirstGo==false && objXMLHttp.GetReadyState()!=4){
					UpdateOptTableByTimeOut(tableID,Page,filename,method);	
				} else {
					FirstGo = false;
					status = false;
					tmpDivId = tableID;
					if (Page!='') {
						var objMyDiv = document.getElementById(tableID);
						objMyDiv.innerHTML = '<img src="/images/ajax-loader.gif" alt="" />';
						objXMLHttp.GetUrlContent(Page,null,GetResponse2,filename);				
					}
				}
			}		

			function UpdateOptTableByTimeOut(a, b, c, d){
				if(objXMLHttp.GetReadyState()!=4 && time<2001){
					time++;				
					if (time==2001){ alert("server is not answering, please try later");}
					setTimeout('UpdateOptTableByTimeOut("'+a+'", "'+b+'", "'+c+'", "'+d+'")', 200);
				}
				if(objXMLHttp.GetReadyState()==4 && time<2001){
					UpdateOptTable(a, b, c, d);
				}
			}	

			function UpdateDivByTimeOut(a, b, c, d, e, f){
				if(objXMLHttp.GetReadyState()!=4 && time<2001){
					time++;				
					if (time==2001){ alert("server is not answering, please try later");}
					setTimeout('UpdateDivByTimeOut("'+a+'", "'+b+'", "'+c+'", "'+d+'", "'+e+'", "'+f+'")', 200);
				}
				if(objXMLHttp.GetReadyState()==4 && time<2001){
					UpdateDiv(a, b, c, d, e, f);
				}
			}				