var ie=(document.all && document.all.item && !window.opera)?1:0;



function checkf() {

	a=checkf.arguments;

	form=a[0];

	noerror=true;

	for (i=1;i<a.length;i++) if (form[a[i]].value.length==0) noerror=false;

		if (!noerror) alert('Не заполены все требуемые поля!');

	return noerror;

}



function deleteMe(what, id){

	MM_findObj('make_do').value = 'delete';

	MM_findObj('make_what').value = what;

	MM_findObj('make_id').value = id;

	MM_findObj('make').submit();

}





function showMe(what, id)

{

	if (!c_id) c_id = -1;

	MM_findObj(c_what).style.display = 'none';

	MM_findObj(what).style.display = 'block';

	MM_findObj(c_what+'_'+c_id).style.display = 'none';

	MM_findObj(what+'_'+id).style.display = 'block';

	if (c_what!=what) {

		if (obj = MM_findObj(what+'_img')) obj.src = 'images/cabinet/t2_.gif';

		if (obj = MM_findObj(c_what+'_img')) obj.src = 'images/cabinet/t2.gif';

		MM_findObj(what+'_a').style.textDecoration = 'underline';

		MM_findObj(c_what+'_a').style.textDecoration = 'none';

	}

	MM_findObj('date_td_'+c_what+'_'+c_id).bgColor = "#FFFFFF";

	MM_findObj('date_td_'+what+'_'+id).bgColor = "#F6E3C8";

	c_what = what;

	c_id = id;

	return false;	

}



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); 

	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 changeHeight(){

	for (i=1; i<=top.frames['infoFrame'].imax; i++)

	{

		obj_menu = MM_findObj('td_'+i, top.frames['leftFrame'].document);

		obj = MM_findObj('td_'+i+'_1', top.frames['infoFrame'].document);

		if (obj_menu) obj_menu.height = 24;

		if (obj) obj.height = 24;

		if (obj&&obj_menu)

		{

			if (obj_menu.clientHeight > obj.clientHeight)

				obj.height = obj_menu.clientHeight;

			else obj_menu.height = obj.clientHeight;

		}

	}

}



function changeWith(elem1, elem2){

	var tmp = elem1.innerText;

	if (elem1.filters[0]) elem1.filters[0].Apply();

	if (elem2.filters[0]) elem2.filters[0].Apply();

	elem1.innerText = elem2.innerText;

	elem2.innerText = tmp;

	if (elem1.filters[0]) elem1.filters[0].Play();

	if (elem2.filters[0]) elem2.filters[0].Play();



}



function changeInfoRows(elem1, elem2){

	for (i=1; i<=top.frames['infoFrame'].jmax; i++)

	{

		obj1 = MM_findObj('info_'+elem1+'_'+i, top.frames['infoFrame'].document);

		obj2 = MM_findObj('info_'+elem2+'_'+i, top.frames['infoFrame'].document);

		if (obj1.filters[0]) obj1.filters[0].Apply();

		if (obj2.filters[0]) obj2.filters[0].Apply();

		tmp = obj1.innerText;

		obj1.innerText = obj2.innerText;

		obj2.innerText = tmp;

		if (obj1.filters[0]) obj1.filters[0].Play();

		if (obj2.filters[0]) obj2.filters[0].Play();

	}

	changeHeight();

}



function changeInfoCols(elem1, elem2){

	for (i=1; i<=top.frames['infoFrame'].imax; i++)

	{

		obj1 = MM_findObj('info_'+i+'_'+elem1, top.frames['infoFrame'].document);

		obj2 = MM_findObj('info_'+i+'_'+elem2, top.frames['infoFrame'].document);

		if (obj1.filters[1]) obj1.filters[1].Apply();

		if (obj2.filters[1]) obj2.filters[1].Apply();

		tmp = obj1.innerText;

		obj1.innerText = obj2.innerText;

		obj2.innerText = tmp;

		if (obj1.filters[1]) obj1.filters[1].Play();

		if (obj2.filters[1]) obj2.filters[1].Play();



	}

}



function getInfoData(){

	data = new Array();

	str = '';

	for (i=1; i<=top.frames['infoFrame'].imax; i++)

	{

		data[i] = new Array();

		for(j=1; j<=top.frames['infoFrame'].jmax; j++)

		{

			str = str + MM_findObj('info_'+i+'_'+j, top.frames['infoFrame'].document).innerText;

			if (j!=top.frames['infoFrame'].jmax) str = str+'<col>';

		}

		if (i!=top.frames['infoFrame'].imax) str = str+'<row>';

	}

	return str;

}



function show_div(id)

{

	if (!divs||print_id == id) 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 SetHiddenVar(variable,val) {

	var forma = document.forms['search'];

	forma.elements[variable].value = val;

	forma.submit();

	return false;

}



var options = Array();

function show_option(id){



 for(i in options) 

  {

 	document.all[i].style.display = 'none'; 

  }



 options[id] = 1;

 document.all[id].style.display = 'block';

 return false;

}



function openImage(image) {

	window.open("/popup.php?img="+image, "popupimage", "scrollbars=0, resizable=1, width=520, height=450").focus();

}



function downloadprice(file){

	window.open('/downloadprice/?file='+file,'popupimage', 'scrollbars=1, resizable=1, menubar=1, width=320, height=150');

//	return false;

}
