              
            
            var preColor ='0'
            var preSize ='0'
            var chosedColorInfo ='0'
            var chosedSize ='0'
            var sizeType ='null'
            var productIdForLoginWindow =0
            var bookItems


//----------Change top tabs
            var preTabColl ='0'
            var tabCaseColl
            function changeTabsColl(obj, Case)
            { if(preTabColl !=obj)
              { tabCaseColl =Case
              	switch(Case)
              	{ case 1: getObj('pIcon').style.background='url(img/collection/wIcon.jpg)'
              	          loadProduct('D',0,'W')
              	          break
                  case 2: getObj('pIcon').style.background='url(img/collection/mIcon.jpg)'
                          loadProduct(0,0,'M')
                          break
                  case 3: getObj('pIcon').style.background='url(img/collection/mIcon.jpg)'
                          loadProduct(0,0,'C')
                          break
                  case 4: getObj('pIcon').style.background='url(img/collection/mIcon.jpg)'
                          loadProduct(0,0,'A')
                          break }
              	obj.bgColor='white'
                obj.style.borderBottomWidth='0px'
                obj.style.color ='black'
                if(preTabColl !='0')
                { preTabColl.bgColor=''
                  preTabColl.style.borderBottomWidth='1px' }
                preTabColl =obj
            } }


//----------Load products
            var xmlColl
            var preCategory ='0'
            function loadProduct(mid, page, type)
			{ xmlColl =getXMLHttpObject()
			  if(xmlColl ==null)
			  { alert("Browser does not support HTTP Request"); return; }
			  setPreLoader(getObj('collectionTd'))
			  var url ='modulee/ajax/productLoader.php?type='+ type +'&mid='+ mid +'&page='+ page
			  xmlColl.onreadystatechange =stateChanged_Collection
			  xmlColl.open("GET",url,true)
			  xmlColl.send(null) }
		    
		    function stateChanged_Collection()
			{ if(xmlColl.readyState ==4 || xmlColl.readyState =="complete")
			  getObj('collectionTd').innerHTML =xmlColl.responseText }


//----------View products
            function getProduct(id,code)
            { xmlPro =getXMLHttpObject()
			  if(xmlPro ==null)
			  { alert("Browser does not support HTTP Request"); return }
			  var url ='modulee/ajax/productView.php?id='+ id +'&code='+ code
			  xmlPro.onreadystatechange =stateChanged_viewProduct
			  xmlPro.open("GET",url,true)
			  xmlPro.send(null) }
              
		    function stateChanged_viewProduct()
			{ if(xmlPro.readyState ==4 || xmlPro.readyState =="complete")
			  { getObj('proBody').innerHTML =xmlPro.responseText;
			    getObj('proName').innerHTML ='PRODUCTS'
			    preLoaderControl(false)
            } }


//----------Change big Image
            function changeImg(bInd, type)
            { getObj('bImg').innerHTML ='<img src="file/product/men/'+ str[ind] +'">'
            }


//----------Show choosed color image
            function showChoosedColorImage(img)
            { getObj('choosedColorImg').innerHTML ='<img src="test2.php?src=http://www.altaicashmere.mn/file/color/'+ img +'&w=126&h=95&q=100">'
            }
            
            
//----------Check choice before import to booking list table
            function checkChoice(table)
            { tmp =chosedColorInfo.split(',')
              if(table.rows.length >2)
              for(var i=2; i<table.rows.length; i++)
              { if(tmp[1] +'.'+ chosedSize ==table.rows[i].cells[0].childNodes[0].rows[0].cells[1].innerHTML +'.'+ table.rows[i].cells[1].childNodes[0].innerHTML)
                return false
              } return true
            }
            
            
//----------Gather all booking items
            function gatherBooking()
            { bookItems =''
              var table =getObj('bookingListTable')
              for(var i=2; i<table.rows.length; i++)
              { var colorName =table.rows[i].cells[0].childNodes[0].rows[0].cells[1].innerHTML
              	var size =table.rows[i].cells[1].childNodes[0].innerHTML
              	var pcs =table.rows[i].cells[2].childNodes[0].childNodes[0].value
              	bookItems +=colorName +':'+ size +':'+ pcs +':'
            } }


