function resizeWindow(isCatalog)
{
	var mainWidth = document.getElementById('mainArea');
	var merka = document.getElementById('merka'); 
	var welcomeTxt = document.getElementById('welcomeTxt');
	//var welcomeTxtIns = document.getElementById('welcomeTxtIns');
	var welcomeNews = document.getElementById('welcomeNews');
	
	if (mainWidth)
	{
		//alert(merka.clientWidth);
		//alert(mainWidth.clientWidth);
		var aWidth = "";
		var cWidth = 0;
		//if (isCatalog)
		//{
			cWidth = 1250;
			aWidth = "1250px";
		//}
		//else
		//{
			//cWidth = 1250;
			//aWidth = "1250px";
		//}
			
		if (mainWidth.clientWidth > cWidth && merka.clientWidth > cWidth)
		{
			mainWidth.style.width = aWidth;
			if (welcomeTxt)
				welcomeTxt.style.width = "350px";
			//if (welcomeTxtIns)
				//welcomeTxtIns.style.width = "100%";				
			if (welcomeNews)
				welcomeNews.style.width = "430px";				
		}
		else
		{
			mainWidth.style.width = "100%";
			if (welcomeTxt)
				welcomeTxt.style.width = "100%";		
			//if (welcomeTxtIns)
				//welcomeTxtIns.style.width = "100%";					
			if (welcomeNews)
				welcomeNews.style.width = "100%";								
		}
	} 	
}

function RolloverImgs(imgObg,img) 
{ 
	//var imgObj = document.getElementById(img);
	if (imgObg && img)
	{
		imgObg.src = img;
	}
}

var itemInBasket = new Array;

function setBg(id,bgType,urlHome,idItem)
{
	if (itemInBasket)
		if (bgType == 2 && itemInBasket[id])
			return;
	
	var trObj = document.getElementById(id);
	
	if (trObj)
	{
		for (i=0; i<trObj.cells.length; i++)
		{
			switch (bgType)
			{
				case 1:
					color = "#ffffff";
					color2 = "#ffffff";
					if (idItem)
					{
						var inpObj = document.getElementById('total_list_0'+idItem);
						if (inpObj)
							inpObj.disabled = 1;
					}					
					break;
					
				case 2:
					color = "#ffffff";
					color2 = "#ffffff";
					break;	
					
				case 3:
					color = "#ffffff";
					color2 = "#ffffff";
					if (idItem)
					{
						var inpObj = document.getElementById('total_list_0'+idItem);
						if (inpObj)
							inpObj.disabled = 0;
					}
					break;					
			}
			
			trObj.cells[i].style.background = color;
		}
	}
	
	var imgObj = document.getElementById('img_'+id);
	if (imgObj)
		switch (bgType)
		{
			case 1:
				imgObj.src = urlHome+"img/icons/basket2.gif";
				break;
					
			case 2:
				imgObj.src = urlHome+"img/icons/basket1.gif";
				break;	
				
			case 3:
				imgObj.src = urlHome+"img/icons/basket1.gif";
				break;					
		}
		
	var inpObj = document.getElementById('total_'+id);
	if (inpObj)
		inpObj.style.background = color2;
}

function replaceContent(id,url)
{	
	//ShowMessage();
	HTML_AJAX.replace(id,url);
}

function changeValue(id,SendURL,urlHome,idItem)
{
	addToBasket(id,SendURL,urlHome,idItem,-1)
}

