/*
navHover = function() 
	{
	var lis = document.getElementById("mainmenu").getElementsByTagName("LI");
	for (var i=0; i<lis.length; i++) 
		{
		lis[i].onmouseover=function() 
			{
			this.className+=" iehover";
			}
		lis[i].onmouseout=function() 
			{
			this.className=this.className.replace(new RegExp(" iehover\\b"), "");
			}
		}
	}
if (window.attachEvent) window.attachEvent("onload", navHover);
*/


function fncjsGlobalCheckNumber(varUnknown, flagInteger, flagMinus, flagZero)
	{
		var val = new Number(varUnknown).valueOf();
		
		if (isNaN(val))
			return false;

		if (flagInteger && Math.round(val) != val)
			return false;
			
		if (flagMinus && val < 0)
			return false;
			
		if (flagZero && val == 0)
			return false
			
		return true;
	}
	
function fncjsGlobalCheckEmail(varUnknown)
	{
 	return /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(varUnknown);
	}
	
function fncjsGlobalCheckPhone(varUnknown)
	{
	return /^[0-9 -]+$/.test(varUnknown);
	}
	
function fncjsGlobalTrim(str)
	{
	return str.replace(/^ */, '').replace(/ *$/, '');
	}
	
	
function fncjsGlobalOneIfEmpty(strId)
	{
		inp = document.getElementById(strId);
		if (inp.value == '')
			{
			inp.value = '1';
			inp.select();
			}
	}
	
function fncjsGlobalHttpRequest()
	{
	var xmlHttp=null;
	try
	  {
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp=new XMLHttpRequest();
	  }
	catch (e)
	  {
	  // Internet Explorer
	  try
		{
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
	  catch (e)
		{
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	  }
	return xmlHttp;
	}
	
	
//function fncjsGlobalHttpRequestGet(xmlHttp, strUrl, fncResponse)
//	{
//	if (xmlHttp == null) return false;
//	
//	xmlHttp.onReadyStateChange
//	
////	xmlHttp.onReadyStateChange = function()
////		{
////		alert("state change: "+xmlHttp.readyState);
//////		if (xmlHttp.readyState==4)
//////			{ 
//////			eval(fncResponse+"(xmlHttp.responseText)");
//////			}		
////		};
//	xmlHttp.open("GET",strUrl,true);
//	xmlHttp.send(null);	
//	return true;
//	}
//	

function fncjsGlobalCheckProduct(strForm, flagInteger)
	{
	var obForm=document.getElementById(strForm);
	var iFoundQuantity = 0;
	var bFilledQuantity = false;
	var bIncorrectQuantity = false;
	var bError = false;
	
	for(var intD=0; intD<obForm.elements.length;intD++ )
		{
		//alert(obForm.elements[intD].name);
		if (	/^skuquantity.*$/.test(obForm.elements[intD].name) 
			|| 	/^param_quantity.*$/.test(obForm.elements[intD].name)
			||  /^matrix.*$/.test(obForm.elements[intD].name)
		   )
		   {
			//alert ('found quantity: '+obForm.elements[intD].name);
			++iFoundQuantity;
			if ('' != obForm.elements[intD].value)
				{
				bFilledQuantity = true;
				if (!fncjsGlobalCheckNumber(obForm.elements[intD].value, flagInteger, true, true))
					bIncorrectQuantity = true;
				}
		   }
		}
	
	if (iFoundQuantity > 0)
		{
		if (!bFilledQuantity)
			{
			if (iFoundQuantity > 1)
				alert (arrLanguage[11]);
			else
				alert (arrLanguage[14]);
			bError = true;
			}
		else if(bIncorrectQuantity)
			{
			if (flagInteger)
				{
				if (iFoundQuantity > 1)
					alert (arrLanguage[12]);
				else
					alert (arrLanguage[15]);
				}
			else
				{
				if (iFoundQuantity > 1)
					alert (arrLanguage[13]);
				else
					alert (arrLanguage[16]);
				}
			bError = true;
			}
		}
		
	if (!bError)
		{
		// testing only
		//alert ('OK');
		//return;
		// end of testing only
		
		for(var intD=0; intD<obForm.elements.length;intD++ )
			{
			obForm.elements[intD].disabled=false;
			}
		obForm.submit();
		}

	}

function detailKeyPress(ev)
	{
	var keynum='';
	if(window.event) // IE
		{
		keynum = ev.keyCode;
		}
	else if(ev.which) // Netscape/Firefox/Opera
		{
		keynum = ev.which;
		}
		
	if (keynum == 13)
		{
	 	fncjsGlobalCheckProduct('frmaddtocart');
	 	return false;
	 	}
	return true;	 	
  	}
  	
  function imageHover(idBigImage, strImagePath, alt, width, height)
  	{
  	obBigImage = document.getElementById(idBigImage);
  	obBigImage.src = strImagePath;
  	obBigImage.alt = alt;
  	obBigImage.width = width;
  	obBigImage.height = height;
  	obBigImage.style.width = width;
  	obBigImage.style.height = height;
  	}

//function fncjsImageHoverOnload()    
//	{
//	var sWidth;
//	var sHeight;
//	
////	if (isNaN(iBigImageHeight))
////		iBigImageHeight = document.getElementById('product_bigimage').style.height;
//
////    var sWidth = document.getElementById('product_bigimage').width;
////    var sHeight = document.getElementById('product_bigimage').height;
//    
////    if (!isNaN(sWidth) && !isNaN(sHeight))
////        {
//
////        document.getElementById('product_bigimage').width = '';
////        document.getElementById('product_bigimage').height = '';
//        
//
//	var arrImage = document.getElementsByTagName('img');
//	var bFirst = true;
//	for (var i = 0; i < arrImage.length; i++) 
//		{
//		if (arrImage[i].className == 'hover_thumb_image')
//			{
//			if (bFirst)
//				{
//				bFirst = false;
//				if (iHoverThumbHeight== '' || isNaN(iHoverThumbHeight))
//					iHoverThumbHeight = arrImage[i].height;
//				if (iHoverThumbHeight== '' || isNaN(iHoverThumbHeight))
//					break;
//				}
//				
//			sWidth = arrImage[i].width;
//			sHeight = arrImage[i].height;
//			
//			arrImage[i].width = '';
//			arrImage[i].height = '';
//			
//			arrImage[i].style.height = iHoverThumbHeight+'px';
//
//			if (iHoverThumbWidth == '' || isNaN(iHoverThumbWidth))
//				{
//				if (!isNaN(sHeight) && !isNaN(sWidth))
//					arrImage[i].style.width = (sWidth / sHeight * iHoverThumbHeight)+'px';
//				else
//					break;
//				}
//			else
//				{
//				arrImage[i].style.width = iHoverThumbWidth+'px';
//				}
//			}
//		}
//    
//
//
//
////    iBigImageHeight = document.getElementById('product_bigimage').style.height;
////    if (isNaN(iBigImageHeight))
////        iBigImageHeight = document.getElementById('product_bigimage').height;"
////
////    var sWidth = document.getElementById('product_bigimage').width;"
////    var sHeight = document.getElementById('product_bigimage').height;"
////    if (!isNaN(sWidth) && !isNaN(sHeight))"
////        {"
////        document.getElementById('product_bigimage').width = '';"
////        document.getElementById('product_bigimage').height = '';"
////        document.getElementById('product_bigimage').style.width=(sWidth/sHeight*iBigImageHeight)+'px';"
////        document.getElementById('product_bigimage').style.height=iBigImageHeight+'px';"
////        }"
////    "
//
//    }

