var jsHTML = window.jsHTML || {};

jsHTML.weatherLocation = function(_this) {
	$("body").createAppend('div', {id:'changeMyLocation', className: 'popupBox', style: 'left: ' + ($(_this).offset().left - 430) + 'px; top: 25px; display: none;'}, [
		'div', {className:'title'}, 'Change your weather location',
		'a', {className: 'close', href: '#'}, 'CLOSE',
		'div', {className:'btnHolder'}, [
			'a', {className: 'btnAZ', href: '#'}, 'A-Z',
			'span', {}, '|',
			'a', {className: 'btnIslands selected', href: '#'}, 'North - South'
		],
		'div', {className:'content'}, [
				'div', {className:'group selected'}, [
					'div', {className:'subTitle'}, 'North Island',
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeather', value: 'Kaitaia', id: 'a_Kaitaia'},,
						'span', {}, 'Kaitaia'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeather', value: 'Gisborne', id: 'a_Gisborne'},,
						'span', {}, 'Gisborne'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeather', value: 'Dargaville', id: 'a_Dargaville'},,
						'span', {}, 'Dargaville'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeather', value: 'Napier', id: 'a_Napier'},,
						'span', {}, 'Napier'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeather', value: 'Paihia', id: 'a_Paihia'},,
						'span', {}, 'Paihia/Russell'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeather', value: 'Hastings', id: 'a_Hastings'},,
						'span', {}, 'Hastings'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeather', value: 'Whangarei', id: 'a_Whangarei'},,
						'span', {}, 'Whangarei'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeather', value: 'New_Plymouth', id: 'a_New_Plymouth'},,
						'span', {}, 'New Plymouth'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeather', value: 'Auckland', id: 'a_Auckland'},,
						'span', {}, 'Auckland'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeather', value: 'Palmerston_North', id: 'a_Palmerston_North'},,
						'span', {}, 'Palmerston North'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeather', value: 'Thames', id: 'a_Thames'},,
						'span', {}, 'Thames'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeather', value: 'Wanganui', id: 'a_Wanganui'},,
						'span', {}, 'Wanganui'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeather', value: 'Te_Kuiti', id: 'a_Te_Kuiti'},,
						'span', {}, 'Te Kuiti'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeather', value: 'Taumarunui', id: 'a_Taumarunui'},,
						'span', {}, 'Taumarunui'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeather', value: 'Hamilton', id: 'a_Hamilton'},,
						'span', {}, 'Hamilton'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeather', value: 'Dannevirke', id: 'a_Dannevirke'},,
						'span', {}, 'Dannevirke'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeather', value: 'Taupo', id: 'a_Taupo'},,
						'span', {}, 'Taupo'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeather', value: 'Masterton', id: 'a_Masterton'},,
						'span', {}, 'Masterton'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeather', value: 'Tokoroa', id: 'a_Tokoroa'},,
						'span', {}, 'Tokoroa'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeather', value: 'Levin', id: 'a_Levin'},,
						'span', {}, 'Levin'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeather', value: 'Tauranga', id: 'a_Tauranga'},,
						'span', {}, 'Tauranga'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeather', value: 'Paraparaumu', id: 'a_Paraparaumu'},,
						'span', {}, 'Paraparaumu'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeather', value: 'Whakatane', id: 'a_Whakatane'},,
						'span', {}, 'Whakatane'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeather', value: 'Wellington', id: 'a_Wellington'},,
						'span', {}, 'Wellington'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeather', value: 'Rotorua', id: 'a_Rotorua'},,
						'span', {}, 'Rotorua'
					]
				],
				'div', {className:'group selected'}, [
					'div', {className:'subTitle'}, 'South Island',
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeather', value: 'Reefton', id: 'a_Reefton'},,
						'span', {}, 'Reefton'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeather', value: 'Timaru', id: 'a_Timaru'},,
						'span', {}, 'Timaru'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeather', value: 'Westport', id: 'a_Westport'},,
						'span', {}, 'Westport'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeather', value: 'Oamaru', id: 'a_Oamaru'},,
						'span', {}, 'Oamaru'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeather', value: 'Greymouth', id: 'a_Greymouth'},,
						'span', {}, 'Greymouth/Hokitika'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeather', value: 'Dunedin', id: 'a_Dunedin'},,
						'span', {}, 'Dunedin'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeather', value: 'Nelson', id: 'a_Nelson'},,
						'span', {}, 'Nelson'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeather', value: 'Alexandra', id: 'a_Alexandra'},,
						'span', {}, 'Alexandra'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeather', value: 'Motueka', id: 'a_Motueka'},,
						'span', {}, 'Motueka'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeather', value: 'Wanaka', id: 'a_Wanaka'},,
						'span', {}, 'Wanaka'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeather', value: 'Blenheim', id: 'a_Blenheim'},,
						'span', {}, 'Blenheim'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeather', value: 'Queenstown', id: 'a_Queenstown'},,
						'span', {}, 'Queenstown'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeather', value: 'Kaikoura', id: 'a_Kaikoura'},,
						'span', {}, 'Kaikoura'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeather', value: 'Gore', id: 'a_Gore'},,
						'span', {}, 'Gore'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeather', value: 'Christchurch', id: 'a_Christchurch'},,
						'span', {}, 'Christchurch'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeather', value: 'Invercargill', id: 'a_Invercargill'},,
						'span', {}, 'Invercargill'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeather', value: 'Ashburton', id: 'a_Ashburton'},,
						'span', {}, 'Ashburton'
					]
				],
				'div', {className:'groupAll'}, [
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeatherAll', value: 'Alexandra', id: 'b_Alexandra'},,
						'span', {}, 'Alexandra'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeatherAll', value: 'Hamilton', id: 'b_Hamilton'},,
						'span', {}, 'Hamilton'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeatherAll', value: 'Oamaru', id: 'b_Oamaru'},,
						'span', {}, 'Oamaru'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeatherAll', value: 'Te_Kuiti', id: 'b_Te_Kuiti'},,
						'span', {}, 'Te Kuiti'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeatherAll', value: 'Ashburton', id: 'b_Ashburton'},,
						'span', {}, 'Ashburton'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeatherAll', value: 'Hastings', id: 'b_Hastings'},,
						'span', {}, 'Hastings'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeatherAll', value: 'Paihia', id: 'b_Paihia'},,
						'span', {}, 'Paihia/Russell'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeatherAll', value: 'Thames', id: 'b_Thames'},,
						'span', {}, 'Thames'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeatherAll', value: 'Auckland', id: 'b_Auckland'},,
						'span', {}, 'Auckland'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeatherAll', value: 'Invercargill', id: 'b_Invercargill'},,
						'span', {}, 'Invercargill'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeatherAll', value: 'Palmerston_North', id: 'b_Palmerston_North'},,
						'span', {}, 'Palmerston North'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeatherAll', value: 'Timaru', id: 'b_Timaru'},,
						'span', {}, 'Timaru'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeatherAll', value: 'Blenheim', id: 'b_Blenheim'},,
						'span', {}, 'Blenheim'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeatherAll', value: 'Kaikoura', id: 'b_Kaikoura'},,
						'span', {}, 'Kaikoura'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeatherAll', value: 'Paraparaumu', id: 'b_Paraparaumu'},,
						'span', {}, 'Paraparaumu'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeatherAll', value: 'Tokoroa', id: 'b_Tokoroa'},,
						'span', {}, 'Tokoroa'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeatherAll', value: 'Christchurch', id: 'b_Christchurch'},,
						'span', {}, 'Christchurch'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeatherAll', value: 'Kaitaia', id: 'b_Kaitaia'},,
						'span', {}, 'Kaitaia'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeatherAll', value: 'Queenstown', id: 'b_Queenstown'},,
						'span', {}, 'Queenstown'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeatherAll', value: 'Wanaka', id: 'b_Wanaka'},,
						'span', {}, 'Wanaka'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeatherAll', value: 'Dannevirke', id: 'b_Dannevirke'},,
						'span', {}, 'Dannevirke'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeatherAll', value: 'Levin', id: 'b_Levin'},,
						'span', {}, 'Levin'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeatherAll', value: 'Reefton', id: 'b_Reefton'},,
						'span', {}, 'Reefton'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeatherAll', value: 'Wanganui', id: 'b_Wanganui'},,
						'span', {}, 'Wanganui'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeatherAll', value: 'Dargaville', id: 'b_Dargaville'},,
						'span', {}, 'Dargaville'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeatherAll', value: 'Masterton', id: 'b_Masterton'},,
						'span', {}, 'Masterton'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeatherAll', value: 'Rotorua', id: 'b_Rotorua'},,
						'span', {}, 'Rotorua'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeatherAll', value: 'Wellington', id: 'b_Wellington'},,
						'span', {}, 'Wellington'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeatherAll', value: 'Dunedin', id: 'b_Dunedin'},,
						'span', {}, 'Dunedin'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeatherAll', value: 'Motueka', id: 'b_Motueka'},,
						'span', {}, 'Motueka'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeatherAll', value: 'Taumarunui', id: 'b_Taumarunui'},,
						'span', {}, 'Taumarunui'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeatherAll', value: 'Westport', id: 'b_Westport'},,
						'span', {}, 'Westport'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeatherAll', value: 'Gisborne', id: 'b_Gisborne'},,
						'span', {}, 'Gisborne'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeatherAll', value: 'Napier', id: 'b_Napier'},,
						'span', {}, 'Napier'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeatherAll', value: 'Taupo', id: 'b_Taupo'},,
						'span', {}, 'Taupo'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeatherAll', value: 'Whakatane', id: 'b_Whakatane'},,
						'span', {}, 'Whakatane'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeatherAll', value: 'Gore', id: 'b_Gore'},,
						'span', {}, 'Gore'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeatherAll', value: 'Nelson', id: 'b_Nelson'},,
						'span', {}, 'Nelson'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeatherAll', value: 'Tauranga', id: 'b_Tauranga'},,
						'span', {}, 'Tauranga'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeatherAll', value: 'Whangarei', id: 'b_Whangarei'},,
						'span', {}, 'Whangarei'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeatherAll', value: 'Greymouth', id: 'b_Greymouth'},,
						'span', {}, 'Greymouth/Hokitika'
					],
					'div', {className:'rowRadio'}, [
						'input', {type: 'radio', name: 'radioWeatherAll', value: 'New_Plymouth', id: 'b_New_Plymouth'},,
						'span', {}, 'New Plymouth'
					]
				],
				'div', {className:'hr'},,
				'input', {type:'image', src: 'http://images.tvnz.co.nz/tvnz_site_images/images/btnSaveChanges.gif', className: 'button', id: 'changeWeather'},,
		],
		'img', {src: 'http://images.tvnz.co.nz/tvnz_site_images/images/makeHPArrow.gif', height:'9', width:'17', className:'arrow', alt:'Make TVNZ my Homepage'}
	]);
}

