
function ValidateOrderForm()
{ 
   
    var txtName = document.getElementById("txtName");
    var txtStreetAddress = document.getElementById("txtStreetAddress");
    var txtZipCode = document.getElementById("txtZipcode");
    var txtEmail = document.getElementById("txtEmail");
    var ddlCopies = document.getElementById("txtNumCopies");
    
    if (txtName != null)
    {
         if (txtName.value == "")
         {
            alert("Venligst indgiv dit navn!");
            return false;
          }
            
         if (txtStreetAddress.value == "")
         {
            alert("Venligst indgiv din adresse og vej nummer!");
            return false;
          }
            
         if (txtZipCode.value == "")
         {
            alert("Venligst indgiv postnummer og by!");
            return false;
         }
            
                   
         if (!emailcheck(txtEmail.value))
         {
             return false;
         }
         
                
         if (ddlCopies.selectedIndex == 0)
         {
            alert("Venligst indgiv det antal du ønsker tilsendt!");
            return false;
         }
         
         return true;
    }
    
}



function showDivSendVideoLink()
{
	var h= (screen.height/2) - 125;
    var w = (screen.width/2) - 200;
	window.open('/k9vfri_sendvideo_link.aspx?videoid=' + videoid,'VideoLink','height=250,width=400,left=' + w + ',top=' + h + ',resizable=no,scrollbars=no,toolbar=no,status=no');
}

function PopUpCommentBox(s)
{
    var div = document.getElementById("div_comment");
    document.getElementById("_ctl3_zenpanes_CenterPane__ctl3_txtMessage").value = '';
    document.getElementById("_ctl3_zenpanes_CenterPane__ctl3_txtName").value = '';
    if (s == 'top')
    {
        div.style.bottom = '';
        div.style.top = '38px';
        div.style.display = 'block';
    }
    
    if (s == 'bottom')
    {
        div.style.top = '';
        div.style.bottom = '30px';
        div.style.display = 'block';
    }    
}



/*added */
var rateClickStatus = 0;var rate = 0;var siteUrl = "";var videoid = -1;var ip = "";var views = 0;
var hdnVotes;var hdnVoters;var isFromList;var isMostPopular;
var siteUrl = window.location.toString().substr(0,window.location.toString().indexOf("/site"));

function getFlash() {
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	return (isIE) ? window["buttonrate"] : document["buttonrate"];
}
        
function GetRateData()
{   
    
    if (rate > 0 && videoid > -1)
    {
        if (CheckCookie())
        {              
            return siteUrl + "/k9vfri_rateit.aspx" + "|" + videoid + "|" + ip + "|" + rate;
        }
        else
            return "";
    }
    else
        return "";
}

function jsRateError()
{
    alert("Der opstod en fejl. Venligst prøv en gang til.");
}

function jsRateSuccess()
{
    try
    {               
        var sRating;
                        
        if (isFromList == "true")
        {                          
          if (hdnVotes.value == "")
            hdnVotes.value = 0;
          
          if(hdnVoters.value == "")
            hdnVoters.value = 0;
            hdnVotes.value = parseInt(hdnVotes.value) + parseInt(rate);
            hdnVoters.value = parseInt(hdnVoters.value) + 1;
            var rating = parseFloat(hdnVotes.value)/parseFloat(hdnVoters.value);
            sRating = rating.toString().substr(0,4); 
        }                
       
        if (isFromList == "false" || isMostPopular == "true")                
        {  
            var hdnVotes_2 = 0;   
            if (hdnVotes.toString().length == 0) 
                hdnVotes_2 = 0;
            else
                hdnVotes_2 = hdnVotes;
                
            if (hdnVoters == "")
                hdnVoters == 0;
                                 
            hdnVotes_2 = parseInt(hdnVotes_2) + parseInt(rate);
            hdnVoters = parseInt(hdnVoters) + 1;
            
            var rating = parseFloat(hdnVotes_2)/parseFloat(hdnVoters);
            sRating = rating.toString().substr(0,4);   
        }            
        
        sRating = sRating.replace('.',',');
        document.getElementById('_ctl3_zenpanes_CenterPane__ctl1_lblVideoRating').innerHTML = sRating;
        
        var spanObj = document.getElementById((document.getElementById('_ctl3_zenpanes_CenterPane__ctl2_hdnRateLabelClientId').value));
        
        if (spanObj != null)
            spanObj.innerHTML = sRating;       
    }
    catch(err)
    {
        rating = 0;
    }
    
    if (document.getElementById("rate_casted") != null)
    {
         document.getElementById("rate_casted").style.display = "block";
         document.getElementById("rate_once").style.display = "none";
    }
}

