javascript:var req = new XMLHttpRequest();
req.open('GET', document.location, false);req.send(null);
var headers = req.getAllResponseHeaders().toLowerCase();
//alert(headers);  
			

function is_mobile_browser() {
	//headers = isset(headers) ? headers : '';
	
	var mobile_browser = '0';
 
	if((navigator.userAgent).toLowerCase().match('(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|iphone|ipad|ipod|android|xoom)'))
		mobile_browser++;
			 
	var mobile_ua = (navigator.userAgent).substr(0,4).toLowerCase();
	var mobile_agents = new Array(
						'w3c ','acs-','alav','alca','amoi','audi','avan','benq','bird','blac',
						'blaz','brew','cell','cldc','cmd-','dang','doco','eric','hipt','inno',
						'ipaq','java','jigs','kddi','keji','leno','lg-c','lg-d','lg-g','lge-',
						'maui','maxo','midp','mits','mmef','mobi','mot-','moto','mwbp','nec-',
						'newt','noki','oper','palm','pana','pant','phil','play','port','prox',
						'qwap','sage','sams','sany','sch-','sec-','send','seri','sgh-','shar',
						'sie-','siem','smal','smar','sony','sph-','symb','t-mo','teli','tim-',
						'tosh','tsm-','upg1','upsi','vk-v','voda','wap-','wapa','wapi','wapp',
						'wapr','webc','winw','winw','xda','xda-'
						);
 
	if( (jQuery.inArray(mobile_ua, mobile_agents)) != -1)
		mobile_browser++;
 
	if(strpos(headers.toLowerCase(), 'operamini') !== false)
		mobile_browser++;
 
	// Pre-final check to reset everything if the user is on Windows
	if(strpos((navigator.userAgent).toLowerCase(), 'windows') !== false)
		mobile_browser=0;
 
	// But WP7 is also Windows, with a slightly different characteristic
	if(strpos((navigator.userAgent).toLowerCase(), 'windows phone') !== false)
		mobile_browser++;
 
	if(mobile_browser>0)
		return true;
	else
		return false;
}

function strpos (haystack, needle, offset) {
	var i = (haystack + '').indexOf(needle, (offset || 0));
	return i === -1 ? false : i;
}
			
function in_array(string, array) {
	for (var i = 0; i < array.length; i++)
		if(array[i] == string) 
			return true;
	return false;
}


var mobile_browser = is_mobile_browser();



if(mobile_browser) {
var videoList = $("object");

videoList.each(function(i) {

	//get the path
	var temppath = new Array();
	temppath = $(this).html().split(' src="');
	urllength = temppath[1].indexOf('"');
	path = temppath[1].substring(0, urllength)

	if( path.toLowerCase().indexOf('tc-helicon.com/files/flashfiles/player.swf') != -1 ){
		// get the video path
		videopath_i1 = path.indexOf('?file=')+6;
		videopath_i2 = path.indexOf('&amp;image=')-3;
		videopath = path.substring(videopath_i1, videopath_i2)+'mp4';
		// get the image path
		imagepath_i1 = path.indexOf('&amp;image=')+11;
		imagepath_i2 = path.length
		imagepath = path.substring(imagepath_i1, imagepath_i2);
		$(this).before('<video id="banner-video" width="570" height="320" controls poster="http://kidman.itide.dk/tccinema/tc-helicon/'+imagepath+'" onplay="_gaq.push([\'_trackEvent\', \'Embedded Video - html5\', \'Play\', \''+document.URL+'\']);" onpause="_gaq.push([\'_trackEvent\', \'Embedded Video - html5\', \'Pause\', \''+document.URL+'\']);"><source src="http://kidman.itide.dk/tccinema/tc-helicon/'+videopath+'" /></video>');
		$(this).remove();
	}
});
}

