var ans   = "";
var check = true;
var cap   = false;

function request(url, target, callback) {
	if (!document.getElementById) {return false;}
	if (window.ActiveXObject)        {req = new ActiveXObject("Microsoft.XMLHTTP");}
	else if (window.XMLHttpRequest)  {req = new XMLHttpRequest();} 
	if (req == undefined)             return false;
		
	if (callback != undefined)       {req.onreadystatechange = eval(callback);}
	else                             {req.onreadystatechange = function() { response(url, target); }}
	
	req.open("GET", url, true);	
	req.send(null);
}

function response(url, target) {
	if (req.readyState == 4) {
    if(req.responseText=="false") 
     {var cOut = document.getElementById('coutput'); cOut.innerHTML = "Âû óêàçàëè íåâåðíûé êîä."; check = false;}
    else
     {var cOut = document.getElementById('coutput'); cOut.innerHTML = ""; check = true; cap=true; document.forms["order"].submit();}
    //document.getElementById(target).innerHTML = (req.status == 200) ? req.responseText : "An error was encountered: " + req.status;
   }
}

function kaptcha() {
                      if (document.forms["order"].keystring.value && cap==false) {
                        request("/include/kcaptcha/ttest.php?keystring=" + document.forms["order"].keystring.value, "answer");
                       }
                    	if(check && cap){
                    		document.forms["order"].submit();
                    		return true;
                    		}
                    	else
                    		return false;		
}




nn4 = (document.layers) ? true : false;

ie4 = (document.all) ? true : false;

dom = (document.createTextNode)? true : false;


function popupWindow(fileUrl, winW, winH, winN, scrollB) {

	var winWidth = (winW)? winW : 740;
	
	var winHeight = (winH)? winH : 520;

	var winName = (winN)? winN : 'popupWin';
	
	winWidth = parseInt(winWidth) + 18;
	winHeight = parseInt(winHeight) + 27;
		
	var scrollBars = (scrollB)? scrollB : 'auto';

	if (nn4 || ie4 || dom) {

		if (screen.width < winWidth + 50) { winWidth = screen.width - 50; scrollbars = 'yes'; }

		if (screen.height < winHeight + 100) { winHeight = screen.height - 100; scrollbars = 'yes'; }

		posX = Math.round((screen.width - winWidth) / 2);

		posY = Math.round((screen.height - winHeight) / 2);

		posCode = (nn4)? "screenX="+posX+",screenY="+posY : "left="+posX+",top="+posY;

	} else {

		posCode = "";

	}
	
	var popupWin = window.open(fileUrl, winName,"menubar=no,toolbar=no,scrollbars=" + scrollBars + ",status=yes,resizable=yes,width=" + winWidth + ",height=" + winHeight + "," + posCode);

	if (popupWin) popupWin.focus();

}

		function my_confirm(to, what){
			if (confirm(what))
				document.location=to;
		}

		var foto_windows = new Array();
		function open_foto(url, winname, width, height){
			foto_windows[foto_windows.length] = window.open(url,winname,'height='+height+',width='+width+',resizable=0,scrollbars=no,menubar=no,status=no');
			for(i = 0; foto_windows.length > i; i++){
				if(!foto_windows[i].closed)
					foto_windows[i].focus();
			}
		}

		function newWindow(url,w,h){
		w = w + 18;
		h = h + 27;
		Win = window.open(url, "Win", "width=" + w + ",height=" + h + "location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0","top=0,left=0");}