function CheckCookie()
{   
    //return true;
    
    try
    {      
        if (Get_Cookie("k9vfri") != null)
        {        
            var temp =  Get_Cookie("k9vfri");
            //alert("if " + temp);
            if (temp.indexOf("|" + videoid + "|") > -1)
            {
                 document.getElementById("rate_casted").style.display = "none";
                 document.getElementById("rate_once").style.display = "block";
                 return false;
            }
            else
            {        
                temp = temp + videoid + "|";
                Set_Cookie("k9vfri",temp,365);
                document.getElementById("rate_casted").style.display = "none";
                document.getElementById("rate_once").style.display = "none";
                return true;
            }
        }   
        else
        {
            Set_Cookie("k9vfri","|" + videoid + "|",365);
            var temp =  Get_Cookie("k9vfri");
            //alert("else  " + temp);
            if (Get_Cookie("k9vfri") != null)
            {                        
                return true;
            }
            else
            {
                alert("Cookies skal være slået til ");
                return false;
            }
        }
    }
    catch(err)
    {
        alert("Cookies skal være slået til ");
        return false;
    }
}

function StarClick(num)
{       
    rate = num;   
}

function CheckToShowVideoList()
{
    var showThis = document.getElementById("_ctl3_zenpanes_CenterPane__ctl0_hdnShowThis");
    if (showThis != null)
    {
        var start = document.getElementById("_ctl3_zenpanes_CenterPane__ctl0_hdnStart");
        var end = document.getElementById("_ctl3_zenpanes_CenterPane__ctl0_hdnEnd");
        
        if (showThis.value == "true")
        {
            if (start != null && end != null)        
                window.open('/k9vfri_videolist.aspx?start=' + start.value + "&end=" + end.value,'_blank');
        }
        
        showThis.value == "false";
    }
}

function jsSendVideoLinkSuccess()
{
    alert("E-mail sendt!");
}

function jsSendVideoLinkError()
{   
    alert("Der opstod en fejl. Venligst prøv en gang til.");
}

function PlayVideo(flvPath,playAuto,videoTitle,videoId,ipAdd,senderName,ratingAve,hdnClientId,hdnCIdVotes,hdnCIdVoters, fromList, mostPopular)
{       
    var so = new SWFObject('/_1902_FlashPlayerFrontEnd.swf', 'flvPlayer', '302', '244', '9', 'black');
    so.addVariable("url", flvPath);
    so.addVariable("playauto", playAuto);
    so.addParam("wmode","transparent");
	so.write('flashcontent1');
	var totalView = 0 ;
	var rating = 0 ;
	isFromList = fromList;
	isMostPopular = mostPopular;
	if (isMostPopular != "true")
	{
        if (fromList == "true")
    	{	   
        	hdnVotes = document.getElementById(hdnCIdVotes);
        	hdnVoters = document.getElementById(hdnCIdVoters);      
        }   		
        else
        {       
            hdnVotes = hdnCIdVotes;
            hdnVoters = hdnCIdVoters;
        }
    }
    else
    {
        hdnVotes = hdnCIdVotes;
        hdnVoters = hdnCIdVoters;
    }
   
  
    document.getElementById('_ctl3_zenpanes_CenterPane__ctl1_lblVideoSender').innerHTML = senderName;
	document.getElementById('_ctl3_zenpanes_CenterPane__ctl1_lblVideoTitel').innerHTML = videoTitle;
	document.getElementById('_ctl3_zenpanes_CenterPane__ctl1_lblVideoRating').innerHTML = ratingAve;
	document.getElementById('_ctl3_zenpanes_CenterPane__ctl1_lblVideoSender').innerHTML = senderName;
	document.getElementById('_ctl3_zenpanes_CenterPane__ctl1_lblTotalView').innerHTML = totalView;      
	videoid = videoId;
    ip = ipAdd;
    document.getElementById("rate_casted").style.display = "none";
    document.getElementById("rate_once").style.display = "none";
    
    //if (playAuto == "true")	
    //    document.location.href = "#video";
}

function CheckUploadStatus()
{
    var hdnUploadStat = document.getElementById("_ctl3_zenpanes_CenterPane__ctl1_hdnUpload"); 
    var span_Upload = document.getElementById("spanUpload");
    if (hdnUploadStat!= null && hdnUploadStat.value == "success" && span_Upload != null)    
    {
        span_Upload.innerHTML = "Din video er modtaget";
        span_Upload.style.display = "block";
    }
    
    if (hdnUploadStat!= null && hdnUploadStat.value == "error" && span_Upload != null)    
    {
        span_Upload.innerHTML = "Error uploading your video";
        span_Upload.style.display = "block";
    }            
    
    var div_FlashUploadingSWF = document.getElementById("flashprogress");
    if (div_FlashUploadingSWF != null)
        div_FlashUploadingSWF.style.visibility = "hidden";
 
}

