﻿
//	OD - override default SharePoint functions in "_layouts/1033/init.js"

function FixRibbonAndWorkspaceDimensions() {
	ULSA13: ;
	g_frl = true;
	var b = GetCachedElement("s4-ribbonrow"),
		a = GetCachedElement("s4-workspace"),
		f = GetCachedElement("s4-titlerow"),
		c = GetCachedElement("s4-bodyContainer");
	//	OD - add header, footer height and statusbar height (external to "s4-workspace")
	//	head = GetCachedElement("header_OD");
	//	foot = GetCachedElement("footer_OD");
		statusbar = GetCachedElement("s4-statusbarcontainer");
	//	alert("statusbar: "+statusbar.offsetHeight)
		if ( statusbar != null && statusbar != 'undefined' )
			if ( isNaN(statusbar.offsetHeight) || statusbar.offsetHeight == 'undefined' )
				statusbar.offsetHeight = 0;
	if (!b || !a || !c) return;
	if (!g_setWidthInited) {
		var h = true;
		if (a.className.indexOf("s4-nosetwidth") > -1) h = false;
		g_setWidth = h;
		g_setWidthInited = true
	} else
	var h = g_setWidth;
	var l = RibbonIsMinimized() ? 44 : 135,
		j = l + g_wpadderHeight;
	if (GetCurrentEltStyle(b, "visibility") == "hidden") j = 0;b.style.height = j + "px";
	var d = g_viewportHeight;
	if (null === d) {
		d = GetViewportHeight();
		g_viewportHeight = d
	}
//	OD - deduct head height, footer height and statusbar height (external to "s4-workspace")
	var statusBarHeight = statusbar.offsetHeight;
	if ( jQuery('#s4-statusbarcontainer').length > 0 )
	{
		if ( jQuery('#pageStatusBar').html().length == 0 )
		{
			statusBarHeight = 0;
		}
	}
	else
	{
		statusBarHeight = 0;
	}
	var e = d - b.offsetHeight - AbsTop(b) - statusBarHeight;// - head.offsetHeight;// - foot.offsetHeight;
//	alert(d +" | "+ b.offsetHeight +" | "+ AbsTop(b) +" | "+ statusBarHeight)
//	alert(e)
	if (e < 0) e = 0;
	a.style.height = e + "px";
	if (h) {
	//	OD - override width
		a.style.width = "1017px";
		if (c.offsetWidth < a.clientWidth) c.style.width = a.clientWidth + "px";
		if (f) {
		//	f.style.width = Math.max(c.offsetWidth - 1, 0) + "px";
		//	OD - override width
		//	f.style.width = "960px";
			f.style.width = "auto";
			f.className += " ms-titlerowborder"
		}
	}
	var m = browseris.ie && browseris.iever == 7 && !browseris.ie8standard;
	if (!g_setScrollPos) {
		browseris.firefox && browseris.firefox36up && window.scroll(0, 0);
		if (window.location.search.match("[?&]IsDlg=1")) if (!m || a.scrollHeight < a.clientHeight) a.style.overflowY = "auto";
		var g = document.getElementById("_maintainWorkspaceScrollPosition");
		if (g != null && g.value != null) a.scrollTop = g.value;
		g_setScrollPos = true
	}
	for (var k = [].concat(g_workspaceResizedHandlers), i = 0, n = k.length; i < n; i++) k[i]();g_frl = false

//	OD - call "OD_gest_ribbon"
//	OD_gest_ribbon(publicLang,privateLang);
	OD_gest_ribbon();
}

function _ribbonFixHeaderWidth(a) {
	ULSA13:;
	if (!g_fhs) return;
	var b = _ribbonCalculateWidth(a);
//	OD - override width
	a.style.width = "997px";
	a._widthAdded = true
}

function addStatus(f, g, e) {
	ULSA13:;
	var a = document.getElementById("pageStatusBar");
	if (a != null) {
		a.setAttribute("aria-live", "polite");
		a.setAttribute("aria-relevant", "all");
		var b = _createStatusMarkup(f, g, true);
		if (!e) a.appendChild(b);
		else {
			var c = a.getElementsByTagName("SPAN"),
				d = c.length > 0 ? c[0] : null;
			if (d != null) a.insertBefore(b, d);
			else a.appendChild(b)
		}
		if (a.childNodes.length == 1) {
			StatusIdWithTopPriority = b.id;
			StatusColorWithTopPriority = 1
		}
		a.style.display = "block";
	//	OD - update height
		FixRibbonAndWorkspaceDimensions();
		return b.id
	}
}