jsHTML.makeHomeMozilla = function(_this) {
	$("body").createAppend('div', {id:'makeThisMyHP', className: 'popupBox', style: 'left: ' + ($(_this).offset().left - 320) + 'px; top: 25px; display: none;'}, [
		'div', {className:'title'}, 'How to make TVNZ.co.nz your homepage',
		'a', {className:'close'}, 'CLOSE',
		'div', {className:'content'}, [
			'ol', {}, [
				'li', {}, [
					'a', {href:'http://tvnz.co.nz', title:'Make TVNZ.co.nz your homepage'}, [
						'img', {src: 'http://images.tvnz.co.nz/tvnz_site_images/images/hpIcon.gif', width:'29', height:'29', align:'left', alt:'Make TVNZ.co.nz your homepage'}
					],
					'span', {}, 'Drag this TVNZ icon and drop it onto the "house icon" in the tool bar of the browser'
				],
				'li', {}, [
					'span', {}, 'Select "Yes" from the popup window and you\'re done!'
				]
			],
			'a', {href:'/content/2353278', className:'moreInfo'}, 'More Information'
		],
		'img', {src: 'http://images.tvnz.co.nz/tvnz_site_images/images/makeHPArrow.gif', height:'9', width:'17', className:'arrow', alt:'Make TVNZ my Homepage'}
	]);
}

