
extendsObj(VideoGL,PopupDiv);function VideoGL(objName,projectUrl,userID,redirectTo,spotid)
{if(arguments.length>0)
{this.init(objName,projectUrl,userID,redirectTo,spotid);}}
VideoGL.prototype.config=function()
{this.objNames={'form':'uplForm'+this.timeId,'iframe':'uplIframe_'+this.timeId,'answerFuncName':this.objName+'.answerFunction','video':'video_'+this.timeId,'fileDiv':'filediv_'+this.timeId,'ytDiv':'ytdiv_'+this.timeId,'spanTitle':'spTitle'+this.timeId};};VideoGL.prototype.init=function(objName,projectUrl,userID,redirectTo,spotid)
{VideoGL.superclass.init.call(this,'videoUpload');this.objName=objName;this.projectUrl=projectUrl;this.ajaxPHPScript=projectUrl+'ajax.post.php';this.userID=(userID?userID:0);this.redirectTo=redirectTo;this.id=0;this.spotId=(spotid?spotid:0);this.config();this.setContentDiv();};VideoGL.prototype.showDiv=function(isEdit)
{this.isEdit=(isEdit?true:false);player=$('player1')
if(player){player.style.visibility='hidden';}
VideoGL.superclass.showDiv.call(this);this.changeShowing();};VideoGL.prototype.simpleShowDiv=function()
{VideoGL.superclass.showDiv.call(this);};VideoGL.prototype.hideDiv=function()
{player=$('player1')
if(player){player.style.visibility='visible';}
VideoGL.superclass.hideDiv.call(this);}
VideoGL.prototype.clear=function()
{this.data=null;this.responseText=null;}
VideoGL.prototype.loadVideoId=function(id)
{this.id=id;this.clear();var referenceThis=this;var url=this.projectUrl+'ajax.get.php';new Ajax.Request(url,{method:'get',parameters:{event:'LoadVideo',id:this.id},onSuccess:function(transport)
{referenceThis.responseText=transport.responseText;try
{referenceThis.data=referenceThis.responseText.evalJSON();}catch(e){}
referenceThis.onLoadImage();},onFailure:function(transport)
{alert('Please, check your connection.');}});}
VideoGL.prototype.changeShowing=function()
{document.forms[this.objNames.form].reset();if(this.isEdit)
{$(this.objNames.fileDiv).style.display='none';$(this.objNames.ytDiv).style.display='none';setFormElement(this.objNames.form,'button1','Save');$(this.objNames.spanTitle).update('Edit Video');}
else
{this.id=0;$(this.objNames.fileDiv).style.display='block';$(this.objNames.ytDiv).style.display='block';setFormElement(this.objNames.form,'button1','Add this video');$(this.objNames.spanTitle).update('Upload Your Video');}
setFormElement(this.objNames.form,'id',this.id);}
VideoGL.prototype.onLoadImage=function()
{if(this.data)
{this.showDiv(true);setFormElement(this.objNames.form,'userid',this.data.userid);setFormElement(this.objNames.form,'tags',this.data.tags.join(', '));setFormElement(this.objNames.form,'title',this.data.title);setFormElement(this.objNames.form,'description',this.data.description);setFormElement(this.objNames.form,'spotid',this.data.spotid);}
else
{}}
VideoGL.prototype.saveDiv=function()
{var viewUplImage=new SubmitForm(this.objNames.form,'uploadVideo',this.objNames.answerFuncName);this.wait=new MSGWait(this.objName+'.wait',this.projectUrl);this.wait.showDiv();this.hideDiv();}
VideoGL.prototype.answerFunction=function(responseText)
{if(responseText)
{try
{var data=responseText.evalJSON();}catch(e){}
this.wait.hideDiv();switch(data.event)
{case'uploadVideo':alert(data.message);if(data.type=='OK')
{if(this.redirectTo&&this.userID>0)
{redirect(this.redirectTo);}}
else
{this.simpleShowDiv();}
break;}}};VideoGL.prototype.setContentDiv=function()
{var html='<iframe name="'+this.objNames.iframe+'" width=0 height=0 style="display: none;"></iframe>';html+='<form id="'+this.objNames.form+'" name='+this.objNames.form+' method="POST" action="'+this.ajaxPHPScript+'" enctype="multipart/form-data" target="'+this.objNames.iframe+'">';html+='<input type="hidden" name="event" value="">';html+='<input type="hidden" name="answerFuncName" value="'+this.objNames.answerFuncName+'">';html+='<input type="hidden" name="userid" value="'+this.userID+'">';html+='<input type="hidden" name="MAX_FILE_SIZE" value="209715200" />';html+='<input type="hidden" name="id" value="'+this.id+'">';html+='<input type="hidden" name="spotid" value="'+this.spotId+'">';html+='<div class="title"><b><span id="'+this.objNames.spanTitle+'" style="float: left;">Upload your video</span></b>'
if(this.userID!=0)
{html+='&nbsp;</div>';}
else
{html+='<span style="float: right;"><span style="color: maroon;">You are not logged in.</span> Please, <a class="minilink" style="font-size: 12px;" href="'+this.projectUrl+'logon.php">login</a></span>&nbsp;</div>';}
html+='        <div><label>&nbsp; &nbsp; &nbsp; Video Title:&nbsp;<input type="text" name="title" size="40" maxlength="100"/></label></div>';html+='    <div id="'+this.objNames.fileDiv+'"><label> Select your video (<200Mb): <input type="file" name="videoFile" size="40"> </label></div>';html+='        <div id="'+this.objNames.ytDiv+'"><label> YouTube URL:&nbsp;&nbsp;&nbsp;<input type="text" name="youtube" size="40" maxlength="100"/></label></div>';html+='<div><label> Tags (separated by comma , ) <textarea name="tags" cols="60" rows="2"></textarea> </label></div>';html+='<div><label> Description <textarea name="description" cols="60" rows="4"></textarea> </label></div>';html+='<div><input name="button1" type="button" value="Add video" onclick="'+this.objName+'.saveDiv();" /><input type="button" value="cancel" onclick="'+this.objName+'.hideDiv();"/></div>';html+='    </form>';VideoGL.superclass.setContentDiv.call(this,html);}