function confirm_delete() {
	return (window.confirm('Вы действительно хотите удалить этот товар?'));
	}


//скрипт изменения цвета
/*
var ccol=1;

function ch_col() {
	
	obj=document.getElementById('corp_cl');
	
	if (obj) {
		if (ccol) {
			obj.style.color='#FFFFFF';
			ccol=0;
			setTimeout("ch_col()", 500);
		}
		else {
			obj.style.color='#790000';
			ccol=1;
			setTimeout("ch_col()", 200);
		}
	}
	

}

*/

function show_contact_window() {
	myWin= open("", "displayWindow", 
	"width=500,height=230,status=no,toolbar=no,menubar=no");
	
	myWin.document.open();
	
	myWin.document.write("<html><head><title>Не можете дозвониться?");
	myWin.document.write('</title><link href="http://www.ufl.ua/style.css" rel="stylesheet" type="text/css" /></head>');
	myWin.document.write('<body style="color:#555555; font-family:Tahoma,Verdana,Arial,sans-serif; font-size:12px;">');
	myWin.document.write("Все заказы принимаются через вебсайт.<br />Воспользуйтесь альтернативными контактам:<br /><br />(044) 561 80 50<br />(093) 827 73 27<br /><br />");
	myWin.document.write('<!-- BEGIN ProvideSupport.com Graphics Chat Button Code --><div id="ciBvBh" style="z-index:100;position:absolute"></div><div id="scBvBh" style="display:inline"></div><div id="sdBvBh" style="display:none"></div><script type="text/javascript">var seBvBh=document.createElement("script");seBvBh.type="text/javascript";seBvBh.defer=true;seBvBh.src=(location.protocol.indexOf("https")==0?"https://secure.providesupport.com/image":"http://image.providesupport.com")+"/js/uaflowers/safe-standard.js?ps_h=BvBh\u0026ps_t="+new Date().getTime();document.getElementById("sdBvBh").appendChild(seBvBh)</script><noscript><div style="display:inline"><a href="http://www.providesupport.com?messenger=uaflowers">Live Support</a></div></noscript><!-- END ProvideSupport.com Graphics Chat Button Code --><br /><br />');
	myWin.document.write('<a href="http://web.icq.com/whitepages/message_me/1,,,00.icq?uin=135355135&action=message"><img src="http://www.ufl.ua/images_new/icq_ico.gif" alt="" height="15" width="15" /></a> 135-355-135<br /><br />');
	myWin.document.write('<a href="skype:ufl.ua?call" title="Позвонить" style="text-decoration: none"><img vspace=2 src="http://www.ufl.ua/images_new/skype_ico.gif" alt="" height="16" width="16" /></a> ufl.ua<br /><br />');
	myWin.document.write("");
	myWin.document.write("</body></html>");

	myWin.document.close();  

}

function showMess (text) {
	
	document.getElementById('mess_block').innerHTML=text;
	
	setOpacity();
}

var value = 0;
var posed = 0;
var messVisible=false;

function watchScroll() {
	if (messVisible) {
		var wdiv=document.getElementById('warning');
		
		var top=window.scrollY+(window.innerHeight/2)-30;
		top=parseInt(top);
		wdiv.style.top=top+'px';
		
		setTimeout("watchScroll()", 200);
	}
}