function AdjustLayout()
{      
    CheckUploadStatus();
    CheckToShowVideoList();
    
    var hdnDefaultVideo = document.getElementById('_ctl3_zenpanes_CenterPane__ctl2_hdnDefaultVideo');
    if (hdnDefaultVideo != null)
    {
      var thisFlvPath = "";var thisPlayAuto = "false";var thisTitle = "";var thisVideoId = "";var thisIpAdd = "";var thisSender = "";  
      var thisRating = "";var thisTotalView = "";var thisTotalVotesId = "";var thisTotalVotersId = "";var temp =  hdnDefaultVideo.value.split('|');
      var thisMostPopular = "";
      
      thisFlvPath = temp[0];thisPlayAuto = temp[1];thisTitle = temp[2];thisVideoId = temp[3];thisIpAdd = temp[4];
      thisSender = temp[5];thisRating = temp[6];thisTotalView = temp[7];thisTotalVotesId = temp[8];
      thisTotalVotersId = temp[9];thisFromList = temp[10];thisMostPopular=temp[11];
      if (thisMostPopular != "true")
      {
          if (thisFromList == "false")                  
              PlayVideo(thisFlvPath,thisPlayAuto,thisTitle,thisVideoId,thisIpAdd,thisSender,thisRating,thisTotalView,thisTotalVotesId,thisTotalVotersId,"false","false");
              
          if (thisFromList == "true")
          {          
              thisTotalVotesId = document.getElementById('_ctl3_zenpanes_CenterPane__ctl2_hdncIdTotalVotes').value;    
              thisTotalVotersId = document.getElementById('_ctl3_zenpanes_CenterPane__ctl2_hdncIdTotalVoters').value;           
              PlayVideo(thisFlvPath,thisPlayAuto,thisTitle,thisVideoId,thisIpAdd,thisSender,thisRating,thisTotalView,thisTotalVotesId,thisTotalVotersId,"true","false");
          }
    }
    else
    {
          PlayVideo(thisFlvPath,thisPlayAuto,thisTitle,thisVideoId,thisIpAdd,thisSender,thisRating,thisTotalView,thisTotalVotesId,thisTotalVotersId,"false","true");          
    }
    
   	if (document.getElementById('musthavelatestflash') != null)
   	{
   	    //document.getElementById('musthavelatestflash').style.display = "block"; 
    }	     
    
    var txtfocus = document.getElementById("_ctl3_zenpanes_CenterPane__ctl0_txtName"); 
    if (txtfocus != null)
    {   
        txtfocus.focus();   
    }        
  }
}

function GetVideoId()
{        
    return siteUrl + "/k9vfri_sendvideo_link.aspx" + "|" + videoid + "|1";     
}

var sendLinkShown = "false";

function CloseSendLinkDialogue()
{
    var divDialogue = document.getElementById("flashcontent4"); 
    divDialogue.style.visibility = "hidden";
    sendLinkShown = "false";
}

function showDivSendVideoLink()
{    
   
    if (sendLinkShown == "false")
    {
        sendLinkShown = "true";
        //var so4 = new SWFObject('/_1902_SendLinkDialogue.swf', 'dialogue', '400', '240', '9', 'black');
        //var so4 = soDialogue;
        //window["dialogue"] = new Object();            
        //so4.addParam("wmode","transparent");
        //so4.write('flashcontent4');        
        
        var x = parseFloat(navigator.userAgent.toLowerCase().indexOf("safari"));
        if (x < 0)
        {   
            soDialogue.write('flashcontent4');
        }
           
        soDialogue.play;
    	
    	var divDialogue = document.getElementById("videopage");    
        
        var h= (divDialogue.clientHeight/2) - 130;
        var w = (divDialogue.clientWidth/2) - 200;    
            
        var divDialogue = document.getElementById("flashcontent4");    
        divDialogue.style.visibility = "visible";
        divDialogue.style.top = h + "px";
        divDialogue.style.left = w + "px";
        
    }
    
    /*
	window.open('/k9vfri_sendvideo_link.aspx?videoid=' + videoid,'VideoLink','height=300,width=400,left=' + w + ',top=' + h + ',resizable=no,scrollbars=no,toolbar=no,status=no');
    */
}

