var agent = navigator.userAgent.toLowerCase();
var major = parseInt(navigator.appVersion);
var minor = parseFloat(navigator.appVersion);

var isNN = ((agent.indexOf('mozilla') != -1) && ((agent.indexOf('spoofer') == -1) && (agent.indexOf('compatible') == -1)));
var isNN4 = (isNN && (major == 4));
var isNN6 = (isNN && (major >= 5));

var isOPERA = agent.indexOf("opera")>-1 && window.opera;
var isIE4 = (agent.indexOf("msie") != -1 && !isOPERA);

function rusoft() {
  window.open('http://www.rusoft.ru');
}
function setBigImg(img) {
	document.getElementById('big_img').innerHTML = '<img src="files/'+img+'" alt="" width="465" height="550" border="0">';
	return false;
}
function imgOpen(id,Title,pid) {
	new_window = window.open('/popup/?id='+id+'&title='+Title+'&pid='+pid,'_blank','toolbar=no,menubar=no,location=no,status=no,resizable=yes,scrollbars=no,left=0,top=0');
	new_window.focus();
	return false
}
function showGallery(count,mode,col_pages){
	if ((mode*4-4)>=0 && (mode*4-4)<count) {
		document.getElementById('td0').innerHTML = par[mode*4-4];	
		document.getElementById('td1').innerHTML = par[mode*4-3];
		document.getElementById('td2').innerHTML = par[mode*4-2];
		document.getElementById('td3').innerHTML = par[mode*4-1];
	}
	var string_page='';
	for (j=1; j<col_pages+1; j++){
		if (j!=mode) string_page = string_page + '<a href="#" onclick="showGallery('+count+','+j+','+col_pages+'); return false;">'+j+'</a>&nbsp;';
		else string_page = string_page + j+'&nbsp;';
		
	}
	document.getElementById('pages').innerHTML = string_page;
	/*if (i==0) document.getElementById('prev').src = "images/"+lang+"/left_arrow_disable.gif";	
	else document.getElementById('prev').src = "images/"+lang+"/left_arrow.gif";	

	if ((i+4)>=count) document.getElementById('next').src = "images/"+lang+"/right_arrow_disable.gif";	
	else document.getElementById('next').src = "images/"+lang+"/right_arrow.gif";	
*/
	return false;
}
function ShowMail(user, domain1, domain2) {
	var email = user+'&#64;'+domain1+'&#46;'+domain2;
	if (ShowMail.arguments[3]) name = ShowMail.arguments[3];
	else name = email;
	document.writeln('<a href="mailto:'+email+'">'+name+'</a>');
}

function openImage(image) {
	if (image) window.open("/popup.php?img="+image, "popupimage", "scrollbars=no, resizable=1, width=100, height=100, top=0, left=0").focus();
	return false;
}

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 leftmargin="0" '+
		' topmargin="0" '+
		'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
}

function Step1toStep2(){
	type = document.getElementsByName('fld[type][]');
	if (type[0].checked) x = 'fiz'; // Физическое лицо
	else x = 'jur'; // Юридическое лицо
	if (isNN6) location.href = "/login/registration/step2?type="+x;
	else document.location.href = "/login/registration/step2?type="+x;
	return false
}

var f = 0;

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 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 Show1(image, id){
	document.getElementById('image'+id).src = image;
}

