﻿// JScript File


function OpenUrl(newLocation)
{
    window.open(newLocation);
}

function SetUrlLearnMore()
{
    window.location.href = "http://www.oovoo.com/business" ; 
}

function ShowTestimonialPopup(url)
{
    newwindow = window.open( url ,'Testimonial' , 'height=400,width=400' );
    newwindow.focus();
}

function GetVideo(TestimonialVideo)
{
   newwindow =  window.open('../popups/TestimonialPopup.aspx?video=' + TestimonialVideo ,'TestimonialVideo', 'width=400,height=400,resizable=no');     
   newwindow.focus();
}

 
//Validators for try form------
    
function valid_required(field)
{
    if(field=="") 
    {
        return false;
    }

    return true;
}


function EmailValid(email)
{
	if(email=="")
	{
	alert("Email is required field!")
	return false;
	}
	len = email.length
	
	if((email.charAt(1)=='@')||(email.charAt(1)=='.'))
	{
	alert("Invalid Email Please try again!")
	return false;
	}
	if((email.charAt(len-2)=='@')||(email.charAt(len-2)=='.'))
	{
	alert("Invalid Email Please try again!")
	return false;
	}		
	
	count=0
	dotcount=0
    
    for (i=0; i< email.length; i++)
	    {
		    if(email.charAt(i)=='@')
		    count++
		    if(email.charAt(i)=='.')
		    dotcount++
	     }
		
		     if((count !=1)||(dotcount !=1))
		 	    {
		 	    alert("Invalid Email Please try again!")
		 	    return false
		 	    }    		    		
    return true;
}


function valForm()
{	
  
	if(!valid_required(document.getElementById("firstName").value))
	{
	    alert("First name is required field.")
	
		return false
	}
	
	if(!valid_required(document.getElementById("lastName").value))
	{
	    alert("Last name is required field.")
	
	    return false
	}
	
	if(!valid_required(document.getElementById("email").value))
	{
	    alert("Email is required field.")
	
	    return false
	}
	
	if(!EmailValid(document.getElementById("email").value))
	{
	    return false
	}

    return true
}


//---------Get url params for download  button -----------

function GetVCValue()
{ 
    var btnDownload = document.getElementById('btnDownload');

    qsL ="vc" ;
    qsU ="VC" ;
    
    userL ="USERNAME" ;
    userU ="username" ; 
       
    hu = window.location.search.substring(1);    
    gy = hu.split("&");
    
    for (i = 0; i < gy.length; i++)
    {
        ft = gy[i].split("=");
		if (btnDownload!=null )
		{
		        if (ft[0] == qsU || ft[0] == qsL )        
		        {
		            btnDownload.href = "http://www.oovoo.com/Download.aspx?VC=" + ft[1];
		            break;
		        }
		        else
		        {
	           	    btnDownload.href = "http://www.oovoo.com/Download.aspx";
        		}  
		}      
      }


     
     for (i = 0; i < gy.length; i++)
     {
        ft = gy[i].split("=");
		if (btnDownload!=null )
		{
		        if (ft[0] == userL || ft[0] == userU )        
		        {
		            btnDownload.href += "&username=" + ft[1];
		            break;
		        }
		}      
    } 



}

onload = function()
{
    GetVCValue();
}

//---------Get url params for download  button -----------



