﻿// JScript File


 function ConfirmPrint() {
	var answer = confirm("Are you sure you want to print this page?")
	if (answer){
		window.print();
		window.close();
	}
	else{
		//alert("Thanks for sticking around!")
		window.close();
	}
}

function showEmailDiv(val)
{
    if(document.getElementById(val).style.display == 'none')
    {
        document.getElementById(val).style.display = 'block';
    }
}

function hideEmailDiv(val)
{
    if(document.getElementById(val).style.display == 'block')
    {
        document.getElementById(val).style.display = 'none';
    }
}

function removeData(id,textValue)
{
    if(document.getElementById(id).value == textValue)
    {
        document.getElementById(id).value = '';
    }
}

function fillData(id,textValue)
{
    if(document.getElementById(id).value == '')
    {
        document.getElementById(id).value = textValue;
    }
}

function validate(val)
{
    var email = document.getElementById(val).value;
   // var yourEmail = document.getElementById('ctl00$ContentPlaceHolder1$yourEmail').value;
    var err = '';
   
    if(document.getElementById('ctl00$ContentPlaceHolder1$fullName').value == 'Your Name')
    {
        err += '- Your name\n';
    }
//     if(yourEmail == 'Your email')
//    {
//        err += '- Your email\n';
//    }
//    else if(!yourEmail.match(/^([a-zA-Z0-9])+([.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-]+)+/))
//    {
//        err += '- Your email is invalid\n';
//    }
    if(document.getElementById('ctl00$ContentPlaceHolder1$friendName').value == 'Friend Name')
    {
        err += '- Your friend name\n';
    }
    if(document.getElementById(val).value == 'Email Address')
    {
        err += '- Your friend email\n';
    }
    else if(!email.match(/^([a-zA-Z0-9])+([.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-]+)+/))
    {
        err += '- Your friend email is invalid\n';
    }
    if(err == '')
    {
        return true;
    }
    else
    {   
        alert('Please check following field for error\n\n'+err);
        return false;
    }
}