IE=navigator.appName=="Netscape" && !document.getElementById?false:true;

function zoom(src,w,h) {
	html='<html><head><title>ofoto.ru - цифровая печать</title><SCRIPT LANGUAGE="JavaScript" SRC="/js/win_close.js" TYPE="text/javascript"></SCRIPT>'+
	'</head><body bgcolor=#FFFFFF leftmargin=0 topmargin=0 marginwidth=0 marginheight=0 style="margin:0px">'+
	'<a href="#" onClick="WindowClose()"><img src="'+src+'" border=0 alt="" width='+w+' height='+h+'></a></body></html>';
	w = w + 10;
	h = h + 29;
	if (IE) {
		win=window.open('','acwin','width='+w+',height='+h+',resizable=no,top=100,left=100');
		win.document.open();
		win.document.write(html);
		win.document.close(); 
		win.resizeTo(w,h);
	}
	else {
		win=window.open(src,'acwin','width='+w+',height='+h+',resizable=yes');
	}
	win.focus();
	return false;
}

function selectAll(){
	for (i=0; i<document.fotos.length; i++){
		if (document.fotos.elements[i].type == "checkbox"){
			if (document.fotos.elements[i].name.indexOf("foto_") == 0){
				document.fotos.elements[i].checked = true;
			}
		}
	}
}

function clearAll(){
	for (i=0; i<document.fotos.length; i++){
		if (document.fotos.elements[i].type == "checkbox"){
			if (document.fotos.elements[i].name.indexOf("foto_") == 0){
				document.fotos.elements[i].checked = false;
			}
		}
	}
}

function invertAll(){
	for (i=0; i<document.fotos.length; i++){
		if (document.fotos.elements[i].type == "checkbox"){
			if (document.fotos.elements[i].name.indexOf("foto_") == 0){
				if (document.fotos.elements[i].checked == true){
					document.fotos.elements[i].checked = false;
				}
				else {
					document.fotos.elements[i].checked = true;
				}
			}
		}
	}
}

function ConfirmDelete(message, from, s_id) {
	if (confirm(message)){
		xurl = "/user/delete/"+s_id+"&";
		for (i=0; i<document.fotos.length; i++){
			if (document.fotos.elements[i].type == "checkbox"){
				if (document.fotos.elements[i].name.indexOf("foto_") == 0){
					if (document.fotos.elements[i].checked == true){
						xurl = xurl+document.fotos.elements[i].name+"=on&";
					}
				}
			}
		}
		xurl += "from="+from;
		document.location.href= xurl;
	}
}

function GoTo(f_dir, f_type, sid){
	if (document.location.pathname == "/user/"){
		y = 0;
		xurl = "/print/"+f_dir+"/"+sid+"&";
		for (i=0; i<document.fotos.length; i++){
			if (document.fotos.elements[i].type == "checkbox"){
				if (document.fotos.elements[i].name.indexOf("foto_") == 0){
					if (document.fotos.elements[i].checked == true){
                                                //alert(document.fotos.elements[i].name);  
						y++;
						if (f_type == "m"){
							xurl = xurl+document.fotos.elements[i].name+"=on&";
						}
						else {
							xurl = "/print/"+f_dir+"/?"+document.fotos.elements[i].name+"=on&";
						}
					}
				}
			}
		}
		if (y == 0){
			if (f_type == "m"){
				alert("Для заказа печати сначала выберите фотографии");
			}
			else {
				alert("Для заказа печати сначала выберите фотографию");
			}
		}
		else {
                        document.location.href= xurl;
		}
	}
	else {
		//document.location.href = "/user/";

		document.location.href = "/print/"+f_dir+"/"+sid;
	}
}


