function refreshParent($name) {
  
	document.getElementById('popup_changes').submit();
	window.opener.location.href = window.opener.location.href;

  	if (window.opener.progressWindow)
		
  	{
    	window.opener.progressWindow.close()
  	}
  	window.close();
  	
}

function CloseParent() {
  
  window.close();
  
}



function change_Main(url,theWidth,theHeight){
var theTop=(screen.height/2)-(theHeight/2);
var theLeft=(screen.width/2)-(theWidth/2);
var features=
'height='+theHeight+',width='+theWidth+',top='+theTop+',left='+theLeft+",scrollbars=yes";
theWin=window.open(url,'',features);
}



function pic_open(imageType,imageName,imageWidth,imageHeight,alt,posLeft,posTop) {  // v4.01

	newWindow = window.open("","newWindow","width="+imageWidth+",height="+imageHeight+",scrollbars=no,left="+posLeft+",top="+posTop);
	newWindow.document.open();
	newWindow.document.write('<html><title>'+alt+'</title><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close()">');
	newWindow.document.write('<img src=\"'+imageName+'\" width='+imageWidth+' height='+imageHeight+' alt=\"'+alt+'\">');
	newWindow.document.write('</body></html>');
	newWindow.document.close();
	newWindow.focus(); 

}

function clear_search() {

  document.search.search.value = "";

}

function printf(url_address) {

	 var URL, url_address;
	 URL = "print.php?print=page"+url_address;	 
	 window.open(URL, 'NewPopup','scrollbars=yes, height=600, width=800 , left=50 , top=50');

}

function calCheck(lang) 
{
	var lang;
	var name = document.getElementById('name').value;
	var email= document.getElementById('email').value;
	
	if(name == "")
	{
		if(lang == 'estonian')
		{
			alert('Palun täida kõik kohustuslikud väljad !');
		}
		else if(lang == 'russian')
		{
			alert('??????????, ????????? ??? ??????????? ????');
		}
		else
		{
			alert('Please, feel the "name" field');
		}

		return false;
	}
	else if(email == "")
	{
		if(lang == 'estonian')
		{
			alert('Palun täida kõik kohustuslikud väljad !');
		}
		else if(lang == 'russian')
		{
			alert('??????????, ????????? ??? ??????????? ????');
		}
		else
		{
			alert('Please, feel the "e-mail" field');
		}

		return false;
	}
	else {return true;}
}


function search_check() 
{
	
	var search = document.getElementById('search').value;
	if(search == "")
	{
		alert('Palun sisesta otsingu sõna');
		return false;
	}
	else {return true;}
}


function marketCheck(message) 
{
	var message;
	var name = document.getElementById('name').value;
	var address= document.getElementById('address').value;
	var phone= document.getElementById('phone').value;
	var mail= document.getElementById('mail').value;
	var firm= document.getElementById('firm').value;
	var add_info4= document.getElementById('add_info4').checked;
	
	if(name == "" || address == "" || phone == "" || mail == "" || firm == "" || add_info4 == false)
	{
		alert(message);

		return false;
	}

	else {return true;}
}



function numeric(message,total){
	
	var message;
	var total;
	var radio;
	var mess2;
	
	for (var i=1; i<=total; i++) {
		
		if (document.getElementById('prod_qty_'+i).value != parseInt(document.getElementById('prod_qty_'+i).value)){
		
			alert(document.getElementById('prod_qty_'+i).value+" "+ message);
		
			return false;
		
		}
		
	}
	
	return true;
}


function getSelectedRadio(buttonGroup) {
   // returns the array number of the selected radio button or -1 if no button is selected
    if (buttonGroup[0]) { // if the button group is an array (one button is not an array)
      for (var i=0; i<buttonGroup.length; i++) {
         if (buttonGroup[i].checked) {
            return i;
         }
      }
   } else {
      if (buttonGroup.checked) { return 0; } // if the one button is checked, return zero
   }
   // if we get to this point, no radio button is selected
   return -1;
} // Ends the "getSelectedRadio" function



function checksend(value1,value2,value3,mess){
	
	var mess;

	if(document.getElementById('name').value == "" || document.getElementById('name').value == value1 ) {
		
		alert(mess);
		return false
	}
	
	
	if(document.getElementById('mail').value == "" || document.getElementById('mail').value == value2 ) {
		
		alert(mess);
		return false
	}
	
	if(document.getElementById('textarea').value == "" || document.getElementById('textarea').value == value3 ) {
		
		alert(mess);
		return false
	}
	
	document.form1.submit();
	return true;
	
}