//----------Show big image
			function showBigImg(code,img)
			{ getObj('mainImg').innerHTML ='<img src="file/product/'+ code +'/'+ img +'">'
			}


//----------Import goto booking list table
            var price=0; pcs=0; prePcs=0
            function importChose(table)
            { getObj('noChoseTd').innerHTML =''
              var tBody =table.getElementsByTagName('tbody')[0]
              var row =document.createElement('tr')
          /**/str = '<table cellspacing="0" cellpadding="0">'
              str +='<tr><td style="padding-top:1px">'
              str +='       <img src="test2.php?src=http://www.altaicashmere.mn/file/color/'+ tmp[0] +'&w=20&h=20&q=100"></td>'
              str +='    <td style="padding-left:3px; font-size:12px; color:black; font-weight:bold">'+ tmp[1] +'</td>'
              str +='</tr>'
              str +='</table>'
              addCell(row,str)
          /**/str = '<div style="color:black; padding-left:8px;'
              str +=' font-size:12px; font-weight:bold">'+ chosedSize +'</div>'
              addCell(row,str)
          /**/price =parseInt(document.productForm.price.value)
              pcs =parseInt(getObj('chosedPcs').value)
              str = '<div style="padding-top:1px; padding-left:1px">'
              str +='<input type="text" style="font-weight:bold; width:72px; color:black;'
              str +=' padding-left:5px" maxlength="1" value="'+ getObj('chosedPcs').value +'"'
              str +=' onFocus="prePcs=(this.value!=\'\') ? parseInt(this.value) : 0"'
              str +=' onKeyUp="keyFilter(this);'
              str +='          var newPcs=(this.value!=\'\') ? parseInt(this.value) : 0;'
              str +='          this.parentNode.parentNode.parentNode.cells[3].childNodes[0].rows[0].cells[0].innerHTML ='+ price +'* newPcs;'
              str +='          updateTotal((newPcs-prePcs)*'+ price +',newPcs-prePcs);'
              str +='          prePcs=newPcs">'
              str +='</div>'
              addCell(row,str)
          /**/str = '<table cellspacing="0" cellpadding="0">'
              str +='<tr><td style="padding-left:8px; color:black; font-size:12px;'
              str +='     font-weight:bold">'+ (price * pcs) +'</td>'
              str +='    <td style="color:#4AA83A"><b>$</b></td></tr>'
              str +='</table>'
              addCell(row,str)
          /**/str = '<input type="button" value=" &nbsp;Remove&nbsp; " class="st1"'
              str +=' style="color:black; padding-bottom:1px; cursor:pointer"'
              str +=' onClick="if(confirm(\'Are you sure to delete?\'))'
              str +='          { tmp =this.parentNode.parentNode.cells[2].childNodes[0].childNodes[0];'
              str +='            tmp =(tmp.value !=\'\') ? parseInt(tmp.value) : 0;'
              str +='            getObj(\'bookingListTable\').deleteRow(this.parentNode.parentNode.rowIndex);'
              str +='            updateTotal(-'+ price +'*tmp,-tmp);'
              str +='            if(getObj(\'bookingListTable\').rows.length ==2) emptyTable() }">'
              addCell(row,str)
              tBody.appendChild(row)
              updateTotal(price*pcs,pcs)
            }
            

//----------Update Total statistic
            function updateTotal(Price,Pcs)
            { tmp =parseInt(getObj('totalPriceTd').innerHTML) + Price
              getObj('totalPriceTd').innerHTML =tmp
              tmp =parseInt(getObj('totalPcsTd').innerHTML) + Pcs
              getObj('totalPcsTd').innerHTML =tmp
            }


//----------Append <td> in <tr>
            function addCell(row,value)
            { var cell =document.createElement('td')
              cell.innerHTML =value
              row.appendChild(cell) }
            

