/*jQuery(document).ready(function () {
	jQuery(".homearticlewrapper").rightClick( function(e) {
		alert("aaaa");
	});
});  */

//window.parent.SqueezeBox.close();
function CloseSqueezeboxAndRefresh()
{
	SqueezeBox.close();
	location.reload(true);
}

function CloseSqueezeboxAndGotoUrl(url)
{
	SqueezeBox.close();
	window.location = url;
	return false;
}

function PutInFavourites(title, url)
{
	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true; 
	}else if(document.all)// ie
		window.external.AddFavorite(url, title);
	else {
		alert("Please use CTRL + D to bookmark this website.");
	}
}

function doForm2ContentSubmitInPopup(page, action, projectId, cid)
{
	var addconcat = '';
	if(page.indexOf("?") == -1){
		addconcat = '?';
	}else{
		addconcat = '&';
	}
	
	var url = page + addconcat + 'c=form&projectid=' + projectId + '&option=com_form2content&task=' + action + '&cid[0]=' + cid + '&tmpl=component&popup=1';	
	//alert(url);
	//SqueezeBox.fromElement(url, {size:{x:800, y:600}, handler:'iframe', closeWithOverlay:false, onClose:Class.empty});
	SqueezeBox.initialize({size: {x:800, y:600}});
	//SqueezeBox.resize({x:800,y:600},false);
	SqueezeBox.fromElement(url, {size: {x:800, y:600}, handler: 'iframe', closeWithOverlay:false, onClose:Class.empty});
	//SqueezeBox.document.getElement('iframe').setStyles({'width':800,'height':600});
}

function doPopupLogin()
{
	var url = 'index.php?option=com_comprofiler&task=login&tmpl=component&eximiabg=1';
	SqueezeBox.className = 'modal';
	SqueezeBox.fromElement(url, {size: {x:290, y:100}, handler: 'iframe', closeWithOverlay:false, onClose:Class.empty, classWindow: 'login'});
}

function doPopupRegister()
{
	var url = 'index.php?option=com_comprofiler&amp;task=registers&tmpl=component&eximiabg=1';
	SqueezeBox.className = 'modal';
	//SqueezeBox.fromElement(url, {size: {x:415, y:456}, handler: 'iframe', closeWithOverlay:false, onClose:Class.empty, classWindow: 'login'});
	SqueezeBox.fromElement(url, {size: {x:500, y:500}, handler: 'iframe', closeWithOverlay:false, onClose:Class.empty, classWindow: 'login'});
}

function doPopupForgot()
{
	var url = 'index.php?option=com_comprofiler&amp;task=lostPassword&tmpl=component';
  SqueezeBox.className = 'modal';
	SqueezeBox.fromElement(url, {size: {x:600, y:350}, handler: 'iframe', closeWithOverlay:false, onClose:Class.empty, classWindow: 'login'});
}
function doPopupLoginOnCancelUrl(cancelUrl)
{
	var url = 'index.php?option=com_comprofiler&task=login&tmpl=component';
	//SqueezeBox.initialize({size: {x:300, y:250}});
	SqueezeBox.className = 'modal';
	SqueezeBox.fromElement(url, {size: {x:290, y:100}, handler: 'iframe', closeWithOverlay:false, onClose:function(){CloseSqueezeboxAndGotoUrl(cancelUrl);}, classWindow: 'login'});
}

function doPopupLoginOnCancelUrlAdditionalParams(cancelUrl,params)
{
	var url = 'index.php?option=com_comprofiler&task=login&tmpl=component' + params;		
	//SqueezeBox.initialize({size: {x:300, y:250}});
	SqueezeBox.className = 'modal';
	SqueezeBox.fromElement(url, {size: {x:290, y:100}, handler: 'iframe', closeWithOverlay:false, onClose:function(){CloseSqueezeboxAndGotoUrl(cancelUrl);}, classWindow: 'login'});
}

