﻿
function validatetrust()
{
    var validate = document.getElementById("trustlist");
  
    if (validate.selectedIndex != 0)
    {
       window.location = "http://www.soprotectme.com/orderDetails.aspx?blockerType=Home&license=1&productCode=Blocker29.99&discountCode="+validate.value;
    }
}

var errorColor = "#fffc1c";
var defaultColor = "white";
var validColor = "#93de76";
 
 
function validate()
{
 var check2 = true;
 
   if(document.getElementById("txtfname").value == "")
           {
           check2 = false;
           document.getElementById("fname").style.color = errorColor;
           }
        else
           document.getElementById("fname").style.color = defaultColor;
           
    if(document.getElementById("txtlname").value == "")
           {
           check2 = false;
           document.getElementById("lname").style.color = errorColor;
           }
        else
           document.getElementById("lname").style.color = defaultColor;           
        
    if(document.getElementById("txtemail").value == "")
           {
           check2 = false;
           document.getElementById("email").style.color = errorColor;
           }
        else
           document.getElementById("email").style.color = defaultColor;
                      
        if(check2 == false)
        {
           alert("Please Enter the details for the information labeled in Yellow");
           return false;
         }
        else
            return true;         
}

function redirectSoProtectMePage()
{
    window.location = "http://www.soprotectme.com";
}

function validateUserDetails()
{
    var check = true;
    var check1 = true;
    var check2 = true;
    
    if(document.getElementById("txtfname").value == "")
    {
        check = false;
        document.getElementById("fname").style.color = errorColor;
    }
    else
       document.getElementById("fname").style.color = defaultColor;
           
    if(document.getElementById("txtlname").value == "")
    {
       check = false;
       document.getElementById("lname").style.color = errorColor;
    }
    else
        document.getElementById("lname").style.color = defaultColor;
    
    if(document.getElementById("txtaddress").value == "")
    {
       check = false;
       document.getElementById("address").style.color = errorColor;
    }
    else
        document.getElementById("address").style.color = defaultColor;
           
    if(document.getElementById("txtpincode").value == "")
    {
       check = false;
       document.getElementById("pincode").style.color = errorColor;
    }
    else
        document.getElementById("pincode").style.color = defaultColor;
       
    if(document.getElementById("txtemail").value == "")
    {
       check = false;
       document.getElementById("email").style.color = errorColor;
    }
    else
        document.getElementById("email").style.color = defaultColor;
        
    if(document.getElementById("txtQuantity").value == "")
    {
       check = false;
       document.getElementById("quantity").style.color = errorColor;

    }
    else
        document.getElementById("quantity").style.color = defaultColor;
        
    var email = document.getElementById("txtemail");
    var cemail = document.getElementById("txtcemail");
    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    var address = cemail.value;
    
    var val = document.getElementById("txtCheck").value;
    
    if(Number(document.getElementById("txtCheck").value) == 0)
    {
       check2 = false;
    }

    if(reg.test(address) == false || email.value != cemail.value)
    {
        document.getElementById("email").style.color = errorColor;
        document.getElementById("cemail").style.color = errorColor;
        check1 = false;
    }
    else
    {
        document.getElementById("email").style.color = defaultColor;
        document.getElementById("cemail").style.color = defaultColor;
    }    
    
    if (check == false)
    {
        alert("Please Enter the details for the information labeled in Yellow");
        return false;
    }
    else if(check1 == false)
    {
        alert('Invalid Email Address or Email Addresses does not match');
        return false;
    }
    else if (check2 == false)
    {
        alert(document.getElementById("message").innerHTML);
        return false;  
    }
    else
        return true;  
}

function goToProducts()
{
    window.location = "products.htm";
}

function checkdisabled(el) 
{
    if (el.options[el.selectedIndex].disabled) 
    {
        alert ("This option is not available!")
        el.selectedIndex = 0;
    }
}


function validateSupport()
{
    var check = true;
    var check1 = true;

    if(document.getElementById("txtfname").value == "")
    {
        check = false;
        document.getElementById("fname").style.color = errorColor;
    }
    else
       document.getElementById("fname").style.color = defaultColor;
           
    if(document.getElementById("txtlname").value == "")
    {
       check = false;
       document.getElementById("lname").style.color = errorColor;
    }
    else
        document.getElementById("lname").style.color = defaultColor;
    
    if(document.getElementById("txtQuery").value == "")
    {
       check = false;
       document.getElementById("lblQuery").style.color = errorColor;
    }
    else
        document.getElementById("lblQuery").style.color = defaultColor;
     
    if(document.getElementById("txtemail").value == "")
    {
       check = false;
       document.getElementById("email").style.color = errorColor;
    }
    else
        document.getElementById("email").style.color = defaultColor;
    
    var email = document.getElementById("txtemail");
    var cemail = document.getElementById("txtcemail");
    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    var address = cemail.value;
    
    if(reg.test(address) == false || email.value != cemail.value)
    {
        document.getElementById("email").style.color = errorColor;
        document.getElementById("cemail").style.color = errorColor;
        check1 = false;
    }
    else
    {
        document.getElementById("email").style.color = defaultColor;
        document.getElementById("cemail").style.color = defaultColor;
    }
    
    if (check == false)
    {
        alert("Please Enter the details for the information labeled in Yellow");
        return false;
    }
    else if(check1 == false)
    {
        alert('Invalid Email Address or Email Addresses does not match');
        return false;
    }
    else
        return true; 
}

function showHideSupport()
{
    var supportDiv = document.getElementById("supportForm");
    
    if (supportDiv)
    {
        if (supportDiv.style.visibility  != "visible")
            supportDiv.style.visibility  = "visible";
        else
            supportDiv.style.visibility  = "hidden";
    }
}


function loadPage(url)
{
    window.open(url, '_self', null);
}

function changeClass(divID)
{
    var elem = document.getElementById(divID);
    
    if (elem.className == 'menuButton')
    {
        elem.className = "menuButtonClicked";
    }
    else
    {
        elem.className = "menuButton";
    }
}

function checkSpecialChrs(control)
{
    var checkStr = control.value;
    
    if (checkStr.indexOf("'") != -1         || checkStr.indexOf("\"") != -1         || checkStr.indexOf("&") != -1         || checkStr.indexOf("?") != -1
        || checkStr.indexOf("\\") != -1
        || checkStr.indexOf("=") != -1
        || checkStr.indexOf("*") != -1
        || checkStr.indexOf("%") != -1 )
    {
        alert("Please enter the valid character!");
        
        checkStr = checkStr.replace(/'/, "");
        checkStr = checkStr.replace(/\"/, "");
        checkStr = checkStr.replace(/&/, "");
        checkStr = checkStr.replace(/\?/, "");
        checkStr = checkStr.replace(/\\/, "");
        checkStr = checkStr.replace(/\=/, "");
        checkStr = checkStr.replace(/\*/, "");
        checkStr = checkStr.replace(/\%/, "");
        
        control.value = checkStr;
        control.focus();
    }
}

