var img = new Array(5);
for(i=0;i<img.length;i++) {
	j=i+1;
	img[i] = new Image();
	img[i].src = 'images/menu_active_0'+j+'.jpg';
}
var topimg = new Array(5);
for(i=0;i<img.length;i++) {
	j=i+1;
	topimg[i] = new Image();
	topimg[i].src = 'images/topmenu_act_0'+j+'.jpg';
}
topimg[5] = new Image();
topimg[5].src = 'images/topmenu_act_05_handmade.jpg';
topimg[6] = new Image();
topimg[6].src = 'images/topmenu_act_05_web.jpg';
topimg[7] = new Image();
topimg[7].src = 'images/topmenu_act_05_lenta.jpg';
topimg[8] = new Image();
topimg[8].src = 'images/topmenu_act_05_cost.jpg';

function show_mod(obj) {
	if(obj.style.display == 'none' && document.calc.cms.checked) obj.style.display = 'block';
	else obj.style.display = 'none';
}
 
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 vote() {
    
    var req = getXmlHttp()  
	var design = document.calc.design.options[document.calc.design.selectedIndex].value;
	var flash = (document.calc.flash.checked)?1:0;
	var design2 = (document.calc.design2.checked)?1:0;
	var cms = (document.calc.cms.checked)?1:0;
	if(cms == 1) {
	var module1 = (document.calc.module1.checked)?1:0;
	var module2 = (document.calc.module2.checked)?1:0;
	var module3 = (document.calc.module3.checked)?1:0;
	var module4 = (document.calc.module4.checked)?1:0;
	var module5 = (document.calc.module5.checked)?1:0;
	var module6 = (document.calc.module6.checked)?1:0;
	var module7 = (document.calc.module7.checked)?1:0;
	var module8 = (document.calc.module8.checked)?1:0;
	var module9 = (document.calc.module9.checked)?1:0;
	var module10 = (document.calc.module10.checked)?1:0;
	}
	
	
    req.open('GET', 'price.php?design='+design+'&flash='+flash+'&design2='+design2+'&cms='+cms+
	'&module1='+module1+
	'&module2='+module2+
	'&module3='+module3+
	'&module4='+module4+
	'&module5='+module5+
	'&module6='+module6+
	'&module7='+module7+
	'&module8='+module8+
	'&module9='+module9+
	'&module10='+module10, true);  
 
   
    var statusElem = document.getElementById('cost') 
	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 send_query() {
    
    var req = getXmlHttp()  
	var f_name = document.zapros.name.value;
	var f_email = (document.zapros.email.value != '')?document.zapros.email.value:'error';
	var f_company = document.zapros.company.value;
	var f_text =  document.zapros.text.value;	
	var statusElem = document.getElementById('cost1') 
	if(f_email != 'error') {
    req.open('GET', 'zapros.php?name='+f_name+'&email='+f_email+'&company='+f_company+'&text='+f_text, true);  
 
   
    
	statusElem.innerHTML = '';
    req.onreadystatechange = function() {  
      
 
        if (req.readyState == 4) { 
        
            statusElem.innerHTML = req.statusText 
 
            if(req.status == 200) { 
             
                statusElem.innerHTML = req.responseText;
				document.zapros.name.value = '';
				document.zapros.email.value = '';
				document.zapros.company.value = '';
				document.zapros.text.value = '';	
            }
    
        }
 
    }

 
    req.send(null);
    statusElem.innerHTML = "<img src='images/loading.gif' alt='' />";
	} else {
		statusElem.innerHTML = "Заполните поле Email";
	}
}


var qTipTag = "a,label,input";
var qTipX = 0; 
var qTipY = 15;

tooltip = {
  name : "qTip",
  offsetX : qTipX,
  offsetY : qTipY,
  tip : null
}

tooltip.init = function () {
	var tipNameSpaceURI = "http://www.w3.org/1999/xhtml";
	if(!tipContainerID){ var tipContainerID = "qTip";}
	var tipContainer = document.getElementById(tipContainerID);
  
	if(!tipContainer) {
	  tipContainer = document.createElementNS ? document.createElementNS(tipNameSpaceURI, "div") : document.createElement("div");
		tipContainer.setAttribute("id", tipContainerID);
	  document.getElementsByTagName("body").item(0).appendChild(tipContainer);
	}

	if (!document.getElementById) return;
	this.tip = document.getElementById (this.name);
	if (this.tip) document.onmousemove = function (evt) {tooltip.move (evt)};

	var a, sTitle, elements;
	
	var elementList = qTipTag.split(",");
	for(var j = 0; j < elementList.length; j++)
	{	
		elements = document.getElementsByTagName(elementList[j]);
		if(elements)
		{
			for (var i = 0; i < elements.length; i ++)
			{
				a = elements[i];
				sTitle = a.getAttribute("title");				
				if(sTitle)
				{
					a.setAttribute("tiptitle", sTitle);
					a.removeAttribute("title");
					a.removeAttribute("alt");
					a.onmouseover = function() {tooltip.show(this.getAttribute('tiptitle'))};
					a.onmouseout = function() {tooltip.hide()};
				}
			}
		}
	}
}

tooltip.move = function (evt) {
	var x=0, y=0;
	if (document.all) {//IE
		x = (document.documentElement && document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft;
		y = (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
		x += window.event.clientX;
		y += window.event.clientY;
		
	} else {//Good Browsers
		x = evt.pageX;
		y = evt.pageY;
	}
	this.tip.style.left = (x + this.offsetX) + "px";
	this.tip.style.top = (y + this.offsetY) + "px";
}

tooltip.show = function (text) {
	if (!this.tip) return;
	this.tip.innerHTML = text;
	this.tip.style.display = "block";
}

tooltip.hide = function () {
	if (!this.tip) return;
	this.tip.innerHTML = "";
	this.tip.style.display = "none";
}

window.onload = function () {
	tooltip.init ();
}