function setOpacity() {

	document.getElementById('message_block').style.display = "block";
	
	if (!posed) {
		var wdiv=document.getElementById("message_block");
		
		var pos_left=document.body.clientWidth/2;

		pos_left =pos_left - 250;

		pos_left=parseInt(pos_left);
		
		pos_left=pos_left+'px';
		wdiv.style.left=pos_left;

		var busyLayer = document.getElementById("shadow");

		if (window.innerHeight && window.scrollMaxY) {
			yScroll = window.innerHeight + window.scrollMaxY;
			var deff = document.documentElement;
			var hff = (deff&&deff.clientHeight) || document.body.clientHeight || window.innerHeight || self.innerHeight;
			yScroll -= (window.innerHeight - hff);
		} else if (document.body.scrollHeight > document.body.offsetHeight || document.body.scrollWidth > document.body.offsetWidth){
			yScroll = document.body.scrollHeight;
		} else {
			yScroll = document.body.offsetHeight;
		}

		if (busyLayer != null) {
			busyLayer.style.visibility = "visible";
			busyLayer.style.height = yScroll+'px';
		}
		alert(document.body.scrollHeight);
		var top=window.scrollY+(document.body.clientHeight/2)-30;
		top=parseInt(top);
		alert (top);
		wdiv.style.top=top+'px';

		posed=1;
		messVisible=true;
	}

	value += 1;
	var testObj = document.getElementById('shadow');

	testObj.style.width = "100%";
	//testObj.style.height = "100%";
	testObj.style.display = "block";
	testObj.style.opacity = value/10;
	testObj.style.filter = 'alpha(opacity=' + value*10 + ')';
	myTimeout = setTimeout("setOpacity()", 50);

	if (value >= 5) {
		clearTimeout(myTimeout);
	}
	
	
	watchScroll();
}

function removeOpacity() {
	value -= 1;
	var testObj = document.getElementById('shadow');

	myTimeout2 = setTimeout("removeOpacity()", 50);
	testObj.style.opacity = value/10;
	testObj.style.filter = 'alpha(opacity=' + value*10 + ')';

	if ((value/10) <= 0) {
		testObj.style.display = "none";
		clearTimeout(myTimeout2);
	}
	document.getElementById('message_block').style.display = "none";
	
	posed=0;
	messVisible=false;
}

function get_cities(country_id, city_id, selected_city, lang) {
	
	
    JsHttpRequest.query(
        'http://www.ufl.ua/ajax.php', // backend
        {
            'country_id': document.getElementById(country_id).value,
            'func' : 'get_cities',
            'lang' : lang
        },
        // Function is called when an answer arrives. 
        function(result, errors) {
            // Write the answer.
            
            if (result) {
            	
				var cities=result["cities"];
				
				var city_field_obj=document.getElementById(city_id);
				
				for (i = city_field_obj.options.length; i >= 0; i--) {
					city_field_obj.options[i] = null; 
				}
				
				var i=0;
				
				for (key in cities) {
					if (selected_city==cities[key]['id']) city_field_obj.options[i] = new Option(cities[key]['name'], cities[key]['id'], true, true);
					else city_field_obj.options[i] = new Option(cities[key]['name'], cities[key]['id']);
					i++;
				}
            }
        },
        false  // do not disable caching
    );
}

function bottomGetAllCities(country_id, country_nick, act_city, lang, domain, country_name, country_link) {
    JsHttpRequest.query(
        'http://www.ufl.ua/ajax.php', // backend
        {
            'country_id': country_id,
            'func' : 'get_cities',
            'only_main' : '1',
            'lang' : lang
        },
        // Function is called when an answer arrives. 
        function(result, errors) {
            // Write the answer.
            
            if (result) {
            	
				var cities=result["cities"];
				
				var cities_div=document.getElementById('bottom_cities');
				var cont='';
				
				for (key in cities) {
					if (act_city==cities[key]['nick']) cont=cont+'<font color="Red">'+cities[key]['name']+'</font> | ';
					else cont=cont+'<a href="'+domain+lang+'/to/flowers-'+country_nick+'/'+cities[key]['nick']+'" title="'+cities[key]['name']+'">'+cities[key]['name']+'</a> | ';
				}
				
				if (lang=='ru') cont=cont+'<br /><a href="'+domain+lang+'/regions/'+country_link+'" style="color:red;"><b>Показать все города доставки в '+country_name+'...</b></a>';
				if (lang=='ua') cont=cont+'<br /><a href="'+domain+lang+'/regions/'+country_link+'" style="color:red;"><b>Показати усі міста доставки у '+country_name+'...</b></a>';
				if (lang=='en') cont=cont+'<br /><a href="'+domain+lang+'/regions/'+country_link+'" style="color:red;"><b>Show all delivery cities to '+country_name+'...</b></a>';
				
				cities_div.innerHTML=cont;
            }
        },
        false  // do not disable caching
    );
}

// функции для хоткиев