jsHTML.shareMore = function(_this, _title, _url) {
	$("body").createAppend('div', {id:'shareMore', className: 'popupBox', style: 'left: ' + ($(_this).offset().left - 400) + 'px; top: ' + ($(_this).offset().top + 15) + 'px; display: none;'}, [
		'div', {className:'title'}, 'Share TVNZ stories on some of the most-popular social networking and content sites on the internet.',
		'a', {href: '#', className:'close'}, 'CLOSE',
		'div', {className:'content'}, [
			'a', {href: 'http://del.icio.us/post?url=' + _url + '&title=' + _title, title: 'Bookmark on Delicious', target: '_blank'}, [
				'img', {src: 'http://images.tvnz.co.nz/tvnz_site_images/images/share/shareBoxDelicious.gif', alt:'Delicious'}],
			'a', {href: 'http://digg.com/submit?url=' + _url + '&title=' + _title, title: 'Share on Digg', target: '_blank'}, [
				'img', {src: 'http://images.tvnz.co.nz/tvnz_site_images/images/share/shareBoxDigg.gif', alt:'Digg'}],
			'a', {href: 'http://www.facebook.com/sharer.php?u=' + _url + '&t=' + _title, title: 'Share on Facebook', target: '_blank'}, [
				'img', {src: 'http://images.tvnz.co.nz/tvnz_site_images/images/share/shareBoxFacebook.gif', alt:'Facebook'}],
			'a', {href: 'http://reddit.com/submit?url=' + _url + '&title=' + _title, title: 'Share on Reddit', target: '_blank'}, [
				'img', {src: 'http://images.tvnz.co.nz/tvnz_site_images/images/share/shareBoxReddit.gif', alt:'Reddit'}],
			'a', {href: 'http://technorati.com/faves?add=' + _url, title: 'Share on Technorati', target: '_blank'}, [
				'img', {src: 'http://images.tvnz.co.nz/tvnz_site_images/images/share/shareBoxTechnorati.gif', alt:'Technorati'}],
			'a', {href: 'http://www.newsvine.com/_wine/save?popoff=0&u=' + _url + '&h=' + _title, title: 'Share on Newsvine', target: '_blank'}, [
				'img', {src: 'http://images.tvnz.co.nz/tvnz_site_images/images/share/shareBoxNewsvine.gif', alt:'Newsvine'}],
			'a', {href: 'http://www.stumbleupon.com/submit?url=' + _url + '&title=' + _title, title: 'Share on Stumbleupon', target: '_blank'}, [
				'img', {src: 'http://images.tvnz.co.nz/tvnz_site_images/images/share/shareBoxStumbleupon.gif', alt:'Stumbleupon'}],
			'a', {href: 'http://www.myspace.com/Modules/PostTo/Pages/?u=' + _url + '&t=' + _title, title: 'Share on MySpace', target: '_blank'}, [
				'img', {src: 'http://images.tvnz.co.nz/tvnz_site_images/images/share/shareBoxMyspace.gif', alt:'MySpace'}],
			'a', {href: 'http://www.mixx.com/submit?page_url=' + _url + '&title=' + _title, title: 'Share on Mixx', target: '_blank'}, [
				'img', {src: 'http://images.tvnz.co.nz/tvnz_site_images/images/share/shareBoxMixx.gif', alt:'Mixx'}],
			'a', {href: '#', title: 'Share on Twitter', target: '_blank', id: 'twitterBtn'}, [
				'img', {src: 'http://images.tvnz.co.nz/tvnz_site_images/images/share/shareBoxTwitter.gif', alt:'Twitter'}],
		],
		'img', {src: 'http://images.tvnz.co.nz/tvnz_site_images/images/makeHPArrow.gif', height:'9', width:'17', className:'arrow', alt:'Make TVNZ my Homepage'}
	]);
	$(document).ready(function(){
		$("#twitterBtn").click(function(event){
			twitter_click();
			event.preventDefault();
		});
	});
	
}