//	OD - funzioni personalizzate

jQuery.noConflict();
jQuery.browser.chrome = function() {
	var appver = navigator.appVersion + '';
	if (appver.indexOf('Chrome')>=0) {
		return true;
	}
	return false;
}
jQuery(document).ready(function()
{
	var externalLinks = jQuery('.linkEsterno');
	if (externalLinks.length > 0) {
		externalLinks.each(function() {
			jQuery(this).attr('target','_blank');
		});
	}
//	social networks - init
	var socialnetworks = jQuery('.socialBox');
	if (socialnetworks.length > 0) {
		var currentUrl = escapeProperly(window.location.href);	//	assegnazione link pagina corrente
		socialnetworks.find('a').each(function() {
			var hrefThis = jQuery(this).attr('href').replace('{currentUrl}',currentUrl);
			jQuery(this).attr( 'href' , hrefThis )
			jQuery(this).click(function() {
				window.open(jQuery(this).attr('href'), "social_network_link");
				return false;
			});
		});
	}

//	social networks - end
//	OD_posHeaderHome();
//	OD_posHeaderInterna();
//	OD_posBreadcrumbs();
	OD_slideMenu();
	OD_newsScrollerBox()
	OD_inputSearch();
	OD_removeLeftMenuWhenEmpty();
	OD_gestFormSchedule();
	OD_gestZoomImages();
	OD_dealerLocator();
	OD_formatListResults();
//	OD__doPostBackORIG = __doPostBack;
});


String.prototype.OD_trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}

function getOS()
{
	var OSName = "Unknown OS";
	if ( navigator.appVersion.indexOf("Win")   != -1 ) OSName = "Windows";
	if ( navigator.appVersion.indexOf("Mac")   != -1 ) OSName = "MacOS";
	if ( navigator.appVersion.indexOf("X11")   != -1 ) OSName = "UNIX";
	if ( navigator.appVersion.indexOf("Linux") != -1 ) OSName = "Linux";
	return OSName;
}

function OD_gest_ribbon()	//	cura la miglior gestione del ribbon in situazione di presenza o non
{
	var ribbon_content  = jQuery('#CrifLendingRibbon');
	var ribbon_content2 = jQuery('.CrifLendingRibbon2');

	if ( ribbon_content.length > 0 && ribbon_content2.length > 0 )
	{
	//	jQuery('#header_OD').css('display','none');
	//	jQuery('#breadcrumb_OD').css('display','none');
	//	jQuery('.header').css('height','120px');

//		----- Per liberare spazio ai contenuti -----
//		jQuery('.homepageBox').hide();
//		jQuery('.headlineBox').hide();
//		--------------------------------------------
	}
	else
	{
		jQuery("#body_OD").css('height','auto');
		jQuery("#body_OD").css('overflow','auto');
		jQuery('#header').css('display','inherit');
		jQuery('#breadcrumb_OD').css('display','inherit');
		jQuery("#s4-workspace").css('height','auto');
		jQuery("#s4-workspace").css('overflow','hidden');
		jQuery("#s4-workspace").css('overflowX','hidden');
		jQuery("#s4-workspace").css('overflowY','hidden');
		OD_removePageHeaderWhenEmpty();
	}

//	jQuery("#s4-titlerow").css('float','left');
//	jQuery("#s4-titlerow").css('width','99%');

//	hidden bottom table SP empty
	var tdEmpty = jQuery('#_invisibleIfEmpty:eq(0)');
	if ( tdEmpty.length > 0 )
	{
		jQuery('td[name=_invisibleIfEmpty]:eq(0)').closest('table').parent().closest('table').remove();
	}
}

function OD_gest_lang(publicLang,privateLang)
{
	try
	{
		var userid = _spUserId;
		if ( _spPageContextInfo.currentLanguage != privateLang )
		{
			OnSelectionChange(privateLang); //default language for authenticated  user
		}
  	}
	catch (err)
	{
		if ( _spPageContextInfo.currentLanguage != publicLang )
		{
			OnSelectionChange(publicLang); //default language for anonymous  user
		}
	}
}