function doPopupIcon(url, width, height){
	try{
		var intWidth = parseInt(width);
		var intHeight = parseInt(height);
		SqueezeBox.initialize({size: {x:intWidth, y:intHeight}});
		SqueezeBox.fromElement(url, {size: {x:intWidth, y:intHeight}, handler: 'iframe', closeWithOverlay:false, onClose:Class.empty}); 
	}catch(e){}
}

function doPopupMail(url, width, height){
	doPopupIcon(url, width, height);
}

function doPopupPrint(url, width, height){
	doPopupIcon(url, width, height);
}


function closeSqueezebox(){
	SqueezeBox.close();	
	return false;
}

function resizeSqueezeBox(newWidth, newHeight){
	//PER EVITARE PROBLEMA CON PUBBLICITA
	var iframes = parent.document.getElementsByTagName("iframe");
	try{
			//var i = parent.document.getElementsByTagName("iframe")[0];
			for(var i=0;i<iframes.length;i++){
				if(iframes[i].id == ''){
					parent.SqueezeBox.resize({x:newWidth,y:newHeight},false);
					iframes[i].style.width= newWidth+"px";		
					iframes[i].style.height=newHeight +"px";
				}
			}
	}catch(e){return;}
}
function trim(stringa){
    while (stringa.substring(0,1) == ' '){
        stringa = stringa.substring(1, stringa.length);
    }
    while (stringa.substring(stringa.length-1, stringa.length) == ' '){
        stringa = stringa.substring(0,stringa.length-1);
    }
    return stringa;
}

function openSpecialPagesPopup(pageName, widthPx, heightPx)
{
	var url = pageName;
	SqueezeBox.className = 'modal';
	SqueezeBox.fromElement(url, {size: {x:widthPx, y:heightPx}, handler: 'iframe', closeWithOverlay:false, onClose:Class.empty});
}

/*function makeScrollbar(content,scrollbar,handle,horizontal,ignoreMouse){
	var size = content.getSize().y;
	var scrollSize = content.getScrollSize().y;
	//var steps = (horizontal?(content.getScrollSize().x - content.getSize().x):(content.getScrollSize().y - content.getSize().y))
	var slider = new Slider(scrollbar, handle, {	
		steps: content.getSize().scrollSize.y - content3.getSize().size.y,
		mode: 'vertical',
		onChange: function(step){
			// Scrolls the content element in x or y direction.
			var x = (horizontal?step:0);
			var y = (horizontal?0:step);
			content.scrollTo(x,y);
		}
	}).set(0);
	if( !(ignoreMouse) ){
		// Scroll the content element when the mousewheel is used within the 
		// content or the scrollbar element.
		$$(content, scrollbar).addEvent('mousewheel', function(e){	
			e = new Event(e).stop();
			var step = slider.step - e.wheel * 30;	
			slider.set(step);					
		});
	}
	// Stops the handle dragging process when the mouse leaves the document body.
	$(document.body).addEvent('mouseleave',function(){slider.drag.stop()});
}       */

/*function makeScrollbar(content,scrollbar,handle,horizontal,ignoreMouse){
	if ( content.getScrollSize().y-content.getSize().y > 0){
		var slider = new Slider(scrollbar, handle, {
			steps: 100,
			mode: (horizontal?'horizontal':'vertical'),
			onChange: function(step){
				// Scrolls the content element in x or y direction.
				var x = (horizontal?(((content.getScrollSize().x-content.getSize().x)/100)*step):0);
				var y = (horizontal?0:(((content.getScrollSize().y-content.getSize().y)/100)*step));
				content.scrollTo(x,y);	
			}
		}).set(0);
		if( !(ignoreMouse) ){
		// Scroll the content element when the mousewheel is used within the
		// content or the scrollbar element.
		$$(content, scrollbar).addEvent('mousewheel', function(e){
		e = new Event(e).stop();
		var step = slider.step - e.wheel * 2;
		slider.set(step);
		});
	}
	// Stops the handle dragging process when the mouse leaves the document body.
	$(document.body).addEvent('mouseleave',function(){slider.drag.stop()});
	}else
	scrollbar.fade(0);

} */


