var buf1=0,buf2=0;
function viewNews(){
	obj = document.getElementById("news");
	if(!obj) return false;
	
		obj.style.display = 'block';


}

function HideAllMenu()
{
	buf1 = 0; 
	setTimeout('HideAllMenuNext()',1000);
}

function HideAllMenuNext()
{
	obj = document.getElementById("news");
	if(!obj) return false;
	if(buf1 == 0)
		obj.style.display = 'none';
}

function ClearFlags()
{
	buf1 = 1; 
}

function ClearFlagsNotice()
{
	buf2 = 1; 
}

function viewNotice(){
	obj = document.getElementById("notice");
	if(!obj) return false;
	obj.style.display = 'block';

}

function HideAllMenu_Notice()
{
	buf2 = 0; 
	setTimeout('HideAllMenuNext_Notice()',1000);
}

function HideAllMenuNext_Notice()
{
	obj = document.getElementById("notice");
	if(!obj) return false;
	if(buf2 == 0)
		obj.style.display = 'none';
}

function setStartPage(elem,mainurl)
{
	elem.style.behavior="url(#default#homepage)"; 
	elem.setHomePage(mainurl); 
	return false;
}	
function setFavorities(mainurl,setFavorities)
{
	window.external.addFavorite(mainurl, setFavorities); return false; 
}
function ViewForgotDiv()
{
	el = document.getElementById('divforgot');
	if (el.style.display == 'none')
		el.style.display  = "block";
	else	
		el.style.display  = "none";

}
function checkNum(toCheck) {
  var isNum = true;


  if ((toCheck == null) || (toCheck == "")) {
    isNum = false;
    return isNum;
  }

  for (j = 0; j < toCheck.length; j++) {
    if ((toCheck.substring(j,j+1) != "0") &&
        (toCheck.substring(j,j+1) != "1") &&
        (toCheck.substring(j,j+1) != "2") &&
        (toCheck.substring(j,j+1) != "3") &&
        (toCheck.substring(j,j+1) != "4") &&
        (toCheck.substring(j,j+1) != "5") &&
        (toCheck.substring(j,j+1) != "6") &&
        (toCheck.substring(j,j+1) != "7") &&
        (toCheck.substring(j,j+1) != "8") &&
        (toCheck.substring(j,j+1) != "9") &&

        (toCheck.substring(j,j+1) != ".") &&
        (toCheck.substring(j,j+1) != "-")) {
      isNum = false;
    }
  }

  return isNum;

}

function CheckIsNum(lang,toCheck)
{	
	if (checkNum(toCheck.value) == false)
		{
			toCheck.value = "0";
			if (lang == 'ru')
				alert('Поле должно быть числовое.');
			else
				alert('This field must Numeric.');
		}	
}

function ChangeLang()
{
	document.changeLang.submit();
}

function SubListOff(parent, count)
{
	var i;
	for (i=1; i<=count; i++)
	{
		var div=document.getElementById("div"+parent+"_"+i);
		var hidden = document.getElementById("hidden"+parent+"_"+i);
		var hidden_count = document.getElementById("hidden"+parent+"_"+i+"_count");
		div.style.display = "none";
		if (hidden_count.value > 0)
			SubListff(hidden.value, hidden_count.value);
	}
}

function SubListOn(parent, count)
{
	var i;
	for (i=1; i<=count; i++)
	{
		var div=document.getElementById("div"+parent+"_"+i);
		var hidden = document.getElementById("hidden"+parent+"_"+i);
		var hidden_count = document.getElementById("hidden"+parent+"_"+i+"_count");
		div.style.display = "";
		var img=document.getElementById("img"+hidden.value);
		var buf = img.src.substring(img.src.length-7, img.src.length);
		if (buf != "off.gif")
			SubListOn(hidden.value, hidden_count.value);
	}
}

function SubList(parent, count)
{
	var img=document.getElementById("img"+parent);	
	var buf = img.src.substring(img.src.length-7, img.src.length);

	if (buf == "off.gif")
	{
		img.src = "aimages/blueon.gif";
		img.alt = "Скрыть";
		var i;
		for (i=1; i<=count; i++)
		{
			var div=document.getElementById("div"+parent+"_"+i);
			div.style.display = "";
			var hidden = document.getElementById("hidden"+parent+"_"+i);
			var hidden_count = document.getElementById("hidden"+parent+"_"+i+"_count");
			var img=document.getElementById("img"+hidden.value);
			var buf = img.src.substring(img.src.length-7, img.src.length);
			if (buf != "off.gif")
				SubListOn(hidden.value, hidden_count.value);
		}
	}
	else 
	{
		img.src = "aimages/blueoff.gif";
		img.alt = "Раскрыть";
		var i;
		for (i=1; i<=count; i++)
		{
			var div=document.getElementById("div"+parent+"_"+i);
			var hidden = document.getElementById("hidden"+parent+"_"+i);
			var hidden_count = document.getElementById("hidden"+parent+"_"+i+"_count");
			div.style.display = "none";
			if (hidden_count.value > 0)
				SubListOff(hidden.value, hidden_count.value);
		}
	}
}

