function IsImageOk(img) {
	if(!img) return false;

     if (!img.complete) {
        return false;
    }

    if (typeof img.naturalWidth != "undefined" && img.naturalWidth == 0) {
        return false;
    }

    // No other way of checking: assume it's ok.
    return true;
}
var xmlHttp = createXmlHttpRequestObject();
function createXmlHttpRequestObject()
{
	var xmlHttp;
	if(window.ActiveXObject)
	{
		try		{xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");}
		catch (e)	{xmlHttp = false;}
	}
	else
	{
		try		{xmlHttp = new XMLHttpRequest();}
		catch (e)	{xmlHttp = false;}
	}
	if (!xmlHttp)	alert("Error creating the XMLHttpRequest object.");
	else	return xmlHttp;
}
function getRequestBody(oForm)
{
    var aParams = new Array();
    for(var i = 0; i < oForm.elements.length; i++) {
      var sParam = encodeURIComponent(oForm.elements[i].name);
      sParam += "=";
      sParam += encodeURIComponent(oForm.elements[i].value);
      aParams.push(sParam);
    }
    return aParams.join("&");
}
function show_popup(){
 	var h=0;
	if (self.pageYOffset) {h=self.pageYOffset;}
	else if (document.documentElement && document.documentElement.scrollTop){h=document.documentElement.scrollTop;}
	else if (document.body) {h=document.body.scrollTop;}
	document.getElementById('popup_table2').style.top=(h+150)+'px';
     document.getElementById('popup').style.display='block';
     show_shadow();
 }
 function hide_popup(){
     document.getElementById('popup').style.display='none';
     hide_shadow();
 }
 
/* ----- shadow ----- */
function getPageScroll(){
    var yScroll;
    if (self.pageYOffset) {
        yScroll = self.pageYOffset;
    } else if (document.documentElement && document.documentElement.scrollTop){  // Explorer 6 Strict
        yScroll = document.documentElement.scrollTop;
    } else if (document.body) {// all other Explorers
        yScroll = document.body.scrollTop;
    }
    arrayPageScroll = new Array('',yScroll) 
    return arrayPageScroll;
}
function getPageSize(){
    var xScroll, yScroll;
    if (window.innerHeight && window.scrollMaxY) {  
        xScroll = document.body.scrollWidth;
        yScroll = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
        xScroll = document.body.scrollWidth;
        yScroll = document.body.scrollHeight;
    } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
        xScroll = document.body.offsetWidth;
        yScroll = document.body.offsetHeight;
    }
    var windowWidth, windowHeight;
    if (self.innerHeight) { // all except Explorer
        windowWidth = self.innerWidth;
        windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
    }   
    if(yScroll < windowHeight){
        pageHeight = windowHeight;
    } else { 
        pageHeight = yScroll;
    }
    if(xScroll < windowWidth){  
        pageWidth = windowWidth;
    } else {
        pageWidth = xScroll;
    }
    arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
    return arrayPageSize;
}
function show_shadow(){
    var objOverlay = document.getElementById('overlay');
    var arrayPageSize = getPageSize();
    var arrayPageScroll = getPageScroll();

    objOverlay.style.height = (arrayPageSize[1] + 'px');
    objOverlay.style.width = (arrayPageSize[0] + 'px');
    objOverlay.style.display = 'block';
}
function hide_shadow(){
    objOverlay = document.getElementById('overlay');
    objOverlay.style.display = 'none';
}
function ChangeOpacity(id)
{
	document.getElementById('item_menu_'+id).style.opacity=1;
	document.getElementById('item_menu_'+id).style.filter="alpha(opacity=100)";
}
function ChangeOpacity2(id)
{
	document.getElementById('item_menu_'+id).style.opacity=0.4;
	document.getElementById('item_menu_'+id).style.filter="alpha(opacity=40)";
}
function CheckOrder()
{
	if(document.getElementById('fio').value=='' || document.getElementById('phone').value=='' || document.getElementById('model').value=='')
	{alert("Все поля, отмеченные звездочкой (*), обязательны для заполнения."); return false;}
	if(document.getElementById('email').value!='')
	{
		var reg = /^((\"[^\"\f\n\r\t\v\b]+\")|([\w\!\#\$\%\&'\*\+\-\~\/\^\`\|\{\}]+(\.[\w\!\#\$\%\&'\*\+\-\~\/\^\`\|\{\}]+)*))@((\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9\-])+\.)+[A-Za-z\-]+))$/;
		if(reg.exec(document.getElementById('email').value)==null)
		{
			alert(document.getElementById('email').value+" не является допустимым форматом адреса электронной почты.");
			return false;
		}
	}
	return true;
}