﻿// JScript File

function menuHandler(sItem)
{
	var item = document.getElementById(sItem);
	
	if (item.style.display == "none")
	{
		item.style.display = "";
	}
	else
	{
		item.style.display = "none";
	}
}

/**
* Short cut for getting the element by id
* @param anon the string of the element id
*/
function $() {
	var elements = new Array();
	for (var i = 0; i < arguments.length; i++) {
		var element = arguments[i];
		if (typeof element == 'string')
			element = document.getElementById(element);
		if (arguments.length == 1)
			return element;
		elements.push(element);
	}
	return elements;
}//end $
/**
* This method is used to get around the "new feature"
* in IE for embedding content in websites
* @param container element id of the container
* @param movie the url of the movie
* @param width the width
* @para, height the height
*/
function showFlash(container, movie, width, height) {                                   
    var output = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' width='"+width+"' height='"+height+"' id='myflash'>";
    output += "<param name='allowScriptAccess' value='sameDomain' />";
    output += "<param name='movie' value='" + movie + "' />";
    output += "<param name='quality' value='high' />";
    output += "<embed src='" + movie + "' quality='high' width='"+width+"' height='"+height+"' name='mymovie' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />";
    output += "</object>"; 
    $(container).innerHTML = output;
}//end showFlash 

/**
* This method will change the image
* src to the provided url
* 
* @param element the image element
* @param url the url to use
*/
function changeImage(element, url){
    element.src = url;
}//end changeImage

function openDetails(id) {
    var load = window.open("../Web/MerchandiseDetail.aspx?ID="+id, "DetailWindow", "scrollbars=no,menubar=no,height=520,width=370,resizable=no,toolbar=no,location=no,status=no");
    load.focus(); 
} 

function glFormValidatePhone(src,args) { 
    var homePh = document.getElementById("ctl00$CphMain$HomePhone");
    var workPh = document.getElementById("ctl00$CphMain$WorkPhone");
    if (homePh.value.length < 7 ) {
        args.IsValid = false;
    } 
}

function glFormValidatePayment(src,args) { 
    var pymnt = document.getElementById("ctl00$CphMain$Payment");
    if (pymnt.selectedIndex == 0) {
        args.IsValid = false;
    } 
}

function glFormQuantityVerification(src,args) {
    var elems = document.forms[0].getElementsByTagName("input");
    for (var i=0; i < elems.length; i++) {
        if (elems[i].name.indexOf("qty") > -1) {
             if (elems[i].value != "" && isNaN(elems[i].value)) {
                //alert("Failed");
                args.IsValid = false;
             }
        } 
    }  
}


						