function setbg(e_who,e_color)
{
	e_who.style.background = e_color;
}

function getbg(e_who)
{
	e_who.style.background = e_color;
}


function alphaimage( l_src )
{
	var ver = navigator.appVersion;
	if (ver.indexOf("MSIE") != -1)
	{
		window.document.write( "<img src='/project/templates/site/img/blank.gif' style='filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+l_src+");'>" );
	}else
	{
		window.document.write( "<img src='"+l_src+"'>" );
	}
}//end_ func_ alphaimg

function alphaimage_map( l_src, e_map, e_width, e_height )
{
	var ver = navigator.appVersion;

	var l_begin = ver.indexOf("MSIE");
	var l_end   = ver.indexOf(".",l_begin);
	var l_v = ver.substring(l_begin+5,l_end);
	l_v = l_v-0;

	if (ver.indexOf("MSIE") != -1 && l_v<=6 )
	{
		window.document.write( "<img style=\"cursor:hand;cursor:pointer;\" width="+e_width+" height="+e_height+" usemap=\""+e_map+"\" src='/project/templates/site/img/blank.gif' style='filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+l_src+");'>" );
	}else
	{
		window.document.write( "<img style=\"cursor:hand;cursor:pointer;\" usemap=\""+e_map+"\" src='"+l_src+"'>" );
	}
}//end_ func_ alphaimg


function alphaimage2( l_src, l_id )
{
	var ver = navigator.appVersion;
	l_html = window.document.getElementById(l_id);
	if (ver.indexOf("MSIE") != -1)
	{
		//-debug
		l_html.innerHTML = "<img src='/project/templates/site/img/blank.gif' style='filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+l_src+");'>";
	}else
	{
		//-debug
		l_html.innerHTML = "<img src='"+l_src+"'>";
	}
}//end_ func_ alphaimg

function alphaimage_id( l_src, l_idofimg )
{
	var ver = navigator.appVersion;
	if (ver.indexOf("MSIE") != -1)
	{
		//-debug
		window.document.write( "<img "+l_idofimg+" src='/project/templates/site/img/blank.gif' style='filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+l_src+");'>" );
	}else
	{
		//-debug
		window.document.write( "<img "+l_idofimg+" src='"+l_src+"'>" );
	}
}//end_ func_ alphaimg


function showhtml( l_element_name )
{
	//window.document.getElementById(l_element_name).style.visibility='visible';
	window.document.getElementById(l_element_name).style.display="";
}


function hidehtml( l_element_name )
{
	//window.document.getElementById(l_element_name).style.visibility='hidden';
	window.document.getElementById(l_element_name).style.display="none";
}

function getobject( e_id )
{
	return window.document.getElementById(e_id);
}//end_ func

function texttohtml( e_text, e_id )
{
	l_control = window.document.getElementById(e_id);
	if ( l_control==null ) alert( e_id+' íå íàéäåí' );
	if ( l_control!=null )
	{
		l_control.innerHTML =  e_text;
	}//end_ if
}

function appendtexttohtml( e_text, e_id )
{
	/*
	l_control = window.document.getElementById(e_id);
	if ( l_control!=null )
	{
		//alert( l_control.innerHTML );
		l_control.innerHTML = l_control.innerHTML+e_text;
	}//end_ if
	*/
}


function getgetvar(searchStr)
{
   start_var = 0;
   //while(1)
   for(i=0;i<100;i++)
   {
	//âûäèðàåò êóñîê ñòðîêè... ñíà÷àëî ñ 0 ýëåìåíòà äî êîíöà, ïîòîì ñ íàéäåííîãî è.ò.ä
	from_location = String(location).substring(start_var,String(location).length);
	start_var = String(from_location).indexOf(searchStr);
	if ( start_var==-1 )
	{
		return -1;
		break;
	}

	is_var = String(from_location).substring(start_var-1,start_var);
	if ( is_var=="&" || is_var=="?" )
	{
		start_value = from_location.indexOf(searchStr)+searchStr.length+1;

		end = (from_location.indexOf('&', start_value) == -1)
			? from_location.length
			: from_location.indexOf('&', start_value);

		return unescape( from_location.substring(start_value,end) );
	}


	start_var++;
   }//end_ while
}


function getshorturl()
{
	start_var = String(location).indexOf( "?" );
	//start_var = String(location).indexOf( "//", start_var+1 );
	for( i=start_var; i>0; i-- )
	{
		l_char = String(location).charAt(i);

		if ( l_char=='/' )
		{
			l_short_url = String(location).substring(i,String(location).length);
			return l_short_url;
		}//end_ if
	}//end_ for

	return null;
}//end_ func_ getshorturl