function Calculate(type, s_id){
       ind1 = document.location.href.indexOf(document.location.host);
       ind2 = document.location.href.indexOf('/dfoto/');
//alert(ind2);
//alert (document.location.href.substring(ind1));
	xurl = "/print/"+type+"/calc/"+"?";
	d = document.fotos;
	for (i=0; i<d.length; i++){
		if (d.elements[i].name.indexOf("ott_") == 0){
			xurl = xurl+d.elements[i].name+"="+d.elements[i].value+"&";
		}
	}
	for (i=0; i<d.length; i++){
		if (d.elements[i].name.indexOf("kadr_") == 0){
			if (d.elements[i].checked == true){
					xurl = xurl+d.elements[i].name+"=on&";
			}
		}
	}
	for (i=0; i<d.length; i++){
		if (d.elements[i].name.indexOf("total_") == 0){
			xurl = xurl+d.elements[i].name+"="+d.elements[i].value+"&";
		}
	}
	for (i=0; i<d.length; i++){
		if (d.elements[i].name.indexOf("imgName_") == 0){
			xurl = xurl+d.elements[i].name+"="+d.elements[i].value+"&";
		}
	}
	if(ind2 == '')for (i=0; i<d.length; i++){
		if (d.elements[i].name.indexOf("img_") == 0){
			xurl = xurl+d.elements[i].name+"="+d.elements[i].value+"&";
		}
	}
	for (i=0; i<d.length; i++){
		if (d.elements[i].name.indexOf("material") == 0){
			xurl = xurl+"material="+d.elements[i].value+"&";
		}
	}
	if ((type == "dfoto") || (type == "lfoto")){
		xurl = xurl+"format="+d.all['format'].value+"&";
		xurl = xurl+"paper="+d.all['paper'].value+"&";
	}
	if ((type == "mfoto") || (type == "magnit") || (type == "puzzle") || (type == "plakat") || (type == "blocknote")|| (type == "mug")){
		xurl = xurl+"format="+d.all['format'].value+"&";
	}
	if (type == "tshirt"){
		xurl = xurl+"format_1="+d.all['format_1'].value+"&";
		xurl = xurl+"format_2="+d.all['format_2'].value+"&";
		xurl = xurl+"format_3="+d.all['format_3'].value+"&";
		xurl = xurl+"ts_type="+d.all['ts_type'].value+"&";
		xurl = xurl+"ts_color="+d.all['ts_color'].value+"&";
	}
	
	params = "width=410,height=200,toolbar=no,titlebar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=yes,top=50,left=50";
//	alert(xurl);
        winCalc = window.open(xurl, "winCalc", params);
	winCalc.focus();
}

function ScrollPriceHeader(){
	if (document.body.scrollTop>64){
		Header.style.top = document.body.scrollTop-64;
	}
	else {
		Header.style.top = 0;
	}
}

function MoveObject(){
	Header.style.top = document.body.scrollTop-1;
}

function AlertTestMsg(){
	msg = "Данная опция в тестовом режиме не доступна.\nВам необходимо зарегистрироваться.";
	alert(msg);
}

function SelectFoto(cb_name){
	if (document.fotos.all[cb_name].checked == true){
		document.fotos.all[cb_name].checked = false;
	}
	else {
		document.fotos.all[cb_name].checked = true;
	}
}

function ShowMap(){
	params = "width=285,height=285,toolbar=no,titlebar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,top=50,left=50";
	winMap = window.open("", "winMap", params);
	winMap.focus();
	winMap.document.open();
	winMap.document.write("<html><head><title>Схема проезда</title></head>");
	winMap.document.write("<body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'>");
	winMap.document.write("<img src='/img/map.gif' width='285' height='285' border='0'>");
	winMap.document.write("</body></html>");
	winMap.document.close();
}

function ShowLargeFoto(w, h, fname, s_id){
	xurl = "/user/large/"+s_id+"&w="+w+"&h="+h+"&fname="+fname;
	if (IE) {
		w = w + 10;
		h = h + 29;
		params = "width="+w+",height="+h+",toolbar=no,titlebar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,top=50,left=50";
		winFull = window.open(xurl, "winFull", params);
		winFull.resizeTo(w, h);
	}
	else {
		winFull=window.open(xurl,'winFull','width='+w+',height='+h+',resizable=yes');
	}
	winFull.focus();
}

function ShowLargeFoto2(w, h, src, fname){
	xurl = "/gallery/large/?w="+w+"&h="+h+"&src="+src+"&fname="+fname;
	if (IE) {
		w = w + 10;
		h = h + 29;
		params = "width="+w+",height="+h+",toolbar=no,titlebar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,top=50,left=50";
		winFull = window.open(xurl, "winFull", params);
		winFull.resizeTo(w, h);
	}
	else {
                winFull=window.open(xurl,'winFull','width='+w+',height='+h+',resizable=yes');
	}
	winFull.focus();
}


function Conf_del_from_basket()
{
 if(confirm('Вы действительно хотите удалить данный объект из корзины?') )return true;
 else return false;

}