function OD_slideMenu()
{
//	prova
/*	var divMH = jQuery('.menuHeader .linkMenu');
	divMH.each(function() {
		var strHTML = jQuery(this).html();
		var newStrHTML = strHTML.replace('<a ','<div class="prova" ');
		var newStrHTML = newStrHTML.replace('</a>','</div>');
		var newStrHTML = newStrHTML.replace('<A ','<div class="prova" ');
		var newStrHTML = newStrHTML.replace('</A>','</div>');
		jQuery(this).html(newStrHTML);
	}); */
//	----------
	var divMenu = jQuery('.consolleBox .listItems li a');
	if ( divMenu.length > 0 )
	{
		var indx = 0;
		divMenu.each(function() {
			indx++;
			if ( indx < 10 ) var indxStr = '0' + indx;
			else var indxStr = indx;
			var thisElement = jQuery(this);
			thisElement.attr('id','item'+indxStr);
			var strHTML = thisElement.html();
			var newStrHTML = '<span class="arrowWhiteItem">' + strHTML + '</span>';
			thisElement.html(newStrHTML);
			thisElement.hover(function() {
				var id = jQuery(this).attr('id')
			//	alert(id)
			//	jQuery('.slideBox').attr('class','slideBox img'+id);
				jQuery('.slideBox .listBg li').each(function () { jQuery(this).hide(); });
				jQuery('.slideBox .listBg .img'+id).show();
				jQuery('.consolleBox .listButtons li').each(function () { jQuery(this).hide(); });
				jQuery('.consolleBox .listButtons li#btn'+id).show();
			});
		});
	}

	jQuery('.slideBox .listBg li.imgitem01').show();
	jQuery('.consolleBox .listItems li .arrowWhiteItem:eq(0)').css('backgroundImage','none');

//	pulsanti GET STARTED NOW per homepage
	var divBtns = jQuery('.consolleBox .listButtons li');
	if ( divBtns.length > 0 )
	{
		var indx = 0;
		divBtns.each(function() {
			indx++;
			if ( indx < 10 ) var indxStr = '0' + indx;
			else var indxStr = indx;
			var thisElement = jQuery(this);
			thisElement.attr('id','btnitem'+indxStr);
			thisElement.children('a').addClass('linkOrange2');
			var strHTML = thisElement.children('a').html();
			var newStrHTML  = '<span class="btnOrangeSx2">&nbsp;</span>';
				newStrHTML += '<span class="btnOrangeBg2">';
				newStrHTML += '<span class="txtOrange2">' + strHTML + '</span>';
				newStrHTML += '</span>';
				newStrHTML += '<span class="btnOrangeDx2">&nbsp;</span>';
			thisElement.children('a').html(newStrHTML);
		});
	}
//	pulsanti GET STARTED NOW per sotto-sezioni
	var divBtns = jQuery('.consolleBox .getStarted li');
	if ( divBtns.length > 0 )
	{
		var indx = 0;
		divBtns.each(function() {
			indx++;
			if ( indx < 10 ) var indxStr = '0' + indx;
			else var indxStr = indx;
			var thisElement = jQuery(this);
			thisElement.attr('id','btnitem'+indxStr);
			thisElement.children('a').addClass('linkOrange2');
			var strHTML = thisElement.children('a').html();
			var newStrHTML  = '<span class="btnOrangeSx2">&nbsp;</span>';
				newStrHTML += '<span class="btnOrangeBg2">';
				newStrHTML += '<span class="txtOrange2">' + strHTML + '</span>';
				newStrHTML += '</span>';
				newStrHTML += '<span class="btnOrangeDx2">&nbsp;</span>';
			thisElement.children('a').html(newStrHTML);
		});
	}
}

function OD_inputSearch()
{
	var inputSearch = jQuery('.inputSearch input');
	if ( inputSearch.length > 0 )
	{
		jQuery(inputSearch).focus(function() {
			if ( jQuery(this).attr('value') == 'Search on site...' ) jQuery(this).attr('value','');
		});
		jQuery(inputSearch).removeAttr('OnKeypress');
		jQuery(inputSearch).keypress(function(event) {
			var keycode = (event.keyCode ? event.keyCode : (event.which ? event.which : event.charCode));
			if ( keycode == 13 )	//	keycode for enter key
			{
				var valSearched = jQuery.trim(jQuery(this).val());
				if ( valSearched.length != '' && valSearched != 'Cerca nel sito...' && valSearched != 'Search on site...' )
				{
					executeSearch();
				}
				else
				{
					alert('È necessario specificare almeno un termine di ricerca.');
				}
				return false;
			}
			else
			{
				return true;
			}
		});
	}
}

