 function include(fileName) {
	if (document.getElementsByTagName) {
		var scriptl = document.createElement("script");
		scriptl.setAttribute("type", "text/javascript");
		scriptl.setAttribute("id", "dynscript");
		scriptl.src=fileName;
		document.getElementsByTagName("head")[0].appendChild(scriptl);
	}
}

var form;
var div;
var numpage;
var fields;
var mappingFields;
var debug = 0;

// Save compatibility with Safari / chrome / etc browsers
document.write("<" + "script src=\"http://www.incisiveopinion.com/incisive-theme/javascript/function.js\"></" + "script>"); 
document.write("<" + "script src=\"http://www.incisiveopinion.com/incisive-theme/javascript/registration.js\"></" + "script>"); 
document.write("<" + "script src=\"http://www.incisiveopinion.com/incisive-theme/javascript/ep_IT.js\"></" + "script>"); 
document.write("<" + "script src=\"http://www.incisiveopinion.com/incisive-theme/javascript/ep_FI.js\"></" + "script>"); 

jQuery(document).ready(
	function() {
	}
);

Liferay.Portlet.ready(
	/*
	This function gets loaded after each and every portlet on the page.
	portletId: the current portlet's id
	jQueryObj: the jQuery wrapped object of the current portlet
	*/
	function(portletId, jQueryObj){
		//alert( portletId );
		if ( document.getElementById('p_p_id_58_') ){
			if( typeof setupLoginPortlet == 'undefined' ){
				include("http://www.izatso.com/izatso-theme/javascript/registration.js");
				setupLoginPortlet(); 
			} else {
				setupLoginPortlet();
			}
		}
		if (portletId == 'REGISTRATION_FORM_WAR_registration_formportlet'){
			// COMMON DISPLAY OF PORTLET
			if( typeof hideRefreshButton == 'undefined' ){
				include("http://www.incisiveopinion.com/incisive-theme/javascript/function.js");
				hideRefreshButton();
			} else {
				hideRefreshButton();
			}
			var champ_span = (document.getElementById('portlet-wrapper-REGISTRATION_FORM_WAR_registration_formportlet').getElementsByTagName("span"));		
			if (document.location.href.indexOf('priv.incisiveopinion.com') != -1)
				champ_span[0].innerHTML = '\nModify your registration data\n';
			else
				champ_span[0].innerHTML = '\nRegistration form\n';

			// LOADING FILTERS
			if( document.getElementById("regFormFOBean_form" ) ){
				form = document.getElementById("regFormFOBean_form" );
				divPage = form.getElementsByTagName("div" );
				numpage = divPage[0].childNodes[2].innerHTML;
				if( typeof setupRegistrationForm == 'undefined' ){
					include("http://www.incisiveopinion.com/incisive-theme/javascript/registration.js");
					setupRegistrationForm(numpage); 
				} else {
					setupRegistrationForm(numpage);
				}
			}
		}
		if( portletId == "PANELISTPOINTSACCOUNT_WAR_panelistpointsaccountportlet" ){
			if( typeof setupAccountBalance == 'undefined' ){
				include("http://www.incisiveopinion.com/incisive-theme/javascript/function.js");
				setupAccountBalance();
			} else {
				setupAccountBalance();
			}
		}
		if( portletId == "EXTENDEDPROFILE_WAR_extendedprofileportlet" ){
			if( typeof hideRefreshButton == 'undefined' ){
				include("http://www.incisiveopinion.com/incisive-theme/javascript/function.js");
				hideRefreshButton();
			} else {
				hideRefreshButton();
			}
			// Extended Home
			if( document.getElementById("extendedProfileHomeForm") ){
				var form_home = document.getElementById("extendedProfileHomeForm");
				var portlet_EPIDtmp = "";
				form_home.onsubmit = function(){
						var table_radio = document.getElementsByName('selectedQuestionnaire');
						for(var i =0; i < table_radio.length;i++){
							if (table_radio[i].checked){
								var portlet_EPID = table_radio[i].value;
								break;
							}
						}
						for (var i=0; i<portlet_EPID.length; i++) {
							if( portlet_EPID.charCodeAt(i) == 160 ){
								portlet_EPIDtmp = portlet_EPIDtmp+",";
							}
							else{
								portlet_EPIDtmp = portlet_EPIDtmp+portlet_EPID.charAt(i);
							}								
						}
						form_home.action = form_home.action + "&sq="+portlet_EPIDtmp;
				};
				removeTitle("Extended Profile","span");
				removeTitle("Points","span");
				removeTitle("^0$","span");
			}
			// Exrtended questionnaire
			if( document.getElementById("extendedProfileQuestionnaireForm" ) ){
				form = document.getElementById("extendedProfileQuestionnaireForm" );
				divPage = form.getElementsByTagName("div" );
				numpage = divPage[0].childNodes[2].innerHTML;
				main_ep(portletId,numpage);
			}
		}
	}
);

jQuery(document).last(
	function() {
	}
	/*function() {
		var currURL = document.location.href;
		if( currURL.match("group") ){
				document.getElementById('portlet-wrapper-58').style.marginTop = "5px";
		}
		else{
			var div_portlet_signin = document.getElementById('portlet-wrapper-58');
			var all_input = div_portlet_signin.getElementsByTagName('input');
		
			all_input[2].style.height = "15px";
			all_input[3].style.height = "15px";
		
		}
	}*/
);