
// get domain host
var host = top.location.host;

// generic ajax form data capture object
var CapFormData = {
	
	FORM_ID: 'mobForm',
	AREA_TO_UPDATE_ID: 'mobSubmitStatus',
	SUBMIT_URL: 'http://'+ host+'/formsubmit?',
	PROCESSING_TEXT: 'Please wait...',
	SUCCESS_TEXT: 'You have successfully signed up for Hot Hits Alerts!',
	FAILURE_TEXT: 'Sorry, something went wrong! Try again?',
	
	getSubmitUrl: function () {
		var formparams = $(CapFormData.FORM_ID).toQueryString();
		var submiturl = CapFormData.SUBMIT_URL + formparams;
		// console.log('NEW URL YOYOYO', submiturl);
		return submiturl;
	},
	
	validate: function () {
		var data = $('mobInput').value;
		if (data.test(/04\d/)) {
			return true;
		} else {
			$(CapFormData.AREA_TO_UPDATE_ID).setText('Please enter a valid mobile number!');
			return false;
		}
	},
	
	submit: function () {
		
		if (!CapFormData.validate()) return false;
		
		var captureDataAjax = new Ajax (CapFormData.getSubmitUrl(), {
			method: 'get',
			getHeader: true,
			onRequest: function() {
				$(CapFormData.AREA_TO_UPDATE_ID).setText(CapFormData.PROCESSING_TEXT);
			},
			onComplete:	function(){
				$(CapFormData.AREA_TO_UPDATE_ID).setText(CapFormData.SUCCESS_TEXT);
			},
			onFailure: function() {
				$(CapFormData.AREA_TO_UPDATE_ID).setText(CapFormData.FAILURE_TEXT);
			}
		});	
		captureDataAjax.request();
	}
	
};

function hideFlashElements () {
    var items = $$('.flash');
    $each(items, function (item) {
      item.setStyle('visibility', 'hidden');
    }); 
}

function showFlashElements () {
  setTimeout(function () {
    var items = $$('.flash');
    $each(items, function (item) {
      item.setStyle('visibility', 'visible');
    });
  },500);
  
}

