 	var server_time		= null;
	var demandletsList 	= 'poll,quiz,onTonight,signIn,tvSchedule,azList,userProfile,recShows,onNow,azListPage,emailSignup,txComponent';
	var docRoot 		= (document.location.href.indexOf('/community.')>-1) ? '/community/' : ''; //fix for load balancer redirect manager
	Event.observe(window,'load',function(){
		
		if(!document.getElementById('siteList')) 
			if(getMetaValue('siteUrl') != false) createCookie('defaultHome', getMetaValue('siteUrl'), 30);
		loadScript(docRoot + '/ipui/ip_demandlet.js',function(){ demandletManager.load(demandletsList);	});	
		if($('tvsched_controls')) {
			getShows();
			getTimezones($('timezone_dd'));
			Event.observe('range_full', 'click', changeRange);
			Event.observe('range_prime', 'click', changeRange);
			Event.observe('timezone_dd', 'change', changeTimezone);
			Event.observe('byshow_dd', 'change', changeShow);
			Event.observe('go_search', 'click', keywordSearch);
		}
		if($('tvsched_toolbar')) {
			initiateCalendar();
			Event.observe('tvsched_view', 'click', changeView);
			Event.observe('sched_print', 'click', function(e) {window.print(); Event.stop(e);});
		}
		if($('show-navigation')) {
			shows_sfHover();
		}
		
	});

	function sfHover(){
		if($('main_navigation')){
			new Ajax.Request(docRoot + '/global/subnav.xml', {
				parameters:{nC: noCache()},
				onSuccess:function(t){
					$('main_navigation').innerHTML=renderMainNavigation(t,0);
					var sfEls = $('main_navigation').getElementsByTagName('li');
					for (var i=0;i<sfEls.length;i++){
						sfEls[i].onmouseover=function(){this.className+=' over';};
				        sfEls[i].onmouseout=function(){this.className='';};
			        }
				}
			});	
		}
	};
	function shows_sfHover(){
		if($('show-navigation')){
			new Ajax.Request('subnav.xml',{
				method: 'get',
				parameters:'nC='+noCache(),
				//onFailure:ajaxRequest_Error,
				onSuccess:function(t){
					var mainNav = $('show-navigation');
					mainNav.innerHTML=renderShowNavigation(t,0);
					mainNav.firstChild.lastChild.firstChild.className += ' last';
				}
			});	
		}
	};
	function getSubdomain() {
		var domainName = document.domain;
		var pieces = domainName.split('.');
		var subdomain = domainName;
		if (pieces.length > 1)
			subdomain = pieces[pieces.length-2] + '.' + pieces[pieces.length-1];
		return subdomain;
	}
	function autoRedirect(redirectURL){
		if(readCookie('defaultHome')) document.location.href=readCookie('defaultHome')+redirectURL;
	};
	function siteRedirect(selectValue){
		var values = selectValue.split(',');
		var userStr = '';
		userStr += (values[1] || '') + '__';
		userStr += (values[2] || '') + '__';
		userStr += (values[3] || '') + '__';
		userStr += (values[0] || '');
		var domainStr = userStr;
		domainStr = domainStr.replace('http://','').replace('/default.html','').replace('/','');
		createCookie('userLocation', domainStr, 30);
		document.location.href=values[0];
	};
	function submit_FriendPopup(formObj,hideDivObj,showDivObj){
		if(checkForm(formObj)){
			var site_id 	= getMetaValue('siteIdentifier');
			var site_locale = getMetaValue('default_locale');
			var link = window.opener.location.href;
			var params		= formObj.serialize(true);
                        params.nc = noCache();
                        params.link = link;
                        params.site_id=site_id;
			new Ajax.Request(
				'/ajax/sendFriend.jsp', 
				{
					parameters: params,
					onSuccess: function(xml) 
					{
						var response 		= xml.responseXML.getElementsByTagName(get_firstchild(xml.responseXML.documentElement).nodeName);
						var responseContent = showDivObj.innerHTML;
						if (site_locale == "es-es") {
							if (getNodeValue(response[0]) == '0') 
								showDivObj.innerHTML = responseContent.replace('<!--response-->','Gracias, su mensaje ha sido enviado.');
							else
								showDivObj.innerHTML = responseContent.replace('<!--response-->','Lo sentimos que habÃ­a un problema con su solicitud. Por favor, intÃ©ntelo de nuevo mÃ¡s tarde.');
						} 
						else {
							if (getNodeValue(response[0]) == '0') 
								showDivObj.innerHTML = responseContent.replace('<!--response-->','Thank you, your message has been sent.');
							else
								showDivObj.innerHTML = responseContent.replace('<!--response-->','Sorry there was a problem with your request. Please try again later.');
						}
						
						Element.hide(hideDivObj);
						Element.show(showDivObj);
					}
				}
			);
		}
	};
	function open_ReminderPopup(showtitle, episode, time, scheduleid) {
		newWindow('/reminder.html?showtitle='+showtitle+'&episode='+episode+'&time='+time, scheduleid+'', 315,400,false,false,true);
	};
	function submit_ReminderPopup(formObj,hideDivObj,showDivObj){
		if(checkForm(formObj)){
			var params = formObj.serialize();
			var site_locale = getMetaValue('default_locale');
			
			new Ajax.Request(docRoot + '/ajax/showReminderSave.jsp', {
					parameters:'&nC'+noCache()+'&'+params+'&scheduleid='+window.name,
					onSuccess: function(xml){
						var response 		= xml.responseXML.getElementsByTagName(get_firstchild(xml.responseXML.documentElement).nodeName);
						var responseContent = showDivObj.innerHTML;
						if (site_locale == "es-es") {
							if (getNodeValue(response[0]) == '0') 
								showDivObj.innerHTML = responseContent.replace('<!--response-->','Gracias, su recordatorio sera enviado.');
							else
								showDivObj.innerHTML = responseContent.replace('<!--response-->','Lo sentimos que habÃ­a un problema con su solicitud. Por favor inténtelo nuevamente más tarde.');
						} 
						else {
							if (getNodeValue(response[0]) == '0') 
								showDivObj.innerHTML = responseContent.replace('<!--response-->','Thank you, your reminder will be sent.');
							else
								showDivObj.innerHTML = responseContent.replace('<!--response-->','Sorry there was a problem with your request. Please try again later.');
						}
						
						Element.hide(hideDivObj);
						Element.show(showDivObj);
					}
				}
			);
		}
	};
		   	
	function search_Submit(sObj){
		if($F(sObj)!=''){
			if(document.getElementById('page_id')) 
				document.location.href='/search.jsp?kword='+$F(sObj)+'&page_id='+$F('page_id');
			else 
				document.location.href='/search.jsp?kword='+$F(sObj);
		}
		else
			alert('Please enter a keyword');
	};
	
	function search_Page(pNum,sObj){$('page_id').value=pNum;search_Submit(sObj);};							
	function search_tvSchedule(fObj){
		if(checkForm(fObj)){
			new Ajax.Request(docRoot + '/ajax/tvScheduleProcess.jsp', {
					parameters:{nC: noCache(), keyword: $F(fObj.id + '_keyword')},
					onSuccess:function (xml) {
						display_tvScheduleResults(xml);
					}
				}
			);
		}
	};
	
	function signIn_success(userId, userName, userEmail, userFname, userLname){createCookie('olio', userEmail+"|"+userId+"|"+userName+"|"+userFname+"|"+userLname, 30);};
	function signOut(){eraseCookie('olio');window.location.reload();};
	
	function registerUser(){
		if(checkForm($('registration_form'))){
			if($F('password')!=$F('re_password')){
				alert('Passwords do not match');
			}
			else{
				if(!$('confirm').checked){
					alert('Please agree to terms and conditions');
				}
				else{
					new Ajax.Request(docRoot + '/ajax/registerProcess.jsp', {
							parameters: $('registration_form').serialize(),
							onSuccess:function (xml){
								xml = handleResponse(xml);
								var insertStat 	= xml.getElementsByTagName('insert')[0].firstChild ? xml.getElementsByTagName('insert')[0].firstChild.data : '';
								var error 		= xml.getElementsByTagName('error')[0].firstChild ? xml.getElementsByTagName('error')[0].firstChild.data : 'Unknown error';
								if(insertStat==' Success '){
									var url			= document.location.href;
									var aryCurLoc 	= url.split('/');
									aryCurLoc[aryCurLoc.length - 1] = 'registerthankyou.jsp';
									window.location = aryCurLoc.join('/');
								}
								else
									alert('The following error occured while trying to create your user account:\n' + error);
							}
						}
					);
				}
			}
		}
	};
	
	function signIn(){
		var siteUrl = getMetaValue('siteUrl');
		var locale = getMetaValue('default_locale');
		var loginData = {
			'en-us': { email: 'Email Address:', password: 'Password:', forgot: 'Forgot your password?', 
						register: 'Register', loginLabel:'Login', cancelLabel:'Cancel'},
			'en-eu': { email: 'Email Address:', password: 'Password:', forgot: 'Forgot your password?', 
						register: 'Register', loginLabel:'Login', cancelLabel:'Cancel'},
			'en-sc': { email: 'Email Address:', password: 'Password:', forgot: 'Forgot your password?', 
						register: 'Register', loginLabel:'Login', cancelLabel:'Cancel'},
		    'en-za': { email: 'Email Address:', password: 'Password:', forgot: 'Forgot your password?', 
						register: 'Register', loginLabel:'Login', cancelLabel:'Cancel'},
		    'en-au': { email: 'Email Address:', password: 'Password:', forgot: 'Forgot your password?', 
						register: 'Register', loginLabel:'Login', cancelLabel:'Cancel'},
			'es-es': { email: 'Su correo electrónico:', password: 'Su contraseña:', forgot: 'Ólvidó su contraseña?', 
						register: 'Registro', loginLabel:'Iniciar Sesión', cancelLabel:'Cancelar'},
			'pl': { email: 'Adres mailowy:', password: 'HasÅ‚o:', forgot: 'Nie pamiÄ™tam hasÅ‚a', 
						register: 'Rejestracja', loginLabel:'Logowanie', cancelLabel:'Anuluj' }
		};
		var alertData = {
			'en-us': { email: 'Please enter an email address.', password: 'Please enter password.' },
			'en-eu': { email: 'Please enter an email address.', password: 'Please enter password.' },
			'en-sc': { email: 'Please enter an email address.', password: 'Please enter password.' },
			'en-za': { email: 'Please enter an email address.', password: 'Please enter password.' },
			'en-au': { email: 'Please enter an email address.', password: 'Please enter password.' },
			'es-es': { email: 'Por favor, teclee su correo electrónico.', password: 'Por favor, teclee su contraseña.' },
			'pl': { email: 'Prosimy o wpisanie twego adresu e-mail.', password: 'Prosimy o wpisanie twego hasÅ‚a.'}
		};
		var loc = '';
		if (siteUrl) {
			loc = siteUrl;
		}
		var loginHTML = ''
			+	'<div style="clear:both">'
			+	'</div>'
			+	'<form id="loginForm">'
			+	'<table width="320px">'
			+		'<tr>'
			+			'<td colspan="3">'
			+				'<table>'
			+					'<tr>'
			+						'<td align="right" class="grey 11px" width="130px">'
			+							loginData[locale]['email']
			+						'</td>'
			+						'<td align="left">'
			+							'<input type="text" required alert="'+alertData[locale]['email']+'" id="login_email">'
			+						'</td>'
			+					'</tr>'
			+					'<tr>'
			+						'<td colspan="2">'
			+							'<div style="clear:both">'
			+							'</div>'
			+						'</td>'
			+					'</tr>'
			+					'<tr>'
			+						'<td align="right" class="grey 11px">'
			+							loginData[locale]['password']
			+						'</td>'
			+						'<td align="left">'
			+							'<input type="password" required alert="'+alertData[locale]['password']+'" id="login_password">'
			+						'</td>'
			+					'</tr>'
			+				'</table>'
			+			'</td>'
			+		'</tr>'
			+		'<tr>'
			+			'<td colspan="3">'
			+				'<div style="clear:both">'
			+				'</div>'
			+			'</td>'
			+		'</tr>'
			+		'<tr>'
			+			'<td width="70px">&nbsp;</td>'
			+			'<td align="left">'
			+				'<a href="#" onclick="Dialog.closeInfo();forgotPassDialog(); return false;" class="red 11px">'+loginData[locale]['forgot']+'</a>'
			+			'</td>'
			+			'<td align="right">'
			+				'<a href="'+loc+'/registration.html" class="red 11px">'+loginData[locale]['register']+'</a>'
			+			'</td>'
			+		'</tr>'
			+	'</table>'
			+	'</form>'
			+	'<div style="clear:both">'
			+	'</div>';

		function onOKFn()
		{
			var login_email = $('login_email').value;
			var login_password = $('login_password').value;
			if(checkForm($('loginForm'))) {						
				new Ajax.Request(docRoot + '/ajax/loginProcess.jsp', {
						parameters:{email: login_email, password: login_password, nc: noCache()},
						onComplete:function (xml){
							xml = handleResponse(xml);
							var response,userId,userEmail,userFname,userLname,reasonText;
							if(xml){
								response = xml.getElementsByTagName('response')[0].firstChild ? xml.getElementsByTagName('response')[0].firstChild.data : 'error';
								if(response == '0'){
									userId 		= xml.getElementsByTagName('identifier')[0].firstChild ? xml.getElementsByTagName('identifier')[0].firstChild.data : 'Unknown';
									userName	= xml.getElementsByTagName('username')[0].firstChild ? xml.getElementsByTagName('username')[0].firstChild.data : 'Unknown';
									userEmail 	= login_email;
									userFname	= xml.getElementsByTagName('firstname')[0].firstChild ? xml.getElementsByTagName('firstname')[0].firstChild.data : 'Unknown';
									userLname 	= xml.getElementsByTagName('lastname')[0].firstChild ? xml.getElementsByTagName('lastname')[0].firstChild.data : 'Unknown';
								}
								else
									reasonText = statusCodes[response][getMetaValue('default_locale')];
							}
							else{
								alert('An error occurred while trying to log in.\nSorry for the inconvenience.');
								return false;
							}

							if (response == '6')
							{
								window.location.href = '/accountnotactivated.html';
							}
							else if(response != '0')
							{
								alert(reasonText);
								return false;
							}

							signIn_success(userId, userName, userEmail, userFname, userLname); 
							Dialog.closeInfo();
							window.location.reload();
							return true;
						}
					}
				);
			}
			else
				return false;						
		}

		function processKey(e)
		{
			if(null == e)
				e = window.event ;

			if(e.keyCode == 13)
				onOKFn();
		};

		Dialog.confirm(loginHTML, {
				className:"alphacube",
				width:400, 
				okLabel: loginData[locale]['loginLabel'], cancelLabel: loginData[locale]['cancelLabel'],
		    		onOk: onOKFn
		});

		$('login_email').onkeypress = processKey;
		$('login_password').onkeypress = processKey;
	};

	function forgotPassDialog()	{
		var locale = getMetaValue('default_locale');
		var formData = { 
			'en-us': { email: 'Email Address', emailAlert: 'Please enter your email address.', resetLabel: 'Reset', cancelLabel:'Cancel' },
			'en-eu': { email: 'Email Address', emailAlert: 'Please enter your email address.', resetLabel: 'Reset', cancelLabel:'Cancel' },
			'en-sc': { email: 'Email Address', emailAlert: 'Please enter your email address.', resetLabel: 'Reset', cancelLabel:'Cancel' },
			'en-za': { email: 'Email Address', emailAlert: 'Please enter your email address.', resetLabel: 'Reset', cancelLabel:'Cancel' },
			'en-au': { email: 'Email Address', emailAlert: 'Please enter your email address.', resetLabel: 'Reset', cancelLabel:'Cancel' },
			'es-es': { email: 'Su correo electrónico', emailAlert: 'Por favor, teclee su correo electrónico.', resetLabel: 'Reset', cancelLabel:'Cancelar' },
			'pl': { email: 'Adres mailowy', emailAlert:'Prosimy o wpisanie twego adresu e-mail.', resetLabel:'Resetuj', cancelLabel:'Anuluj' }
		};
		var loginHTML = ''
			+	'<div style="clear:both">'
			+	'</div>'
			+	'<form id="forgotPassForm">'
			+	'<table width="400">'
			+		'<tr>'
			+			'<td class="grey 11px" align="right">'
			+				formData[locale]['email']
			+			'</td>'
			+			'<td align="left">'
			+				'<input required onkeydown="if (event.keyCode == 13) return false;" alert="'+formData[locale]['emailAlert']+'" type="text" id="forgotPass_email" />'
			+			'</td>'
			+		'</tr>'
			+	'</table>'
			+	'</form>'
			+	'<div style="clear:both">'
			+	'</div>';
		Dialog.confirm(loginHTML, {
				className:"alphacube",
				width:400, 
				okLabel: formData[locale]['resetLabel'], cancelLabel:formData[locale]['cancelLabel'],
	    		onOk:function(win){
					var email = $F('forgotPass_email');
					if(checkForm($('forgotPassForm'))) {
						var site_id = getMetaValue('siteIdentifier');
						new Ajax.Request(docRoot + '/ajax/resetPasswordProcess.jsp', {
								parameters:'&email=' + email + '&site_id=' + site_id,
								onSuccess:function (xml){
									xml = handleResponse(xml);
									if(xml){
										var response = xml.getElementsByTagName('response')[0].firstChild ? xml.getElementsByTagName('response')[0].firstChild.data : 'Error';
										if (response != '0'){
											reasonText = statusCodes[response][getMetaValue('default_locale')] || 'Error';
											alert(reasonText);
											return false;
										}
									}
									else{
										alert('An error occurred while trying to reset the password.\nSorry for the inconvenience.');
										Dialog.closeInfo();
										return false;
									}
									alert('The password for this account has been reset and the new password has been sent to the email address.');
									Dialog.closeInfo();
									return true;
								}
							}
						);
					}
					else
						return false;
				}
			}
		);
	};

	function loadProfilePassword(){profilePassword=Math.floor(Math.random()*999999999999)+'';$('password').value=profilePassword;$('re_password').value=profilePassword;};
	function saveProfile(){
		if(checkForm($('profile_form'))) {
			if($F('password')!=$F('re_password'))
				alert('Passwords do not match');
			else{
				if(profilePassword == $('password').value){
					$('password').disabled 		= true;
					$('re_password').disabled 	= true;
				}
				new Ajax.Request('/ajax/registerProcess.jsp', {
						parameters: $('profile_form').serialize(),
						onSuccess:function (xml){
							$('password').disabled 				= false;
							$('re_password').disabled 			= false;
							$('saveSuccess').style.visibility	= 'visible';
						}});
			}
		}
	};
	
	function render_timeZoneList(dObj){
		removeAllOptions(dObj);
		new Ajax.Request(docRoot + '/ajax/data/timeZoneList.xml', {
				parameters:{nC: noCache()},
				onSuccess:function(xml){ 
					xml.responseXML.getElementsByTagName(firstNode.nodeName).each(function(xmlNode){
						addOption(dObj,getNodeValue(xmlNode,'program_title'),getNodeValue(xmlNode,getNodeAttribute(xmlNode,'pk')),false);
					})}
			});
	};

	function render_programList(dObj){
		removeAllOptions(dObj);
		new Ajax.Request(docRoot + '/ajax/data/programList.xml', {
				parameters:{nC: noCache()},
				onSuccess:function(xml){ 
					var x 	= xml.responseXML.getElementsByTagName(get_firstchild(xml.responseXML.documentElement).nodeName);
					for (var i=0;i<x.length;i++)
						addOption(dObj,getNodeValue(x[i],'display_name'),getNodeValue(x[i],'category_id'),false);
				}
			}
		);
	};	

	function render_CountryList(dObj){
		removeAllOptions(dObj);
		new Ajax.Request(docRoot + '/ajax/data/countryList.xml', {
				asynchronous:false,
				onSuccess:function(xml){ 
					var x = xml.responseXML.getElementsByTagName('country');
					for (var i=0;i<x.length;i++)
						addOption(dObj,getNodeValueByChildName(x[i],'name'),getNodeValueByChildName(x[i],'name'),false);
				}
			});
	};	

	function changeColorTheme(){
        var now 	= new Date();
        var now_hr 	= now.getHours();
        var cssfile = '';
        if (now_hr >= 4 && now_hr < 12) {
                cssfile		= docRoot + '/media/global/ip_orange.css';
				flashColor 	= 'orange';
		} else if (now_hr >= 12 && now_hr < 18) {
                cssfile		= docRoot + '/media/global/ip_green.css';
				flashColor 	= 'green';
		} else if ((now_hr >= 18 && now_hr <= 23) || (now_hr >= 0 && now_hr < 4)) {
                cssfile		= docRoot + '/media/global/ip_purple.css';
				flashColor 	= 'purple';
		}
        document.write('<link rel="stylesheet" type="text/css" href="' + cssfile + '" />');
	};
	
	function getRegTheme() {
		var siteName = window.location.href.split('://')[1].split('/')[0];
		var cssfile = '';
		if (siteName.indexOf('prime') > -1) {
			addMetaNode('siteIdentifier', '3');
			cssfile = 'http://community.bbcprime.com/community/style/bbc-prime.css';
		} else if (siteName.indexOf('food') > -1) {
			addMetaNode('siteIdentifier', '4');
			cssfile = 'http://community.bbcfood.com/community/style/bbc-food.css';
		}
		document.write('<link rel="stylesheet" type="text/css" media="all" href="' + cssfile + '" />');
	};
	function addMetaNode(name, content) {
		if (!name || !content) return;
		var head = document.getElementsByTagName('head');
		if (head.length) {
			var metaTag = document.createElement('meta');
			metaTag.setAttribute('name', name);
			metaTag.setAttribute('content', content);
			head[0].appendChild(metaTag);
		}
	};
	function renderMainNavigation(req,parent_id){
		var tmp			= '';
		var subTmp		= '';
		var subNodes	= '';
		var k			= req.responseXML.getElementsByTagName('nav');
		var navLen		= k.length;
		for(var j=0;j<k.length;j++){
			tmp					= '';
			subNodes			= '';
			var nLabel			= getNodeAttribute(k[j],'label');
			var nUrl			= getNodeAttribute(k[j],'url');
			var popup			= getNodeAttribute(k[j],'popup');
			var popupWidth		= getNodeAttribute(k[j],'width');
			var popupHeight		= getNodeAttribute(k[j],'height');
			var popupScroll		= getNodeAttribute(k[j],'scroll');
			var popupToolbar	= getNodeAttribute(k[j],'toolbar');
			var popupResize		= getNodeAttribute(k[j],'resize');
			var nParent			= getNodeAttribute(k[j],'parent_id');
			var nOrder			= getNodeAttribute(k[j],'order');
			var nId				= getNodeAttribute(k[j],'nav_id');
			var topImg			= 'top_'+nId;
			
			if(nParent==parent_id){
				if(parent_id==0){
					if(popup=='1'){
						tmp+='<a class="nav_' + SearchAndReplace(nLabel.toLowerCase(),' ', '') + '" href="#" onclick="open_win('
							+ '\'' + nUrl + '\','+'\''+nLabel+'\','
							+ '\'toolbar=' + popupToolbar
							+ ',scrollbars='+popupScroll+','
							+ 'location=0,resizable='+popupResize+','
							+ 'width='+popupWidth
							+ ',height='+popupHeight
							+ '\');this.blur();return false;">';
					} else {
						tmp += '<a class="nav_' + SearchAndReplace(nLabel.toLowerCase(),' ', '') + '" href="'+nUrl+'">';
						eval('pic'+j+'= new Image(1,1)');
						
						if(/bbcknowledge.com/i.test(window.location.href)){
							eval('pic'+j+'.src="/media/global/nav_' + SearchAndReplace(nLabel.toLowerCase(),' ', '') + '_active.png"');	
						}
					}	
					tmp += '<span>' + nLabel + '</span></a>';
					
					subNodes = renderMainNavigation_sub1(req,nId,topImg);
					
					if(subNodes!=''){
						tmp+='<ul>'+subNodes+'</ul>';
					}
				}
			}
					
			if(tmp!='')
				subTmp += '<ul><li>'+tmp+'</li></ul>';
		}
		return subTmp;
	};
	
	function renderMainNavigation_sub1(req,parent_id,mainImage){
		var tmp			= '';
		var subTmp		= '';
		var subNodes	= '';
		var k			= req.responseXML.getElementsByTagName('nav');
		for(var j=0;j<k.length;j++){
			tmp	='';
			subNodes='';
			var nLabel			= getNodeAttribute(k[j],'label');
			var nUrl			= getNodeAttribute(k[j],'url');
			var popup			= getNodeAttribute(k[j],'popup');
			var popupWidth		= getNodeAttribute(k[j],'width');
			var popupHeight		= getNodeAttribute(k[j],'height');
			var popupScroll		= getNodeAttribute(k[j],'scroll');
			var popupToolbar	= getNodeAttribute(k[j],'toolbar');
			var popupResize		= getNodeAttribute(k[j],'resize');
			var nParent			= getNodeAttribute(k[j],'parent_id');
			var nOrder			= getNodeAttribute(k[j],'order');
			var nId				= getNodeAttribute(k[j],'nav_id');
			if(nParent==parent_id){
				tmp+='<li>';
				if(popup=='1')
					tmp+='<a href="#" '
					 + 'onclick="open_win(\'' + nUrl + '\',\''+nLabel+'\',\'toolbar='
					 + popupToolbar+',scrollbars='+popupScroll+',location=0,resizable='
					 + popupResize+',width='+popupWidth+ ',height='+popupHeight
					 + '\');this.blur();return false;">' + nLabel + '</a>';
				else
					tmp+='<a href="'+nUrl+'">' + nLabel + '</a>';
					
				subNodes=renderMainNavigation_sub2(req,nId);
				if(subNodes!='')
					tmp+='<ul>'+subNodes+'</ul>\n';
			}
			if(tmp!='')
				subTmp+=tmp+'</li>\n';
		}
		return subTmp;
	};
	
	function renderMainNavigation_sub2(req,parent_id){
		var tmp='';
		var subTmp='';
		var k=req.responseXML.getElementsByTagName('nav');
		for (var j=0;j<k.length;j++){
			tmp='';
			var nLabel=getNodeAttribute(k[j],'label');
			var nUrl=getNodeAttribute(k[j],'url');
			var popup=getNodeAttribute(k[j],'popup');
			var popupWidth=getNodeAttribute(k[j],'width');
			var popupHeight=getNodeAttribute(k[j],'height');
			var popupScroll=getNodeAttribute(k[j],'scroll');
			var popupToolbar=getNodeAttribute(k[j],'toolbar');
			var popupResize=getNodeAttribute(k[j],'resize');
			var nParent=getNodeAttribute(k[j],'parent_id');
			var nOrder=getNodeAttribute(k[j],'order');
			var nId=getNodeAttribute(k[j],'nav_id');
			if(nParent==parent_id){
				tmp+='<li>';
				if(popup=='1'){
					tmp += '<a href="#" onclick="open_win('+'\''+nUrl+'\','+'\''+nLabel+'\','
					+ '\'toolbar='+popupToolbar+','+'scrollbars='+popupScroll+','+'location=0,'
					+ 'resizable='+popupResize+','+'width='+popupWidth+','+'height='+popupHeight
					+ '\');this.blur();return false;">' + nLabel + '</a>';
				}
				else{
					tmp+='<a href="'+nUrl+'">' + nLabel + '</a>';
				}
				if(tmp!=''){
					tmp+='</li>\n';
				}
			}
			if(tmp!=''){
				subTmp+=tmp;
			}
		}
		return subTmp;
	};	
	
	function renderShowNavigation(req,parent_id){
		var tmp			= '';
		var subTmp		= '';
		var subNodes	= '';
		var k			= req.responseXML.getElementsByTagName('nav');
		var navLen		= k.length;
		var topLevelCnt	= 0;
		for(var j=0;j<k.length;j++){
			tmp					= '';
			subNodes			= '';
			var nLabel			= getNodeAttribute(k[j],'label');
			var nUrl			= getNodeAttribute(k[j],'url');
			var popup			= getNodeAttribute(k[j],'popup');
			var popupWidth		= getNodeAttribute(k[j],'width');
			var popupHeight		= getNodeAttribute(k[j],'height');
			var popupScroll		= getNodeAttribute(k[j],'scroll');
			var popupToolbar	= getNodeAttribute(k[j],'toolbar');
			var popupResize		= getNodeAttribute(k[j],'resize');
			var nParent			= getNodeAttribute(k[j],'parent_id');
			var nOrder			= getNodeAttribute(k[j],'order');
			var nId				= getNodeAttribute(k[j],'nav_id');
			var topImg			= 'top_'+nId;
			if(nParent==parent_id){
				topLevelCnt++;
				var link = (popup=='1') ? '<a href="'+nUrl+'" target="_blank"><span>' + nLabel + '</span></a>' : '<a href="'+nUrl+'"><span>' + nLabel + '</span></a>';
				tmp+=link;
				//subNodes = renderMainNavigation_sub1(req,nId,topImg);
				if(subNodes!='')
					tmp+='<ul>'+subNodes+'</ul>';
			}
			if(tmp!='')
				subTmp += '<li class="item'+ topLevelCnt + '">'+tmp+'</li>';
		}
		subTmp += '<li class="item_spacer"></li>';
		return '<div class="hr-show-nav"></div><ul id="show-nav" class="show-nav">'+subTmp+'</ul><div class="hr-grey"></div>';
	};
	
	//ip_common.js
	function newWindow(wURL,wName,wWidth,wHeight,wScroll,wResizable,wCentered){
		var settings = 'height='+wHeight+',width='+wWidth+'scrollbars='+wScroll+',resizable='+wResizable;
		if(wCentered==true){
			lPosition	= (screen.width) ? (screen.width-wWidth)/2 : 0;
			tPosition	= (screen.height) ? (screen.height-wHeight)/2 : 0;	
			settings	+= ',left=' + lPosition + ',top=' + tPosition;
		}
		var nWindow	= window.open(wURL,wName,settings);
		nWindow.focus();
	};
	function disableContextMenu(event){Event.stop(event);event.oncontextmenu = function(){return false;}};
	function truncateText_Append(txtString,len,append){
		  var trunc = txtString;
		  if (trunc.length > len){
		    trunc = trunc.substring(0, len);
		    trunc = trunc.replace(/\w+$/, '');
		    trunc += append;
		  }
		  return trunc;
	};
	function getPage(url){return url.substring(url.lastIndexOf('/') + 1);};
	function hasZero(value){return (value+0<10) ? '0' + value : '' + value;};
	function noCache(){return Math.random(0, 1000)+'='+Math.random(0,1000);};
	function uniqueId(){var rndId = Math.random(0, 1000)+'';return rndId.replace('.','');};
	function addDays(myDate,days){return new Date(myDate.getTime() + days*24*60*60*1000);};	
	function getMetaValue(metaName){
		var metaArray = document.getElementsByTagName('meta');
		for(m=0;m<metaArray.length;m++){
			if(metaArray[m].name==metaName) {
				return metaArray[m].content;
				break;
			}	
		}
		return false;
	};			
	function getFileExtension(fileName){
		if( fileName.length == 0 ) return ''; 
		var dot = fileName.lastIndexOf('.'); 
		if( dot == -1 ) return ''; 
		return fileName.substr(dot,fileName.length); 
	};
	function SearchAndReplace(Content, SearchFor, ReplaceWith){
	   var tmpContent = Content;
	   var tmpBefore = new String();   
	   var tmpAfter = new String();
	   var tmpOutput = new String();
	   var intBefore = 0;
	   var intAfter = 0;
	   if (SearchFor.length == 0) return;
	   while (tmpContent.toUpperCase().indexOf(SearchFor.toUpperCase()) > -1) {
	      intBefore = tmpContent.toUpperCase().indexOf(SearchFor.toUpperCase());
	      tmpBefore = tmpContent.substring(0, intBefore);
	      tmpOutput = tmpOutput + tmpBefore;
	      tmpOutput = tmpOutput + ReplaceWith;
	      intAfter = tmpContent.length - SearchFor.length + 1;
	      tmpContent = tmpContent.substring(intBefore + SearchFor.length);
	   }
	   return tmpOutput + tmpContent;
	};
	function createCookie(name,value,days){
		if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = '; expires='+date.toGMTString();
		}
		else var expires = '';
		document.cookie = name+'='+escape(value)+expires+';domain='+getSubdomain()+'; path=/';
		if (days == -1) {
			document.cookie = name+'='+escape(value)+expires+';domain='+getSubdomain()+'; path=/';
		}
	};
	function readCookie(name) {
		var nameEQ = name + '=';
		var ca = document.cookie.split(';');
		for(var i=0;i<ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return unescape(c.substring(nameEQ.length,c.length));
		}
		return null;
	};
	function eraseCookie(name){createCookie(name,'',-1);};
	function parseCookie() {
		var x = new Object();
		var y = readCookie('olio');
		if (y) {
			var tmp = y.split("|");
			if (tmp.length==5) x={userid:tmp[0], username:tmp[1], email:tmp[2], fname:tmp[3], lname:tmp[4] };
		}
		return x;
	};
	
	function loadScript(url, callback) {
		var f = arguments.callee;
		if (!("queue" in f))
			f.queue = {};
		var queue =  f.queue;
		if (url in queue) {
			if (callback) {
				if (queue[url])
					queue[url].push(callback);
				else
					callback();
			}
			return;
		}
		queue[url] = callback ? [callback] : [];
		var script = document.createElement("script");
		script.type = "text/javascript";
		if ((/WebKit/i.test(navigator.userAgent)) || (/opera/i.test(navigator.userAgent))) {
			var _timer = setInterval(function() {
				if (/loaded|complete/.test(document.readyState)) {
					clearInterval(_timer);
					while (queue[url].length) {
						queue[url].shift()();
					}
					queue[url] = null;
				}
			}, 1000);
		} else {
			script.onload = script.onreadystatechange = function() {
				if (script.readyState && script.readyState != "loaded" && script.readyState != "complete")
					return;
				script.onreadystatechange = script.onload = null;
				while (queue[url].length) {
					queue[url].shift()();
				}
				queue[url] = null;
			};
		}
		script.src = url;
		document.getElementsByTagName("head")[0].appendChild(script);
		
	};

	// ip_xml.js
	function getPropertyNodeByName(object,name){try{var propertyNode=object.getElementsByTagName(get_firstchild(object).nodeName);var propertyLen=propertyNode.length;for(var j=0;j<propertyLen;j++){switch(getNodeAttribute(propertyNode[j],'name')){case name:return getNodeValue(propertyNode[j]);break;}}}catch(err){return '';}};
	function getNodeValueByChildName(node,childname){var tmpString='';try{if(node.getElementsByTagName(childname)[0].firstChild.nodeValue=='null'){return '';}else{for(var i=0;i<node.getElementsByTagName(childname)[0].childNodes.length;i++){tmpString+=node.getElementsByTagName(childname)[0].childNodes[i].nodeValue;}return tmpString;}}catch(err){return '';}};
	function getNodeValue(node){var tmpString='';try{for(var i=0;i<node.childNodes.length;i++){tmpString+=node.childNodes[i].nodeValue;}return tmpString;}catch(err){return '';}};
	function getNodeChildObj(obj,tag){var tmpString='';try{if(obj.getElementsByTagName(tag)[0].firstChild.nodeValue=='null')return '';else{return obj.getElementsByTagName(tag);}}catch(err){return '';}};
	function getNodeName(obj){return obj.firstChild.nodeName;};
	function getNodeAttribute(obj,attr){try{return obj.getAttribute(attr);}catch(err){return '';}};
	function get_firstchild(n){try{var x=n.firstChild;while(x.nodeType!=1){x=x.nextSibling;}return x;}catch(err){return '';}};
	function hasChildElements(rootNode){try{for(var i=0;i<rootNode.childNodes.length;i++){if(rootNode.childNodes[i].nodeType == 1){return true;}}return false;}catch(err){return '';}};

	function xmlExtract(content, startTag, endTag) {
		var exContent = content.substring( content.indexOf(startTag), content.indexOf(endTag)+endTag.length );
		var xmlDoc;
		try { //IE
		    xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
		    xmlDoc.loadXML(exContent);
		}
		catch(e) {
			try { //The Rest
		        xmlDoc = (new DOMParser()).parseFromString(exContent, "text/xml");
		  	}
		  	catch(e){}
		}
		return xmlDoc;
	};	

	function handleResponse(response){ //extract xml from HTML response or XML response - fix for JIVE FTL issue
		return (docRoot!='') ? xmlExtract(response.responseText.stripScripts(),'<xml>','</xml>') : response.responseXML;
	};

	//ip_select.js
	function hasOptions(obj){if(obj!=null&&obj.options!=null){return true;}else{return false};};
	function selectMatchingOptions(obj,regex){selectUnselectMatchingOptions(obj,regex,'select',false);};
	function selectOnlyMatchingOptions(obj,regex){selectUnselectMatchingOptions(obj,regex,'select',true);};
	function unSelectMatchingOptions(obj,regex){selectUnselectMatchingOptions(obj,regex,'unselect',false);};
	function selectUnselectMatchingOptions(obj,regex,which,only){if(window.RegExp){if(which=='select'){var selected1=true;var selected2=false;}else if(which=='unselect'){var selected1=false;var selected2=true;}else{return;}var re=new RegExp(regex);if(!hasOptions(obj))return;for(var i=0;i<obj.options.length;i++){if(re.test(obj.options[i].value))obj.options[i].selected=selected1;else {if(only==true) obj.options[i].selected=selected2;}}}};
	function removeSelectedOptions(from){if(!hasOptions(from)){return;}if(from.type=="select-one"){from.options[from.selectedIndex]=null;}else{for(var i=(from.options.length-1);i>=0;i--){var o=from.options[i];if(o.selected)from.options[i]=null;}}from.selectedIndex=-1;};
	function removeAllOptions(from){if(!hasOptions(from))return;for(var i=(from.options.length-1);i>=0;i--){from.options[i]=null;}from.selectedIndex=-1;};
	function addOption(obj,text,value,selected){if(obj!=null&&obj.options!=null)obj.options[obj.options.length]=new Option(text,value,selected);};
	function removeOption(fOBJ,value){for(i=0;i<fOBJ.options.length;i++){if(fOBJ.options[i].value==value)fOBJ.options[i]=null;}};
	function getSelectList(fOBJ){var pars='';for(i=0;i<fOBJ.length;i++){if(i>0)pars=pars+',';pars=pars+fOBJ.options[i].value;}return pars;};
	function getSelectListSelected(fOBJ){var pars='';var count=0;for(i=0;i<fOBJ.length;i++){if(fOBJ.options[i].selected==true){if(count>0)pars=pars+',';count++;pars=pars+fOBJ.options[i].value;}}return pars;};
	function display_Select(sOptions,sSelected){var tmpData='';var x=sOptions.split(',');for(var i=0;i<x.length;i++){var sltcd='';var items=x[i].split('|');if(items[0]==sSelected)sltcd='selected="selected"';tmpData+='<option value="'+items[0]+'" '+sltcd+'>'+items[1]+'</option>';}return tmpData;};
		
	// ip_form.xml
	var dfltValue   = '**NO VALUE**';
	var dfltChars   = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.?-()[]+=_-;:/#@$%&!,*<>\"\'\n\r ';
	var dfltMethod  = 'POST';
	
	function checkForm(object){
		errFlag = false;
	    for(var i=0;i<object.elements.length;i++){
	    	if(object.elements[i].attributes['id']){
				theO		= $(object.elements[i]);
				oType		= theO.type;
		        oName  		= theO.attributes['id'].value;
				theO.name 	= oName;
		        oValue 		= $F(theO);
			    (theO.attributes["required"]) ? oReqd=true : oReqd=false;
			   	(theO.attributes["alert"]) ? oAlert=theO.attributes['alert'].value : oAlert ='';
		       	(theO.attributes["chars"]) ? oChars=theO.attributes['chars'].value : oChars=dfltChars;
		        (theO.attributes["editor"]) ? oEditor=true : oEditor=false;
		        (theO.attributes["parent"]) ? oParent=theO.attributes['parent'].value : oParent='';
				(theO.attributes["minLen"]) ? oMin=theO.attributes['minLen'].value : oMin=1;
		        (theO.attributes["maxLen"]) ? oMax=theO.attributes['maxLen'].value : oMax=100;
				if(oReqd==true||(document.getElementById(oParent)&&oParent!=''&&$(oParent).checked==true)){
		        	if(oEditor==true){
						var tmpValue = getEditor(oName);
						if(tmpValue.length<oMin || tmpValue.length>oMax){
							errFlag=true;
							if(oAlert!='') alert(oAlert);
							break;
						}
		        	}
		        	else {
			            if(oName.toLowerCase().indexOf('email')>-1){ 
			                if(isValidEmail(oValue)==false) {
			                	errFlag = true;
								if(oAlert!='') alert(oAlert);
								break;
			                }
			             } 
			             else if(validate(oValue,oChars)==false||oValue.length<oMin||oValue.length>oMax){
			             	errFlag = true;
							if(oAlert!='') alert(oAlert);
							break;
			             }
			     	}
		        }
			}
	    }
		if(errFlag==false) 
			return true;
		else 
			return false;
	};
	function isValidEmail(string){if(string.length<1)return false;if(string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/)!=-1){return true;}else{return false;}};
	function validate(strVl,strChrs){if(!strVl) return false;if(strVl==dfltValue)return false;if(strVl.length<1)return false;for(i=0;i<strVl.length;i++){if(strChrs.indexOf(strVl.charAt(i))==-1)return false;}return true;};	

	//ip_date.js
	function isDate(p_Expression){return !isNaN(new Date(p_Expression));};
	function dateAdd(p_Interval, p_Number, p_Date){
		if(!isDate(p_Date)){return "invalid date: '" + p_Date + "'";}
		if(isNaN(p_Number)){return "invalid number: '" + p_Number + "'";}	
		p_Number = new Number(p_Number);
		var dt = new Date(p_Date);
		switch(p_Interval.toLowerCase()){
			case "yyyy": {
				dt.setFullYear(dt.getFullYear() + p_Number);
				break;
			}
			case "q": {
				dt.setMonth(dt.getMonth() + (p_Number*3));
				break;
			}
			case "m": {
				dt.setMonth(dt.getMonth() + p_Number);
				break;
			}
			case "y":
			case "d":
			case "w": {
				dt.setDate(dt.getDate() + p_Number);
				break;
			}
			case "ww": {
				dt.setDate(dt.getDate() + (p_Number*7));
				break;
			}
			case "h": {
				dt.setHours(dt.getHours() + p_Number);
				break;
			}
			case "n": {
				dt.setMinutes(dt.getMinutes() + p_Number);
				break;
			}
			case "s": {
				dt.setSeconds(dt.getSeconds() + p_Number);
				break;
			}
			case "ms": {
				dt.setMilliseconds(dt.getMilliseconds() + p_Number);
				break;
			}
			default: {
				return "invalid interval: '" + p_Interval + "'";
			}
		}
		return dt;
	};
	
	function dateDiff(p_Interval, p_Date1, p_Date2, p_firstdayofweek, p_firstweekofyear){
		if(!isDate(p_Date1)){return "invalid date: '" + p_Date1 + "'";}
		if(!isDate(p_Date2)){return "invalid date: '" + p_Date2 + "'";}
		var dt1 = new Date(p_Date1);
		var dt2 = new Date(p_Date2);
		var iDiffMS = dt2.valueOf() - dt1.valueOf();
		var dtDiff = new Date(iDiffMS);
		var nYears  = dt2.getUTCFullYear() - dt1.getUTCFullYear();
		var nMonths = dt2.getUTCMonth() - dt1.getUTCMonth() + (nYears!=0 ? nYears*12 : 0);
		var nQuarters = parseInt(nMonths/3);	
		var nMilliseconds = iDiffMS;
		var nSeconds = parseInt(iDiffMS/1000);
		var nMinutes = parseInt(nSeconds/60);
		var nHours = parseInt(nMinutes/60);
		var nDays  = parseInt(nHours/24);
		var nWeeks = parseInt(nDays/7);
		var iDiff = 0;		
		switch(p_Interval.toLowerCase()){
			case "yyyy": return nYears;
			case "q": return nQuarters;
			case "m": return nMonths;
			case "y": 
			case "d": return nDays;
			case "w": return nDays;
			case "ww":return nWeeks;	
			case "h": return nHours;
			case "n": return nMinutes;
			case "s": return nSeconds;
			case "ms":return nMilliseconds;
			default: return "invalid interval: '" + p_Interval + "'";
		}
	};

	function datePart(p_Interval, p_Date, p_firstdayofweek, p_firstweekofyear){
		if(!isDate(p_Date)){return "invalid date: '" + p_Date + "'";}
		var dtPart = new Date(p_Date);
		switch(p_Interval.toLowerCase()){
			case "yyyy": return dtPart.getFullYear();
			case "q": return parseInt(dtPart.getMonth()/3)+1;
			case "m": return dtPart.getMonth()+1;
			case "y": return dateDiff("y", "1/1/" + dtPart.getFullYear(), dtPart);			// day of year
			case "d": return dtPart.getDate();
			case "w": return dtPart.getDay();	// weekday
			case "ww":return dateDiff("ww", "1/1/" + dtPart.getFullYear(), dtPart);		// week of year
			case "h": return dtPart.getHours();
			case "n": return dtPart.getMinutes();
			case "s": return dtPart.getSeconds();
			case "ms":return dtPart.getMilliseconds();	// millisecond	// <-- extension for JS, NOT available in VBScript
			default: return "invalid interval: '" + p_Interval + "'";
		}
	};
	// REQUIRES: isDate()
	// NOT SUPPORTED: firstdayofweek (does system default)
	function weekdayName(p_Date, p_abbreviate){
		if(!isDate(p_Date)){return "invalid date: '" + p_Date + "'";}
		var dt = new Date(p_Date);
		var retVal = dt.toString().split(' ')[0];
		var retVal = Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday')[dt.getDay()];
		if(p_abbreviate==true){retVal = retVal.substring(0, 3)}	// abbr to 1st 3 chars
		return retVal;
	}
	// REQUIRES: isDate()
	function monthName(p_Date, p_abbreviate){
		if(!isDate(p_Date)){return "invalid date: '" + p_Date + "'";}
		var dt = new Date(p_Date);	
		var retVal = Array('January','February','March','April','May','June','July','August','September','October','November','December')[dt.getMonth()];
		if(p_abbreviate==true){retVal = retVal.substring(0, 3)}	// abbr to 1st 3 chars
		return retVal;
	};
	
	function DateAdd(p_Interval, p_Number, p_Date){return dateAdd(p_Interval, p_Number, p_Date);};
	function DateDiff(p_interval, p_date1, p_date2, p_firstdayofweek, p_firstweekofyear){return dateDiff(p_interval, p_date1, p_date2, p_firstdayofweek, p_firstweekofyear);};
	function DatePart(p_Interval, p_Date, p_firstdayofweek, p_firstweekofyear){return datePart(p_Interval, p_Date, p_firstdayofweek, p_firstweekofyear);};
	function getTimeFromDate(date_time){return hasZero(datePart('h', date_time)) + ":" + hasZero(datePart('n', date_time));};
	
	function parseDateObj(dateobj){
		var x = new Object();
		x['month'] = hasZero(dateobj.getMonth()-1);
		x['day'] = hasZero(dateobj.getDate());
		x['year'] = dateobj.getYear();
		x['hour'] = hasZero(dateobj.getHours());
		x['minute'] = hasZero(dateobj.getMinutes());
		x['second'] = hasZero(dateobj.getSeconds());
		return x;
	};
	
	function createDateObj(date_time){return new Date(Date.parse(date_time));};
	
	function convertTimeZone(dateObj, diff){
		var tmp = "";
		var plusminus = 1;
		if (diff.split("-").length > 1){
			tmp = diff.split("-")[1];
			plusminus = -1;
		} else if (diff.split("+").length > 1){
			tmp = diff.split("+")[1];
			plusminus = 1;
		}
		if (tmp.length){
			dateObj = dateAdd('n', plusminus * tmp.split(":")[1], dateObj);
			dateObj = dateAdd('h', plusminus * tmp.split(":")[0], dateObj);
		}
		return dateObj;
	};
	
	function convertToGMT(dateObj, diff){
		var tmp = "";
		var plusminus = 1;
		if (diff.split("-").length > 1){
			tmp = diff.split("-")[1];
			plusminus = 1;
		} else if (diff.split("+").length > 1){
			tmp = diff.split("+")[1];
			plusminus = -1;
		}
		if (tmp.length){
			dateObj = dateAdd('n', plusminus * tmp.split(":")[1], dateObj);
			dateObj = dateAdd('h', plusminus * tmp.split(":")[0], dateObj);
		}
		return dateObj;
	};
	
	function getServerTime(){
		if (!server_time) {
			new Ajax.Request(docRoot + '/ajax/date.jsp', {
				asynchronous:false,
				parameters:{nC: noCache()},
				onSuccess:function(xml){server_time = getNodeValue(get_firstchild(xml.responseXML.documentElement));}
			});
		}
	};

	/**
	 * SWFObject v1.4.4: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
	 *
	 * SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:
	 * http://www.opensource.org/licenses/mit-license.php
	 *
	 * **SWFObject is the SWF embed script formerly known as FlashObject. The name was changed for
	 *   legal reasons.
	 */
	if(typeof deconcept=="undefined"){var deconcept=new Object();}
	if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}
	if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}
	deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b){if(!document.getElementById){return;}
	this.DETECT_KEY=_b?_b:"detectflash";
	this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);
	this.params=new Object();
	this.variables=new Object();
	this.attributes=new Array();
	if(_1){this.setAttribute("swf",_1);}
	if(id){this.setAttribute("id",id);}
	if(w){this.setAttribute("width",w);}
	if(h){this.setAttribute("height",h);}
	if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}
	this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();
	if(c){this.addParam("bgcolor",c);}
	var q=_8?_8:"high";
	this.addParam("quality",q);
	this.setAttribute("useExpressInstall",_7);
	this.setAttribute("doExpressInstall",false);
	var _d=(_9)?_9:window.location;
	this.setAttribute("xiRedirectUrl",_d);
	this.setAttribute("redirectUrl","");
	if(_a){this.setAttribute("redirectUrl",_a);}};
	deconcept.SWFObject.prototype={setAttribute:function(_e,_f){
	this.attributes[_e]=_f;
	},getAttribute:function(_10){
	return this.attributes[_10];
	},addParam:function(_11,_12){
	this.params[_11]=_12;
	},getParams:function(){
	return this.params;
	},addVariable:function(_13,_14){
	this.variables[_13]=_14;
	},getVariable:function(_15){
	return this.variables[_15];
	},getVariables:function(){
	return this.variables;
	},getVariablePairs:function(){
	var _16=new Array();
	var key;
	var _18=this.getVariables();
	for(key in _18){_16.push(key+"="+_18[key]);}
	return _16;},getSWFHTML:function(){var _19="";
	if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){
	if(this.getAttribute("doExpressInstall")){
	this.addVariable("MMplayerType","PlugIn");}
	_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\"";
	_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";
	var _1a=this.getParams();
	for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}
	var _1c=this.getVariablePairs().join("&");
	if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";
	}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");}
	_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\">";
	_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";
	var _1d=this.getParams();
	for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}
	var _1f=this.getVariablePairs().join("&");
	if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}
	return _19;
	},write:function(_20){
	if(this.getAttribute("useExpressInstall")){
	var _21=new deconcept.PlayerVersion([6,0,65]);
	if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){
	this.setAttribute("doExpressInstall",true);
	this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));
	document.title=document.title.slice(0,47)+" - Flash Player Installation";
	this.addVariable("MMdoctitle",document.title);}}
	if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){
	var n=(typeof _20=="string")?document.getElementById(_20):_20;
	n.innerHTML=this.getSWFHTML();return true;
	}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}
	return false;}};
	deconcept.SWFObjectUtil.getPlayerVersion=function(){
	var _23=new deconcept.PlayerVersion([0,0,0]);
	if(navigator.plugins&&navigator.mimeTypes.length){
	var x=navigator.plugins["Shockwave Flash"];
	if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}
	}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}
	catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
	_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}
	catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}
	catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}
	return _23;};
	deconcept.PlayerVersion=function(_27){
	this.major=_27[0]!=null?parseInt(_27[0]):0;
	this.minor=_27[1]!=null?parseInt(_27[1]):0;
	this.rev=_27[2]!=null?parseInt(_27[2]):0;
	};
	deconcept.PlayerVersion.prototype.versionIsValid=function(fv){
	if(this.major<fv.major){return false;}
	if(this.major>fv.major){return true;}
	if(this.minor<fv.minor){return false;}
	if(this.minor>fv.minor){return true;}
	if(this.rev<fv.rev){
	return false;
	}return true;};
	deconcept.util={getRequestParameter:function(_29){
	var q=document.location.search||document.location.hash;
	if(q){var _2b=q.substring(1).split("&");
	for(var i=0;i<_2b.length;i++){
	if(_2b[i].substring(0,_2b[i].indexOf("="))==_29){
	return _2b[i].substring((_2b[i].indexOf("=")+1));}}}
	return "";}};
	deconcept.SWFObjectUtil.cleanupSWFs=function(){if(window.opera||!document.all){return;}
	var _2d=document.getElementsByTagName("OBJECT");
	for(var i=0;i<_2d.length;i++){_2d[i].style.display="none";for(var x in _2d[i]){
	if(typeof _2d[i][x]=="function"){_2d[i][x]=function(){};}}}};
	deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};
	__flash_savedUnloadHandler=function(){};
	if(typeof window.onunload=="function"){
	var _30=window.onunload;
	window.onunload=function(){
	deconcept.SWFObjectUtil.cleanupSWFs();_30();};
	}else{window.onunload=deconcept.SWFObjectUtil.cleanupSWFs;}};
	if(typeof window.onbeforeunload=="function"){
	var oldBeforeUnload=window.onbeforeunload;
	window.onbeforeunload=function(){
	deconcept.SWFObjectUtil.prepUnload();
	oldBeforeUnload();};
	}else{window.onbeforeunload=deconcept.SWFObjectUtil.prepUnload;}
	if(Array.prototype.push==null){
	Array.prototype.push=function(_31){
	this[this.length]=_31;
	return this.length;};}
	var getQueryParamValue=deconcept.util.getRequestParameter;
	var FlashObject=deconcept.SWFObject;
	var SWFObject=deconcept.SWFObject;

	/**
	 * @author Ryan Johnson <ryan@livepipe.net>
	 * @copyright 2007 LivePipe LLC
	 * @package Control.Tabs
	 * @license MIT
	 * @url http://livepipe.net/projects/control_tabs/
	 * @version 1.6.0
	 */
	if(typeof(Control) == "undefined")
		var Control = {};
	Control.Tabs = Class.create();
	Object.extend(Control.Tabs,{
		tabs: $A([]),
		responders: $A([]),
		addResponder: function(responder){
			Control.Tabs.responders.push(responder);
		},
		removeResponder: function(responder){
			Control.Tabs.responders = Control.Tabs.responders.without(responder);
		},
		notifyResponders: function(event_name,argument_one,argument_two){
			Control.Tabs.responders.each(function(responder){
				if(responder[event_name])
					responder[event_name](argument_one,argument_two);
			});
		},
		findByTabId: function(id){
			return this.tabs.find(function(tab){
				return tab.links.find(function(link){
					return link.key == id;
				});
			});
		}
	});
	Object.extend(Control.Tabs.prototype,{
		activeContainer: false,
		activeLink: false,
		initialize: function(tab_set,options){
			Control.Tabs.tabs.push(this);
			tab_set = $(tab_set);
			this.options = $H({
				beforeChange: Prototype.emptyFunction,
				afterChange: Prototype.emptyFunction,
				linkSelector: 'li a',
				activeClassName: 'active',
				defaultTab: 'first',
				autoLinkExternal: true
			});
			if(options)
				for(o in options)
					this.options[o] = options[o];
			this.containers = $H({});
			this.links = (typeof(this.options.linkSelector == "string")
				? tab_set.getElementsBySelector(this.options.linkSelector)
				: this.options.linkSelector(tab_set)
			).findAll(function(link){return (/^#/).exec(link.href.replace(window.location.href.split('#')[0],''));});
			this.links.each(function(link){
				link.key = $A(link.getAttribute('href').replace(window.location.href.split('#')[0],'').split('/')).last().replace(/#/,'');
				this.containers[link.key] = $(link.key);
				link.onclick = function(link){
					this.setActiveTab(link);
					return false;
				}.bind(this,link);
			}.bind(this));
			if(this.options.defaultTab == 'first')
				this.setActiveTab(this.links.first());
			else if(this.options.defaultTab == 'last')
				this.setActiveTab(this.links.last());
			else
				this.setActiveTab(this.options.defaultTab);
			target_regexp = /#(.+)$/;
			targets = target_regexp.exec(window.location);
			if(targets && targets[1]){
				$A(targets[1].split(',')).each(function(target){
					this.links.each(function(target,link){
						if(link.key == target){
							this.setActiveTab(link);
							throw $break;
						}
					}.bind(this,target));
				}.bind(this));
			}
			if(this.options.autoLinkExternal){
				$A(document.getElementsByTagName('a')).each(function(a){
					if(!this.links.include(a)){
						clean_href = a.href.replace(window.location.href.split('#')[0],'');
						if(clean_href.substring(0,1) == '#'){
							if(this.containers.keys().include(clean_href.substring(1))){
								$(a).observe('click',function(event,clean_href){
									this.setActiveTab(clean_href.substring(1));
								}.bindAsEventListener(this,clean_href));
							}
						}
					}
				}.bind(this));
			}
		},
		setActiveTab: function(link){
			if(typeof(link) == "undefined" || link == false)
				return;
			if(typeof(link) == "string"){
				this.links.each(function(_link){
					if(_link.key == link){
						this.setActiveTab(_link);
						throw $break;
					}
				}.bind(this));
			}else{
				this.containers.each(function(item){
					item[1].hide();
				});			
				this.links.each(function(item){
					item.removeClassName(this.options.activeClassName);
				}.bind(this));
				link.addClassName(this.options.activeClassName);
				this.options.beforeChange(this,this.activeContainer);
				Control.Tabs.notifyResponders('beforeChange',this,this.activeContainer);
				this.activeContainer = this.containers[link.key];
				this.activeLink = link;
				this.containers[link.key].show();
				this.options.afterChange(this,this.containers[link.key]);
				Control.Tabs.notifyResponders('afterChange',this,this.containers[link.key]);
			}
		},
		next: function(){
			this.links.each(function(link,i){
				if(this.activeLink == link && this.links[i + 1]){
					this.setActiveTab(this.links[i + 1]);
					throw $break;
				}
			}.bind(this));
		},
		previous: function(){
			this.links.each(function(link,i){
				if(this.activeLink == link && this.links[i - 1]){
					this.setActiveTab(this.links[i - 1]);
					throw $break;
				}
			}.bind(this));
		},
		first: function(){
			this.setActiveTab(this.links.first());
		},
		last: function(){
			this.setActiveTab(this.links.last());
		}
	});
	
	/*
	 * Toolbar for tv schedule
	 */
	 function getShows() {
		new Ajax.Request(docRoot + '/ajax/data/'+getMetaValue('siteIdentifier')+'/programList.xml', { 
				parameters:{nC: noCache()},
				onSuccess:function(xml){ 
					var x = xml.responseXML.getElementsByTagName(get_firstchild(xml.responseXML.documentElement).nodeName);
					for (var i = 0; i < x.length; i++) {
						addOption($('byshow_dd'), getNodeValueByChildName(x[i], 'display_name'), getNodeValueByChildName(x[i], 'category_id'), false);
						$('byshow_dd').options[i+1].setAttribute('short_name', getNodeValueByChildName(x[i], 'short_name'));
					} 
				}
			}
		);
	};
	function getTimezones(dropdown) {
		new Ajax.Request(docRoot + '/media/global/timezones.xml', {
				onFailure:function() {
					var country = getMetaValue('siteCountry');
					var tz = getMetaValue('defaultTimeZone');
					if (country && tz)
						addOption(dropdown, country, tz);
					dropdown.value = tz;
					dropdown.onchange = null;
				},
				onSuccess:function(xml) {
					var x = xml.responseXML.getElementsByTagName(get_firstchild(xml.responseXML.documentElement).nodeName);
					for(var i=0; i<x.length;i++) addOption(dropdown, getNodeValueByChildName(x[i], 'location'), getNodeValueByChildName(x[i], 'timezone'));
				},
				onComplete:function() {
					var userInfo = getUserLocale();
					if (document.location.hostname.indexOf(userInfo.site) > -1) {
						for(var i=0;i<dropdown.length;i++){
							if (dropdown.options[i].text.toLowerCase() == userInfo.location.toLowerCase()){
								dropdown.options[i].selected = true;
								break;
							}
						}
						/*dropdown.selectedIndex = userInfo.dropdownIndex;
						if (dropdown.options[dropdown.selectedIndex].text != userInfo.location) {
							dropdown.value = '';
							dropdown.selectedIndex = 0;
						}*/
					}
				}
			}
		);
	};
	
	function changeDate(calendar, date) {
		if (calendar.dateClicked) {
			calendar.callCloseHandler(); 
			gotoDate($$('.tvSchedule')[0], createDateObj(date));
		}
	};
	
	function closeCalendar(calendar) {calendar.destroy();};
	
	function changeRange(e) {
		var evt = e || window.event;
		var evtTarget = evt.target || evt.srcElement;
		changeSchedRange($$('.tvSchedule')[0], evtTarget.value);
	};
	
	function changeShow(e) {
		var evt = e || window.event;
		var evtTarget = evt.target || evt.srcElement;
		if (evtTarget.value != '') {
			viewSchedByShow($$('.tvSchedule')[0], evtTarget.value, evtTarget.options[evtTarget.selectedIndex].getAttribute('short_name'));
			evtTarget.value = '';
		}
	};
	
	function keywordSearch() {
		if ($('kwsearch').value.length) {
			if ($('kwsearch').value.length < 4) {
				var alertMessageValues = {
					'en-us': 'Please enter 4 or more characters for search.',
			        'en-eu': 'Please enter 4 or more characters for search.',
			        'en-sc': 'Please enter 4 or more characters for search.',
			        'en-za': 'Please enter 4 or more characters for search.',
			        'en-au': 'Please enter 4 or more characters for search.',
			        'es-es': 'Por favor escribe 4 o más letras para realizar la búsqueda.',
			        'pl': 'Please enter 4 or more characters for search.'
				}
				var alertMessage=alertMessageValues[getMetaValue('default_locale')] || 'Error';
				alert(alertMessage);
			}
			else 
				viewSchedBySearch($$('.tvSchedule')[0], $('kwsearch').value);
		}
	};
	
	function changeTimezone(e) {
		var evt = e || window.event;
		var evtTarget = evt.target || evt.srcElement;
		if (evtTarget.value != '') {
			var x = readCookie('userLocation');
			if (!x || (x.split('__')[0].toLowerCase() != evtTarget.options[evtTarget.selectedIndex].text.toLowerCase())) {
				createCookie('userLocation', evtTarget.options[evtTarget.selectedIndex].text+'__'+evtTarget.value+'__'+evtTarget.selectedIndex+'__'+document.location.hostname, 30);
				initiate_tvSchedule($$('.tvSchedule')[0]);
			}
		}
		Event.stop(e);
	};
	
	function initiateCalendar() {
		Calendar.setup( {
			ifFormat: "%m/%d/%Y %H:%M:%S",
			weekNumbers: false,
			button: 'popup_cal',
			inputField: 'goto_date',
			onSelect: changeDate,
			onClose: closeCalendar
			});
	};
	
	function changeView(e) {
		var evt = e || window.event;
		var evtTarget = evt.target || evt.srcElement;
		if (evtTarget.id == "list_view") 
			changeViewLayout($$('.tvSchedule')[0], "list");
		else if (evtTarget.id == "grid_view") 
			changeViewLayout($$('.tvSchedule')[0], "grid");
		else if (evtTarget.id == "detail_view")
			changeViewLayout($$('.tvSchedule')[0], "detail");
		Event.stop(e);
	};
	/* end toolbar for tv schedule */
	function getUserLocation() {
		var value = readCookie('userLocation');
		var locInfo = { location: '', timezone: '', site: '' };
		if (value) {
			var pieces = value.split('__');
			locInfo.site = pieces[3].replace('/','') || '';
			locInfo.location = pieces[0] || '';
			locInfo.timezone = pieces[1] || '';
			locInfo.dropdownIndex = pieces[2] || '';
		}
		return locInfo;
	};
	function getUserLocale() {
		var uInfo = getUserLocation();
		// if user visits a site that doesn't have associated cookie, then use default meta values
		if (document.location.hostname.indexOf(uInfo.site) < 0 || !uInfo.timezone || !uInfo.location) {
			uInfo.timezone = getMetaValue('defaultTimeZone');
			uInfo.location = getMetaValue('siteCountry');		
		}
		return  uInfo;
	};
	function getNewTimezone(loc) {var f = { 'malaysia': 'GMT+08:00' };return f[loc.toLowerCase()];};
	var statusCodes = {
		0: { 'en-us': 'Success', 'en-eu': 'Success', 'en-sc': 'Success', 'en-za': 'Success', 'en-au': 'Success', 'es-es': 'Success', 'pl': 'Success' },
		1: { 'en-us': 'Error Confirming Account', 'en-eu': 'Error Confirming Account', 'en-sc': 'Error Confirming Account', 'en-za': 'Error Confirming Account', 'en-au': 'Error Confirming Account', 'es-es': 'Error Confirming Account', 'pl': 'Error Confirming Account' },
		2: { 'en-us': 'Invalid Code/ Expired Code. Contact administrator', 'en-eu': 'Invalid Code/ Expired Code. Contact administrator', 'en-sc': 'Invalid Code/ Expired Code. Contact administrator', 'en-za': 'Invalid Code/ Expired Code. Contact administrator', 'en-au': 'Invalid Code/ Expired Code. Contact administrator', 'es-es': 'Invalid Code/ Expired Code. Contact administrator', 'pl': 'Przykro nam, wystÄ…piÅ‚y pewne problemy z rejestracjÄ… twojego konta. SprÃ³buj ponownie.' },
		3: { 'en-us': 'Provide code as Parameter', 'en-eu': 'Provide code as Parameter', 'en-sc': 'Provide code as Parameter', 'en-za': 'Provide code as Parameter', 'en-au': 'Provide code as Parameter', 'es-es': 'Provide code as Parameter', 'pl': 'Provide code as Parameter' },
		4: { 'en-us': 'Your E-mail address was not recognized', 'en-eu': 'Your E-mail address was not recognized', 'en-sc': 'Your E-mail address was not recognized', 'en-za': 'Your E-mail address was not recognized', 'en-au': 'Your E-mail address was not recognized', 'es-es': 'Your E-mail address was not recognized', 'pl': 'TwÃ³j adres mailowy nie zostaÅ‚ rozpoznany' },
		5: { 'en-us': 'The password you have entered is incorrect', 'en-eu': 'The password you have entered is incorrect', 'en-sc': 'The password you have entered is incorrect', 'en-za': 'The password you have entered is incorrect', 'en-au': 'The password you have entered is incorrect', 'es-es': 'The password you have entered is incorrect', 'pl': 'The password you have entered is incorrect' },
		6: { 'en-us': 'Your account has not been confirmed', 'en-eu': 'Your account has not been confirmed', 'en-sc': 'Your account has not been confirmed', 'en-za': 'Your account has not been confirmed', 'en-au': 'Your account has not been confirmed', 'es-es': 'Your account has not been confirmed', 'pl': 'Your account has not been confirmed' },
		7: { 'en-us': 'Provide password as parameter', 'en-eu': 'Provide password as parameter', 'en-sc': 'Provide password as parameter', 'en-za': 'Provide password as parameter', 'en-au': 'Provide password as parameter', 'es-es': 'Provide password as parameter', 'pl': 'Provide password as parameter' },
		8: { 'en-us': 'Provide email as parameter', 'en-eu': 'Provide email as parameter', 'en-sc': 'Provide email as parameter', 'en-za': 'Provide email as parameter', 'en-au': 'Provide email as parameter', 'es-es': 'Provide email as parameter', 'pl': 'Provide email as parameter' },
		9: { 'en-us': 'Specify poll_id as a parameter', 'en-eu': 'Specify poll_id as a parameter', 'en-sc': 'Specify poll_id as a parameter', 'en-za': 'Specify poll_id as a parameter', 'en-au': 'Specify poll_id as a parameter', 'es-es': 'Specify poll_id as a parameter', 'pl': 'Specify poll_id as a parameter' },
		10: { 'en-us': 'Error in inserting', 'en-eu': 'Error in inserting', 'en-sc': 'Error in inserting', 'en-za': 'Error in inserting', 'en-au': 'Error in inserting', 'es-es': 'Error in inserting', 'pl': 'Error in inserting' },
		11: { 'en-us': 'Invalid value for questionCount', 'en-sc': 'Invalid value for questionCount', 'en-za': 'Invalid value for questionCount', 'en-au': 'Invalid value for questionCount', 'es-es': 'Error in inserting', 'pl': 'Invalid value for questionCount' },
		12: { 'en-us': 'Provide questionCount as parameter', 'en-eu': 'Provide questionCount as parameter', 'en-sc': 'Provide questionCount as parameter', 'en-za': 'Provide questionCount as parameter', 'en-au': 'Provide questionCount as parameter', 'es-es': 'Invalid value for questionCount as parameter', 'pl': 'Provide questionCount as parameter' },
		13: { 'en-us': 'Error in inserting quiz_result', 'en-eu': 'Error in inserting quiz_result', 'en-sc': 'Error in inserting quiz_result', 'en-za': 'Error in inserting quiz_result', 'en-au': 'Error in inserting quiz_result', 'es-es': 'Error in inserting quiz_result', 'pl': 'Error in inserting quiz_result' },
		14: { 'en-us': 'No matching record found', 'en-eu': 'No matching record found', 'en-sc': 'No matching record found', 'en-za': 'No matching record found', 'en-au': 'No matching record found', 'es-es': 'No matching record found', 'pl': 'No matching record found' },
		15: { 'en-us': 'Provide score as parameter', 'en-eu': 'Provide score as parameter', 'en-sc': 'Provide score as parameter', 'en-za': 'Provide score as parameter', 'en-au': 'Provide score as parameter', 'es-es': 'Provide score as parameter', 'pl': 'Provide score as parameter' },
		16: { 'en-us': 'Invalid quiz type value', 'en-eu': 'Invalid quiz type value', 'en-sc': 'Invalid quiz type value', 'en-za': 'Invalid quiz type value', 'en-au': 'Invalid quiz type value', 'es-es': 'Invalid quiz type value', 'pl': 'Invalid quiz type value' },
		17: { 'en-us': 'Invalid quiz id value', 'en-eu': 'Invalid quiz id value', 'en-sc': 'Invalid quiz id value', 'en-za': 'Invalid quiz id value', 'en-au': 'Invalid quiz id value', 'es-es': 'Invalid quiz id value', 'pl': 'Invalid quiz id value' },
		18: { 'en-us': 'Provide quiz_id as parameter', 'en-eu': 'Provide quiz_id as parameter', 'en-sc': 'Provide quiz_id as parameter', 'en-za': 'Provide quiz_id as parameter', 'en-au': 'Provide quiz_id as parameter', 'es-es': 'Provide quiz_id as parameter', 'pl': 'Provide quiz_id as parameter' },
		19: { 'en-us': 'Missing few questionINDEX as parameter', 'en-eu': 'Missing few questionINDEX as parameter', 'en-sc': 'Missing few questionINDEX as parameter', 'en-za': 'Missing few questionINDEX as parameter', 'en-au': 'Missing few questionINDEX as parameter', 'es-es': 'Missing few questionINDEX as parameter', 'pl': 'Missing few questionINDEX as parameter' },
		20: { 'en-us': 'Error in inserting user_optins', 'en-eu': 'Error in inserting user_optins', 'en-sc': 'Error in inserting user_optins', 'en-za': 'Error in inserting user_optins', 'en-au': 'Error in inserting user_optins', 'es-es': 'Error in inserting user_optins', 'pl': 'Error in inserting user_optins' },
		21: { 'en-us': 'No optins info provided', 'en-eu': 'No optins info provided', 'en-sc': 'No optins info provided', 'en-za': 'No optins info provide', 'en-au': 'No optins info provide', 'es-es': 'No optins info provided', 'pl': 'No optins info provided' },
		22: { 'en-us': 'Error in deleting user_optins data', 'en-eu': 'Error in deleting user_optins data', 'en-sc': 'Error in deleting user_optins data', 'en-za': 'Error in deleting user_optins data', 'en-au': 'Error in deleting user_optins data', 'es-es': 'Error in deleting user_optins data', 'pl': 'Error in deleting user_optins data' },
		23: { 'en-us': 'Error in updating site_user', 'en-eu': 'Error in updating site_user', 'en-sc': 'Error in updating site_user', 'en-za': 'Error in updating site_user', 'en-au': 'Error in updating site_user', 'es-es': 'Error in updating site_user', 'pl': 'Error in updating site_user' },
		24: { 'en-us': 'Site data not found', 'en-eu': 'Site data not found', 'en-sc': 'Site data not found', 'en-za': 'Site data not found', 'en-au': 'Site data not found', 'es-es': 'Site data not found', 'pl': 'Site data not found' },
		25: { 'en-us': 'Email and Username already registered', 'en-eu': 'Email and Username already registered', 'en-sc': 'Email and Username already registered', 'en-za': 'Email and Username already registered', 'en-au': 'Email and Username already registered', 'es-es': 'Email and Username already registered', 'pl': 'Email and Username already registered' },
		26: { 'en-us': 'Email already registered', 'en-eu': 'Email already registered', 'en-sc': 'Email already registered', 'en-za': 'Email already registered', 'en-au': 'Email already registered', 'es-es': 'Email already registered', 'pl': 'Email already registered' },
		27: { 'en-us': 'Username already registered', 'en-eu': 'Username already registered', 'en-sc': 'Username already registered', 'en-za': 'Username already registered', 'en-au': 'Username already registered', 'es-es': 'Username already registered', 'pl': 'Username already registered' },
		28: { 'en-us': 'Error inserting user_optins', 'en-eu': 'Error inserting user_optins', 'en-sc': 'Error inserting user_optins', 'en-za': 'Error inserting user_optins', 'en-au': 'Error inserting user_optins', 'es-es': 'Error inserting user_optins', 'pl': 'Error inserting user_optins' },
		29: { 'en-us': 'No category record found', 'en-eu': 'No category record found', 'en-sc': 'No category record found', 'en-za': 'No category record found', 'en-au': 'No category record found', 'es-es': 'No category record found', 'pl': 'No category record found' },
		30: { 'en-us': 'Error inserting site_user', 'en-eu': 'Error inserting site_user', 'en-sc': 'Error inserting site_user', 'en-za': 'Error inserting site_use', 'en-au': 'Error inserting site_use', 'es-es': 'Error inserting site_user', 'pl': 'Error inserting site_user' },
		31: { 'en-us': 'Provide email as Parameter', 'en-eu': 'Provide email as Parameter', 'en-sc': 'Provide email as Parameter', 'en-za': 'Provide email as Parameter', 'en-au': 'Provide email as Parameter', 'es-es': 'Provide email as Parameter', 'pl': 'Provide email as Parameter' },
		32: { 'en-us': 'Error sending email', 'en-eu': 'Error sending email', 'en-sc': 'Error sending email', 'en-za': 'Error sending email', 'en-au': 'Error sending email', 'es-es': 'Error sending email', 'pl': 'Error sending email' },
		33: { 'en-us': 'Email address is not valid', 'en-eu': 'Email address is not valid', 'en-sc': 'Email address is not valid', 'en-za': 'Email address is not valid', 'en-au': 'Email address is not valid', 'es-es': 'Email address is not valid', 'pl': 'TwÃ³j adres mailowy jest niewaÅ¼ny' },
		34: { 'en-us': 'Error in updating password', 'en-eu': 'Error in updating password', 'en-sc': 'Error in updating password', 'en-za': 'Error in updating password', 'en-au': 'Error in updating password', 'es-es': 'Error in updating password', 'pl': 'Error in updating password' },
		35: { 'en-us': 'Provide username/email and site_id as parameter', 'en-eu': 'Provide username/email and site_id as parameter', 'en-sc': 'Provide username/email and site_id as parameter', 'en-za': 'Provide username/email and site_id as parameter', 'en-au': 'Provide username/email and site_id as parameter', 'es-es': 'Provide username/email and site_id as parameter', 'pl': 'Provide username/email and site_id as parameter' },
		37: { 'en-us': 'Error in inserting data', 'en-eu': 'Error in inserting data', 'en-sc': 'Error in inserting data', 'en-za': 'Error in inserting data', 'en-au': 'Error in inserting data', 'es-es': 'Error in inserting data', 'pl': 'Error in inserting data' },
		38: { 'en-us': 'Specify email,scheduleid,hours,name and timezone as parameters', 'en-eu': 'Specify email,scheduleid,hours,name and timezone as parameters', 'en-sc': 'Specify email,scheduleid,hours,name and timezone as parameters', 'en-za': 'Specify email,scheduleid,hours,name and timezone as parameters', 'en-au': 'Specify email,scheduleid,hours,name and timezone as parameters', 'es-es': 'Specify email,scheduleid,hours,name and timezone as parameters', 'pl': 'Specify email,scheduleid,hours,name and timezone as parameters' },
		39: { 'en-us': 'No record for tvschedule found', 'en-eu': 'No record for tvschedule found', 'en-sc': 'No record for tvschedule found', 'en-za': 'No record for tvschedule found', 'en-au': 'No record for tvschedule found', 'es-es': 'No record for tvschedule found', 'pl': 'No record for tvschedule found' },
		40: { 'en-us': 'Provide category_id and count as parameters', 'en-eu': 'Provide category_id and count as parameters', 'en-sc': 'Provide category_id and count as parameters', 'en-za': 'Provide category_id and count as parameters', 'en-au': 'Provide category_id and count as parameters', 'es-es': 'Provide category_id and count as parameters', 'pl': 'Provide category_id and count as parameters' },
		41: { 'en-us': 'Unknown error', 'en-eu': 'Unknown error', 'en-sc': 'Unknown error', 'en-za': 'Unknown error', 'en-au': 'Unknown error', 'es-es': 'Unknown error', 'pl': 'Unknown error' }
	};
	function compareDefaultTz(tz) {
		var defaultValue = getMetaValue('defaultTimeZone').split('GMT')[1];
		tz = tz.split('GMT')[1];
		defaultValue = parseFloat(defaultValue.replace(':', '.'));
		tz = parseFloat(tz);
		if (defaultValue == tz) {
			return 'same';
		} else if (defaultValue > tz) {
			return 'next';
		} else if (defaultValue < tz) {
			return 'previous';
		} else {
			return null;
		}
	};	
	var dataManager = new function () {
		var cbMap = {};
		var dataMap = {};
		function callback(url) {
			while (cbMap[url].length > 0)
				cbMap[url].shift()(dataMap[url]);
		};
		function retrieve(url, options) {
			if (options) {
				options.onComplete = update.bindAsEventListener(this, url);
				new Ajax.Request(url.split('?')[0], options);
			} 
			else
				new Ajax.Request(url, { onComplete: update.bindAsEventListener(this, url) });
		};
		function update(resp, url) {
			dataMap[url]=resp; callback(url);
		};
		this.emptyCache = function (url) {
			if(dataMap[url]) dataMap[url] = null;
		};
		this.register = function (urls, cb, options) {
			if (urls.constructor == String)
				urls = [urls];
			if (urls.constructor == Array && urls.length && typeof cb == 'function') {
				var url = '';
				for (var i = 0; i < urls.length; i++) {
					url = urls[i];
					if (options) {
						var params = '';
						if (options.method)
							params += 'method='+options.method+'&';
						if (options.parameters)
							params += 'parameters='+options.parameters+'&';
						if (params != '')
							url += '?'+params;
					}
					if (!dataMap[url]) {
						dataMap[url] = 'retrieving';
						retrieve(url, options);
					}
					if (!cbMap[url])
						cbMap[url] = new Array;
					if(typeof dataMap[url] == 'string')
						cbMap[url].push(cb);
					else
						cb(dataMap[url]);
				}
			}
		};
	};	
	function translate(phrase) {
		var translations = {
			'new': { 'pl': 'new', 'es-es': 'new', 'en-au': 'new', 'en-za': 'new', 'en-sc':'new', 'en-eu':'new', 'en-us':'new' }
		};
		phrase = phrase.toLowerCase();
		return (translations[phrase] && translations[phrase][getMetaValue('default-locale')]) || '';
	}
	
	
		// timeValue is time value xx:xx
function determine12HourClock(timeValue) {
	var clock12 = "0";
	
	if(getMetaValue('tz_format')) {
		clock12 = getMetaValue('tz_format');
	}
	
	if(clock12=="0") {
		return timeValue;
	}
	else {
		var AmPM = "am";
		if(timeValue.substring(0,1)=="1" || timeValue.substring(0,1)=="2") {
			var timeValueInt = timeValue.substring(0,2) - 0;
			if (timeValueInt >12) {
      			timeValueInt = timeValueInt - 12;
      			AmPM = "pm";
    		} else {
				timeValueInt = timeValueInt;
      			AmPM = "am";
			}
			if (timeValueInt == 12) {
      			AmPM = "pm";
    		}
			return timeValueInt + timeValue.substring(2,5) + " " + AmPM;
		} else {
			if(timeValue.substring(0,2)=="00") {
				timeValue = "12" + timeValue.substring(2,timeValue.length);
				return timeValue + " " + AmPM;
			}
			else {
				timeValue = timeValue.substring(1,timeValue.length);
				return timeValue + " " + AmPM;
			}
		}
	}

};
	
function stripTags(originalString) {
		if ( originalString ) {
			var regex_tags = /<\/?[^>]+(>|$)/g;
			var strippedString = originalString.replace(regex_tags,'');
			return strippedString;
		}
		else
			return '';
};