function viewBig(oImg)
{
	bigImg = window.open("", "_blank", "resizable=1, scrollbars=1");
	bigImg.document.write("<html><body onload='window.moveTo(0 ,0);window.resizeTo(document.getElementById(\"Img\").width+18, document.getElementById(\"Img\").height+60);' onclick='window.close();' style='margin:0px;padding: 0px;'><img id='Img' src='"+oImg.src.replace("/preview/", "/fullsize/")+"' /></body></html>");
	bigImg.document.close();
}// end of function viewBig(oImg)

function viewBigOld(oImg)
{
	bigImg = window.open(oImg.src.replace("/preview/", "/fullsize/"), "_blank", "none");
}// end of function viewBig(oImg)

//#######################################################################################
function open_href(objHref, strTarget)
{// function for open window in XHTML 1.1 strict - no target by anchor is allowed
 	window.open(objHref.href, strTarget);
 	return false;
}// end of function window_open_href(objHref)

function setActiveForm()
{
	arrForms = document.getElementsByTagName('Form');
	var arrInpts;
	if(arrForms[0])arrInpts = arrForms[0].getElementsByTagName('Input');
	if(arrInpts && arrInpts[0] && arrInpts[0].type!='hidden')
		arrInpts[0].focus();
}

function fireChangeEvent(control, targetWindow) 
{ 
	if(!targetWindow)targetWindow = window;
    if (document.all) 
    { 
        control.fireEvent("onchange"); 
    } 
    else 
    { 
		var changeevent=targetWindow.document.createEvent("HTMLEvents")
		changeevent.initEvent("change", true, true)
		control.dispatchEvent(changeevent)
    } 
}// end of function fireChangeEvent(control, targetWindow) 

function shopCheckDeposit(oInput, strDeposit, variantSelectType, strAlert)
{
	var maxDeposit = 0;
	var	idSelectedVariant = 0;
	// 1 - get variant select type and selcted variant value
	if(strDeposit.indexOf(",") != -1)
	{// are variants
		arrDeposit = strDeposit.split(",");
		if(variantSelectType == 0)
		{// checkbox
			// get checked variant
			for(i=0; i< arrDeposit.length; ++i)
			{
				arrDepositVariant = arrDeposit[i].split("-");
				oChkbox = document.getElementById("variant_radio_"+arrDepositVariant[0]);
				if(oChkbox && oChkbox.checked)
					idSelectedVariant = arrDepositVariant[0];
			}// end of for 
			
		}else
		{// selectbox
			idSelectedVariant = document.getElementById("IdVariant-"+parseInt(arrDeposit[0])).value;
		}// end of else

		// get max items on deposit
		for(i=1; i< arrDeposit.length; ++i)
		{
			arrDepositVariant = arrDeposit[i].split("-");
			if(arrDepositVariant[0] == idSelectedVariant)
				maxDeposit = arrDepositVariant[1];
		}// end of for 
			
	}// end of if are variants
	// if is no deposit by variant or are no variants use deposit from article
	if(maxDeposit == 0)
		maxDeposit = parseInt(strDeposit.substr(strDeposit.indexOf("-")+1));// there are no variants
	if(parseInt(oInput.value) > parseInt(maxDeposit))
	{
		oInput.value=maxDeposit;
		window.alert(strAlert.replace("{Count}", maxDeposit));
	}// end of if is value more than maxDeposit	
}// end of function shopCheckDeposit(oInput, strDeposit, variantSelectType, alert)

function changeFolder(activeId, noactiveId)
{
  document.getElementById(activeId).style.display="block";
  document.getElementById(noactiveId).style.display="none";
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}
