var ie=(document.all && document.all.item && !window.opera)?1:0;
var opera=(window.opera)?1:0;

function MM_findObj(n, d) { 
  	var p,i,x;  
	if(!d) d=document; 
	if((p=n.indexOf("?"))>0&&parent.frames.length) {
	    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all) x=d.all[n]; 
	for (i=0;!x&&i<d.forms.length;i++) 
		x=d.forms[i][n];
  	for(i=0;!x&&d.layers&&i<d.layers.length;i++) 
		x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) 
		x=d.getElementById(n);
/*	if(!x && d.getElementsByName) 
		x=d.getElementsByName(n);*/
	return x;
}

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 OpenPrint(link_name) {
	window.open("/view/"+link_name, "OpenPrint", "scrollbars=1, resizable=1, width=600, height=500").focus();
}

function show_div(name){

	obj = MM_findObj('info');
	if(!obj) return false;
	childs = obj.childNodes;
	if (!childs) return false;
   	var cnt  = childs.length;
   	for (c = 0; c < cnt; c++) {
		childs[c].className = 'invisible';
    }
	
	divtoshow = MM_findObj(name);
	if (divtoshow){
		divtoshow.className = '';
		if (opera) window.location = '#info';
		else divtoshow.scrollIntoView(true);
	}
	return false;
	//if (!divs||print_id == id) return true;
/*	if (!divs) return true;
	for (key in divs){
		Obj = MM_findObj(divs[key]);
		Obj.className = 'invisible';
		Obj2 = MM_findObj('a_'+divs[key]);
		Obj2.className = 'pmenu';
	}
	obj = MM_findObj(id);
	if (obj) {
		obj.className='visible'; 
		obj2 = MM_findObj('a_'+id);
		obj2.className = 'redlink';
		window.location = '#info';
		return false;
	}
	else return true;*/
}

function openImage(image) {
	window.open("/popup.php?img="+image, "popupimage", "scrollbars=0, resizable=1, width=520, height=450").focus();
	return false;
}

function openLink(link_id) {
	obj = MM_findObj(link_id);
	if (obj.href) window.open(obj.href, '_self');
}

function openUrl(url) {
	if (url) window.open(url, '_self');
}

function colorTables() {
	obj = document.getElementsByTagName('table');
	if(!obj) return false;
	
   	var cnt  = obj.length;
	if (cnt > 0)
		for (c = 0; c < cnt; c++) 
			if(obj[c].className == 'border') 
				colorTable(obj[c]);

	return true;
}

function colorTable(obj) {
	if(!obj) return false;
	is_colored = false; 
	r = 0;
	while (obj.rows[r] != null) { 
		if (is_colored) obj.rows[r].className = 'no_colored';
		else obj.rows[r].className = 'colored';
		is_colored = !is_colored;
		r++; 
	}
	return true;
}

function cartpopup(url)
{
	return window.open(url, "cart_window", "scrollbars=1, resizable=1, width=550, height=500").focus();
}
function rusoft() {
  window.open('http://www.rusoft.ru');
}