function MakeOn(url)
{
//	var expand = document.getElementById('expand');
//	url = url+"&expand="+expand.value;
	location.href=url;
}

function DopImg()
{
        targetId="dopimg";
        targetElement = document.getElementById(targetId);
	if (targetElement.style.display == "none")
	        targetElement.style.display= "";
	else targetElement.style.display = "none";
	location.href = "#dopimg";
}

var curid;
function ContextMenu(event, id){
	if (event.button == 3) return false;

	if (curid)
	{
	        var o = document.getElementById(curid);
	       	o.style.visibility ='';
	}
	curid = id;
        var o = document.getElementById(id);
		o.style.left = event.clientX+document.body.scrollLeft;
        o.style.top = event.clientY+document.body.scrollTop;
        o.style.visibility ='visible';
		preventBubble();
}
function ContextMenuHide(){
	if (curid)
	{
	        var o = document.getElementById(curid);
        	o.style.visibility ='';
	}
}

function highlightie5(){
if (event.srcElement.className=="menuitems"){
event.srcElement.style.backgroundColor="highlight"
event.srcElement.style.color="white"
}
}

function lowlightie5(){
if (event.srcElement.className=="menuitems"){
event.srcElement.style.backgroundColor=""
event.srcElement.style.color="black"
window.status=''
}
}

function jumptoie5(){
if (event.srcElement.className=="menuitems"){
if (event.srcElement.getAttribute("target")!=null)
window.open(event.srcElement.url,event.srcElement.getAttribute("target"))
else
window.location=event.srcElement.url
}
}

function showImage(src){document.getElementById("bigimage").src=src;}

var u=navigator.userAgent;
var isIE=(u.indexOf("MSIE")>0);
var isMoz=(u.indexOf("Gecko")>0);
var isOp=(u.indexOf("Opera")>0);
if(isOp) isIE=false;

function preventBubble(E){
	if(isIE){
		event.cancelBubble=true;
		event.returnValue=false
	}
	else if(isOp){
		if(DocumentEvent.stopPropagation)DocumentEvent.stopPropagation();
		 else DocumentEvent.preventBubble()
	}
	else {
		if(E.stopPropagation)E.stopPropagation();
		 else E.preventBubble()
	}
}

function showIgor()
{
	var buf = document.getElementById("igor");
	buf.style.visibility="";
}

<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  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 MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->

function GetCollects(t)
{
	obj = document.getElementById('collect1');
	while (obj.firstChild)
		obj.removeChild(obj.firstChild);
	var i=0;	
    obj.options[i] = new Option();
    obj.options[i].text = "Подождите...";
    obj.options[i].value = 0;
	obj.disabled=true;

	var buf = document.getElementById('brand1');	
	JsHttpRequest.query('/include/core/getcollects.php',{brand: buf.value, t: t},function(result, errors) {changeCollect(result);}, true);		
	return false;		
}

function changeCollect(result){
	if(!result) 
	{
		obj = document.getElementById('collect1');
		while (obj.firstChild)
			obj.removeChild(obj.firstChild);
		var i=0;	
		obj.options[i] = new Option();
		obj.options[i].text = "<--";
		obj.options[i].value = 0;
		obj.disabled=false;
		return false;
	}	
	obj = document.getElementById('collect1');
	while (obj.firstChild)
		obj.removeChild(obj.firstChild);
	var i=0;	
    obj.options[i] = new Option();
    obj.options[i].text = "<--";
    obj.options[i].value = 0;
	for (var key in result){	
		i++;
	    obj.options[i] = new Option();
	    obj.options[i].text = result[key]["text_name"];
	    obj.options[i].value = result[key]["id"];
	}	
	obj.disabled=false;
}

function sethidden(action)
{
	var buf = document.getElementById('dop');
	buf.value = action;
}

function MyCheck(r, id)
{
	var element = r+id;
	var target = "cc";	
	var buf = document.getElementById(target);
	var temp = new Array();
	temp = buf.value.split('#');
	var pr=0;
	var newstr = "";
	for(i=0; i<temp.length; i++)
	{
		if (temp[i] == element)
			pr=1;
		else
		{
			if (newstr == "")
				newstr = temp[i];
			else newstr = newstr+"#"+temp[i];
		}	
	}
	if (pr == 0)
	{
		if (newstr == "")
			newstr = element;
		else newstr = newstr+"#"+element;
	}
	buf.value = newstr;
}

