function ValidateVideoUpload(myform){
	if(document.getElementById('VideoFile').value==""){
		alert("Upload Video field Should not be empty");
		myform.VideoFile.focus();
		return false;
	}
	if(document.getElementById('Video_Title').value==""){
		//alert(document.getElementById('Video_CategoryId').value);
		alert("Video Title Should Not Be Empty");
		myform.Video_Title.focus();
		return false;
	}

	document.NewVideo.fAction.value = "new";
	return true;
}

function DeleteVideo(VideoId,VideoTags,TagType)
{
  if(confirm("Do you really want to Delete this Videos?"))
	{
	var success = function(t){doDeleteVideoComplete(t);}
	var failure = function(t){loadfailed(t,curobj)}
	var url = 'ajax/videos.php';
	var pars = 'op=delete&VideoId='+VideoId +'&VideoTags='+VideoTags;
	var myAjax = new Ajax.Request(url, {method:'post',postBody:pars, onSuccess:success, onFailure:failure});
  }
}
function doDeleteVideoComplete(t){
	window.location.href = t.responseText;		
}
var VideoDisplayScript	= function(VideosDisplayPath,Width,Height,Path)	{
		strConfigFile = "videoconfig.xml";

		if($("LoadVideo")){
		    var EmbedSrc  ='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0" id="/YouTube_video/youtube" width="'+ Width +'" height="'+ Height +'">';
			EmbedSrc +='<param name="allowFullScreen" value="true" />';
			EmbedSrc +='<param name="wmode" value="transparent" />';
			EmbedSrc +='<param name="movie" value="renchenza.swf?xml=' + strConfigFile + '&video=' + VideosDisplayPath + '" />';
			EmbedSrc +='<param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />';
			EmbedSrc +='<embed src="renchenza.swf?xml=' + strConfigFile + '&video=' + VideosDisplayPath + '" quality="high" bgcolor="#ffffff" width="'+ Width +'" height="'+ Height +'" name="/YouTube_video/youtube" align="middle" wmode="transparent" allowFullScreen="true" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
			EmbedSrc +='</object>';
			$("LoadVideo").innerHTML = EmbedSrc;
		}
}
var VideoDisplayScriptForHome	= function(VideosDisplayPath,Width,Height,Path,Title)	{
    strConfigFile = "videoconfig.xml";
	if($("flashcontent")){
			var EmbedSrc  = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0" id="/YouTube_video/youtube" width="'+ Width +'" height="'+ Height +'">';
			EmbedSrc +='<param name="allowFullScreen" value="true" />';
			EmbedSrc +='<param name="wmode" value="transparent" />';
			EmbedSrc +='<param name="movie" value="renchenza.swf?xml=' + strConfigFile + '&video=' + VideosDisplayPath + '" />';
			EmbedSrc +='<param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />';
			EmbedSrc +='<embed src="renchenza.swf?xml=' + strConfigFile + '&video=' + VideosDisplayPath + '" quality="high" bgcolor="#ffffff" width="'+ Width +'" height="'+ Height +'" name="/YouTube_video/youtube" align="middle" wmode="transparent" allowFullScreen="true" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
			EmbedSrc +='</object>';
			$("flashcontent").innerHTML = EmbedSrc;	
	}
	$("HomeVideoTop").innerHTML = '<img src="images/icon2.gif" width="32" height="31" align="absmiddle" />Video of the Day- '+Title; 
}
function ViewVideoAction(Type){
 switch(Type){
	 case "bookmark":
		document.ViewVideo.fAction.value="bookmark";
		document.ViewVideo.submit();
	 break;
	 case "viewrss":
		document.ViewVideo.fAction.value="viewrss";
		document.ViewVideo.submit();
	 break;
 }
}
function Tabs(Name){
	 
	 UploadVideoId 			= "UploadVideo"; 
	 UploadVideoTabLeftId 	= "UploadVideoTabLetf";
	 UploadVideoTabRightId	= "UploadVideoTabRight";
	 UploadVideoTabBgId		= "UploadVideoTabBg";
	 
	 EmbedVideoId =  "EmbedVideo";
	 EmbedVideoTabLeftId 	= "EmbedVideoTabLetf";
	 EmbedVideoTabRightId	= "EmbedVideoTabRight";
	 EmbedVideoTabBgId		= "EmbedVideoTabBg";
	 switch(Name){
		case "upload":
			//$(UploadVideoId).style.position   	= "relative";
			$(UploadVideoId).style.display 		= "block";
			//$(EmbedVideoId).style.position   	= "absolute";
			$(EmbedVideoId).style.display 		= "none";
			
		    $(UploadVideoTabLeftId).className 	= "VideoTabSelected_Left";
			$(UploadVideoTabRightId).className 	= "VideoTabSelected_Right";
			$(UploadVideoTabBgId).className 	= "VideoTabSelected_Bg";
			
			$(EmbedVideoTabLeftId).className 	 = "VideoTabNormal_Left";
			$(EmbedVideoTabRightId).className 	 = "VideoTabNormal_Right";
			$(EmbedVideoTabBgId).className 		 = "VideoTabNormal_Bg";
		break;
		case "embed":
		   // $(EmbedVideoId).style.position  	 = "relative";
			$(EmbedVideoId).style.display		 = "block";
			//$(UploadVideoId).style.position	     = "absolute";
			$(UploadVideoId).style.display		 = "none";
			
			$(EmbedVideoTabLeftId).className 	 = "VideoTabSelected_Left";
			$(EmbedVideoTabRightId).className 	 = "VideoTabSelected_Right";
			$(EmbedVideoTabBgId).className 		 = "VideoTabSelected_Bg";
			
			$(UploadVideoTabLeftId).className 	= "VideoTabNormal_Left";
			$(UploadVideoTabRightId).className 	= "VideoTabNormal_Right";
			$(UploadVideoTabBgId).className 	= "VideoTabNormal_Bg";
		break;
	 }
}
function ValidateVideoEmbed(myform){
	if((trim(document.getElementById('YouTubeUrl').value)=="")&&(trim(document.getElementById('YouTubeEmbedLink').value)=="")){
		alert("Embed Video field Should not be empty");
		myform.YouTubeUrl.focus();
		return false;
	}
	if(trim(document.getElementById('YouTubeUrl').value)!=""){
	     if(!isUrl(document.getElementById('YouTubeUrl').value)){
		      alert("Invalid url");
			  myform.YouTubeUrl.focus();
		      return false; 
		 }
		 searchUrl= "youtube.com";
		 Url = document.getElementById('YouTubeUrl').value;
		 if(Url.indexOf(searchUrl) == -1){
			  alert("YouTube url allows link only from YouTube. otherwise enter Embed Link for videos in Video Embed Link field");
			   myform.YouTubeUrl.value = "";
			  myform.YouTubeUrl.focus();
		      return false;  
		 }
	}
	if(document.getElementById('EmbedVideo_Title').value==""){	
		alert("Video Title Should Not Be Empty");
		myform.EmbedVideo_Title.focus();
		return false;
	}

	document.EmbedVideo.fAction.value = "embed";
	return true;
}
function isUrl(s) {
 	var regexp = /http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/;
 	return regexp.test(s);
}

function getVideos(Event,Id){
	if(Event == "Comments"){
		document.getElementById("MyDogName[1]").className = "MyDogHeadingNormalTab";
		document.getElementById("MyDogName[2]").className = "MyDogHeadingOverTab";
		document.ViewVideo.fAction.value="Comments";
		document.ViewVideo.submit();
	}
	if(Event == "Reviews"){
		document.getElementById("MyDogName[2]").className = "MyDogHeadingNormalTab";
		document.getElementById("MyDogName[1]").className = "MyDogHeadingOverTab";
		document.ViewVideo.fAction.value="Reviews";
		document.ViewVideo.submit();
	}
	
}