﻿
function OpenCloseDiv(objDiv)
{
	var objDiv = document.getElementById(objDiv);
	if (objDiv.style.display == "block")
		objDiv.style.display = "none";
	else 
		objDiv.style.display = "block";	
}

function OpenLabLocator()
	{
	    // online
		window.open("http://www.onlineuha.com/lab-locator.aspx?Param=0;0;0&lati=37.090240&long=-95.712891&zoom=5","Lab_Locator","width=756,height=527, resizable=no");
		// local
		//window.open("http://192.168.0.15/lab-locator.aspx?Param=0;0;0&lati=37.090240&long=-95.712891&zoom=5","Lab_Locator","width=756,height=527, resizable=no");
	}
function openMemberRegistration()
{
	    // online
		window.open("http://www.onlineuha.com/popup/subscriber.aspx","_blank","width=500,height=400,top=120,left=250,resizable=no");
		// local
		//window.open("http://localhost:1672/OnlineUHA/popup/subscriber.aspx","_blank","width=500,height=400,top=120,left=250,resizable=no");
	}
function CheckEmptyTextBox(txt)
{
    var str = /^\s*$/;
    if (str.test(document.getElementById(txt).value))
    {
        document.getElementById(txt).focus();
        return false;
    }
    return true;
}

function CheckZipCode(txt)
{
    var str = /^([0-9]{5})$/;
    if (!str.test(document.getElementById(txt).value))
    {
       document.getElementById(txt).focus();  
       return false;
    }
    return true;
}

function CheckPhoneNo(txt)
{
    var str = /^([0-9]{4}-[0-9]{4}-[0-9]{3})$/;
    if (!str.test(document.getElementById(txt).value))
    {
       document.getElementById(txt).focus();  
       return false;     
    }
    return true;
}

function CheckTrueFalse(chk)
{
    if (document.getElementById(chk).checked == false)
    {
        document.getElementById(chk).focus();
        return false;
    }
    return true;
}

function CheckEmailAddress(str) 
{
    var emailpat = /^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9])+(\.[a-zA-Z0-9_-]+)+$/;
    if(!emailpat.test(str)) 
       return false;
    return true; 
}

/*function CheckEmailAddress(str) 
 {
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){return false}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){return false}
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){return false}
    if (str.indexOf(at,(lat+1))!=-1){return false}
    if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){return false}
	if (str.indexOf(dot,(lat+2))==-1){return false}
    if (str.indexOf(" ")!=-1){return false}
    return true					
 }*/

/**************** Generic function for pages *********************/
/* 
cart.aspx
*/

function ValidateQuantity(txt)
{
    if (txt != null)
    {
        if (CheckEmptyTextBox(txt.id) == false) 
        { 
            alert('Product quantity should not left blank..');
            return false; 
        } 
        else if (parseInt(txt.value) < 1)
        {
            alert('Quantity should be greater then 0.');
	        txt.focus();
	        return false;
        }
    }
	return true;
}

function DescriptionCounter(field,cntfield,maxlimit) 
{
    if (field.value.length > maxlimit) // if too long...trim it!
    {
        alert("Maximum limit 300 characters for description");
        field.value = field.value.substring(0, maxlimit);
    }
    //otherwise, update 'characters left' counter
    else
       document.getElementById(cntfield).innerHTML = maxlimit - field.value.length;
}