window.addEvent('load', function () { 
	
	if ($('txthelp')) {
		var txthelp = new AscDialog({ isModal:true, classPrefix: 'popup tc_', maskOpacity: 0.6 });
    txthelp.set_contents('<h2>Having Trouble</h2><p>Click on the link in the message to go straight to the action. If your message does not display a link some handsets will display "go to" at the base of the screen simply hit corresponding button on your keypad.</p>');
    $('txthelp').addEvent('click', function (e) {
      if(e) e = new Event(e).stop();
      hideFlashElements();
      txthelp.show();
    });
	}
	
	if ($('faqs')) {
		var faqs = new AscDialog({ isModal:true, classPrefix: 'popup tc_', maskOpacity: 0.6 });
	  faqs.set_contents('<h2>FAQ</h2><p><strong>Q: How do I to access The Hot Hits Live from LA on my mobile?</strong> SMS "HITS" to 966 or go to Optus Zoo on your handset then browse to the Hot Hits Live from LA.</p><p><strong>Q: Is my mobile compatible?</strong> To access The Hot Hits Live from LA you need a GRPS compatible phone, which will allow you to access Optus Zoo and the Hot Hits site.  To view the Hot Hits videos, your mobile must also be 3G/dual band and video capable.</p><p><strong>Q: How do I get Optus Zoo settings on my handset?</strong> Go to Optus Zoo and follow the <a href="http://mobile.optuszoo.com.au/cocoon/cgi-bin/info2you/static_file/display_file.cgi?file=mymobile-setup.html&node_id=30040" rel="external">steps</a>.</p><p><strong>Q: How do I get my alerts?</strong> Alerts are sent as WAP push messages, and they are usually received in your messaging inbox. However, this can differ with different handset models.</p><p><strong>Q: When do I get my alerts?</strong> You will get an alert when the video show is ready to watch (Tuesdays & Fridays) and also when the radio show is ready to listen to. If we have any special coverage (like Grammy&#39;s, Arias) you will also get an alert.</p><p><strong>Q: What happens when I send "HITS" to 966?</strong> You get a service message which contains a link that you should select and click on. This will take you to the Hot Hits Live from LA homepage.</p><p><strong>Q: How do I stop the alerts? </strong><br /> You can visit the My Alerts section on the mobile site and cancel your alerts from there or alternatively you can send "STOP" to 19728364</p><p><strong>Q: I cannot find the service message, where is it?</strong> Depending on the type of handset, you would get the service message either in the messaging inbox folder or in the service inbox folder.</p><p><strong>Q: Can I preview songs online before I buy them?</strong> Yes. You can listen to a preview of the song for free before you buy it.</p><p><strong>Q: Does the customer need to be in a particular coverage area to use these services?</strong> Yes they need to be within a 3G/dual band coverage area to enjoy the Hot Hits Live from LA video service.  For coverage details see www.optus.com.au/coverage. However for everything else, 2G coverage is sufficient.</p><p><strong>Q: Can I pause and resume play for any of the video and audio content?</strong> No you cannot pause and play any of the video and audio content. Once you stop the playing of the audio or video content, you will have to reconnect again and the content will start showing from the beginning.</p>');
    $('faqs').addEvent('click', function (e) {
      if(e) e = new Event(e).stop();
      hideFlashElements();
      faqs.show();
    });
	}
	
	if ($('features')) {
		var features = new AscDialog({ isModal:true, classPrefix: 'popup tc_', maskOpacity: 0.6 });
    features.set_contents('<h2>What content is available on my handset?</h2><table id="mobilePhonesTable" cellspacing="0" cellpadding="0"><tr><td></td><td>3G handset<br /> (Excludes iphone 3G)</td><td>2G handset</td></tr><tr><td>Video Show</td><td><img src="/images/mobile/icon_tick.gif" alt="Tick" /></td><td><span style="float:left; margin-right:4px; margin-top:3px;"><img src="/images/mobile/icon_cross.gif" alt="Cross" /></span> (Audio Only)</td></tr><tr><td>Weekly Radio Show</td><td><img src="/images/mobile/icon_tick.gif" alt="Tick" /></td>  <td><img src="/images/mobile/icon_tick.gif" alt="Tick" /></td></tr><tr><td>The Hot Hits Live from LA Chart</td><td><img src="/images/mobile/icon_tick.gif" alt="Tick" /></td><td><img src="/images/mobile/icon_tick.gif" alt="Tick" /></td></tr><tr><td>Entertainment News</td><td><img src="/images/mobile/icon_tick.gif" alt="Tick" /></td><td><img src="/images/mobile/icon_tick.gif" alt="Tick" /></td></tr><tr><td>Who\'s Hot</td><td><img src="/images/mobile/icon_tick.gif" alt="Tick" /></td><td><img src="/images/mobile/icon_tick.gif" alt="Tick" /></td></tr><tr><td>Artist Pics - Wallpapers</td><td><img src="/images/mobile/icon_tick.gif" alt="Tick" /></td><td><img src="/images/mobile/icon_tick.gif" alt="Tick" /></td></tr><tr><td>Purchase music tracks &amp; ringtones</td><td><img src="/images/mobile/icon_tick.gif" alt="Tick" /></td><td><img src="/images/mobile/icon_tick.gif" alt="Tick" /></td></tr></table></p>');
    $('features').addEvent('click', function (e) {
      if(e) e = new Event(e).stop();
      hideFlashElements();
      features.show();
    });
	}
		
	if ($('tcs')) {
		var tcs = new AscDialog({ isModal:true, classPrefix: 'popup tc_', maskOpacity: 0.6 });
   	tcs.set_contents('<h2>Terms &amp; Conditions</h2>SMS to 966: No charges apply to SMS 966.  Your handset must be compatible to receive a WAP push message.  When you SMS "HITS" to 966 you will automatically receive a free weekly alert to advise of new content available on the Hot Hits Mobile site.  There is no charge to receive the alert. Optus Pre-Paid mobile customer will be charged a Flagfall of 22c to  click on the link in the alerts and access the Hot Hits Mobile homepage  The Hot Hits Mobile site: Your handset must be 3G and video-capable to access The Hot Hits video service and GPRS compatible to access the remainder of the site.  Standard data browsing and downloading charges apply to access some areas of the Hot Hits Mobile site and to to navigate to Hot Hits from Optus Zoo main menu. Full terms and conditions available at <a href="http://www.optuszoo.com.au/mobile" rel="external">www.optuszoo.com.au/mobile</a>');
   	$('tcs').addEvent('click', function (e) {
     	if(e) e = new Event(e).stop();
     	hideFlashElements();
     	tcs.show();
   	});
	}
	
	if ($('txthelp')) {
		var txthelp = new AscDialog({ isModal:true, classPrefix: 'popup tc_', maskOpacity: 0.6 });
    txthelp.set_contents('<h2>Having Trouble</h2><p>Click on the link in the message to go straight to the action. If your message does not display a link some handsets will display "go to" at the base of the screen simply hit corresponding button on your keypad.</p>');
    $('txthelp').addEvent('click', function (e) {
      if(e) e = new Event(e).stop();
      hideFlashElements();
      txthelp.show();
    });
	}     

  $$('div[class$=_Close] a').addEvent('click', function (e) {
     showFlashElements();
   });

});


// DD_belatedPNG definitions for mobile page
if (typeof DD_belatedPNG != 'undefined') { DD_belatedPNG.fix('#body, #titleHolder'); }