var imageWindow; 
function ImgWin(src,width,height,print,title){ 
	var scroll='no';
	if (print==true)
	{	var w=20;	var h=20;	}
	else{ var w=20;	var h=0;		}

	if( height>600 ) { w = w+width; h=600; scroll='yes'; }
	else { w=width; h=h+height; scroll='no'; }

	title=(!title)?"<Строй-комплекс>":"<Строй-комплекс> : "+title;

	if(imageWindow)
		imageWindow.close(); 
	imageWindow=window.open("","blankImageWindow", 'status=no,scrollbars='+scroll+',resizable=0,width='+w+',height='+h+''); 
	imageWindow.document.write("<html><head><title>"+title+"</title><link rel='stylesheet' type='text/css' href='./inc/normal.css'></head>"); 
	imageWindow.document.write("<body topmargin=0 marginheight=0 leftmargin=0 marginwidth=0 bgcolor=white text=black link=black alink=black vlink=black>"); 
	imageWindow.document.write("<center>"); 
	imageWindow.document.write("<table border=0 cellspacing=0 cellpadding=0 bgcolor=#FFFFFF>"); 
	imageWindow.document.write("<tr><td align=center bgcolor=white>"); 
	imageWindow.document.write("<a href='javascript:self.close();' title='закрыть окно'><img src='"+src+"' width="+width+" height="+height+" border=0></a>"); 
	if (print==true)
		imageWindow.document.write("</td></tr><tr><td align='center'><a class='cat' href='javascript:self.print();'>Распечатать</a></td></tr>"); 
	else
		imageWindow.document.write("</td></tr>"); 
	imageWindow.document.write("</table>"); 
	imageWindow.document.write("</body></html>"); 
	imageWindow.document.close(); 
	imageWindow.focus(); 
} 


var docWindow; 
function DocWin(src){ 
	var scroll='yes';
	var xAll=document.body.clientWidth;
	var yAll=document.body.clientHeight;
	var w=710; 
	var h=560;
	var l=(xAll-w)/2;
	var t=(yAll-h)/2;

	//if(docWindow)	docWindow.close();
	docWindow=window.open(src,"blankDocWindow", 'status=no,scrollbars='+scroll+',resizable=0,top='+t+',left='+l+',width='+w+',height='+h+''); 
	docWindow.focus(); 
} 


var hlpWindow; 
function ShowHelpWin(src){ 
	var scroll='yes';
	var w=500; 
	var h=400;

	hlpWindow=window.open("../template/"+src,"blankHelpWindow", 'status=no,scrollbars='+scroll+',resizable=0,width='+w+',height='+h+''); 
	hlpWindow.focus(); 
} 

var shWindow; 
function ShowWin(src){ 
	var scroll='yes';
	var w=500; 
	var h=400;

	shWindow=window.open("","blankDocWindow", 'status=no,scrollbars='+scroll+',resizable=0,width='+w+',height='+h+''); 
	shWindow.document.location="./control/show.php?id="+src;
	shWindow.focus(); 
} 

function GoToSite(src)
{
	window.open(src,"general"); 
	self.close();
}

function mailTo(oHref,atString) {
	if(atString){
		oHref.oldHref = oHref.href;
		oHref.href = oHref.href.replace(atString,"@");
	}else{
		oHref.href = oHref.oldHref;
	}
		return oHref.href;
}

var bookmarkurl="http://www.strblik.ru/"
var bookmarktitle="СтарБлик - Жалюзи, рулонные шторы и рольставни"

function addbookmark()
{
	if (document.all) window.external.AddFavorite(bookmarkurl,bookmarktitle)
}

/*function myHomePage()
{
	this.style.behavior='url(#default#homepage)';
	document.setHomePage(bookmarkurl);
}
*/
// ........................................................
// Версия для печати
var classFix = (document.all)?"className":"class";
var PrintObject = null;
var HideObject = null;
function PrintVersion(){
	if(PrintObject==null){
		PrintObject = document.createElement("div");
		PrintObject.setAttribute(classFix,"printversion");
/*		PrintObject.appendChild(document.getElementById("navigation").cloneNode(1));*/
		PrintObject.appendChild(document.getElementById("nodecontent").cloneNode(1));
		
		HideObject = document.createElement("div");
		HideObject.innerHTML = document.body.innerHTML;
		document.body.innerHTML = "";
		document.body.background = "none";
		HideObject.style.display = "none";
		
		document.body.appendChild(PrintObject);
		document.body.appendChild(HideObject);
	}else{
		document.body.innerHTML = HideObject.innerHTML;
		PrintObject = null;
		HideObject = null;
	}
}
// ........................................................
// Конвертор языков
	function convertInputValue(idInput,idOut){
		var oInput = (idInput.tagName=="INPUT")?idInput:document.getElementById(idInput);
		var oOut = (idOut.tagName=="INPUT")?idOut:document.getElementById(idOut);
		var match  = new Array(" ","А","Б","В","Г","Д","Е","Ё","Ж","З","И","Й","К","Л","М","Н","О","П","Р","С","Т","У","Ф","Х","Ц","Ч","Ш","Щ","Ъ","Ы","Ь","Э","Ю","Я","а","б","в","г","д","е","ё","ж","з","и","й","к","л","м","н","о","п","р","с","т","у","ф","х","ц","ч","ш","щ","ъ","ы","ь","э","ю","я");
		var replace= new Array("_","A","B","V","G","D","E","E","Zh","Z","I","J","K","L","M","N","O","P","R","S","T","U","F","H","Tc","Ch","Sh","Sch","","Y","","E","Ju","Ya","a","b","v","g","d","e","e","zh","z","i","y","k","l","m","n","o","p","r","s","t","u","f","h","tc","ch","sh","sch","","y","","e","ju","ya");
		var value = oInput.value;
		for(var i=0; i<match.length;i++){
			var re = eval("/"+match[i]+"/g");
			value	= value.replace(re,replace[i]);
		}
		value	= value.replace(/(_+)/g,"_");
		value	= value.replace(/([^0-9a-zA-Z_])/g,"");
		oOut.value = value;
	}
