function recount(CountPackage, CountGoods) {

	if(CountGoods.value > CountPackage) {
		CountGoods.value = Math.ceil(CountGoods.value / CountPackage) * CountPackage
	}
	else {
		CountGoods.value = CountPackage
	}
}


function IsDigit() {
  return (((event.keyCode >= 48) && (event.keyCode <= 57)) || (event.keyCode == 32) || (event.keyCode == 43));
}

function showSearchBox() {
	var HelpWidth = (document.body.clientWidth - 994)
	if (HelpWidth < 0) {
		HelpWidth = 0
		}
	document.getElementById('SearchBox').style.left= (HelpWidth/2) + 16;
	document.getElementById('searchbox').style.display='block';
	return false
}

function hideSearchBox() {
	document.getElementById('searchbox').style.display='none';
}

//Global test for support Regular Expressions
var g_RegExpSupported = 0;
if(window.RegExp)
{
	var tempStr = "a";
	var tempReg = new RegExp(tempStr);
	if(tempReg.test(tempStr)) 
		g_RegExpSupported = 1;
}

/////////////////////////////////////////////////////////////////////////////////////
// Author: webProgress, s.r.o.
// Programmer: Richard Machát
// Date: 29.5.2002
//
// Dependency: webBlast_PageID_5_LanguageID_(X).xsl - language independent
//
// Description: Pří SUBMIT kontroluje jestli je vyplněno
//								-
//								-
//								-
//								-
//								-
//
/////////////////////////////////////////////////////////////////////////////////////

 function validateOrder(ThisForm){
	var strHTML=ThisForm.TitleTextForJS.value+'\n';	
	var submitForm = true
 	var msg = ThisForm.sEmailForJS.value;	
	var str = ThisForm.sEmail.value;

	if(!g_RegExpSupported){
		if(!(str.indexOf(".") > 2) && (str.indexOf("@") > 0))
		{
			if(strHTML != ''){
			strHTML += '\n'
			}
			strHTML += msg;
			ThisForm.sEmailForm.focus();
			submitForm = false;
		}	
	}
	else
	{	
		var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
		var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,5}|[0-9]{1,3})(\\]?)$");
		if(!(!r1.test(str) && r2.test(str)))
		{
			if(strHTML != ''){
			strHTML += "\n"
			}
			strHTML += msg;
			ThisForm.sEmail.focus();
			submitForm = false;
		}
	}

	if(ThisForm.sName.value==''){
			if(strHTML != ''){
			strHTML += "\n"
			}	
			strHTML += (ThisForm.sNameForJS.value);
			submitForm = false;
	}

	if(ThisForm.sSurName.value==''){
			if(strHTML != ''){
			strHTML += "\n"
			}
			strHTML += (ThisForm.sSurNameForJS.value);
			submitForm = false;
	}
	
	if(ThisForm.sStreet.value==''){
			if(strHTML != ''){
			strHTML += "\n"
			}
			strHTML += (ThisForm.sStreetForJS.value);
			submitForm = false;
	}

	if(ThisForm.sZIP.value==''){
			if(strHTML != ''){
			strHTML += "\n"
			}
			strHTML += (ThisForm.sZIPForJS.value);
			submitForm = false;
	}
	if(ThisForm.sCity.value==''){
			if(strHTML != ''){
			strHTML += "\n"
			}
			strHTML += (ThisForm.sCityForJS.value);
			submitForm = false;
	}
	
//	if(ThisForm.sDeliveryZIP.value=='' && (ThisForm.sZIP.value!=='' && (ThisForm.sZIP.value.charAt(0)>7 || ThisForm.sZIP.value.charAt(0)<1)) || ThisForm.sDeliveryZIP.value!=='' &&  (ThisForm.sDeliveryZIP.value.charAt(0)>7 || ThisForm.sDeliveryZIP.value.charAt(0)<1)){
	if(ThisForm.sZIP.value==''){
			if(strHTML != ''){
			strHTML += "\n"
			}
			strHTML += ("Není zadáno PSČ!");
//			strHTML += ("PSČ není pro Českou Republiku!");
			submitForm = false;
	}

	if(!submitForm){
		alert(strHTML);
		return false
	}
	else{
	//slouceni zpravy obchodnika a cisla HUDYPartner karty
		ThisForm.sMessage.value = ThisForm.sMessage1.value
		if (ThisForm.sHUDYPartner_Card.value!==''){
		ThisForm.sMessage.value += "|*/+|"
		ThisForm.sMessage.value += "Číslo HUDYPartner karty: "+ThisForm.sHUDYPartner_Card.value
		}
		if(document.getElementById('giftbasket') && document.getElementById('Price').value > 1000) {
			document.getElementById('sDeliveryCountry').style.display='none';
			document.getElementById('sCountry').style.display='none';
			
			window.scrollTo(0, 0);
			
			document.getElementById('giftbasket').style.left = 230;
			document.getElementById('giftbasket').style.display='block';
			return false
		} else {
			return true
		}
	}
}