var vPlayer = function(){
    this.stageW;
    this.stageH;
    this.flashvars = {
imagePath:null,videoPath:null,
title:null,description:null,viewInfoButton:"true",viewFullscreenButton:"true",viewScaleButton:"true",viewVolumeControls:"true",viewTime:"true",viewBigPlayButton:"true",viewRightClickMenu:"true",mouseHide:"true",mouseHideTime:"3",doubleClick:"true",oneClick:"true",spaceKey:"true",videoLoop:"true",videoAutoPlay:"false",videoBufferTime:"0.1",tlInterval:"100000",soundVolume:"0.8",fullSizeView:"3",spacing:"10",controlHeight:"25",volumeLengthW:"50",color1:"0x2e2e2e",color2:"0x000000",alpha1:"1",alpha2:"1",borderColor:"0x555555",borderAlpha:"1",timeColor1:"0x333333",timeColor2:"0x111111",timeAlpha1:"1",timeAlpha2:"1",timeTextColor1:"0xffffff",timeTextColor2:"0x888888",scrubberHeight:"3",scrubberColor1:"0x333333",scrubberAlpha1:"1",scrubberColor2:"0x47d2ff",scrubberAlpha2:"1",filterColor:"0x0066ff",filterAlpha:"1",titleColor:"0x47d2ff",descriptionColor:"0xD3D3D3",infoBackgroundColor:"0x000000",infoBackgroundAlpha:"0.5"},
    this.params = {
	scale:"noscale",
	allowfullscreen:"true",
	salign:"tl",
	bgcolor: "000000",
	wmode: "window"
    },
    this.attributes = {wmode: "window"};
    this.run = function(name,width,height){
	swfobject.embedSWF("/Service/video-player.swf", name, width, height, "9.0.0", false, this.flashvars, this.params, this.attributes);
//	swfobject.embedSWF("/Service/video-player.swf", name, this.stageW, this.stageH, "9.0.0", false, this.flashvars, this.params, this.attributes);
    }
}

function ClickVideo(name,width,height,videoURL,imageURL,auto){
	if (!auto) auto = 'true';
	var o = new vPlayer;
	o.flashvars.imagePath = imageURL;
	o.flashvars.videoPath = videoURL;
	o.flashvars.videoAutoPlay= auto;
	o.run(name,width, height);
}


$(document).ready(function(){
	if ($("#onevideo[psrc]").length){
	    if ($("#onevideo[psrc]").attr("psrc").search(/\.wmv$/i)!=-1)
		ClikWmv("onevideo",379,276,$("#onevideo").attr("psrc"),$("#onevideo").attr("pimg"),'false');
	    else
		ClickVideo("onevideo",379,276,$("#onevideo").attr("psrc"),$("#onevideo").attr("pimg"),'false');
	}
});
function BigVideoOur(contid,id, width, height){
	var name="videocontain"+contid;
        $("#"+name).append('<div id="videoplayer"></div>');
        $("#videoplayer").css("z-index","10000");
        $("object").css("display","none");
        $("#videoplayer").dialog({
    	    position: ["center","center"],
    	    close: function(event, ui) {
    		$(this).dialog("destroy");
    		$(this).remove();
    		$("object").css("display","");
    	    },
    	    width: 640,
    	    height: 510,
    	    resizable: false,
    	    modal: true,
    	    stack: true,
    	    zIndex: 10000,
    	    dialogClass: "dialog"
        });
        $("#videoplayer").dialog('moveToTop');
    	
//        $.post("/Service/getvideo.php",{id: id,width:width,height:height}
	setTimeout(function(){
        $.ajax({
    	    url:"/Service/getvideo.php",
    	    data:	"id="+id+"&width="+width+"&height"+height+"&rand="+Math.random(),
    	    dataType: "text",
    	    async: false,
    	    success: function(msg){
    		if (msg.search(/<object/)!=-1){
    		    $("#videoplayer").html(msg);
    		}
    		if (msg.search(/^http:\/\//i)!=-1){
    		    if (msg.search(/\.wmv$/i)!=-1){
    			ClikWmv("videoplayer", 640,510, msg, '');
    		    }else{
    			ClickVideo("videoplayer",640,510,msg,'','true');
    		    }
    		}
    	    }
        });
        },700);
        
        
}

function BigVideo(id){
        var ids = "videocontain"+id;
        var copy = $("#"+ids).html();
        $("#"+ids+" .object").dialog({
    	    position: ["center","center"],
    	    close: function(event, ui) {
    		$(this).dialog("destroy");
    		$("#"+ids).html(copy);
    	    },
    	    buttons: {
    		"Закрыть": function() {
    		    $(this).dialog("destroy");
    		    $("#"+ids).html(copy);
    		}
    	    },
    	    width: 640,
    	    height: 510,
    	    resizable: false,
    	    modal: true,
    	    dialogClass: "dialog"
        });
}
$(document).ready(function(){
    var originalSizes = new Array();
    
    var width = 0;
    $(".listinteres ul").children().each(function(e){
	width = width + $(this).width()
    });
    width = width + 10;
    $(".listinteres ul").width(width);
    $('.moreinteres .controles a').click(function(){
	var pos = $(this).parent().attr('pos'), max = $(this).parent().attr('maxpos') ;
	if ($(this).hasClass("pgr_gt")){
	    if (pos == 0) $(this).parent().children(".dis_lt").addClass("pgr_lt").removeClass("dis_lt");
	    pos = eval(pos) + 1;
	    if (pos == max) $(this).addClass("dis_gt").removeClass("pgr_gt");
	}else if ($(this).hasClass("pgr_lt")){
	    if (pos == 1) $(this).addClass("dis_lt").removeClass("pgr_lt");
	    pos = eval(pos) - 1;
	    if (pos == (max-1)) $(this).parent().children(".dis_gt").addClass("pgr_gt").removeClass("dis_gt");
	}
	$(".listinteres").scrollTo("li:eq("+pos+")","slow");
	$('.moreinteres .controles').attr('pos',pos);
	return false;
    });
})
function ClikWmv(idname, width, height, videourl, image){
    var fobj = '<object classid="clsid:6bf52a52-394a-11d3-b153-00c04f79faa6" width="'+width+'" height="'+height+'" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"><param name="url" value="'+videourl+'" /><embed type="application/x-mplayer2" width="'+width+'" height="'+height+'" src="'+videourl+'" url="'+videourl+'"></embed></object>';
    $("#"+idname).html(fobj);
}

/*GNU GPL*/ 

