﻿function myXMLHttpRequest ()
{
	var xmlhttplocal;
	try {
		xmlhttplocal = new ActiveXObject ("Msxml2.XMLHTTP")}
	catch (e) {
		try {
			xmlhttplocal = new ActiveXObject ("Microsoft.XMLHTTP")
		}
		catch (E) {
			xmlhttplocal = false;
		}
  	}
	if (!xmlhttplocal && typeof XMLHttpRequest != 'undefined') {
		try {
			var xmlhttplocal = new XMLHttpRequest ();
		}
		catch (e) {
	  		var xmlhttplocal = false;
			alert ('couldn\'t create xmlhttp object');
		}
	}
	return (xmlhttplocal);
}


	
	function load_script(where, url, params)
	{
			var xmlHttp, page;
				
			xmlHttp = new myXMLHttpRequest ();
			
			
	// обработка истории загрузок
	if(url=="")
			{
				var i;
				var Cookies = document.cookie.split(";");
				for(i=0; i <Cookies.length; i++)
				{
					if(Cookies[i].split("=")[0]=="page")
						{
							if(Cookies[i].split("=")[1]!= null) url = Cookies[i].split("=")[1];
						}
				}
			}
			
			if(url=="") url="main.php";
			var date = new Date();
			date.setTime(date.getTime()+500000);
			
			if(params !="script" ) document.cookie = "page="+url+"; expires="+date;
		
		//	var content = params;
    		xmlHttp.open ("POST", url, true);
    		xmlHttp.setRequestHeader ('Content-Type','application/x-www-form-urlencoded; charset=utf-8');
			

			if(url!="#")  xmlHttp.send (""); 
			document.getElementById(where).innerHTML = "Подождите. Идет загрузка.";
			
			xmlHttp.onreadystatechange = function (){
				if(xmlHttp.readyState==4)
				{
					
						document.getElementById(where).innerHTML = xmlHttp.responseText;
						
						if(url == "main.php")
						{
							load_script("short_news","./php_scripts/short_news.php","script");
							load_script("short_konkurs","./php_scripts/short_konkurs.php","script");
						}
							
	
				}
			
			}
	}
	
	
	
	function ask_for_support()
	{
			var xmlHttp;
			
			xmlHttp = new myXMLHttpRequest ();
			var url="support1.php";

			var type = document.getElementById("MTP5").checked?"MTP5":"";
			var type = document.getElementById("MTP5polar").checked?"MTP5polar":"";
			var type = document.getElementById("DHS").checked?"DHS":"";
			
			var feedback = document.getElementById("feedback").value;
			var name = document.getElementById("name1").value;
			var email = document.getElementById("email").value;
			
			
			var content = "type="+type+"&feedback="+feedback+"&name="+name+"&email="+email+"&submit=1";
    		xmlHttp.open ("POST", url, true);
    		xmlHttp.setRequestHeader ('Content-Type','application/x-www-form-urlencoded; charset=utf-8');
			
		
			xmlHttp.send (content); 
			
			
			xmlHttp.onreadystatechange = function (){
				if(xmlHttp.readyState==4)
				{
						document.getElementById("content").innerHTML = xmlHttp.responseText;
		
				}
			
			}
	}
	
	