var isIE4=(navigator.appVersion.indexOf("MSIE")!=-1 && parseFloat(navigator.appVersion)>=4)?true:false;
var isNN4=(navigator.appName=="Netscape" && parseFloat(navigator.appVersion)<5)?true:false;
var isNN6=(navigator.appName=="Netscape" && parseFloat(navigator.appVersion)>=5)?true:false;
var isOPERA=(navigator.appName=="Opera" && parseFloat(navigator.appVersion)>=7)?true:false;

function rusoft() {
  window.open('http://rusoft.ru');
}

function alert_close() {
	if (prompt("Закрыть окно?") == true) window.close();
}

function imgOpen(imgURL,imgWidth,imgHeight,Title) {
	var imgWndw=window.open('','_blank','width='+imgWidth+',height='+
	imgHeight+',toolbar=no,menubar=no,location=no,status=no,'+
	'resizable=yes,scrollbars=no');
	var imgTitle=(Title)?Title:imgURL+": "+imgWidth+'x'+imgHeight;
	with (imgWndw.document){
		open();
		write('<ht'+'ml><he'+'ad><ti'+'tle>'+imgTitle+'</ti'+'tle>'+
		'</he'+'ad><bo'+'dy onclick="window.close(); return false;" leftmargin="0" '+
		' topmargin="0" oncontextmenu="window.close(); return false;" '+
		'rightmargin="0" bottommargin="0" marginwidth="0" '+
		'marginheight="0"><img src="'+imgURL+'" width="'+imgWidth+
		'" height="'+imgHeight+'" border="0" alt="'+imgTitle+
		'"></bo'+'dy></ht'+'ml>');
		close();
	}
	return false
}

function OpenPopup(src) {
	if (arguments[1]) popup_name = arguments[1];
	else popup_name = 'popup';
	if (arguments[2]) popup_width = arguments[2];
	else popup_width = 500;
	if (arguments[3]) popup_height = arguments[3];
	else popup_height = 400;
	window.open(src, popup_name, 'toolbar=no,location=no,status=no,menubar=no,resizable=yes,directories=no,scrollbars=yes,width='+popup_width+',height='+popup_height).focus();
	return false
}

var f = 0;

function onClick1(param,href) {
	if (f != 1)
		if (href) {
			if (isNN6) location.href = "http://"+location.host+"/"+href+"?goods_id="+param;
			else document.location.href = "http://"+location.host+"/"+href+"?goods_id="+param;
		}
		else {
			if (isNN6) location.href = "?goods_id="+param;
			else document.location.href = "?goods_id="+param;
		}
	f = 0;
	return false
}

function onClick2(form_name,id,count) {
	if (document.getElementById(id).value == 'шт.' || document.getElementById(id).value == '') document.getElementById(id).value = 1;
	if (check(form_name,count) == true)
		document.forms[form_name].submit();
	f = 1;
	return false
}

function check(form_name,all_count) {
	count = 0;
	for(kk=0;kk<document.forms[form_name].elements.length;kk++) {
		if (document.forms[form_name].elements[kk].value == 'шт.' || document.forms[form_name].elements[kk].value == '') count++;
	}
	if (count == all_count) { alert("Введите количество товаров!"); return false; }
	return true
}

function about_bill(id) {
	if (f != 1) 
		if (isNN6) location.href = "/cabinet/accounts/your_accounts?bill_id="+id;
		else document.location.href = "/cabinet/accounts/your_accounts?bill_id="+id;
	f = 0;
	return false
}

function delete_bill(id){
	if (confirm('Удаление счета № '+id+'. Вы уверены?') == true) {
		if (isNN6) location.href = "/cabinet/accounts/your_accounts?act=delete&bill_id="+id;
		else document.location.href = "/cabinet/accounts/your_accounts?act=delete&bill_id="+id;
	}
	f = 1;
	return false
}

function about_order(id) {
	if (f != 1) 
		if (isNN6) location.href = "/cabinet/orders/your_orders?order_id="+id;
		else document.location.href = "/cabinet/orders/your_orders?order_id="+id;
	f = 0;
	return false
}

function delete_order(id){
	if (confirm('Удаление заказа № '+id+'. Вы уверены?') == true) {
		if (isNN6) location.href = "/cabinet/orders/your_orders?act=delete&order_id="+id;
		else document.location.href = "/cabinet/orders/your_orders?act=delete&order_id="+id;
	}
	f = 1;
	return false
}

function return_to_cart(referer){
	if (!referer) return false;
	document.forms['cabinet'].reset();
	if (isNN6) location.href = referer;
	else document.location.href = referer;
}

// новый каталог, показ 2 уровня

//function showCat() {
//	if (document.getElementById('dropCat').style.display != 'block') {
//		document.getElementById('dropCat').style.display = 'block';
//		document.getElementById('open').src = '/images/new_cat_minus.gif';
//		document.getElementById('open').alt = 'закрыть'
//	}
//	else {
//		document.getElementById('dropCat').style.display = 'none';
//		document.getElementById('open').src = '/images/new_cat_plus.gif';
//		document.getElementById('open').alt = 'открыть'
//	}
//}

function showCat(objLi) {
	if (objLi.parentNode.className != 'active') {
		objLi.parentNode.className = 'active';
		objLi.src = '/images/new_cat_minus.gif';
		objLi.alt = 'закрыть';
	}
	else {
		objLi.parentNode.className = '';
		objLi.src = '/images/new_cat_plus.gif';
		objLi.alt = 'открыть';
	}
}