function add_comment(id)
{
	var comm	= document.add_comm;
	if (!comm)	return;
	var name  = comm.name.value;
	var email = comm.email.value;
	var comment = comm.comment.value;
	var code  = comm.code.value;
	JsHttpRequest.query(
		'/include/core/ajax_comment.php',
		{id:id,email:email,name:name,comment:comment,code:code},
		function(result, errors)
		{
			var buf = document.getElementById('add_comment');
			if (result && buf) buf.innerHTML = result;
		},
		true);
	return false;
}

function page(page)
{
	form = document.getElementById('search_result');
	form.page.value	= page;
	form.submit();
}

function showLayer(id, event)
{
	var iDivObj = document.createElement("div");	
	iDivObj.name = "myDiv";		
	iDivObj.id = "myDiv";				
	iDivObj.style.position = "absolute";	
	iDivObj.style.top = "0px";
	iDivObj.style.left = "0px";
	iDivObj.style.width = "100%";	
	iDivObj.style.height = getDocumentHeight();						
	iDivObj.style.backgroundColor = "#000000";
	document.body.appendChild(iDivObj);
	setElementOpacity(iDivObj, 0.5);
	var buf = document.getElementById('goodtext');	
	buf.innerHTML = "Пожалуйста подождите...";
	var buf = document.getElementById('good');	
	var ll = getDocumentWidth()/2-400;		
	buf.style.left = ll;	
	res = mousePageXY(event);
	buf.style.top = res.y-200;
	buf.style.display = "";	
	JsHttpRequest.query('/include/core/getOboiInfo.php',{id: id}, 
	function(result, errors) {showLayerDone(result);}, true);
	return false;		
}

function showLayerDone(result)
{
	var buf = document.getElementById('goodtext');
	buf.innerHTML = result;	
}

function setElementOpacity(oElem, nOpacity)
{
    var p = getOpacityProperty();
    (setElementOpacity = p=="filter"?new Function('oElem', 'nOpacity', 'nOpacity *= 100;    var oAlpha = oElem.filters["DXImageTransform.Microsoft.alpha"] || oElem.filters.alpha;    if (oAlpha) oAlpha.opacity = nOpacity; else oElem.style.filter += "progid:DXImageTransform.Microsoft.Alpha(opacity="+nOpacity+")";'):p?new Function('oElem', 'nOpacity', 'oElem.style.'+p+' = nOpacity;'):new Function)(oElem, nOpacity);
}

function getOpacityProperty()
{
    var p;
    if (typeof document.body.style.opacity == 'string') p = 'opacity';
    else if (typeof document.body.style.MozOpacity == 'string') p =  'MozOpacity';
    else if (typeof document.body.style.KhtmlOpacity == 'string') p =  'KhtmlOpacity';
    else if (document.body.filters && navigator.appVersion.match(/MSIE ([\d.]+);/)[1]>=5.5) p =  'filter';
 
    return (getOpacityProperty = new Function("return '"+p+"';"))();
}

function get_e(e) 
{
	return (e)?e:(window.event)?event:null
} 

function mousePageXY(e)
{
  var x = 0, y = 0;

  if (e.pageX || e.pageY)
  {
    x = e.pageX;
    y = e.pageY;
  }
  else if (e.clientX || e.clientY)
  {
    x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
    y = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
  }

  return {"x":x, "y":y};
}

var ua = navigator.userAgent.toLowerCase();
var isOpera = (ua.indexOf('opera')  > -1);
var isIE = (!isOpera && ua.indexOf('msie') > -1);
 
function getDocumentHeight() 
{
  return Math.max(document.compatMode != 'CSS1Compat' ? document.body.scrollHeight : document.documentElement.scrollHeight, getViewportHeight());
}
 
function getDocumentWidth() 
{
  return Math.max(document.compatMode != 'CSS1Compat' ? document.body.scrollWidth : document.documentElement.scrollWidth, getViewportWidth());
}
 
function getViewportHeight() 
{
  return ((document.compatMode || isIE) && !isOpera) ? (document.compatMode == 'CSS1Compat') ? document.documentElement.clientHeight : document.body.clientHeight : (document.parentWindow || document.defaultView).innerHeight;
}
 
function getViewportWidth() 
{
  return ((document.compatMode || isIE) && !isOpera) ? (document.compatMode == 'CSS1Compat') ? document.documentElement.clientWidth : document.body.clientWidth : (document.parentWindow || document.defaultView).innerWidth;
}

function CloseGood()
{
	document.getElementById('good').style.display = "none";
	var p = parent.document.body;
	var p_div = parent.document.getElementById("myDiv");	
	throwaway = p.removeChild(p_div);		
}

function mySubmit(val, pr, to)
{		
	JsHttpRequest.query('/include/core/addInCart.php',{val: val, pr: pr, to: to}, 
	function(result, errors) {mySubmitDone(result);}, true);
	return false;		
}

function mySubmitDone(result)
{
	alert(result);
}
