/* Browser check */
IS_DOM = (document.getElementById) ? true : false;

function toggleList()
{
	var theListItems = document.getElementById("penListUl").getElementsByTagName("LI");
	if (penListState == "off") {
		turnListOn(theListItems);
	} else {
		turnListOff(theListItems);
	}
}

function turnListOn(theListItems)
{
	for (var i = 0; i < theListItems.length; i++)
	{ 
		theListItems[i].style.display = "inline";
	}
	penListState = "on";
}

function turnListOff(theListItems)
{
	for (var i = 0; i < theListItems.length; i++)
	{ 
		theListItems[i].style.display = "none";
	}
	document.getElementById("firstOne").style.display = "inline";
	penListState = "off";
}

// JavaScript Document
// JavaScript Document
var address;
function displayEmail() { 
    var x = document.getElementsByTagName('span');

    for (var i=0;i<x.length;i++) {
        if (x[i].className == 'hiddenemail') {
			scanHiddenEmail(x[i])
                if ((x[i].innerHTML !== null) && (address !== null))
                x[i].innerHTML = '<a href=\'mailto:' + address + '\'>' + address + '</a>';
        }
		
		if (x[i].className == 'hiddenTitleEmail') {	
			scanHiddenEmail(x[i])
                if ((x[i].innerHTML !== null) && (address !== null))
  				         x[i].innerHTML = '<a href=\'mailto:' + address + '\'><img src=\'../../images/subpage-email.gif \' height= \'33\' /> </a>';
             
		}
        
        if (x[i].className == 'hiddenMenuEmail') {    
            scanHiddenEmail(x[i])
                if ((x[i].innerHTML !== null) && (address !== null))
                           x[i].innerHTML = '<a href=\'mailto:' + address + '\'><img src=\'images/subpage-email.gif \' height= \'33\' /> </a>';
             
        }
        
		if (x[i].className == 'hiddenMainPageEmail') {	
			scanHiddenEmail(x[i])
                if ((x[i].innerHTML !== null) && (address !== null))
  				         x[i].innerHTML = '<a href=\'mailto:' + address + '\'><img src=\'images/email.gif \' width=\'233\' height= \'27\' /> </a>';
             
		}
		
    }
}


function scanHiddenEmail(s) {
	var y = s.getElementsByTagName('span');
                for (var j=0;j<y.length;j++) {
                    if (y[j].className == 'name') {
                        if (y[j].innerHTML !== null)
                        address = y[j].innerHTML + '@';
                    }
                    if (y[j].className == 'domain') {
                        if (y[j].innerHTML !== null)
                        address = address + y[j].innerHTML + '.';
                    }
                    if (y[j].className == 'extension') {
                        if (y[j].innerHTML !== null)
                        address = address + y[j].innerHTML;
                    }
                 }
 return address;           
}

function copyrightYear(startYear)
{
	d = new Date();
	
	if (startYear != d.getFullYear())
		{
		return startYear + " - " + d.getFullYear();
		}
	else
		{
		return startYear;
		}
}

var penListState = "off";

function toggleList(collapse) {
	if (collapse == "off") { penListState = "on"; }
	var theListItems = document.getElementById("pensList").getElementsByTagName("li");
	if (penListState == "off") {		
		turnListOn(theListItems);
	} else {
		turnListOff(theListItems);
	}
}
						
function turnListOn(theListItems) {
	
	for (var i = 0; i < theListItems.length; i++) 
	{
		theListItems[i].style.display = "block";
	}
	penListState = "on";
}

function turnListOff(theListItems) {
	for (var i = 0; i < theListItems.length; i++){
		theListItems[i].style.display = "none";
	}
	document.getElementById("firstOne").style.display = "block";
	penListState = "off";
}

function check(min)
{
	if(isNaN(document.first_quote.quantity.value))
	{
		alert("Please enter a numerical value for Quantity");
		document.first_quote.quantity.focus();
		return false;
	}
	//$myrow["category_min"]
	var min_quantity = min;
	var input = document.first_quote.quantity.value;
	if( input < min_quantity )
	{
		alert("Please enter an amount higher than the minimum order quantity (minimum for this product is "+min_quantity+")");
		document.first_quote.quantity.focus();
		return false;
	}
	//document.first_quote.action="personailized_quote_new.php";
}

function checkmail()
{
	var regEmail = /^([-a-zA-Z0-9._]+@[-a-zA-Z0-9.]+(\.[-a-zA-Z0-9]+)+)$/;  ////E-Mail Checking
	if(!regEmail.test(document.frmMail.youremail.value))
	{
		alert("Please enter your e-mail address");
		document.frmMail.youremail.focus();
		return false;
	}
	if(!regEmail.test(document.frmMail.friendemail.value))
	{
		alert("Please enter an e-mail address for your friend");
		document.frmMail.friendemail.focus();
		return false;
	}		
}

function grabimage() 
{	
	document.getElementById('prodimginput').value = document.getElementById('prodimg').src;		
}

function fastquoteSubmit(name, id)
{
	document.getElementById('fqName').value = name;
	document.getElementById('fqID').value = id;
	
	document.getElementById('fqForm').submit();
}