﻿<!--

        function closeAll(id, lnk)
        {
            if (document.getElementById('overview'))
            {
                document.getElementById('overview').style.display = 'none';    
                document.getElementById('overviewlnk').style.color = '#000000';
            }
                
            if (document.getElementById('ingredients'))
             {
                document.getElementById('ingredients').style.display = 'none';    
                document.getElementById('ingredientslnk').style.color = '#000000';
            }
                
            if (document.getElementById('usage'))        
             {
                document.getElementById('usage').style.display = 'none';    
                document.getElementById('usagelnk').style.color = '#000000';
            }
                
            if (document.getElementById('info'))
             {
                document.getElementById('info').style.display = 'none';    
                document.getElementById('infolnk').style.color = '#000000';
            }                            
                
            document.getElementById(id).style.display = '';
            document.getElementById(lnk).style.color = '#acd01a';
        }

        function goToPayPal()
        {
            var previousAction = document.forms[0].action;
            var previousTarget = document.forms[0].target;
            document.forms[0].action = 'https:\/\/www.paypal.com\/cgi-bin\/webscr';
            document.forms[0].target = 'PAYPAL';
            document.forms[0].submit();
            document.forms[0].action = previousAction;
            document.forms[0].target = previousTarget;
        }    
        
        function ViewPayPalCart()
        {
            var addId = document.getElementById("addId");
            addId.name = addId.name + "_";
            
            var item_nameId = document.getElementById("item_nameId");
            item_nameId.name = item_nameId.name + "_";
            
            var item_numberId = document.getElementById("item_numberId");
            item_numberId.name = item_numberId.name + "_";
            
            var amountId = document.getElementById("amountId"); //document.getElementById('productprice').innerText;
            amountId.name = amountId.name + "_";
            
            var no_shippingId = document.getElementById("no_shippingId");
            no_shippingId.name = no_shippingId.name + "_";
            
            var no_noteId = document.getElementById("no_noteId");
            no_noteId.name = no_noteId.name + "_";
            
            var currency_codeId = document.getElementById("currency_codeId");
            currency_codeId.name = currency_codeId.name + "_";
            
            var lcId = document.getElementById("lcId");
            lcId.name = lcId.name + "_";
            
            var bnId = document.getElementById("bnId");
            bnId.name = bnId.name + "_";
            
            goToPayPal();
        }
        
        function AddToPayPalCart()
        {
            var display = document.getElementById("displayId");
            display.name = display.name + "_";
            // Set the price
            HandlePayPalPrice(GetItemPrice());
            
            goToPayPal();
        }
        
        function GetItemPrice()
        {
            //var productPriceLable = document.getElementById("productTopContentRepeater_ctl00_productPriceLabel");
            var price = document.getElementById('productprice').innerText;
            return price;
        }
        
        function HandlePayPalPrice(price)
        {
            price = price.replace(/\$/,"");
            // change the amountId (paypal) value
            var amountId = document.getElementById("amountId");
            if(amountId != null)
            {
                amountId.value = price;
            }
        }   


function sendMail()
{
//'Dim fname, lname, email, phone, address, country, remarks
	var fname = document.getElementById("fname")
	var lname = document.getElementById("lname")
	var email = document.getElementById("email")
	var phone = document.getElementById("phone")
	
	
	if(validateEmpty(fname) == false) 
	{	
		alert("wrong value");
		return false;
	}
	
	if(validateEmpty(lname) == false) 
	{	
		alert("wrong value");
		return false;
	}


	if(validateEmpty(email) == false) 
	{	
		alert("wrong value");
		return false;
	}
	else
	{
	    if(checkMail(email) == false) 
		    return false;
	}	

	if(checkPhone(phone) == false) 
		return false;
	
}


function checkMail(obj)
{
	if (obj.value != "") 
	{
		var x = obj.value;
		var msg = "wrong email"
		
		if (x.indexOf("@") == -1 || x.indexOf(".") == -1) 
		{
			alert(msg);
			obj.focus();
			return false;
		}
	}
	
	return true;
}

