var curTab;var subscriptionDivId;function vote(media){reload(media);return false;}function loadVideo(tab,country,catid,pageByCountry){curTab=tab;reload(country,catid,pageByCountry);return false;}function reload(country,catid,pageByCountry){selectTab(curTab);var htab=document.getElementById('h'+curTab);if(htab.value==""){var tabEl=document.getElementById(curTab);tabEl.innerHTML="<img src=\"/images/misc/loading.gif\" border=0 />";var url="/loadfrontvideos.ashx";var qs="tab="+curTab+(country!=""?"&country="+country:"")+"&catid="+catid+"&pbc="+pageByCountry;AjaxPostCall(url,qs,updateContent);}return false;}function updateContent(){if(req.readyState==4){var sucess=false;var updTab=document.getElementById(curTab);if(req.status==200){var rtext=req.responseText;if(rtext!=""){sucess=true;updTab.innerHTML=rtext;document.getElementById('h'+curTab).value='loaded';}}if(!sucess)updTab.innerHTML="There was an error when loading data from server. Please try again later";}}function UpdateMediaAlbum(url,albumSelectionId,userId,mediaId,divLoading,divReplace){var albumId=document.getElementById(albumSelectionId).value;var qs='';qs+="aid=";qs+=albumId;qs+="&uid=";qs+=userId;qs+="&mid=";qs+=mediaId;GenericAjaxLink(divLoading,divReplace,url,qs,"Error","",0);}function selectTab(tab){resetTab();document.getElementById(tab).style.display='block';document.getElementById("t"+tab).className="tabhl";}function resetTab(){document.getElementById('featured').style.display="none";document.getElementById('recent').style.display="none";document.getElementById('viewed').style.display="none";document.getElementById('discussed').style.display="none";document.getElementById('tfeatured').className="tab";document.getElementById('trecent').className="tab";document.getElementById('tviewed').className="tab";document.getElementById('tdiscussed').className="tab";}function resetall(){document.getElementById('hfeatured').value="";document.getElementById('hrecent').value="";document.getElementById('hviewed').value="";document.getElementById('hdiscussed').value="";}function Querystring(qs){this.params=new Object()
this.get=Querystring_get
if(qs==null)qs=location.search.substring(1,location.search.length);if(qs.length==0)return;qs=qs.replace(/\+/g,' ');var args=qs.split('&');for(var i=0;i<args.length;i++){var value;var pair=args[i].split('=');var name=unescape(pair[0]);if(pair.length==2)value=unescape(pair[1]);else if(pair.length==3)value=unescape(pair[1])+'='+unescape(pair[2]);this.params[name]=value;}}function Querystring_get(key,default_){if(default_==null)default_=null;var value=this.params[key];if(value==null)value=default_;return value;}function updatevideodetail(id,details){var url="/loadtopvideodetail.aspx?crypid="+id;AjaxCall(url,updateVideoInfo);}function updateVideoInfo(){if(req.readyState==4){if(req.status==200){var rtext=req.responseText;if(rtext!=""){var d=document.getElementById('videoinfo');d.innerHTML=rtext;}}}}function GetVoteStr(vote){if(vote==1)return"<strong>1</strong><br><span class=size9>Hit Vote</span>";else{if(vote>=1000)return"<span class=size14><strong>"+vote+"</strong></span><br><span class=size9>Hit Votes</span>";else return"<span class=size20><strong>"+vote+"</strong></span><br><span class=size9>Hit Votes</span>";}}function suggestVideoToFriends(crypId,location){if(confirm("Are you sure you want to suggest this video to all your friends?")){var idName="";if(location==0){idName="divAjaxResponse";}else if(location==1){idName="divProfileSuggestions";}var objSuggestion=document.getElementById(idName);var url="/media/suggestToFriends.ashx";var qs="cid="+crypId;qs+="&loc="+location;objSuggestion.innerHTML='<img src=/images/misc/loading.gif>';if(location==0){var idName="divFriendSuggestionsLoading";var objSuggestion=document.getElementById(idName);objSuggestion.innerHTML='<img src=/images/misc/loading.gif>';document.getElementById('divIdFriendSuggestionListings').style.display='none';AjaxPostCall(url,qs,updateMediaSuggestionDiv);}else{AjaxPostCall(url,qs,updateProfileSuggestionDiv);}}}function SuggestVideoToSelectedFriends(crypId,userIds,userNames,divLoading,divReplace){var objSuggestion=document.getElementById(divLoading);var url="/media/suggestToFriends.ashx";var qs="cid="+crypId;qs+="&uids="+userIds;qs+="&unms="+userNames;GenericAjaxLink(divLoading,divReplace,url,qs,'Error sending suggestion to friends.<br>Please try again later.',"Are you sure you want to suggest this video to the friends you selected?",0);}function updateMediaSuggestionDiv(){if(req.readyState==4){ShowDivById('divAjaxResponse');updateAjaxControl('divAjaxResponse','Error sending suggestion to friends.<br>Please try again later.');}HideDivById('divFriendSuggestionsLoading');}function updateProfileSuggestionDiv(){if(req.readyState==4){updateAjaxControl('divProfileSuggestions','Error sending suggestion to friends.<br>Please try again later.');}}function addSubscription(aid,alertStr,divId){subscriptionDivId=divId;document.getElementById(subscriptionDivId).innerHTML='<img src=/images/misc/loading.gif>';var url='/user/addSubscription.ashx';var qs='aid='+aid+'&alert='+alertStr;AjaxPostCall(url,qs,updateSubscriptionDiv);return false;}function updateSubscriptionDiv(){if(req.readyState==4){updateAjaxControl(subscriptionDivId,'Error sending suggestion to friends.<br>Please try again later.');}}function AddToFavorites(mId){var favDiv=document.getElementById('divFavorites');favDiv.innerHTML='<img src=/images/misc/loading.gif>';var url="/media/addToFavorites.ashx";var qs="mId="+mId;AjaxPostCall(url,qs,updateFavoritesDiv);}function updateFavoritesDiv(){if(req.readyState==4){updateAjaxControl('divFavorites','Error adding to favorites.<br>Please try again later.');}}function RateVideo(crypId,mId,curRate,live){var ratingDiv=document.getElementById('divRating');ratingDiv.innerHTML='<table align=center border=0 cellpadding=10 cellspacing=0><tr><td align=center valign=middle><img src=/images/misc/loading.gif></td></tr></table>';var url="/media/addRating.ashx";var qs="cid="+crypId+"&mId="+mId+"&l="+live+"&cr="+curRate;AjaxPostCall(url,qs,updateRatingDiv);}function updateRatingDiv(){if(req.readyState==4){updateAjaxControl('divRating','Error updating rating.<br>Please try again later.');}}var DelFAVDIV;function DF(mId,type,pageId,divid){DelFAVDIV=divid;if(confirm('Are you sure that you want to delete this from your favorites?')){var obj=document.getElementById(divid);obj.style.innerHTML='';var url='/media/DeleteFavorite.ashx';var qs='v=favorite&t='+type+'&mid='+mId+"&p="+pageId;AjaxPostCall(url,qs,updateDFDiv);}return false;}function updateDFDiv(){if(req.readyState==4){updateAjaxControl(DelFAVDIV,'Error deleting your favorites.<br>Please try again later.');}}var DelMDIV;function DM(cId,type,pageId,divid){DelMDIV=divid;if(confirm('Are you sure that you want to delete this video?')){var obj=document.getElementById(divid);obj.style.innerHTML='';var url='/media/DeleteMedia.ashx';var qs='v=my&t='+type+'&cid='+cId+"&p="+pageId;AjaxPostCall(url,qs,updateDMDiv);}return false;}function updateDMDiv(){if(req.readyState==4){updateAjaxControl(DelMDIV,'Error deleting your video.<br>Please try again later.');}}function ShowFriendsAreaByDefault(){ShowDivById('idTblFriendArea');HideDivById('idTblFriendFields');}function ShowFriendsArea(){var addresses="";var buffer="";if(document.getElementById('txtFriend10').value.length>0){document.getElementById('idTblFriendFields').style.display='none';document.getElementById('idTblFriendFields3').style.display='none';document.getElementById('idTblFriendFields4').style.display='none';document.getElementById('idTblFriendFields5').style.display='none';document.getElementById('idTblFriendFields6').style.display='none';document.getElementById('idTblFriendFields7').style.display='none';document.getElementById('idTblFriendFields8').style.display='none';document.getElementById('idTblFriendFields9').style.display='none';document.getElementById('idTblFriendFields10').style.display='none';document.getElementById('idTblFriendArea').style.display='block';addresses=GetFriendsFromList();document.getElementById('idTxtAreaFriends').value=addresses;document.getElementById('idTxtAreaFriends').focus();if(document.selection){var cursor=document.all.idTxtAreaFriends.createTextRange();cursor.collapse(false);cursor.select();}}}function GetFriendsFromList(){var addresses="";addresses=GetTellFriendsValue('txtFriend1',addresses);addresses=GetTellFriendsValue('txtFriend2',addresses);addresses=GetTellFriendsValue('txtFriend3',addresses);addresses=GetTellFriendsValue('txtFriend4',addresses);addresses=GetTellFriendsValue('txtFriend5',addresses);addresses=GetTellFriendsValue('txtFriend6',addresses);addresses=GetTellFriendsValue('txtFriend7',addresses);addresses=GetTellFriendsValue('txtFriend8',addresses);addresses=GetTellFriendsValue('txtFriend9',addresses);addresses=GetTellFriendsValue('txtFriend10',addresses);return addresses;}function GetTellFriendsValue(idTxtFriend,buffer){var strNew="";strNew=document.getElementById(idTxtFriend).value;if(strNew.length>0){if(buffer.length>0){strNew=buffer+","+strNew;}}else{strNew=buffer;}return strNew;}function ToggleFriendsDiv(){if(document.getElementById('divTellFriends').style.display=='none'){document.getElementById('divTellFriends').style.display='block';document.getElementById('divIdTellFriendsListings').style.display='block';}else{if(document.getElementById('divIdTellFriendsListings').style.display=='none'){document.getElementById('divIdTellFriendsListings').style.display='block';}else{document.getElementById('divTellFriends').style.display='none';}}ClearAjaxResponseDiv();}function TellFriendsNow(cid,nurl,ntitle){if(document.getElementById('idTextEmail').value.length>5){if(document.getElementById('txtFriend1').value.length>5){ShowDivById('divTellFriendsLoading');currProfileControlId='divAjaxResponse';currProfileSectionStr="<br /><b>Email sent out successfully</b><br />";var addresses="";var url="sn="+escape(document.getElementById('idTextName').value);url+="&se="+escape(document.getElementById('idTextEmail').value);if(document.getElementById('idTxtAreaFriends').value.length==0){addresses=GetFriendsFromList();}else{addresses=document.getElementById('idTxtAreaFriends').value;}url+="&re="+escape(addresses);url+="&msg="+escape(document.getElementById('idtxtMessage').value);url+="&cid="+cid;url+="&nurl="+nurl;url+="&ntitle="+ntitle;if(document.getElementById('idChkCopy').checked==true){url+="&cpy=1";}else{url+="&cpy=0";}ClearAllTellFriends();document.getElementById('divAjaxResponse').innerHTML='<br /><table width=100% border=0><tr><td id=WarningBoxSuccess><br /><b>Your email is being sent...</b><br /></td></tr></table>';ShowDivById('divAjaxResponse');HideDivById('divIdTellFriendsListings');AjaxPostCall("/media/tellFriends.ashx",url,updateAjaxResponse);HideDivById('divTellFriendsLoading');}else{alert("Please enter a valid email address for Friend 1");}}else{alert("Please enter your valid email address");}}function ShowMoreFriends(callingDivId,divId){var objtxtCallingDiv=document.getElementById(callingDivId);if(objtxtCallingDiv.value.length>0){document.getElementById(divId).style.display='block';}}function ConfirmClearFriends(){if(confirm('Are you sure that you want to clear all current friend emails on this form?'))ClearAllTellFriends();return false;}function ClearAllTellFriends(){document.getElementById('idTblFriendFields').style.display='inline';document.getElementById('idTblFriendFields3').style.display='none';document.getElementById('idTblFriendFields4').style.display='none';document.getElementById('idTblFriendFields5').style.display='none';document.getElementById('idTblFriendFields6').style.display='none';document.getElementById('idTblFriendFields7').style.display='none';document.getElementById('idTblFriendFields8').style.display='none';document.getElementById('idTblFriendFields9').style.display='none';document.getElementById('idTblFriendFields10').style.display='none';document.getElementById('idTblFriendArea').style.display='none';document.getElementById('txtFriend1').value='';document.getElementById('txtFriend2').value='';document.getElementById('txtFriend3').value='';document.getElementById('txtFriend4').value='';document.getElementById('txtFriend5').value='';document.getElementById('txtFriend6').value='';document.getElementById('txtFriend7').value='';document.getElementById('txtFriend8').value='';document.getElementById('txtFriend9').value='';document.getElementById('txtFriend10').value='';document.getElementById('idTxtAreaFriends').value='';}function ToggleAjaxDiv(divId){ToggleDiv(divId);ClearAjaxResponseDiv();}function ToggleDiv(divId){if(document.getElementById(divId).style.display=='none')ShowDivById(divId);else HideDivById(divId);}function SendReportVideo(cid,uid,replaceDivId){if(document.getElementById('cbReportCopyright').checked&&document.getElementById('txtReportInfo').value.length<=0){alert('If you are reporting a copyright violation, you must provide additional information in the textarea provided.');return;}if(!document.getElementById('cbReportCopyright').checked&&!document.getElementById('cbReportHate').checked&&!document.getElementById('cbReportPorn').checked){if(document.getElementById('cbMissing')!=undefined){if(!document.getElementById('cbMissing').checked){alert('Please check at least one reason why you are reporting that this video contains inappropriate content.');}}else{alert('Please check at least one reason why you are reporting that this video contains inappropriate content.');}return;}var url='&cid='+cid;url+='&uid='+uid;if(document.getElementById('cbReportCopyright').checked)url+='&c=1';if(document.getElementById('cbReportHate').checked)url+='&r=1';if(document.getElementById('cbReportPorn').checked)url+='&p=1';if(document.getElementById('cbMissing')!=undefined){if(document.getElementById('cbMissing').checked)url+='&m=1';}url+='&t='+escape(document.getElementById('txtReportInfo').value.substr(0,1000));GenericAjaxLink('divSendReportLoading',replaceDivId,'/media/addReportContent.ashx',url,'Error reporting this video.<br>Please try again later.','Are you sure that you want to report that this video contains inappropriate content?',0);}function SubmitAddToChannels(uid,mid,replaceDivId){var dataToSubmit=false;var cbEle;var cbId='';var counter=1;var url='uid='+uid+'&mid='+mid+'&acid=';while(counter<1000){cbId='cbAddToChannelId'+String(counter);cbEle=document.getElementById(cbId);if(cbEle==undefined){counter=1000;}else{if(cbEle.checked){url+=String(cbEle.value);url+=",";dataToSubmit=true;}}counter++;}if(dataToSubmit)GenericAjaxLink('divSubmitAddChannelsLoading',replaceDivId,'/media/addLinkedMedia.ashx',url,'Error adding this video to the selected channel(s).<br>Please try again later.','Are you sure that you want to add this video to the selected channels?',0);else alert('You must select at least one channel to add this video to');}function updateAjaxResponse(){if(req.readyState==4){ShowDivById('divAjaxResponse');updateAjaxControl('divAjaxResponse','');}}function ClearAjaxResponseDiv(){document.getElementById('divAjaxResponse').innerHTML='';HideDivById('divAjaxResponse');}function videoComplete(){}function GetFrontTopVideo(type){var qs="type="+type;GenericAjaxLink("","topplayer","/loadtopvideodetail.aspx",qs,"","",0)
return false;}var GROUP_COUNT=20;var ArraySelected=new Array();function selectAllFriends(checked){var obj;var objName='';var rootElement='idGroup';var indexCounter=0;var selectcounter=0;var unselected=0;for(indexCounter;indexCounter<GROUP_COUNT;indexCounter++){objName=rootElement+String(indexCounter);obj=document.getElementById(objName);if(obj!=undefined){if(checked){obj.checked=true;selectcounter++;}else{obj.checked=false;unselected++;}}}}function ClearAllSelected(){ArraySelected=null;ArraySelected=new Array();selectAllFriends(false);UpdateSelection();}function UpdateSelection(){var obj;var objName='';var rootElement='idGroup';var indexCounter=0;var userIds='';var userNames='';for(indexCounter;indexCounter<GROUP_COUNT;indexCounter++){objName=rootElement+String(indexCounter);obj=document.getElementById(objName);if(obj!=undefined){if(ArraySelected[obj.name]!=undefined){obj.checked=true;}}}}function AddNewSelection(){var obj;var objName='';var rootElement='idGroup';var indexCounter=0;var userIds='';var userNames='';var arrRemove=new Array();var arrNew=new Array();for(indexCounter;indexCounter<GROUP_COUNT;indexCounter++){objName=rootElement+String(indexCounter);obj=document.getElementById(objName);if(obj!=undefined){if(obj.checked==true){if(ArraySelected[obj.name]==undefined){ArraySelected[obj.name]=obj.value;}}else{if(ArraySelected[obj.name]!=undefined){arrRemove[obj.name]=obj.value;}}}}for(name in ArraySelected){if(arrRemove[name]==undefined){arrNew[name]=ArraySelected[name];}}ArraySelected=null;ArraySelected=new Array();ArraySelected=arrNew;}function SendFriendSuggestionNow(){SendFriendSuggestionWithCrypIdNow(CrypId);}function SendFriendSuggestionWithCrypIdNow(crypId,divLoading,divReplacing){var obj;var objName='';var rootElement='idGroup';var indexCounter=0;var userIds='';var userNames='';var first=true;var nArrayLength=0;AddNewSelection();for(name in ArraySelected){nArrayLength++;}if(nArrayLength){for(value in ArraySelected){if(first!=true){userIds+=",";userNames+=",";}userIds+=ArraySelected[value];userNames+=value;first=false;}SuggestVideoToSelectedFriends(crypId,userIds,userNames,divLoading,divReplacing);}else{alert("Please select at least one friend");}}function PostContentToBlog(replaceDivId,qs){var loadingDivId='divPostContentSaving';var ti=document.getElementById('txtPostContentTitle');var tx=document.getElementById('txtPostContentDesc');var ddlBlog=document.getElementById('ddlPostContentBlogList');var blogId=ddlBlog.options[ddlBlog.selectedIndex].value;qs+='&bid='+blogId;qs+='&btitle='+ti.value;qs+='&btext='+tx.value;GenericAjaxLink(loadingDivId,replaceDivId,'/ajax/shared/postContentToBlog.ashx',qs,'Error posting content to your blog.<br>Please try again later.','Are you sure that you want to post this content to your selected blog?',0);}function PopUpDialog(evt,divhtml,submitButton){var dlgPopUp=document.getElementById(divhtml);dlgPopUp.style.zIndex=10000;dlgPopUp.style.display="block";dlgPopUp.style.visibility="visible";dlgPopUp.style.position="absolute";if(evt){var target=evt.target?evt.target:evt.srcElement;if(target.nodeType==3){target=target.parentNode;}var offsets=GetOffsets(target);dlgPopUp.style.left=offsets.x+"px";dlgPopUp.style.top=offsets.y+15+"px";}document.getElementById(submitButton).style.visibility='visible';return false;}function PopUpSubscriptionWindow(evt,windowName,subscriptionId){var divPopupName="divAlert"+windowName;var divContainerId="subscriptionContainer"+windowName;var divLoadingId="divSubscriptionLoading"+windowName;var divSubscription="divSubscriptionId"+windowName;var submitButtonId="subscriptionSubmit"+windowName;var dlgPopUp=document.getElementById(divPopupName);dlgPopUp.style.zIndex=10000;dlgPopUp.style.display="block";dlgPopUp.style.visibility="visible";dlgPopUp.style.position="absolute";var target=evt.target?evt.target:evt.srcElement;if(target.nodeType==3){target=target.parentNode;}var offsets=GetOffsets(target);dlgPopUp.style.left=offsets.x+"px";dlgPopUp.style.top=offsets.y+15+"px";var container=document.getElementById(divContainerId);var inputs=container.childNodes;for(index=0;index<inputs.length;index++){if(inputs[index].nodeName.toLowerCase()=='input'){inputs[index].checked=false;}}document.getElementById(divSubscription).innerHTML=subscriptionId;document.getElementById(divLoadingId).innerHTML="";document.getElementById(submitButtonId).style.visibility="visible";return false;}function AddExtraSubscriptions(subscriptionObjId,subscriberId,containerId,loadingDiv,submitButton){var container=document.getElementById(containerId);var inputs=container.childNodes;var inputsSelected='';var inputArray=new Array();var subscriptionId=document.getElementById(subscriptionObjId).innerHTML;for(index=0;index<inputs.length;index++){if(inputs[index].nodeName.toLowerCase()=='input'){if(inputs[index].checked==true){if(inputsSelected.length>0){inputsSelected+=',';}inputsSelected+=inputs[index].value;}}}document.getElementById(loadingDiv).innerHTML='<img src=/images/misc/loading.gif>';document.getElementById(submitButton).style.visibility='hidden';var url='/user/addExtraSubscriptions.ashx';var qs='sid='+subscriptionId+'&uid='+subscriberId+'&subs='+inputsSelected;GenericAjaxLink(loadingDiv,loadingDiv,url,qs,"","",0);}