﻿// JScript File
var currentVideoId;
var UID;

function toggleLayer( whichLayer, login ) {
    var elem, vis;
    if(login=="") {
        alert("Login to add a comment.");
    } else { 
        if( document.getElementById ) // this is the way the standards work    
            elem = document.getElementById( whichLayer );  
        else if( document.all ) // this is the way old msie versions work      
            elem = document.all[whichLayer];  
        else if( document.layers ) // this is the way nn4 works    
            elem = document.layers[whichLayer];  
        vis = elem.style;  
        // if the style.display value is blank we try to figure it out here  
        if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)    
            vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';  
        vis.display = (vis.display==''||vis.display=='block')?'none':'block';
    }
}

function loginAlert(login,msg) {   
    if(login=="") {
        alert(msg);
        return false;
    } else {
        return true;
    }
}

function HideContent(d) {
    if(d.length < 1) { return; }
    document.getElementById(d).style.display = "none";
}


function ShowContent(d) {
    if(d.length < 1) { return; }
    document.getElementById(d).style.display = "block";
}

function ReverseContentDisplay(d) {
    if(d.length < 1) { return; }
    if (d == "divMatureContentAlert") {
        top.location.href="../MatureVideo.aspx?VideoId=" + currentVideoId ;
    }
    if (d == "divRatingSystem") {
        top.location.href="../VideoRating1.aspx";
    }
    if (d == "divBox") {
        top.location.href="../SendVideo.aspx";
    }
    if (d == "DivEmbed") {
        top.location.href="../VideoEmbed.aspx";
    }
}

//--- This will display popups for Mature Content and LipSync videos ---//
function privacyAlert1(login,msg,privacy) {   
    if(login=="" && privacy==2) {  
        alert(msg);
        return false;
    }
}
    
function InvokePop(videoId,viewerRatingId,userId,age) {
    if(userId == "" && viewerRatingId >= 3) {           
        ReverseContentDisplay('divMatureContentAlert',viewerRatingId); 
        return false; 
    } 
    else if(userId != "" && viewerRatingId >= 4 && age >= 18){
         top.location.href="../MatureVideo.aspx?VideoId=" + currentVideoId + "&Rating=" + viewerRatingId; 
        return false; 
    }
    else {
        if(userId != "" && viewerRatingId >= 3 && age < 18 ) { 
            alert("You must be 18 or older to view this video.")
            return false;
        } else {
            return true;
        }
     }
}

function wrapper(videoId,viewerRatingId,userId,age,msg,privacy) {
    var val = true;
    currentVideoId= videoId;
//    document.getElementById("txtVideoId").value=videoId;
//    parent.document.getElementById("txtVideoId").value=videoId;
    val = InvokePop(videoId,viewerRatingId,userId,age);
    // in case function_1 returns true we call function_2
    if (val) {   
        val = privacyAlert1(userId,msg,privacy);
    }
    return val;
}

function loginRedirect() {
    if (currentVideoId) {
        // no problems
    } else {
        // currentVideoId got lost, get it from recentlyviewed hidden input
        currentVideoId = document.getElementById("txtVideoId").value;
    }
    top.location.href="../login.aspx?VideoId="+currentVideoId
}

function chkValidate1(imgRate, userid,rating) {
    if(userid==0) {
        alert("Please login to rate the video.")
        return false;
    } else {
        if(rating==1) {
            alert("You already rated this video.")
            return false;
        }
    }
    return true;
}

function chkValidate(imgRate, userid,rating) {
    if(userid==0) {
        alert("Please login to rate the video.")
        return false;
    } else {
        if(rating==1) {
            alert("You already rated this video.")
            return false;
        }
    }
    return true;
}

var rate

function fillImage1(imgRate) {
    var lblrate
    lblrate=document.getElementById("lblrate")
    if(imgRate=="img1") {
        lblrate.innerHTML="Poor"
    } else if(imgRate=="img2") {  
        lblrate.innerHTML="Good"
    } else if(imgRate=="img3") {  
        lblrate.innerHTML="Very Good"
    } else if(imgRate=="img4") {  
    lblrate.innerHTML="Excellent"
     } else if(imgRate=="img5") {  
    lblrate.innerHTML="Awesome!"
     }
}

function changeText1(imgRate) {
   var imgRate1,lblrate
   lblrate=document.getElementById("lblrate")
   lblrate.innerHTML="Click a Star to Rank Video"
}

function btnCopyClicked() {
    var txtClientID = document.getElementById("ClientID").value;
    var code = document.getElementById(txtClientID+'txtCode');
    var codeValue = code.value;
    //clear clipboard data
     window.clipboardData.clearData();
    //copy to clipboard 
    window.clipboardData.setData('Text', codeValue);  
}

function MarkCmtAsSpam() {
    var x
    if(UID=="") {
        alert("Please login to mark as Inappropriate");
        return false;
    } else {
    x=confirm("Are you sure you want to mark this comment as Inappropriate?");
     return x;
     }
}


function confirmation(profileUrl, userUrl) {
    if (userUrl == ""){
	    var answer = confirm("Login Required.  Would you like to continue?");
	    if (answer){	
		    window.location = "../login.aspx?ProfileUrl="+profileUrl;
	    }
	    else{
	        return false;
        }
    }
    else{
        return true;
    }
}


function DeleteContent(contentType) {
    alert("WARNING: This will delete your " + contentType + ".");
     x=confirm("Are you sure you want to delete your " + contentType + "?");
     return x;
}