function checkPhone(obj)
{
	var x, msg;
	
	if (obj.value != "") 
	{
		msg = "wrong phone number"
		x = obj.value;
		if (isNaN(x)) 
		{
			alert(msg);
			obj.focus();
			return false;
		}

		if (x.length < 7) {
			alert(msg);
			obj.focus();
			return false;
		}
		
		/*if (x.substring(0,1) < 2)
		{
			alert(msg);
			obj.focus();
			return false;
		}*/
	}
	return true;
}

function validateEmpty(field)
{
	if (field.value == "")
	{
		field.focus();
		field.select();
		return false;
	}
}

function charValidate(type) 
{
	var chr = event.keyCode;
	var isValidChar;

	switch (type) 
	{
		case "numeric":		// (Only numbers)
			isValidChar = (chr >= 48 && chr <= 57);
			break;

		case "phone":	// (Numbers & "-")
			isValidChar = ( (chr >= 48 && chr <= 57) || chr == 45 );
			break;
			
		case "date":		// (Numbers & "/")
			isValidChar = ( (chr >= 48 && chr <= 57) || chr == 47 );
			break;
			
		case "name":		// (Hebrew and English (both cases), Space, "-", """)
			isValidChar = ( (chr >= 65 && chr <= 90) || (chr >= 97 && chr <= 122) || (chr >= 227 && chr <= 250) ||  (chr >= 1488 && chr <= 1514) || chr == 32 || chr == 34 || chr == 45 );
			break;
			
		case "english":		// (English (both cases) and Space)
			isValidChar = ( (chr >= 65 && chr <= 90) || (chr >= 97 && chr <= 122) || chr == 32 );
			break;
			
		case "user":		// (English (both cases) and Numbers)
			isValidChar = ( (chr >= 48 && chr <= 57) || (chr >= 65 && chr <= 90) || (chr >= 97 && chr <= 122) );
			break;
			
		case "email":		// (English and Numbers and "_", "-", ".", "@",	"-", "/")
			isValidChar = ( ( chr >= 45 && chr <= 57) || ( chr >= 65 && chr <= 90) || ( chr >= 97 && chr <= 122) || chr == 64 || chr == 95 );
			break;
			
		default:
			isValidChar = true
	}

	if (!isValidChar) 
		event.returnValue = false;
}


function sendMail_heb()
{
//'Dim fname, lname, email, phone, address, country, remarks
	var fname = document.getElementById("fname")
	var lname = document.getElementById("lname")
	var email = document.getElementById("email")
	var phone = document.getElementById("phone")
	
	
	if(validateEmpty(fname) == false) 
	{	
		alert("חסרים נתונים");
		return false;
	}
	
	if(validateEmpty(lname) == false) 
	{	
		alert("חסרים נתונים");
		return false;
	}


	if(validateEmpty(email) == false) 
	{	
		alert("חסרים נתונים");
		return false;
	}
	else
	{
	    if(checkMailHeb(email) == false) 
		    return false;
	}	

	if(checkPhoneHeb(phone) == false) 
		return false;
			

}


function checkMailHeb(obj)
{
	if (obj.value != "") 
	{
		var x = obj.value;
		var msg = "דואר אלקטרוני אינו תקין"
		
		if (x.indexOf("@") == -1 || x.indexOf(".") == -1) 
		{
			alert(msg);
			obj.focus();
			return false;
		}
	}
	
	return true;
}

function checkPhoneHeb(obj)
{
	var x, msg;
	
	if (obj.value != "") 
	{
		msg = "מספר טלפון אינו תקין"
		x = obj.value;
		if (isNaN(x)) 
		{
			alert(msg);
			obj.focus();
			return false;
		}

		if (x.length < 7) {
			alert(msg);
			obj.focus();
			return false;
		}
		
		/*if (x.substring(0,1) < 2)
		{
			alert(msg);
			obj.focus();
			return false;
		}*/
	}
	return true;
}

-->