function open_in_new_window(href,width,height)
{
	l_window = window.open(
		href,
		'',
		'width='+width+'px,height='+height+'px;toolbar=no,menubar=no,location=no,directories=no,status=yes,scrollbars=yes,resizable=yes');
}


//===================================
// ==== ÎÁÐÀÁÎÒÊÀ ÊÓÊÈÑÎÂ ==========
//===================================

function getCookieVal (offset)
{ 
	var endstr = document.cookie.indexOf (";", offset); 
	if (endstr == -1) 
	endstr = document.cookie.length; 
	return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie( name )
{ 
	//alert( document.cookie );
	var arg = name + "="; 
	var alen = arg.length; 
	var clen = document.cookie.length; 
	var i = 0; 
	while (i < clen)
	{ 
		var j = i + alen; 
		if (document.cookie.substring(i, j) == arg) 
		return getCookieVal (j); 
		i = document.cookie.indexOf(" ", i) + 1; 
		if (i == 0) break; 
	}//end_ while
	return null;
}



function SetCookie(name, value)
{ 
	var argv = SetCookie.arguments; 
	var argc = SetCookie.arguments.length; 
	var expires = (argc > 2) ? argv[2] : null; 
	var path = "/";//(argc > 3) ? argv[3] : null; 
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false; 
	document.cookie = name + "=" + escape (value) + 
		((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
		((path == null) ? "" : ("; path=" + path)) + 
		((domain == null) ? "" : ("; domain=" + domain)) + 
		((secure == true) ? "; secure" : "");
}

function DeleteCookie( name )
{
	var argv = DeleteCookie.arguments; 
	var argc = DeleteCookie.arguments.length; 
	var path = (argc > 3) ? argv[3] : null; 
	var domain = (argc > 4) ? argv[4] : null; 

	if ( GetCookie(name) )
	{
		document.cookie = name + '=' +
				( ( path ) ? ';path=' + path : '') +
				( ( domain ) ? ';domain=' + domain : '' ) +
				';expires=Thu, 01-Jan-1970 00:00:01 GMT';
	}//end_ if
}

function __getNameOfCook( e_Cook )
{
	var endstr = e_Cook.indexOf("=", 0 ); 
	return e_Cook.substring(0, endstr);
}//end_ func


function DeleteCookieArray( e_name_of_cook )
{
	for( k=0; k<10; k++ )
	{
		var l_name_of_cook  = "";
		var l_index_of_cook_spacer = -2; 
		var l_result_cooks  = "";
		var l_cookie_value  = "";
		var clen = document.cookie.length; 

		for( j=0; j<clen; j++ )
		{
			l_temp = getCookieVal( l_index_of_cook_spacer+2 );
			l_name_of_cook = __getNameOfCook( l_temp );
	
			if ( l_name_of_cook.indexOf(e_name_of_cook,0)>=0 )
			{
				//alert( 1 );
				DeleteCookie( l_name_of_cook );
			}//end_ if
	
			l_index_of_cook_spacer += 1;
	
			l_index_of_cook_spacer = document.cookie.indexOf( "; ", l_index_of_cook_spacer )
			if ( l_index_of_cook_spacer==-1 ) break;
		}//end_ while
	}//end_ for_ k
}//end_ func




function setCheckboxes( e_this, the_form, do_check )
{
	l_elements = document.forms[the_form].getElementsByTagName("input");


	for( i=0; i<l_elements.length; i++ )
	{
		l_element = l_elements[i];
		if ( (l_element.type=="checkbox") && (l_element!=e_this) )
		{
			l_element.checked = e_this.checked;
		}
	}
} // end of the 'setCheckboxes()' function




//===================================
// ==== ÀÂÒÎÌÎÁÈËÈ ÌÅÍÞ è ÖÅÍÀ=======
//===================================

var c_cost = 0;

//îáíîâèòü îáùóþ öåíó
function updateCost()
{
	texttohtml( c_cost, "cost" );
	c_cost_complect = c_cost;
	updateCost2();
	/*window.opener.c_cost_complect = c_cost;
	window.opener.updateCost2();*/
}//end_ func_ updateCost

//çíà÷åíèå ÷åêåòà â êóêèñ.
function setValue( e_id, e_value )
{
	l_old_value = GetCookie("dop_optsii["+e_id+"]");
	e_value=e_value-0;
	if ( (l_old_value>=0) && (l_old_value!=null) )
	{
		c_cost -= e_value;
		//e_value = -1;
		DeleteCookie( "dop_optsii["+e_id+"]" );
	}else
	{
		SetCookie( "dop_optsii["+e_id+"]", e_value );
		c_cost += e_value;
	}//end_ if

	updateCost();
}//end_ func


