﻿var icon = new Array(14);
for(i=0;i<icon.length;i++) {
icon[i] = new Image;
}
icon[0].src = 'images/horseman_over.png';
icon[1].src = 'images/foot_over.png';
icon[2].src = 'images/painting_over.png';
icon[3].src = 'images/accessories_over.png';
icon[4].src = 'images/multi_over.png';
icon[5].src = 'images/sets_over.png';
icon[6].src = 'images/russian_over.png';

icon[7].src = 'images/horseman_s_over.png';
icon[8].src = 'images/foot_s_over.png';
icon[9].src = 'images/painting_s_over.png';
icon[10].src = 'images/accessories_s_over.png';
icon[11].src = 'images/multi_s_over.png';
icon[12].src = 'images/sets_s_over.png';
icon[13].src = 'images/russian_s_over.png';

function getXmlHttp(){
  var xmlhttp;
  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;
}

function baget_change(mode,file_name,ID) {
    
    var req = getXmlHttp();
	var php_data = new Array();
	var str = '';
	
    req.open('GET', 'change_baget_img.php?mode='+mode+'&file_name='+file_name+'&ID='+ID+'&r='+Math.random(), true);  
 
   
    var statusElem = document.getElementById('baget_content') 
	statusElem.innerHTML = '';
    req.onreadystatechange = function() {  
      
 
        if (req.readyState == 4) { 
        
            statusElem.innerHTML = req.statusText 
 
            if(req.status == 200) { 
				str = req.responseText;
				php_data = str.split("::");
				document.getElementById('next_but').className = php_data[0];
				document.getElementById('prev_but').className = php_data[1];
                if(file_name == 'portfolio.php') {
					statusElem.innerHTML = "<a href='"+php_data[2]+".jpg' rel='lightbox'><img src='"+php_data[2]+".jpg' width='493' height='350' alt='' border='0' /></a>";
					$('a[rel*=lightbox]').lightBoxClone();
				} else {
					statusElem.innerHTML = "<img src='"+php_data[2]+".jpg' width='493' height='350' alt='' />";
				}
            }
    
        }
 
    }

 
    req.send(null);
    statusElem.innerHTML = "<center><p>Loading...</p></center>";
}
function addToCart(tovarID) {
    
    var req = getXmlHttp()  
	req.open('GET', 'ajax.php?tovarID='+tovarID, true);  
	
   
    var statusElem = document.getElementById('basket_num'); 
	statusElem.innerHTML = '';
    req.onreadystatechange = function() {  
      
 
        if (req.readyState == 4) { 
        
            statusElem.innerHTML = req.statusText 
 
            if(req.status == 200) { 
             
                statusElem.innerHTML = req.responseText;
            }
    
        }
 
    }

 
    req.send(null);
    statusElem.innerHTML = '';
	/*"<img src='images/loading.gif' alt='' />";*/
}

function show_obj(obj) {
	if(obj.style.display == 'none') obj.style.display = 'block';
	else obj.style.display = 'none';
}