/*
function showDivSendVideoLink()
{
	var h= (screen.height/2) - 125;
    var w = (screen.width/2) - 200;
	window.open('/k9vfri_sendvideo_link.aspx?videoid=' + videoid,'VideoLink','height=300,width=400,left=' + w + ',top=' + h + ',resizable=no,scrollbars=no,toolbar=no,status=no');
}
*/

function getIEVersion()
{
	if(!document.all)
		return 0;
          		
	var ua = navigator.userAgent;
	var msie = ua.indexOf("MSIE");	
	return parseFloat(ua.substring(msie+5, ua.indexOf(";", msie)));
} 

function showBlog(obj,str)
{
    var div = document.getElementById("div_blogmsg");
    var div_display = document.getElementById("div_display_message"); 
    
    var x = 0, y = 0;
    var origObj = obj;
    while (obj != null)
    {		    
        x += obj.offsetLeft - obj.scrollLeft;
        y += obj.offsetTop - obj.scrollTop;
        obj = obj.offsetParent;           	    
    }    
    
    var addToTop = (document.body.scrollTop || document.documentElement.scrollTop)
    
    div.style.left = x - 310 + "px";
    
    if (div != null)
    {
        if (navigator.appName == "Microsoft Internet Explorer")
        {
            div.style.top = y - 0 + addToTop + "px";        
        }
        else
        {
            div.style.top = y - 0 + "px";
        }        
        
        div_display.innerText = str;
        div.style.display = "block";        
    } 
}

function hideBlog()
{
    var div = document.getElementById("div_blogmsg");
    
    if (div != null)
    {
        div.style.display = "none";        
    } 
}

function checkAll()
{
var chk = document.getElementById("_ctl3_zenpanes_CenterPane__ctl0_chkAll");

if (chk.checked == true)
  CheckBox_Check();
else
  CheckBox_UnCheck();
}

function CheckBox_Check()
{
  var container = document.getElementById("_ctl3_zenpanes_CenterPane__ctl0_dlBlogList");
  var con_inputs = container.getElementsByTagName('input');  
  if (container != null && con_inputs != null)
  {
    for (var i = 0; i <= con_inputs.length; i++)
    { 
      try
      {  
          if (con_inputs[i].type == "checkbox")
          {
              con_inputs[i].checked = true;
          }
      }
      catch(err){}
    }
  }
}

function CheckBox_UnCheck()
{
  var container = document.getElementById("_ctl3_zenpanes_CenterPane__ctl0_dlBlogList");
  var con_inputs = container.getElementsByTagName('input');
  
  if (container != null && con_inputs != null)
  {
    for (var i = 0; i <= con_inputs.length; i++)
    {
      try
      { 
        if (con_inputs[i].type == "checkbox")
        {
            con_inputs[i].checked = false;
        }
      }
      catch(err){}
    }
  }
}

function checkUnRevVid()
{
var chkRVid = document.getElementById("_ctl3_zenpanes_CenterPane__ctl0_chkUVid");

if (chkRVid.checked == true)
  CheckBoxUVid_Check();
else
  CheckBoxUVid_UnCheck();
}


function CheckBoxUVid_Check()
{
  var container1 = document.getElementById("_ctl3_zenpanes_CenterPane__ctl0_dlVideos");

  var con_inputs = container1.getElementsByTagName('input');  
  if (container1 != null && con_inputs != null)
  {
    for (var i = 0; i <= con_inputs.length; i++)
    { 
      try
      {          
          if (con_inputs[i].type == "checkbox")
          {
              con_inputs[i].checked = true;
          }
      }
      catch(err)
      {            
       }
    }
  }

}

function CheckBoxUVid_UnCheck()
{
  var container1 = document.getElementById("_ctl3_zenpanes_CenterPane__ctl0_dlVideos");

  var con_inputs = container1.getElementsByTagName('input');
  
  if (container1 != null && con_inputs != null)
  {
    for (var i = 0; i <= con_inputs.length; i++)
    {
       try
      {  
        if (con_inputs[i].type == "checkbox")
        {
         con_inputs[i].checked = false;
        }
      }
        catch(err)
        {
        }
    }
  }
}

function PopContactForm()
{
    var h= (screen.height/2) - 125;
    var w = (screen.width/2) - 200;
	window.open('/k9vfri_order_guide.aspx','','height=320,width=650,left=' + w + ',top=' + h + ',resizable=no,scrollbars=no,toolbar=no,status=no');
}

window.onload = AdjustLayout; 

