function fixPNG(element)
{
  if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent))
  {
    var src;
	
    if (element.tagName=='IMG')
    {
      if (/\.png$/.test(element.src))
      {
        src = element.src;
        element.src = path+"/images/blank.gif";
      }
    }
    else
    {
      src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i);
      if (src)
      {
        src = src[1];
        element.runtimeStyle.backgroundImage="none";
      }
    }
    //var re_scale_mode = /iesizing\-(\w+)/;
    //var m = re_scale_mode.exec(element.className);
    //var scale_mode = (m) ? m[1] : 'crop';
    if (src) element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
  }
}
function openw(res,title) {
   rand=Math.random().toString().substring(2,15);
   window.open(path + "/lib/show_pic.php?src="+res+"&title="+title, 'new_'+rand, "top=50, left=50, width=50, height=50, channelmode=no, toolbar=no, location=no, status=no, directories=no, menubar=no, resizable=yes, scroll=yes");
}
function open_pic(res,title) {
   rand=Math.random().toString().substring(2,15);
   window.open(path + "/lib/show_pic.php?src="+res+"&title="+title, 'new_'+rand, "top=50, left=50, width=50, height=50, channelmode=no, toolbar=no, location=no, status=no, directories=no, menubar=no, resizable=yes, scrollbars=yes");
}
function gggg()
{
        var req = new JsHttpRequest();
        req.onreadystatechange = function() 
        {
           if (req.readyState == 4) {
        	  document.getElementById('order_div').innerHTML=req.responseText;
        	  if (req.responseJS.err != 1)
        	  {
        	  	  fio.value="";
        	  	  company.value="";
        	  	  phone.value="";
        	  	  email.value="";
        	  	  text.value="";
        	  }
           }
        }
        req.open(null, path+'/add_order.html', true);
        req.send( { fio: fio.value, company: company.value, phone: phone.value, email: email.value, text: text.value } );
}
function rand( min, max ) {
    if( max ) {
        return Math.floor(Math.random() * (max - min + 1)) + min;
    } else {
        return Math.floor(Math.random() * (min + 1));
    }
}
var quote_old = -1;
function QuoteChange(n) 
{
    QuoteIndex = rand(0,n-1);
    while (QuoteIndex == quote_old)
    {
    	QuoteIndex = rand(0,n-1);
    }
    quote_old = QuoteIndex;
    //document.getElementById('quotes').innerHTML="123";
    
    var req = new JsHttpRequest();
    req.onreadystatechange = function() 
    {
       if (req.readyState == 4) {
    	  if (req.responseJS.err != 1)
    	  {
    	  	  if (document.getElementById('quotes').style.display == "none")
    	  	  {
    	  	      document.getElementById('quotes').innerHTML=req.responseText;
    	  	      document.getElementById('quotes_extra').style.display="none";
    	  	      $("#quotes").fadeIn(1000);
    	  	  }
    	  	  else
    	  	  {
    	  	      document.getElementById('quotes_extra').innerHTML=req.responseText;
    	  	      document.getElementById('quotes').style.display="none";
    	  	      $("#quotes_extra").fadeIn(1000);
    	  	  }
    	  }
       }
    }
    req.open(null, path+'/change_quote.html', true);
    req.send( { num: QuoteIndex } );
    
    //document.getElementById("div_banners_"+type).innerHTML = document.getElementById(banners_index[BannerIndex]).innerHTML;
}




		var arrErrors;
		var empty_re = /[ \f\n\r\t\v]/g;
		var email_re = /^([a-z]|[0-9]|_|-|\.)*@(([a-z]|[0-9]|_|-)*\.)+[a-z]{2,4}$/i;
		
		function checkFeedback()
		{
			arrErrors = new Array();
			checkEmpty("theme", "Укажите Тему");
			checkEmpty("contact_face", "Укажите Контактное лицо");
			checkEmpty("email", "Укажите E-mail");
			error = 1;
		    if ( document.getElementById("email").value != "" )
				    checkRE( "email", "Неправильный формат E-mail", email_re);
			if (arrErrors.length == 0)
			{
				var oSubmitButton = document.getElementById("send");
				oSubmitButton.disabled = true;
				return true;
			}
			else
			{
				var errMsg = "Пожалуйста, исправьте следующее и попробуйте отправить снова :\n\n";
				for(var i=0; i < arrErrors.length; i++)
					errMsg += "\t" + arrErrors[i].msg + "\n";
				alert(errMsg);
				return false;
			}
		}
		function checkEmpty(elementID, errorMessage)
		{
			var oElement = document.getElementById(elementID);
			var sValue = oElement.value.replace(empty_re, "");
			if (  sValue == "")
			{
				var errorObj = new Object();
				errorObj.elem = oElement;
				errorObj.msg =errorMessage;
				arrErrors.push(errorObj);
			}
		}
		function checkRE(elementID, errorMessage, re)
		{
			var oElement = document.getElementById(elementID);
			if ( !re.test(oElement.value) )
			{
				var errorObj = new Object();
				errorObj.elem = oElement;
				errorObj.msg =errorMessage;
				arrErrors.push(errorObj);
			}
		}