/*
  $Id: common-functions.js,v 1.6 2009/11/09 11:45:45 Tomas Exp $

  *************************************************
  *** V3 common javascript functions            ***
  *************************************************
*/

/*
	This function returns a value of the url parameter 'name'
*/
function getUrlParam( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}


// The funcion opens a new window. URL, name and windowFeatures are arguments.
// The function is used in <A HREF="javascript:openNewWindow(...)"> tag, where it is not possible to use the standard window.open() function
function openNewWindow(aUrl, aWindowName, aWindowFeatures) {
  window.open(aUrl, aWindowName,aWindowFeatures);
}

// This function resizes iframe under the flipping catalog when the product arrangement is changed. This
// function is called from the included iframe.
function SetFlippCatIframeHeight(pIframeId, pHeight){
	jQuery(pIframeId).css("height",pHeight);
}

// This function handles 'enter' key on form field and it clicks on relevant submit button.
// It fixes the behavior of the IE. It expects the input submit tag to be a direct child of the form tag.

jQuery(function(){
  jQuery('input').keydown(function(e){
  	if (e.keyCode == 13) {
    	var cosik = jQuery(this).parents('form').find('input[type=submit]');
      cosik.click();
      return false;
    }
  });
});
