function CheckHTML5Browser(){
	if(navigator.userAgent.indexOf('iPad')>-1 || navigator.userAgent.indexOf('iPhone')>-1) return true;
	else return false;
}

function SetHTML5Player(object_id,src,w,h,auto){
    var out="<video src='/iphone/"+src+".mp4' height='"+h+"' width='"+w+"' autoplay='autoplay' controls='controls'></video>";
    document.getElementById(object_id).innerHTML=out;
}


function LoadTrailer1(user_id, object_id, playlist_id, image, w, h){
	$.get('/_ajax.php', {mode: "user_trailer_show", user_id: user_id, video_id: playlist_id}, function(data) {
    	if (data == 'ok') {
            getFlashPlayer(object_id,playlist_id,image,w,h);
        }
    });
}
function LoadTrailer2(activeuser_id, object_id, playlist_id, image, w, h){
	$.get('/_ajax.php', {mode: "activeuser_trailer_show", activeuser_id: activeuser_id, video_id: playlist_id}, function(data) {
    	if (data == 'ok') {
            getFlashPlayer(object_id,playlist_id,image,w,h);
        }else if (data == 'need_register'){        	document.getElementById('video_place').style.display='none';
        	document.getElementById('trailer_need_register').style.display='block';
        }
    });

}

function getFlashPlayer(id,playlist_id,image,w,h){
	var flashvars = {
		file: "http://www.pornokino.ru/playlist-"+playlist_id+".xml",
		image: image,
		streamer: "lighttpd",
		bufferlength: "1",
		config: "http://www.pornokino.ru/plugins/config.xml",
		stretching: "uniform",
		/*stretching: "exactfit",*/
		autostart: "true"
	};

	var params = {
		movie: "http://www.pornokino.ru/plugins/flashplayer_v42.swf",
		allowfullscreen: "false",
		allowscriptaccess: "always",
		wmode: "transparent"
	};
	var attributes = {
		id: id,
		name: id,
		classid: "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
		width: w,
		height: h,
		type: "application/x-shockwave-flash"
	};

    if(CheckHTML5Browser()){
    	SetHTML5Player(id,playlist_id,w,h,'false');
    }else{
    	swfobject.embedSWF("http://www.pornokino.ru/plugins/flashplayer_v42.swf", id, w, h, "9.0.0", null, flashvars, params, attributes);
    }
}