indxNewsOpen = 1;
timerNews = null;
stepMove = 0;
noClickStep = false;
function OD_newsScrollerBox()
{
	var newsScroller = jQuery('.newsScrollerList li');
	if ( newsScroller.length > 0 )
	{
		var idIndx = 0;
		newsScroller.each(function() {
			idIndx++;
			thisItem = jQuery(this);
			thisItem.attr('id','news'+idIndx);
			
		});
		var arrowSx = jQuery('.newsScrollerBox .arrowSx');
		var arrowDx = jQuery('.newsScrollerBox .arrowDx');
		arrowSx.click(function() {
			OD_newsScroller(-1);
		});
		arrowDx.click(function() {
			OD_newsScroller(1);
		});
		jQuery('.newsScrollerList #news1').show();
		setNextTimeoutNews();
	}
}
function OD_newsScroller(step)
{
	if ( ! noClickStep )
	{
		stepMove = step;
		clearTimeout(timerNews);
		setNextTimeoutNews(true);
	}
}
function fadeComplete(bool)
{
	if ( bool )
	{
		clearTimeout(timerNews)
		var scrollerNews = jQuery('.newsScrollerList li');
		if ( stepMove != 0 ) indxNewsOpen += stepMove;
		else indxNewsOpen++;
		if ( indxNewsOpen > scrollerNews.length ) indxNewsOpen = 1;
		else if ( indxNewsOpen < 1 ) indxNewsOpen = scrollerNews.length;
		jQuery('.newsScrollerList #news'+indxNewsOpen).fadeIn(600,'linear',function()
		{
			fadeComplete(false);
		});
		stepMove = 0;
	}
	else
	{
		noClickStep = false;
		setNextTimeoutNews();
	}
}
function setNextTimeoutNews(bool)
{
	if ( bool )
	{
		noClickStep = true;
		jQuery('.newsScrollerList #news'+indxNewsOpen).fadeOut(600,'linear',function()
		{
			fadeComplete(true);
		});
	}
	else
	{
		timerNews = setTimeout(function()
		{
			noClickStep = true;
			jQuery('.newsScrollerList #news'+indxNewsOpen).fadeOut(600,'linear',function()
			{
				fadeComplete(true);
			});
		},3000);
	}
}

function OD_removeLeftMenuWhenEmpty()
{
	var divMenuLeft = jQuery('.leftNav');
//	alert(divMenuLeft.length+" | "+jQuery.trim(divMenuLeft.html())+" | "+jQuery.trim(divMenuLeft.text()))
	if ( divMenuLeft.length == 0 || jQuery.trim(divMenuLeft.html()) == "" || jQuery.trim(divMenuLeft.text()) == "" )
	{
		var divSearchBox = jQuery('#s4-leftpanel .searchBox');
		if ( divSearchBox.length > 0 )
		{
			jQuery('.searchBoxNav').css('marginTop','0px');
		}
		else
		{
		//	jQuery('#s4-leftpanel').remove();				//	in questo sito, essendoci il searchbox, meglio non usarlo
			jQuery('.s4-ca').css('marginLeft','0px');
			jQuery('.welcome').css('paddingLeft','0px');
		}
	}
}
function OD_removePageHeaderWhenEmpty()
{
	var divPageHeader = jQuery('.pageHeader');
//	alert(divPageHeader.length+"\n-------\n"+jQuery.trim(divPageHeader.html())+"\n-------\n"+jQuery.trim(divPageHeader.text()+"\n-------\n"+jQuery.trim(divPageHeader.text()).indexOf("Abstract")))
	if ( divPageHeader.length == 0 || jQuery.trim(divPageHeader.html()) == "" || (jQuery.trim(divPageHeader.text()) == "" || jQuery.trim(divPageHeader.text())=="Abstract") )
	{
	//	divPageHeader.remove();
	}

}