//----------Booking list table is empty
            function emptyTable()
            { str = '<table width="100%" height="58">'
    	      str +='<tr><td align="center">You haven`t decided yet now!</td></tr>'
    	      str +='</table>'
    	      getObj('noChoseTd').innerHTML =str
    	      getObj('totalPriceTd').innerHTML ='0'
              getObj('totalPcsTd').innerHTML ='0' }


//----------Search by code from product
            function searchProduct()
            { getProduct('search',getObj('searchKey').value)
              str = '<table align="center">'
		  	  str +='<tr><td height="5"></td></tr>'
		  	  str +='<tr><td><input type="button" class="st1" value=" Close window " style="color:black; '
			  str +='         cursor:pointer; padding-bottom:2px" onClick="closeProgram()"></td></tr>'
		  	  str +='<tr><td height="3"></td></tr>'
		  	  str +='</table>'
		  	  getObj('proExplain').innerHTML =str
            }

//----------Check input values error and send email
            function checkFriendError()
			{ tabPower =false
			  var errorMsg ='';
		      var errorCount =0
			  var form =document.sendFriendForm
			  if(xSpace(form.yourName.value) =='')       errorMsg += ++errorCount +'. Please insert your name!\n';
			  if(xSpace(form.yourEmail.value) =='')      errorMsg += ++errorCount +'. Your E-mail is empty!\n';
			  else
			  { var filter =/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/
			    if(!filter.test(form.yourEmail.value))   errorMsg += ++errorCount +'. Your E-mail is undefined!\n';
			  }
			  if(xSpace(form.friendName.value) =='')     errorMsg += ++errorCount +'. Please insert your friend\'s name!\n';
			  if(xSpace(form.friendEmail.value) =='')    errorMsg += ++errorCount +'. Your friend\'s E-mail is empty!\n';
			  else
			  { var filter =/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/
			    if(!filter.test(form.friendEmail.value)) errorMsg += ++errorCount +'. Your friend\'s E-mail is undefined!\n';
			  }
			  if(errorMsg =='')  sendFriend()
			  else alert('Errors occurred!\n'+ errorMsg)
			}

//----------Send friend email about product
            var httpRequestFriend =false;
			function makePOSTRequest(url,parameters,mode)
			{ httpRequestFriend =getXMLHttpObject()
			  if(httpRequestFriend ==null)  { alert('Cannot create XMLHTTP instance'); return false; }
			  if(mode =='email')  httpRequestFriend.onreadystatechange =onResultFriend;
			  httpRequestFriend.open('POST', url, true)
			  httpRequestFriend.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
			  httpRequestFriend.setRequestHeader("Content-length", parameters.length)
			  httpRequestFriend.setRequestHeader("Connection", "close")
			  httpRequestFriend.send(parameters) }

			function onResultFriend()
			{ if(httpRequestFriend.readyState ==4)
			  { if(httpRequestFriend.status ==200)
			    { preLoaderControl(false)
			      str = '<table>'
			      str +='<tr><td style="padding:5px; padding-top:7px">'
			      str +='    <input type="button" class="st1" value="Öîíõûã õààõ" style="color:black;'
			      str +='         cursor:pointer; padding-bottom:2px" onClick="closeProgram()"></td>'
			      str +='</tr></table>'
		  	      document.getElementById('proExplain').innerHTML =str
		          document.getElementById('proName').innerHTML ='MESSAGE WINDOW'
			      document.getElementById('proBody').innerHTML =httpRequestFriend.responseText; }
			    else alert('There was a problem with the request.')
			} }

			function sendFriend()
			{ preLoaderControl(true)
		      var form =document.sendFriendForm
              str = 'proId='+ form.proId.value +'&'
			  str +='yourName='+ form.yourName.value +'&'
		      str +='yourEmail='+ form.yourEmail.value +'&'
		      str +='friendName='+ form.friendName.value +'&'
		      str +='friendEmail='+ form.friendEmail.value
		      makePOSTRequest('modulee/ajax/sendFriend.php',str) }