function hotkeys(e) {
  if (!e) e = window.event;
  var k = e.keyCode;
  
  if (e.ctrlKey) {
    if (k == 13) {
    	
		$(function(){

			document.getElementById('pframe').src='http://www.ufl.ua/call_confirmation.html';

			// Dialog			
			$('#dialog').dialog({
				autoOpen: false,
				width: 300,
				buttons: {
					"Закрыть": function() { 
						$(this).dialog("close"); 
					}
				}
			});
			
			
			$('#dialog').dialog("open"); 
			
			alert(div);
		});

    	
    }
  }
}

function init() {
  document.onkeyup = hotkeys;
}


// обработка текстов для подмены Читать полностью

function init_read_full(id) {
	var obj=document.getElementById(id);
	obj.style.display = "none";
}

function replace_text(id) {
	var obj=document.getElementById(id);
	var obj2=document.getElementById(id+'_text');
	obj.innerHTML=obj2.innerHTML;
}

function show_other_prod(cat_id, lang) {
    JsHttpRequest.query(
        'http://www.ufl.ua/ajax.php', // backend
        {
            'func' : 'show_other_prod',
            'cat_id' : cat_id,
            'lang' : lang
        },
        // Function is called when an answer arrives. 
        function(result, errors) {
            // Write the answer.
            
            if (result) {
            	
				var cities=result["cities"];
				
				var cities_div=document.getElementById('bottom_cities');
				var cont='';
				
				for (key in cities) {
					if (act_city==cities[key]['nick']) cont=cont+'<font color="Red">'+cities[key]['name']+'</font> | ';
					else cont=cont+'<a href="'+domain+lang+'/flowers-'+country_nick+'/'+cities[key]['nick']+'" title="'+cities[key]['name']+'">'+cities[key]['name']+'</a> | ';
				}
				
				if (lang=='ru') cont=cont+'<br /><a href="'+domain+lang+'/regions/'+country_link+'" style="color:red;"><b>Показать все города доставки в '+country_name+'...</b></a>';
				if (lang=='ua') cont=cont+'<br /><a href="'+domain+lang+'/regions/'+country_link+'" style="color:red;"><b>Показати усі міста доставки у '+country_name+'...</b></a>';
				if (lang=='en') cont=cont+'<br /><a href="'+domain+lang+'/regions/'+country_link+'" style="color:red;"><b>Show all delivery cities to '+country_name+'...</b></a>';
				
				cities_div.innerHTML=cont;
            }
        },
        false  // do not disable caching
    );
}

/**
	
	Функции офф заказа

*/

// аякс отправка email

function ch_submit_email (email, lang, chpwd, password, remind_pwd) {
	
	if (document.location.href.indexOf("individual_order")==-1) {
		var ind_order=false;
	}
	else {
		var ind_order=true;
	}
	
    JsHttpRequest.query(
        '/ajax.php', // backend
        {
            'func' : 'submit_email',
            'email' : email,
            'lang' : lang,
            'chpwd' : chpwd,
            'password' : password,
            'remind_pwd' : remind_pwd,
            'ind_order' : ind_order
        },
        // Function is called when an answer arrives. 
        function(result, cont) {
            // Write the answer.
            
            if (result) {
            	document.location.href=result['redirect'];
            }
            else {
            	document.getElementById('checkout_container').innerHTML=cont;
            }
            
        },
        false  // do not disable caching
    );
}

// показываем подсказки

var timeoutId=false;

function showHelp (obj, show, text) {
	
	if (timeoutId) clearTimeout(timeoutId);
	
	if (show) {
		if (text!=false) {
			$("#help_block_cont").html(text);
		
			$("#help_block").css("left", $(obj).offset().left + $(obj).width()-5 );
			$("#help_block").css("top", $(obj).offset().top - 3);
		}
		
		$("#help_block").css("display", 'block');
		
		return true;
	}
	else {
		$("#help_block_cont").html('');
		$("#help_block").css("display", 'none');
		
		return true;
	}
}

// Мигающее предупреждение на главной

function blink(obj) {
    if (obj.style.color=='red') {
        obj.style.color='#376C17';
    }
    else {
        obj.style.color='red';
    } 
    setTimeout("blink(document.getElementById('beware'));", 500);
}