jsHTML.objWMP = function(_url, _height, _width, _name, _targetID, _quality) {
	$("#" + _targetID).html(" ");
	if ($.browser.msie) {
		try {
			$("#" + _targetID).createAppend('object', 
				{
					id: _name, name: _name, width: _width, height: _height, 
					type: 'application/x-oleobject', classid: 'CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6',
					data: _url
				}, [
					'param', {name: 'URL', value: _url}, null,
					'param', {name: 'ShowStatusBar', value: 'True'}, null,
					'param', {name: 'AutoStart', value: 'True'}, null,
				]
			);
		} catch (e) {
			// seems to be throwing an "Invalid Argument" error!
		}
		try {
			$("#" + _targetID).createAppend('script', 
					{
						type:"text/jscript",
						'for':_name,
						event:"OpenStateChange(new_state)"
					},
					"davPlayerOpenStateChange(new_state)"
				);
		} catch (e) {
			// seems to be throwing an "Invalid Argument" error!
		}
		try {
			$("#" + _targetID).createAppend('script', 
					{
						type:"text/jscript",
						'for':_name,
						event:"PlayStateChange(new_state)"
					},
					"davPlayerStateChange(new_state)"
				);
	} catch (e) {
		// seems to be throwing an "Invalid Argument" error!
	}
	} else {
		$("#" + _targetID).html(
			'<object id="'+_name+'" name="'+_name+'" width="'+_width+'" height="'+_height+'" type="application/x-mplayer2" data="'+_url+'">' +
			'<param name="URL" value="'+_url+'"/>' +
			'<param name="ShowStatusBar" value="True"/>' +
			'<param name="AutoStart" value="True"/>' + 
			'</object>'
		);
	}

	if (_quality == "low") {
		$("#" + _targetID).createAppend('div', {className: 'wmpControls', style: 'width: ' + _width + 'px;'}, [
			'div', {className: 'wmpControlsInner'}, [
				'a', {className: 'changeQualityHigh', href: '#'}, [
					'img', {src: 'http://images.tvnz.co.nz/tvnz_site_images/images/wmpBaseQualityHighOff.jpg', alt: 'Change Video Quality - High'}, null
				],
				'img', {src: 'http://images.tvnz.co.nz/tvnz_site_images/images/wmpBaseSplit.gif', alt: ' '}, null,
				'a', {className: 'changeToFlash', href: '#'}, [
					'img', {src: 'http://images.tvnz.co.nz/tvnz_site_images/images/wmpBaseFlashOff.jpg', alt: 'Change to Flash'}, null
				],
				'img', {src: 'http://images.tvnz.co.nz/tvnz_site_images/images/wmpBaseSplit.gif', alt: ' '}, null,
				'a', {className: 'changeToFullscreen', href: '#'}, [
				'img', {src: 'http://images.tvnz.co.nz/tvnz_site_images/images/wmpBaseFullscreenOff.jpg', alt: 'Change to full screen'}, null
				]
			]
		]);
	} else {
		$("#" + _targetID).createAppend('div', {className: 'wmpControls', style: 'width: ' + _width + 'px;'}, [
			'div', {className: 'wmpControlsInner'}, [
				'a', {className: 'changeQualityLow', href: '#'}, [
					'img', {src: 'http://images.tvnz.co.nz/tvnz_site_images/images/wmpBaseQualityLowOff.jpg', alt: 'Change Video Quality - Low'}, null
				],
				'img', {src: 'http://images.tvnz.co.nz/tvnz_site_images/images/wmpBaseSplit.gif', alt: ' '}, null,
				'a', {className: 'changeToFlash', href: '#'}, [
					'img', {src: 'http://images.tvnz.co.nz/tvnz_site_images/images/wmpBaseFlashOff.jpg', alt: 'Change to Flash'}, null
				],
				'img', {src: 'http://images.tvnz.co.nz/tvnz_site_images/images/wmpBaseSplit.gif', alt: ' '}, null,
				'a', {className: 'changeToFullscreen', href: '#'}, [
				'img', {src: 'http://images.tvnz.co.nz/tvnz_site_images/images/wmpBaseFullscreenOff.jpg', alt: 'Change to full screen'}, null
				]
			]
		]);
	}
}