function goTo(Url)
{
        location.href = Url;
}

function openPicture(ID)
{
        var m_nTop    = (screen.height/2)-375/2;
        var m_nLeft   = (screen.width/2)-500/2;;
        window.open('/gallery/?imageID=' + ID,'simpleGallery',"width=100,height=100,status=no,toolbar=0,menubar=0,location=0,scrollbars=0,top="+m_nTop+",left="+m_nLeft);
}

function resetForm(frmSrc,Message)
{
        if(confirm(Message))
        {
                frmSrc.reset();
        }
}

function sendForm(frmSrc,Message)
{
        passIt = true;
        for(i = 0; i < frmSrc.elements.length; i++)
                if(frmSrc.elements[i].value == "")
                        passIt = false;

        if(!passIt)
        {
                alert(Message);
        }
        else
        {
                frmSrc.submit();
        }
}

function replaceText(fldSrc,Text)
{
        fldSrc.value = replaceString(fldSrc.value, Text, "");
}

function replaceString(sString, sReplaceThis, sWithThis)
{
        if (sReplaceThis != "" && sReplaceThis != sWithThis)
        {
                var counter = 0;
                var start = 0;
                var before = "";
                var after = "";

                while (counter<sString.length)
                {
                        start = sString.indexOf(sReplaceThis, counter);

                        if (start == -1)
                        {
                                break;
                        }
                        else
                        {
                                before = sString.substr(0, start);
                                after = sString.substr(start + sReplaceThis.length, sString.length);
                                sString = before + sWithThis + after;
                                counter = before.length + sWithThis.length;
                        }
                }
        }

        return sString;
}

function showBigImage(File)
{
        myWin= open("", "displayWindow", "width=100,height=100,status=yes,toolbar=0,menubar=0,location=0,scrollbars=0");

         myWin.document.open();

         myWin.document.write("<title>...</title><style>body {margin:0;padding:0;}td { font-family:Tahoma; font-size:12px;}.gray_label {color:#707070;margin-left:5px;}img {border:none;}</style><body onload='self.resizeTo(document.imge.width+100,document.imge.height+230);'><table width='100%' height='100%' cellspacing='0' cellpadding='0'>        <tr>                <td height='16' bgcolor='#cde2f5'>&nbsp;</td>        </tr>        <tr>                <td height='120' style='padding-left:40px;'>                <table height='100%'  cellspacing='0' cellpadding='0'>                        <tr>                                <td><img src='/images/pop_logo.gif'></td>                                <td>                                </td>                        </tr>                </table>                </td>        </tr>        <tr>                <td height='*' style='padding-left:40px;' valign='top'>");
         myWin.document.write("<img src='/images/upload/" + File + "' onload='self.resizeTo(this.width+100,this.height+230);focus();' name='imge'>");
         myWin.document.write("                </td>        </tr></table>");
         myWin.document.close();
                myWin.focus();
}


function showMap()
{
        myWin= window.open("/map.php", "displayWindow", "width=700,height=680,status=yes,toolbar=0,menubar=0,location=0,scrollbars=0");
}

function openGallery(url)
{

var xx=(screen.height/2)-780/2;
var yy=(screen.width/2)-685/2;
        myWin= window.open(url, "displayWindow", "width=780,height=685,status=no,toolbar=0,menubar=0,location=0,scrollbars=0,top="+xx+",left="+yy);
}

function printBigImage(File)
{
        myWin= open("", "displayWindow", "width=100,height=100,status=yes,toolbar=0,menubar=0,location=0,scrollbars=0");

         myWin.document.open();

         myWin.document.write("<html><head><title>Просмотр изображения");
         myWin.document.write("</title></head><body style='margin:0;'>");
         myWin.document.write("<img src='/images/upload/" + File + "' onload='self.resizeTo(this.width,this.height+50);focus();'>");
         myWin.document.write("</body></html>");
         myWin.document.close();
                 myWin.print();
                 myWin.close();
}









var req;
var reqTimeout;
var retVal;
 
function loadXMLDoc(url) {
    req = null;
    if (window.XMLHttpRequest) {
        try {
            req = new XMLHttpRequest();
        } catch (e){}
    } else if (window.ActiveXObject) {
        try {
            req = new ActiveXObject('Msxml2.XMLHTTP');
        } catch (e){
            try {
                req = new ActiveXObject('Microsoft.XMLHTTP');
            } catch (e){}
        }
    }
 
    if (req) {
        req.onreadystatechange = processReqChange;
        req.open("GET", url, true);
        req.send(null);
        reqTimeout = setTimeout("req.abort();", 5000);
    } else {
        alert("Браузер не поддерживает AJAX");
    }
}
 
function processReqChange() {

 
    if (req.readyState == 4) {
        clearTimeout(reqTimeout);
 
        // only if "OK"
        if (req.status == 200) {
			retVal = req.responseText;
            //alert("_"+retVal);
			//console.log(retVal);
			document.all._price.value = retVal;
        } else {
           // alert("Не удалось получить данные:\n" + req.statusText);
        }
    }  
}



var req1;
var reqTimeout1;
var retVal1;
 
function loadXMLDoc1(url) {
    req1 = null;
    if (window.XMLHttpRequest) {
        try {
            req1 = new XMLHttpRequest();
        } catch (e){}
    } else if (window.ActiveXObject) {
        try {
            req1 = new ActiveXObject('Msxml2.XMLHTTP');
        } catch (e){
            try {
                req1 = new ActiveXObject('Microsoft.XMLHTTP');
            } catch (e){}
        }
    }
 
    if (req1) {
        req1.onreadystatechange = processReqChange1;
        req1.open("GET", url, true);
        req1.send(null);
        reqTimeout1 = setTimeout("req1.abort();", 5000);
    } else {
        alert("Браузер не поддерживает AJAX");
    }
}
 
function processReqChange1() {


    if (req1.readyState == 4) {
        clearTimeout(reqTimeout);
 
        // only if "OK"
        if (req1.status == 200) {
			retVal1 = req1.responseText;
            //alert("_"+retVal);
			document.getElementById("rightBlock").innerHTML = retVal1;
			//document.all._price.value = retVal;
        } else {
           // alert("Не удалось получить данные:\n" + req.statusText);
        }
    }  
}

