function AddBookmark() { 
  window.external.addFavorite(location.href, document.title);
}
function AddStartpage(s) { 
  s.style.behavior ='url(#default#homepage)';
  s.SetHomepage(location.href);
}
function ShowAdd(addToFavorites,addToFavoritesCD,makeStartPage) { 
  if (navigator.appName.indexOf('Microsoft')>=0 && navigator.appVersion.indexOf(4.0)>=0) {
     document.write('<a href=# onClick="AddBookmark();return false"><img src="images/btnfavor.gif" width="19" height="19" border="0" align="absmiddle" hspace="2" alt="'+addToFavorites+'"></a>');
     document.write('<a href=# onClick="AddStartpage(this);return false"><img src="images/btnhome.gif" width="19" height="19" border="0" align="absmiddle" hspace="2" alt="'+makeStartPage+'"></a>');
  } else {
     document.write('<img src="images/btnfavor.gif" width="19" height="19" border="0" align="absmiddle" hspace="2" alt="'+addToFavorites+'" - "'+addToFavoritesCD+'">');
  }
}
function OpenImage(img_f,img_w,img_h,img_d,img_s) {
	var leftpos = Math.round(screen.width/2 - img_w/2);
	var toppos = Math.round(screen.height/2 - img_h/2);
	var wwidth = 10 + parseInt(img_w);
	var wheight = 25 + parseInt(img_h);
	var sContent = '<html><head><title>'+img_d+'</title></head><body bgcolor=#FFFFFF text=#000000 marginwidth=0 marginheight=0 topmargin=0 leftmargin=0 rightmargin=0 bottommargin=0>';
	sContent += '<table align=center border=0 cellspacing=5 cellpadding=0 width==100% height=100%><tr><td align=center><img src='+img_f+' border=0 align=center width='+img_w+' height='+img_h+' alt=\"\"><br /><div>'+img_d+'<br />'+img_s+'</div></td></tr></table>';
	sContent += '</body></html>';
	var tWindow=window.open('','image'+img_w+'x'+img_h, 'menubar=0,status=0,toolbar=0,resizable=1,scrollbars=1,width='+wwidth+',height='+wheight+',left='+leftpos+',top='+toppos);
	tWindow.document.open();
	tWindow.document.write(sContent);
	tWindow.document.close();
	tWindow.focus();
}
function OpenImageBig(img_f,img_w,img_h,img_d) {
	var leftpos = Math.round(screen.width/2 - img_w/4);
	var toppos = Math.round(screen.height/2 - img_h/4);
	var wwidth = 10 + parseInt(Math.round(img_w/2));
	var wheight = 10 + parseInt(Math.round(img_h/2));
	var sContent = '<html><head><title>'+img_d+'</title></head><body bgcolor=#FFFFFF text=#000000 marginwidth=0 marginheight=0 topmargin=0 leftmargin=0 rightmargin=0 bottommargin=0>';
	sContent += '<table align=center border=0 cellspacing=5 cellpadding=0 width==100% height=100%><tr><td align=center><img src='+img_f+' border=0 align=center width='+img_w+' height='+img_h+' alt=\"\"></td></tr></table>';
	sContent += '</body></html>';
	var tWindow=window.open('','imagexxx', 'menubar=1,status=0,toolbar=1,resizable=1,scrollbars=1,width='+wwidth+',height='+wheight+',left='+leftpos+',top='+toppos);
	tWindow.document.open();
	tWindow.document.write(sContent);
	tWindow.document.close();
	tWindow.focus();
}
function OpenImageLoad(img_path,img_w,img_h,img_d,str_loading) {
	tempWindow = window.open('','image'+img_w+'x'+img_h, 'menubar=1,status=1,toolbar=1,resizable=1,scrollbars=1');
	tempWindow.document.write('<HTML><HEAD><TITLE>'+img_d+'</TITLE></HEAD>');
	tempWindow.document.write('<BODY BGCOLOR=#FFFFFF TEXT=#000000 LINK=#336699 ALINK=#003366 VLINK=#003366 MARGINWIDTH=0 MARGINHEIGHT=0 TOPMARGIN=0 LEFTMARGIN=0 RIGHTMARGIN=0 BOTTOMMARGIN=0 onLoad="window.focus()">');
	tempWindow.document.write('<TABLE BORDER=0 CELLSPACING=5 CELLPADDING=0 WIDTH=100% HEIGHT=100%><TR><TH><FONT SIZE=1>'+ str_loading +'</FONT></TH></TR></TABLE>');
	tempWindow.document.write('</BODY></HTML>');
	tempWindow.document.close();
	tempWindow.location.replace(img_path);
	if (tempWindow) tempWindow.focus();
}
function OpenWindow(url) {
	tWindow = window.open ( url,'imgxxx','');
	tWindow.focus();
}
function printContent(id,title,sitename,siteurl) {
	var sContent = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><title>'+title+'</title><meta http-equiv="Content-Language" content="ru"><meta http-equiv="Content-Type" content="text/html; charset=windows-1251"><link href="print.css" rel="stylesheet" type="text/css"></head><body><center>'+document.getElementById(id).innerHTML+'<br />'+sitename+', '+siteurl+'<br />&nbsp;</center></body></html>';
	var printwindow=window.open("","","toolbar=yes,location=no,directories=yes,menubar=yes,scrollbars=yes,resizable=yes,width=640,height=480,screenX=200,screenY=50");
	printwindow.document.open();
	printwindow.document.write(sContent);
	printwindow.document.close();
	printwindow.focus();
}
function conf(text) {
	return confirm(text+"?");
}
function toBuf(name){
	if(document.selection.createRange().text!=""){
	name.focus();
	document.selection.createRange().duplicate().execCommand("Copy");
	}else{
	name.focus();
	name.createTextRange().execCommand("Copy");}
}
function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}

