//General Purpose image-rollover Function
function rollOver(image_name, image_location)
{
        if (document.images)
        {
                document [image_name].src = image_location;
        }
}



//General Purpose popUp Function
//usage - call from the onClick: return (#, #, 'name', 'url', 1/0, 1/0) where the last 2 parameters must be a 1 or 0.
function popUpWindow (window_width, window_height, window_name, window_url, _resizeable, _scrollbars )
{
	var options="resizable="+_resizeable+",scrollbars="+_scrollbars+",width="+window_width+",height="+window_height+"";
	popupWin=window.open(window_url, window_name, options);
	return false;
}



//Full Window (all the browser bells and whistles) popUp Function
//usage - call from the onClick: return (#, #, 'name', 'url', 1/0, 1/0) where the last 2 parameters must be a 1 or 0.
function popUpFullWindow (window_width, window_height, window_name, window_url)
{
	var options="resizable=1,scrollbars=1,toolbar=1,location=1,menubar=1,status=1,directories=1,width="+window_width+",height="+window_height+"";
	popupWin=window.open(window_url, window_name, options);
	return false;
}


//Handy email validation function
function checkEmail(checkString)
{  
    var newstr = ""; 
    var at = false;
    var dot = false;

    if (checkString.indexOf("@") != -1)
    {
      at = true;
    } 
    else if (checkString.indexOf(".") != -1)
    {
      dot = true;
    }
    for (var i = 0; i < checkString.length; i++)
    {
        ch = checkString.substring(i, i + 1)
        if ((ch >= "A" && ch <= "Z") || (ch >= "a" && ch <= "z") || (ch == "@") || (ch == ".") || (ch == "_") || (ch == "-") || (ch >= "0" && ch <= "9"))
        {
            newstr += ch;
                if (ch == "@")
                {
                    at=true;
                }
                if (ch == ".")
                {
                    dot=true;
                }
        }
    }
    if ((at == true) && (dot == true))
    {
        return true;
    }
    else
    {
        //alert ("Sorry, the email address you\nentered is not in the correct\nformat.");
        return false;
    }
}


//Function to update any class on any stylesheet
function modifyCSSClass(class_name, css_element, css_value)
{
	var rule_descriptor;
	//Insert cheap ie detector here :()
	if(document.all)
	{
		rule_descriptor = "rules";
	}
	else
	{
		rule_descriptor = "cssRules";
	}
	
	for(var n=0; n<document.styleSheets.length; n++)
	{
		for(var p=0; p<document.styleSheets[n][rule_descriptor].length; p++)
		{
			if(document.styleSheets[n][rule_descriptor][p].selectorText.toLowerCase() == class_name.toLowerCase())
			{
				document.styleSheets[n][rule_descriptor][p].style[css_element] = css_value;
			}
		}
	}
}


//function used on all the product pages to simplify the popup call
function showProductScreen(section_number, screen_number)
{
	return popUpWindow(660, 555, "product_screenshot", "screenshot_popup.php?section=" + section_number + "&screen=" + screen_number, 1, 1);
}

