function popupWindow(url) {
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,left=150')
}

function rowOverEffect(object) {
  if (object.className == 'moduleRow') object.className = 'moduleRowOver';
}

function rowOutEffect(object) {
  if (object.className == 'moduleRowOver') object.className = 'moduleRow';
}

function checkBoxNewsletter(object) {
  document.account_newsletter.elements[object].checked = !document.account_newsletter.elements[object].checked;
}

function checkBoxNotifications(object) {
  document.account_notifications.elements[object].checked = !document.account_notifications.elements[object].checked;
}

function popupWindowAvdancedSearch(url) {
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=450,height=280,screenX=150,screenY=150,top=150,left=150')
}

function checkFormRewiewsWrite() {
  var error = 0;
  var error_message = "<?php echo JS_ERROR; ?>";

  var review = document.product_reviews_write.review.value;

  if (review.length < "<?php echo REVIEW_TEXT_MIN_LENGTH; ?>") {
    error_message = error_message + "<?php echo JS_REVIEW_TEXT; ?>";
    error = 1;
  }

  if ((document.product_reviews_write.rating[0].checked) || (document.product_reviews_write.rating[1].checked) || (document.product_reviews_write.rating[2].checked) || (document.product_reviews_write.rating[3].checked) || (document.product_reviews_write.rating[4].checked)) {
  } else {
    error_message = error_message + "<?php echo JS_REVIEW_RATING; ?>";
    error = 1;
  }

  if (error == 1) {
    alert(error_message);
    return false;
  } else {
    return true;
  }
}

var selected;

function selectRowEffect(object, buttonSelect) {
  if (!selected) {
    if (document.getElementById) {
      selected = document.getElementById('defaultSelected');
    } else {
      selected = document.all['defaultSelected'];
    }
  }

  if (selected) selected.className = 'moduleRow';
  object.className = 'moduleRowSelected';
  selected = object;

// one button is not an array
  if (document.checkout_address.address[0]) {
    document.checkout_address.address[buttonSelect].checked=true;
  } else {
    document.checkout_address.address.checked=true;
  }

// one button is not an array
  if (document.checkout_address.shipping[0]) {
    document.checkout_address.shipping[buttonSelect].checked=true;
  } else {
    document.checkout_address.shipping.checked=true;
  }

// one button is not an array
  if (document.checkout_payment.payment[0]) {
    document.checkout_payment.payment[buttonSelect].checked=true;
  } else {
    document.checkout_payment.payment.checked=true;
  }
}

function check_form_optional(form_name) {
  var form = form_name;

  var firstname = form.elements['firstname'].value;
  var lastname = form.elements['lastname'].value;
  var street_address = form.elements['street_address'].value;

  if (firstname == '' && lastname == '' && street_address == '') {
    return true;
  } else {
    return check_form(form_name);
  }
}

var i=0;
function resize() {
  if (navigator.appName == 'Netscape') i=40;
  if (document.images[0]) window.resizeTo(document.images[0].width +30, document.images[0].height+60-i);
  self.focus();
}

// Ascunde/afiseaza obiect HTML
function ToggleComandaPrinCont() 
{
	if (document.getElementById('comandaPrinCont').style.display=='none') {
		document.getElementById('butonToggleComandaPrinCont').src = "includes/languages/romanian/images/buttons/button_template-faraCont.gif";
		document.getElementById('explicatiiComandaPrinCont').style.display='none';
		document.getElementById('comandaPrinCont').style.display= '';
		document.getElementById('explicatiiComandaFaraCont').style.display='';		
	}
	else
	{
		document.getElementById('butonToggleComandaPrinCont').src = "includes/languages/romanian/images/buttons/button_template-cuCont.gif";
		document.getElementById('explicatiiComandaPrinCont').style.display='';
		document.getElementById('comandaPrinCont').style.display= 'none';
		document.getElementById('explicatiiComandaFaraCont').style.display='none';		
		
	}
}

// Banner Switch ---
var currentImgNo = 1;
var t
var i = 7000;
function timedImgSwitch()
{
	/*
	if (currentImgNo >= 8)
		{
		currentImgNo = 1;
		}

	switchImg(currentImgNo);
	currentImgNo = currentImgNo + 1;
	t=setTimeout("timedImgSwitch()",i);
	*/
}

function switchImg(currentImgNo)
{
	var currentImg = "templates/interlink01/banner/banner_" + currentImgNo + ".jpg";
	document.images["bannerImg"].src = currentImg;
}

function setImgNrAndSwitch(sentImgNo)
{
	currentImgNo = sentImgNo
	var currentImg = "templates/interlink01/banner/banner_" + currentImgNo + ".jpg";
	document.images["bannerImg"].src = currentImg;
}
// --- End Banner Switch


var good;
function checkEmailAddress(field) 
{
	// Note: The next expression must be all on one line...
	// allow no spaces, linefeeds, or carriage returns!
	var goodEmail = field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);

	if (goodEmail)
	{
		good = true
	}
	else 
	{
		alert('Va rugam introduceti o adresa valabila de e-mail.')
		field.focus()
		field.select()
		good = false
	}
 }


function sendOff()
	{
	nmcheck = document.form.email.value
	if (nmcheck.length <1) 
	{
		alert('Va rugam sa introduceti adresa de email.')
		return false
	}
	good = false
	checkEmailAddress(document.form.email)
	if (good)
	{
		return true
	}
	else
	{
		return false
	}
}