var PeeVeeObject = function(contenturl, usernumber, contentnumber, playsecond, width, height)
{
  this.contenturl = contenturl;
  this.usernumber = usernumber;
  this.contentnumber = contentnumber;
  this.playsecond = playsecond;
  this.width = width;
  this.height = height;

  	this.usernumber48 = 48000000;
	if(this.usernumber != null) {
		this.usernumber48 += Number(this.usernumber);
	}

	this.isiphone = false;
	this.isipad = false;
	this.isandroid = false;
	var useragent = navigator.userAgent;
	if(useragent != null) {
        useragent = useragent.toLowerCase();
        if (useragent.indexOf("ipad") > -1) {
            this.isipad = true;
        } else if(useragent.indexOf("iphone") > -1) {
            this.isiphone = true;
        } else if(useragent.indexOf("android") > -1) {
        	this.isandroid = true;
        	var idx = useragent.indexOf("android") + "android".length;
        	var ver = useragent.substring(idx, idx+2).trim();
        	if(ver == "1") {
            	this.androidver = 1;
        	} else {
            	this.androidver = 2;
        	}
        }
	}
	this.videotype = 0;
	this.domain = "http://douga.zaq.ne.jp";

}

var PVO = PeeVeeObject.prototype;

PVO.write = function()
{
    var tag = '';
    var sdhd = '';
//    if(this.videotype == 2) {
//    	sdhd = "hd";
//    }
    tag = '<div id="videocontainer">';
    if(this.isiphone == true) {
    	tag += '<embed src="' + this.domain + '/img/userimg/' + this.usernumber48 + 'peevee' + this.contentnumber + '_1.jpg' + '" href="' + this.domain + '/userdir/h.264' + '/'  + this.usernumber48 + 'peevee' + this.contentnumber + '.m4v' + '" autohref="' + this.autoplay + '" width="'+this.width+'" height="'+this.height+'" type="video/x-m4v" target="myself" scale="1"></embed>';
    } else if(this.isipad == true) {
    	tag += '<video controls poster="' + this.domain + '/img/userimg/' + this.usernumber48 + 'peevee' + this.contentnumber + '_1.jpg' + '" src="' + this.domain + '/userdir/h.264' + '/' + this.usernumber48 + 'peevee' + this.contentnumber + '.m4v' + '" width="' + this.width + '" height="' + this.height+'">';
    	tag += '</video>';
    } else {
	  tag += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'+this.width+'" height="'+this.height+'" id="pluginplayer" align="middle">';
	  tag += '<param name="allowScriptAccess" value="always" />';
	  tag += '<param name="movie" value="http://douga.zaq.ne.jp/pluginplayerv3.swf?video_id='+this.contenturl+'" />';
	  tag += '<param name="quality" value="high" />';
	  tag += '<param name="bgcolor" value="#cccccc" />';
	  tag += '<embed src="http://douga.zaq.ne.jp/pluginplayerv3.swf?video_id='+this.contenturl+'" quality="high" bgcolor="#cccccc" width="'+this.width+'" height="'+this.height+'" name="pluginplayer" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">';
	  tag += '</embed>';
	  tag += '</object>';
	  tag += '<img src="http://blog.peevee.tv/cgi-bin/zaq/acclog.cgi?';
	  tag += 'referrer='+document.referrer+'&';
	  tag += 'width='+screen.width+'&';
	  tag += 'height='+screen.height+'&';
	  tag += 'color='+screen.colorDepth+'">';
	  tag += '<img src="http://douga.zaq.ne.jp/externalcounter.jspx?Usernumber='+this.usernumber+'&Contentnumber='+this.contentnumber+'">';
    }
    tag += '</div>';
    document.write(tag);

}