function OD_gestZoomImages()
{
	var zoomType1 = jQuery('.ms-rteElement-zoomMe');
	var indxDiv = 0;
	if (zoomType1.length > 0 )
	{
		zoomType1.each(function()
		{
			indxDiv++;
			var zoomBox = jQuery(this);
			var img = jQuery('<div class="deleteAfterUse" idFake="'+indxDiv+'"><img src="'+zoomBox.attr('href')+'" /></div>')
			img.children('img').load(function()
			{
				var arrTmp = [{
								url:		zoomBox.attr('href'),
								width:		jQuery(this).width(),
								height:		jQuery(this).height()
							}];
				jQuery(this).parent('div').remove();
				zoomBox.css('cursor','pointer');
				zoomBox.click(function ()
				{
					zoomin(0,arrTmp);
					return false;
				});
			});
			zoomBox.after(img);
		});
	}

	var zoomType2 = jQuery('.ms-rteStyle-zoomMe');
	if (zoomType2.length > 0 )
	{
		zoomType2.each(function()
		{
			indxDiv++;
			var zoomBox = jQuery(this);
			var img = jQuery('<div class="deleteAfterUse" idFake="'+indxDiv+'"><img src="'+zoomBox.attr('href')+'" /></div>')
			img.children('img').load(function()
			{
				var arrTmp = [{
								url:		zoomBox.attr('href'),
								width:		jQuery(this).width(),
								height:		jQuery(this).height()
							}];
				jQuery(this).parent('div').remove();
				zoomBox.css('cursor','pointer');
				zoomBox.click(function ()
				{
					zoomin(0,arrTmp);
					return false;
				});
			});
			zoomBox.after(img);
		});
	}
}

function OD_gestFormSchedule()
{
	var moreInfoOptions = jQuery('#MoreInfoOptions .inputField');
	if ( moreInfoOptions.length > 0 )
	{
		var indx = 0;
		moreInfoOptions.each(function()
		{
			indx++;
			if (/* indx == 2 ||*/ indx == 4 )
			{
				jQuery(this).after('<div class="clear">&nbsp;</div>');
			}
		});
	}

	var onLineDemoOptions = jQuery('#OnLineDemoOptions .inputField');
	if ( onLineDemoOptions.length > 0 )
	{
		var indx = 0;
		onLineDemoOptions.each(function()
		{
			indx++;
			if (/* indx == 2 ||*/ indx == 4 )
			{
				jQuery(this).after('<div class="clear">&nbsp;</div>');
			}
		});
	}

	var onSiteDemoOptions = jQuery('#OnSiteDemoOptions .inputField');
	if ( onSiteDemoOptions.length > 0 )
	{
		var indx = 0;
		onSiteDemoOptions.each(function()
		{
			indx++;
			if (/* indx == 2 ||*/ indx == 4 )
			{
				jQuery(this).after('<div class="clear">&nbsp;</div>');
			}
		});
	}

	var elementAjaxToModify = jQuery('select[onchange*=__doPostBack]');
	if ( elementAjaxToModify.length > 0 )
	{
		elementAjaxToModify.each(function() {
			var thisItem = jQuery(this);//javascript:setTimeout('__doPostBack(\'ctl00$ctl24$g_0295f125_15f1_4b41_89cb_a482d91a7dd3$ctl00$HeardFrom\',\'\')', 0)
			var strAttrOnChange = thisItem.attr('onchange').toString();
			
			
			strAttrOnChange = strAttrOnChange.split("\n").join('');//.split("\r").join('');
		//	alert('function: '+strAttrOnChange );
		/*	var indxInit = strAttrOnChange.indexOf('setTimeout(') + 12;
			var indxEnd = strAttrOnChange.indexOf(')') + 1;
				strAttrOnChange = strAttrOnChange.substr(indxInit,indxEnd-indxInit);
			var strAttrOnChangeOD = strAttrOnChange.replace('__doPostBack(\'','');
				strAttrOnChangeOD = strAttrOnChangeOD.replace('\')','');
				strAttrOnChangeODarr = strAttrOnChangeOD.split('\',\''); */
			var splt1 = strAttrOnChange.split('doPostBack(');
			var splt2 = splt1[1].split(',');
			var splt3 = splt2[1].split(')');
			if ( jQuery.browser.msie )
			{
			//	alert(splt2[0].split("\\'").join('')+" | "+splt3[0].split("\\'").join(''));
				var firstParam = splt2[0].split("\\'").join('');
				var secondParam = splt3[0].split("\\'").join('');
			}
			else
			{
			//	alert(splt2[0].split("'").join('')+" | "+splt3[0].split("'").join(''));
				var firstParam = splt2[0].split("'").join('');
				var secondParam = splt3[0].split("'").join('');
			}
			thisItem.firstParam = firstParam;
			thisItem.secondParam = secondParam;
		//	alert(thisItem.firstParam+" | "+thisItem.secondParam)
		/*	thisItem.removeAttr('onchange');
			thisItem.change(function() {
				OD__doPostBack(thisItem.firstParam,thisItem.secondParam);
			}); */
		});
	}
}

