
/* Start : search  Suggest*/
Event.observe(window,'load',pageLoad);

function searchSuggest(text, li) {
	var qElm = li.down();
	var qHTML = qElm.innerHTML;
	var qText = qElm.innerHTML.stripTags();

	var htmlNode = document.createElement("DIV");
	htmlNode.innerHTML = qHTML;
	if(htmlNode.innerText)
	{
		qText = htmlNode.innerText; // IE
	}
	else
	{
		qText = qText.unescapeHTML();
	}

//alert('qHTML : '+qHTML);

//var myNewString = myOldString.replace(/username/g, visitorName);

	//return htmlNode.textContent; // FF

//alert('qText : '+qText);
	var qField = $('q');
	qField.value = qText;
	var myForm = $('product-search-form');
	myForm.submit();
}

function suggestCallback(inputField,suggestQuery)
{
	var typeField = $F('q_support');
	
	var qString = 'http://www.editionsmontparnasse.fr/ajax/search_suggest.php?'+suggestQuery+'&type='+typeField;

	return qString;
}

function pageLoad()
{
	var suggestMinChars = 2;
	/*if(Prototype.Browser.IE)
	{
		Prototype.Browser.IE6 = Prototype.Browser.IE && parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5)) == 6;
		Prototype.Browser.IE7 = Prototype.Browser.IE && parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5)) == 7;

		if(Prototype.Browser.IE6)
		{
			suggestMinChars = 1;
		}
		else if(Prototype.Browser.IE7)
		{
			suggestMinChars = 1;
		}
	}*/
	//Prototype.Browser.IE8 = Prototype.Browser.IE && !Prototype.Browser.IE6 && !Prototype.Browser.IE7;

	new Ajax.Autocompleter( 'q','search-suggest-dropdown','/ajax/search_suggest.php',{minChars:suggestMinChars,callback:suggestCallback,afterUpdateElement:searchSuggest,onHide:function(element, update){ new Element.hide(update) }} );

	/*var suggestBg = new Image();
  suggestBg.src = '/images/layouts/suggest-bg-sprite.png';*/
}
/* End : search  Suggest*/



// Frame breaker
/*if(top.location!=location){
	top.location.href = document.location.href;
}*/


function printPage()
{
	window.print();
};



function toggle_fullscreen(element_id,bg_element_id)
{
//alert('ezdfsqfq');
	var myDiv = $(element_id);
	var bgDiv = $(bg_element_id);
	
	if(myDiv.hasClassName('fullscreen'))
	{
		myDiv.removeClassName('fullscreen');
		bgDiv.removeClassName('fullscreen-bg');
	}
	else
	{
		myDiv.addClassName('fullscreen');
		bgDiv.addClassName('fullscreen-bg');
	}
}


var Popup = {
  open: function(options)
  {
    this.options = {
      url:'#',
      width:740,
      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;
  }
}


function switchClassNames(elmId,oldClassName,newClassName)
{
	if($(elmId).hasClassName(oldClassName))
	{
		$(elmId).removeClassName(oldClassName);
	}

	$(elmId).addClassName(newClassName);
}