function addToBasket(id,SendURL,urlHome,idItem,checkbox)
{		
	//if (itemInBasket[id])
		//return;
		
	if (itemInBasket[id] && checkbox != -1)
	{
		//return;
		SendURL = SendURL.replace(/a=add/gi, "a=del");
	}
			
	var inpObj = document.getElementById('total_'+id);
	if (inpObj && !itemInBasket[id])
		SendURL = SendURL + '&total['+idItem+']=' + inpObj.value;
		
	StatusMessage();
		
	//statusObj = document.getElementById('status_'+idItem);
	
	var callback = function(result) 
	{
		if (itemInBasket[id] && checkbox != -1)
		{
			setBg(id,3,urlHome,idItem);
			itemInBasket[id] = 0;
		}
		else
		{
			setBg(id,1,urlHome,idItem);
			itemInBasket[id] = 1;
		}		
	
		var priceField = document.getElementById('priceBasket');
		if (priceField)
			priceField.innerHTML = result;
			
		var priceField = document.getElementById('priceBasket0');
		if (priceField)
			priceField.innerHTML = result;			
					
		//statusObj.style.display = "none";		
	}	

	//statusObj.style.display = "block";
	HTML_AJAX.onError = function(e) 
	{
		if (confirm("Some errors on server\r\n Repeat request?'"))
			HTML_AJAX.grab(SendURL, callback);
	}		
	
	HTML_AJAX.grab(SendURL, callback);
}

function getContent(idContent,idMenu,url)
{
	//var SendURL = "ajax.php?p="+p+"&"+url;
	var SendURL = url;
	var linkObj = null;
	var linkObjP = null;
			
	StatusMessage();
	
	var contentObj = document.getElementById(idContent);
	
	var loadingM = document.getElementById('loadingSI');
	if (loadingM)
	{
		//loadingM.style.width = "px"; 
		loadingM.style.display = "block"; 
	}
	
	var callback = function(result) 
	{
		contentObj.innerHTML = result;

		if (idMenu)
		{
			for (i=0; i<MainDivs.length;i++)
			{
				linkObj = document.getElementById(MainDivs[i]);
				linkObjP = document.getElementById('p_'+MainDivs[i]);
				
				if (linkObj && MainDivs[i] == idMenu)
				{
					linkObj.className = "current";
					linkObjP.style.display = "block";
				}
				else if (linkObj)
				{
					linkObj.className = "";
					linkObjP.style.display = "none";
				}
			}
		}		
	}	

	HTML_AJAX.onError = function(e) 
	{
		if (confirm("Some errors on server\r\n Repeat request?'"))
			HTML_AJAX.grab(SendURL, callback);
	}		
	
	HTML_AJAX.grab(SendURL, callback);
		
	
	/*
	replaceContent(idContent,SendURL);
	*/
} 

function getCalendar(id,p,url)
{
	var SendURL = "ajax.php?p="+p+"&"+url;
	//alert(SendURL);
	//window.scrollTo(0,0); 
	StatusMessage();
	
	var loadingM = document.getElementById('loadingSI');
	if (loadingM)
		loadingM.style.display = "block"; 
			
	replaceContent(id,SendURL);
}  

function setupMessage()
{
	var loading = document.getElementById('HTML_AJAX_LOADING');
	if (!loading) 
	{
		loading = document.createElement('div');
		loading.id = 'HTML_AJAX_LOADING';
		loading.innerHTML = '';		
		loading.className = 'HTML_AJAX_Loading';
		loading.count = 0;	

		document.body.insertBefore(loading,document.body.firstChild);
	}
	
	loading.style.display = "none";
}

function StatusMessage()
{
	setupMessage();
	return;
	
	//var stMessage = document.getElementById('HTML_AJAX_LOADING');
	//if (stMessage == null)
	//{
		//return;
	//}
		
	//var newPlace = document.getElementById(idContent);	
		
	//if (newPlace != null)
	//{
		//var insertInParent = (newPlace.parentNode)?newPlace.parentNode:newPlace.parent;			
		//insertInParent.appendChild(stMessage);		
	//}
	
	//var parentWidth = insertInParent.offsetWidth;
	
	//stMessage.style.left = "auto";
	//stMessage.style.right = 40 +  "px";
	//stMessage.style.width = 100 +  "px";
	//stMessage.style.height = 20 +  "px";
	//stMessage.style.top = "149px";
	//stMessage.style.display = "block";
}

function makeOrder()
{
	var formObj = document.getElementById('clientData');
	if (formObj)
	{
		var checkEmail = document.getElementById('email');
		var Email = document.getElementById('email2');
		if (checkEmail && Email)
		{
			Email.value = checkEmail.value;
		}
		
		formObj.submit();
	}
}