ODcontentOld = null;
ODtimeoutCheck = null;
function OD__doPostBack(id,param)
{
	OD_openLoading(true);
//	OD__doPostBackORIG(id,param);
	__doPostBack(id,param);
	ODcount = 60;

	if ( jQuery('.alphabetaList').length > 0 )
	{
	/*	jQuery('.alphabetaList').hide();
		jQuery('.prevNextResults').hide();
		jQuery('.resultsTitle').hide();
		jQuery('.resultsList').hide(); */
		ODcontentOld = jQuery('.resultsList:eq(0)').text();
		ODtimeoutCheck = setInterval(function() {
			var ODcontentNew = jQuery('.resultsList:eq(0)').text();
			if ( ODcount <= 0 || ODcontentOld != ODcontentNew ) {
				clearInterval(ODtimeoutCheck);
				OD_dealerLocator();
			/*	jQuery('.alphabetaList').show();
				jQuery('.prevNextResults').show();
				jQuery('.resultsTitle').show();
				jQuery('.resultsList').show(); */
				OD_openLoading(false);
			}
			ODcount--;
		},100);
	}

	if ( jQuery('.formBox').length > 0 )
	{
		ODcontentOld = jQuery('.formBox').text();
		ODtimeoutCheck = setInterval(function() {
			var ODcontentNew = jQuery('.formBox').text();
		//	alert(jQuery('.formBox').length)
			if ( ODcount <= 0 || ODcontentOld != ODcontentNew ) {
				clearInterval(ODtimeoutCheck);
			//	alert(111)
				OD_gestFormSchedule();
			}
			ODcount--;
		},100);
	}
}
function OD_openLoading(bool)
{
	if (!bool)
	{
		jQuery('#bgLoading').remove();
		jQuery('#imgLoading').remove();
	}
	else
	{
		var docu = jQuery(document);
		var obj = {};
		obj.width = docu.width()-0;
		obj.height = docu.height()-0;
		if (jQuery.browser.msie) {
			if (jQuery.browser.version == '6.0') {
				obj.width -= 20;
				obj.height -= 4;
			}
			else if (jQuery.browser.version == '7.0') {
				//obj.width -= 4;
				//obj.height -= 5;
			}
			else if (jQuery.browser.version == '8.0') {
				obj.width -= 4;
				obj.height -= 5;
			}
			else {
				//obj.width -= 4;
				//obj.height -= 5;
			}
		}
		jQuery('body').append('<div id="bgLoading" style="position:absolute;top:0;left:0;width:'+obj.width+'px;height:'+obj.height+'px;background-color:white;z-index:998;"></div>');
		jQuery('#bgLoading').css('opacity',0.5);
		jQuery('body').append('<div id="imgLoading" style="position:absolute;top:0;left:0;width:'+obj.width+'px;height:'+obj.height+'px;background:url(\'/PublishingImages/loading.gif\') no-repeat center center;z-index:999;"></div>');
	}
}
G_cityPolling = null;
function OD_dealerLocator()
{
//	if ( intervLocator != null ) clearInterval(intervLocator);
	var selectState = jQuery('.boxInput select:eq(0)');
	if ( selectState.length > 0 )
	{
		selectState.live('change', function() {
			var selectCity = jQuery('.boxInput select:eq(1)');
			var me = jQuery(this);
			me.data('cityOps', selectCity.text());
			
			OD_openLoading(true);
			
			G_cityPolling = setInterval(function(){
				var selectCity = jQuery('.boxInput select:eq(1)');
				if (me.data('cityOps') != selectCity.text()) {
					clearInterval(G_cityPolling);
					OD_openLoading(false);
				}				
			},100);
		});
	/*	var strAttrOnChange = selectState.attr('onChange');
		if ( strAttrOnChange != 'undefined' && strAttrOnChange != undefined && strAttrOnChange != null )
		{alert(strAttrOnChange)
			var strAttrOnChangeOD = strAttrOnChange.replace('__doPostBack','OD__doPostBack');
			strAttrOnChange.attr('onChange',strAttrOnChangeOD);
		} */
		
	}
	/*var selectCity = jQuery('.boxInput select:eq(1)');
	if ( selectCity.length > 0 )
	{
		selectCity.ready(function() {
			 OD_openLoading(false);
		});

	}*/
	var alphabetaList = jQuery('.alphabetaList li');
	if ( alphabetaList.length > 0 )
	{
		alphabetaList.each(function() {
			var thisItem = jQuery(this);
			if ( thisItem.html().indexOf('disabled') != -1 )
			{
				var saveTxt = thisItem.children('a').html();
				thisItem.removeAttr('a');
				thisItem.html(saveTxt);
			}
			var strAttrOnClick = thisItem.children('a').attr('href');
			if ( strAttrOnClick != 'undefined' && strAttrOnClick != undefined && strAttrOnClick != null )
			{
				var strAttrOnClickOD = strAttrOnClick.replace('__doPostBack','OD__doPostBack');
				thisItem.children('a').attr('href',strAttrOnClickOD);
			}
		});
	}
	var prevNextResults = jQuery('.prevNextResults');
	if ( prevNextResults.length > 0 )
	{
	/*	prevNextResults.click(function() {

		}); */
		prevNextResults.each(function(indx) {
			var thisItem = jQuery(this);
		//	alert(thisItem.index())
		//	alert(thisItem.get(indx)+" | "+indx+" | "+prevNextResults.length)
			if ( indx == 0 ) {
			//	alert('1: '+thisItem.html())
				thisItem.css('float','left');
			}
			if ( indx == prevNextResults.length - 1 ) {
			//	alert('2: '+thisItem.html())
				thisItem.css('text-align','right');
				thisItem.css('float','right');
			}
		});
		prevNextResults.each(function() {
			var thisItem = jQuery(this);
			if ( thisItem.get(0).tagName.toLowerCase() == "span" )
			{
				thisItem.remove();
			}
			else
			{
				var strAttrOnClick = thisItem.attr('href');
			//	alert(strAttrOnClick)
				if ( strAttrOnClick != 'undefined' && strAttrOnClick != undefined && strAttrOnClick != null )
				{
					var strAttrOnClickOD = strAttrOnClick.replace('__doPostBack','OD__doPostBack');
				//	alert(strAttrOnClickOD) //__doPostBack(
					thisItem.attr('href',strAttrOnClickOD);
				}
			}
		});
		jQuery('.prevNextResults:eq(0)').before('<div class="resultsPag">');
		jQuery('.resultsPag').append(jQuery('.prevNextResults'));
		jQuery('.resultsPag').append('<div class="clear">&nbsp;</div>');
		jQuery('.resultsPag').parent('span').css('display','inline').css('margin','0').css('padding','0');
		jQuery('.resultsPag').parent('div').css('display','inline').css('margin','0').css('padding','0');
	}
}

function OD_popUpVideoHome()
{
	var divBtn = jQuery('.imgVideoBtn a');
	if ( divBtn.length > 0 )
	{
		var video_link = '/Documents/video/Banca_IFIS_it.mp4';
		var video_width = '640';
		var video_height = '360';
		var video_preview = '/Documents/video/preview_videoHome.gif';

		divBtn.attr('class','zoomme');
//		divBtn.attr('onclick','return zoom_video("' + video_link + '","' + video_width + '","' + video_height + '");');
		divBtn.click(function() {
			zoom_video(video_link, video_width,video_height,video_preview);
		});
	}
}

function OD_formatListResults()
{
	var divMetaData2 = jQuery('.srch-Metadata2');
	if ( divMetaData2.length > 0 )
	{
	//	tolgo uno spazio vuoto all'inizio di alcune stringhe dentro div di classe srch-Metadata2
		divMetaData2.each(function() {
			var htmlText = jQuery(this).html();
			var arr_tmp = escape(htmlText).split('%u2003');
			if ( arr_tmp[0] == '' ) arr_tmp.splice(0,1);
			var newText = arr_tmp.join('&emsp;');
			newText = unescape(newText);
			jQuery(this).html(newText);
		});
	}
}


