function CreateALLVideo(Width,Height) {
    $('div[@name=VideoContainer]').each( function() {
	CreateVideoMain(this.id, this.innerHTML,Width,Height);
    });
}

function CreateSingleVideo(Width,Height) {
    $('div[@name=VideoContainerSingle]').each( function() {
	CreateVideoMain(this.id, this.innerHTML,Width,Height);
    });
}


function CreateVideoMain(VideoPlayerContainer, VideoURL, Width,Height) {
    VideoId = new SWFObject(VideoURL, 'ply', Width, Height, '9', '#FFFFFF');
    VideoId.addParam('allowfullscreen', 'true');
    VideoId.addParam('wmode', 'transparent');    
    VideoId.addParam('allowscriptaccess', 'always');
    VideoId.addParam('flashvars', '');
    VideoId.write(VideoPlayerContainer);
}

function EditVideoContainer(videoId,editStatus){
    if(editStatus){
	
        $('#viewVideoName' + videoId).hide();
        $('#editVideoName' + videoId).show(); 
        $('#viewVideoDate' + videoId).hide();  
        $('#previewButton' + videoId).show(); 
        $('#editButton' + videoId).hide();  
        $('#deleteButton' + videoId).hide();       
        $('#saveButton' + videoId).show();
        $('#VideoNameContainer' + videoId).show();
        
        
    }else{
        $('#viewVideoName' + videoId).show();
        $('#editVideoName' + videoId).hide(); 
        $('#viewVideoDate' + videoId).show();  
        $('#previewButton' + videoId).hide();   
        $('#editButton' + videoId).show();  
        $('#deleteButton' + videoId).show();
        $('#saveButton' + videoId).hide();  
        $('#VideoNameContainer' + videoId).hide();
    }
}

function newVideoCreate() {
    if($('#videoUrl').val().length > 20){
	$('#VideoUploadTool').hide(); 
	xajax_Video_ParseUrl('NewVideoContainer',$('#videoUrl').val()); 
    }
}

function videolinkTextClick(){
    var nowText = $("#videoUrl").val();
    if(nowText == "http://"){
	$("#videoUrl").val('');	
    }
}


function videolinkTextChange(){
    var nowText = $("#videoUrl").val();
    if(nowText.substring(0,4) != 'http'){
	$("#videoUrl").val('http://');
    }
    
}

function video_PageSectionSave(Id,Process){
    if(Process == 'Edit'){
	xajax_Video_PageSectionEdit(Id,$("#editVideoName" + Id).val());
	$("#viewVideoName" + Id).html($("#editVideoName" + Id).val());
	EditVideoContainer(Id,false);
    }else if(Process == 'New'){
	xajax_Video_PageSectionCreateSave($("#videoUrl").val(),$("#videoName").val());
    }
}




var VideoPage = true;