/*************************
 * cybercartes/common.js *
 *************************/

function isset(variable)
{
	if(typeof(variable) == "undefined")
	{
		return true;
	}
	else
	{
		return false;
	}
}


var Popup = {
  open: function(options)
  {
    this.options = {
      url: '#',
      width: 600,
      height: 500,
      name:"_blank",
      location:"no",
      menubar:"no",
      toolbar:"no",
      status:"yes",
      scrollbars:"yes",
      resizable:"yes",
      left:"",
      top:"",
      normal:false
    }
    
    Object.extend(this.options, options || {});

    if (this.options.normal)
    {
        this.options.menubar = "yes";
        this.options.status = "yes";
        this.options.toolbar = "yes";
        this.options.location = "yes";
    }

    this.options.width=this.options.width < screen.availWidth?this.options.width:screen.availWidth;
    this.options.height=this.options.height < screen.availHeight?this.options.height:screen.availHeight;
    var openoptions = 'width='+this.options.width+',height='+this.options.height+',location='+this.options.location+',menubar='+this.options.menubar+',toolbar='+this.options.toolbar+',scrollbars='+this.options.scrollbars+',resizable='+this.options.resizable+',status='+this.options.status
    if (this.options.top!="")openoptions+=",top="+this.options.top;
    if (this.options.left!="")openoptions+=",left="+this.options.left;
    window.open(this.options.url, this.options.name,openoptions );
    return false;
  }
}

/*
 * Popup des tarifs
 *
 */
function popupTarifs()
{
	Popup.open({
		url: 'http://envoi1.cybercartes.com/pages/popup/tarifs',
		width: 822,
		height: 889,
		left: 10,
		top: 10,
		resizable: 'yes',
		status: 'no',
		location: 'no'
	});
}


function $radio(radioName)
{ 
  var arrayOfInput = $$('input'); 
  var value = null; 
   
  arrayOfInput.each( 
    function (radio)
    { 
      if (radio.hasAttribute("name") && radio.readAttribute("name")==radioName) 
        if (radio.checked=="true" || radio.checked) value=radio.getValue();  
    } 
  );//End of each() 
  return value;  
} 

var fbHelper =
{
	insertWidget: function (where, logobar)
	{
			if(logobar === undefined)
			{
				logobar = 1;
			}
			var str_widget = '<script type="text/javascript" src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php/fr_FR"></script><script type="text/javascript">FB.init("e945c136a774f04fa46c58c996b371e2");</script><fb:fan profile_id="236031939444" stream="0" connections="0" logobar="'+logobar+'" width="300"></fb:fan>';
			$("."+where).append(str_widget);
	}
}