// ........................................................
// Проверка введенных данных
	function checkInputValue(idInput,type){
		var classFix = (document.all)?"className":"class";
		var oInput = document.getElementById(idInput);
		var iclass = oInput.getAttribute(classFix);
		var pos = iclass.indexOf("errorfield");
		if(pos>=0){ 
			if(pos==0) oInput.removeAttribute(classFix);
			else			 oInput.setAttribute(classFix,iclass.substr(0,pos-1));
		}
		switch(type){
			case 0: // положительное целое
				if(oInput.value != oInput.value*1 || !(oInput.value>=0)){
					alert("Ошибка заполнения:\nВведите положительное целое число!");
					oInput.value = 0;
					oInput.focus();
					if(oInput.getAttribute(classFix).length>0)	oInput.setAttribute(classFix,oInput.getAttribute(classFix)+" errorfield");
					else																				oInput.setAttribute(classFix,"errorfield");
					return false;
				}else{
					oInput.value = Math.abs(Math.round(oInput.value));
					return true;
				}
			break;
			case 1: // email
				var re_mail = /([\w\.\-_]+@[\w\.\-_]+)/;
				if(oInput.value.match(re_mail)!=null){
					return true;
				}else{
					alert("Ошибка заполнения:\nВведите email адрес!");
					oInput.focus();
					if(oInput.getAttribute(classFix).length>0)	oInput.setAttribute(classFix,oInput.getAttribute(classFix)+" errorfield");
					else																				oInput.setAttribute(classFix,"errorfield");
					return false;
				}
			break;
			case 2: // пароли
				var oReInput = document.getElementById("re"+idInput);
				iclass = oReInput.getAttribute(classFix);
				var pos = iclass.indexOf("errorfield");
				if(pos>=0){ 
					if(pos==0) oReInput.removeAttribute(classFix);
					else			 oReInput.setAttribute(classFix,iclass.substr(0,pos-1));
				}
				if(oInput.value.length>=3 && oReInput.value==oInput.value){
					return true;
				}else{
					alert("Ошибка заполнения:\nВведенные пароли не совпадают!");
					oInput.value = ""; 
					oReInput.value = "";
					oInput.focus();
					if(oInput.getAttribute(classFix).length>0)	oInput.setAttribute(classFix,oInput.getAttribute(classFix)+" errorfield");
					else																				oInput.setAttribute(classFix,"errorfield");
					if(oReInput.getAttribute(classFix).length>0)	oReInput.setAttribute(classFix,oReInput.getAttribute(classFix)+" errorfield");
					else																				oReInput.setAttribute(classFix,"errorfield");
					return false;
				}
			break;
			default: // не пустое
				if(oInput.value.length>=3){
					return true;
				}else{
					alert("Ошибка заполнения:\nВведите текст!");
					oInput.focus();
					if(oInput.getAttribute(classFix).length>0)	oInput.setAttribute(classFix,oInput.getAttribute(classFix)+" errorfield");
					else																				oInput.setAttribute(classFix,"errorfield");
					return false;
				}
			break;
		}
	}
	/* .......................................................
	Открытия картинки в новом окне
....................................................... */
	var imageWindow;
	function openimage(src,title){ 
		var wWidth = 510;
		var wHeight = 400;
		imageWindow=window.open("","blankImageWindow", 'status=no,scrollbars=no,resizable=yes,width='+(wWidth)+',height='+(wHeight)+'');
			imageWindow.document.write("<html><head><title>"+title+"</title>");
			imageWindow.document.write("<body topmargin=0 marginheight=0 leftmargin=0 marginwidth=0 bgcolor=white text=black link=black alink=black vlink=black "); 
			imageWindow.document.write("onload=\"self.resizeTo(document.getElementById('image').width+25,document.getElementById('image').height+40);\">");
			imageWindow.document.write("<table border=0 cellspacing=0 cellpadding=0 width=100% height=100%><tr><td align=center>");
			imageWindow.document.write("<a href='javascript:self.close();' title='закрыть окно'><img src='"+src+"' border=0 id=image style='padding:1px;border:#FF0303 solid 1px;'></a>");
			imageWindow.document.write("</td></tr></table>");
			imageWindow.document.write("</body></html>");
			imageWindow.document.close();
		imageWindow.focus();
	}
	function get_position(obj,pos){
		if(obj.tagName!="TR" && obj.tagName!="FORM"){
			pos[0] += obj.offsetLeft;
			pos[1] += obj.offsetTop;
			pos[2] = obj.tagName + " ("+ obj.offsetLeft+", "+obj.offsetTop+")\n" + pos[2];
		}
		if(obj.parentNode.tagName != "HTML") pos = get_position(obj.parentNode,pos);
		return pos;
	}
	function overimage(oImage,visible){ 
		var oiLink = document.getElementById("ilink");
		if(visible){
			oiLink.setAttribute(classFix,"visible");
			var pos = new Array(0,0,"");
			get_position(oImage,pos);
			//alert(pos[2]);
			oiLink.style.left = pos[0]-oiLink.offsetWidth-25+oImage.offsetWidth;
			oiLink.style.top = pos[1]-oiLink.offsetHeight-25+oImage.offsetHeight;
		}else{
			oiLink.setAttribute(classFix,"hidden");	
		}
	}