// здесь будут функции которые юзаются и в главной и админской части



// открыть картинку в новом окне

//


function openWindow(im, w, h, name) {



	w = open("", "displayWindow", "width="+w+",height="+h+",status=no,toolbar=no,menubar=no");

  

	w.document.open();

	w.document.write("<html><head><title>doctorhead.ru - " + name);

	w.document.write("</title></head><BODY leftmargin=0 topmargin=0 marginwidth=0 marginheight=0 >");



	// смотрим что у нас картинка, или их несколько

	if (im.constructor.toString().indexOf("Array") == -1) {

		if (im != '') w.document.write("<img src=" + im + ">");

	} else {

		for (var loop = 0; loop < im.length; loop++)

			if (im[loop] != '') w.document.write("<img src=" + im[loop] + ">");

	}

	

	w.document.write("</body></html>");

	w.document.close();

}



function showDesc(id) {

		

	if (document.getElementById(id) == null) {}

	else {

		// ширина

		if (document.compatMode && document.compatMode != "BackCompat")

			theWidth = document.documentElement.clientWidth;

		else

			// всегда работает

			theWidth = document.body.clientWidth;	



		/*

		// высота

		if (document.compatMode && document.compatMode != "BackCompat")

			theHeight = document.documentElement.clientHeight;

		else

			// всегда работает

			theHeight = document.body.clientHeight;

		*/

			

		// смещение

		if (document.documentElement && document.documentElement.scrollTop)

			theTop = document.documentElement.scrollTop;

		else if (document.body && document.body.scrollTop)

			theTop = document.body.scrollTop

		else if (window.pageYOffset)

			theTop = window.pageYOffset;

		else

			theTop = window.screenTop;

				

	    document.getElementById(id).style.top = theTop + theWidth/5 + 'px';

	    document.getElementById(id).style.display = 'block';

	    

	    return true;

	}

    

    return false;

}





function hideDesc(id) {



	if (document.getElementById(id) == null) {}

	else {

		document.getElementById(id).style.display = 'none';

		

		return true;

	}

	

	return false;

}





function trim(TRIM_VALUE) {

	

	if (TRIM_VALUE.length < 1)

		return "";



	TRIM_VALUE = rtrim(TRIM_VALUE);

	TRIM_VALUE = ltrim(TRIM_VALUE);



	if (TRIM_VALUE=="")

		return "";

	else

		return TRIM_VALUE;

}





function rtrim(VALUE) {

	

	var w_space = String.fromCharCode(32);

	var v_length = VALUE.length;

	var strTemp = "";

	

	if (v_length < 0)

		return "";

		

	var iTemp = v_length -1;

	

	while(iTemp > -1) {

		if (VALUE.charAt(iTemp) == w_space) {}

		else {

			strTemp = VALUE.substring(0, iTemp +1);

			break;

		}

		iTemp = iTemp-1;

	} //End While

	

	return strTemp;



} //End Function





function ltrim(VALUE) {

	

	var w_space = String.fromCharCode(32);

	

	if (v_length < 1)

		return "";

		

	var v_length = VALUE.length;

	var strTemp = "";



	var iTemp = 0;

	

	while (iTemp < v_length) {

		if (VALUE.charAt(iTemp) == w_space) {}

		else{

			strTemp = VALUE.substring(iTemp,v_length);

			break;

		}

		

		iTemp = iTemp + 1;

	} //End While

	

	return strTemp;

	

} //End Function


