
	
	
	//Browser Check
	var ns = (navigator.appName.indexOf("Netscape") != -1);
	var ns4 = (document.layers)? true:false;
	var ie = (document.all)? true:false;
	var ie4 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 4.")!=-1)) ? true : false;
	var ie5 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 5.")!=-1)) ? true : false;
	var ie6 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 6.")!=-1)) ? true : false;
	var ie7 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 7.")!=-1)) ? true : false;
	var ns6 = (!document.layers) && (navigator.userAgent.indexOf('Netscape')!=-1)?true:false;
	var isMac = (navigator.appVersion.indexOf("Mac")!=-1) ? true : false;
	var isLinux = (navigator.appVersion.indexOf("Linux")!=-1) ? true : false;

	var GalleryPopupWin;
	var initImages = false;
	var initProducts = false;
	
	function InitMe(){
	    if (initImages) initImageData();
	    if (initProducts) {
	      // alert("InitMe: initProductDetail()...");
	      initProductDetail();
	    }
	}

    function OpenGalleryPopup(nGalleryId)
    {
	    GalleryPopupWin=window.open('/gallerypopup.aspx?GalleryID='+nGalleryId,'PhotoGallery','dependent,resizable,scrollbars,width=865,height=650');
	    GalleryPopupWin.focus();
    }

	function MakeArray(n)
	{
		this.Length = n;
		for ( var i = 1; i <= n; i++)
		{
			this[i] = 0 ;
		}
		return this ;
	}

	function GetRadioValue(objRadio)
	{
		for (var i=0; i < objRadio.length; i++)
	   {
			if (objRadio[i].checked)
	      {
			return objRadio[i].value;
	      }
	   }
	}
	
	function SelectRadioValue(objRadio,strValue)
	{
		for (var i=0; i < objRadio.length; i++)
	   {
		  if ( objRadio[i].value == strValue)
	      {
			objRadio[i].checked = true;
	      }
	   }
	}
	
	function setSelectedIndex(objSelect, strValue) {
		if (objSelect){
			if (objSelect.options.length > 0)
			{
				for (var i = 1;i <= objSelect.options.length; i++)
				{
					if (objSelect.options[i]){
						if ( objSelect.options[i].value == strValue) objSelect.selectedIndex = i;
					}
			  	}
			}
		}
	}
	
	// Custom Dialog Boxes
	//http://www.webreference.com/dhtml/dynomat/dialogs/

	function newAlert(title,mess,icon,mods) {
	   if (ie && !isLinux){
			makeMsgBox(title,mess,icon,0,0,mods);
		}else{
			alert(mess);
		}
	}

	function newConfirm(title,mess,icon,defbut,mods) {
	   if (ie) {
	      //icon = (icon==0) ? 0 : 2;
	      defbut = (defbut==0) ? 0 : 1;
	      retVal = makeMsgBox(title,mess,icon,4,defbut,mods);
	      retVal = (retVal==6);
	   }
	   else {
	      retVal = confirm(mess);
	   }
	   return retVal;
	}

	function newPrompt(title,mess,def) {
	   retVal = (ie) ? makeInputBox(title,mess,def) : prompt(mess,def);
	   return retVal;
	}

	function IEBox(title,mess,icon,buts,defbut,mods) {
	   retVal = (ie) ? makeMsgBox(tit,mess,icon,buts,defbut,mods) : null;
	   return retVal;
	}
		
	function replaceString(oldS,newS,fullS) 
	{
		// Replaces oldS with newS in the string fullS   
		for (var i=0; i<fullS.length; i++)
		{
			if (fullS.substring(i,i+oldS.length) == oldS) 
			{
		        	fullS = fullS.substring(0,i)+newS+fullS.substring(i+oldS.length,fullS.length);
			}
		}
		return fullS;
	}
			
	function Trim(TRIM_VALUE){

		if(TRIM_VALUE.length < 1){
			return"";
		}
		TRIM_VALUE = RTrim(TRIM_VALUE);
		TRIM_VALUE = LTrim(TRIM_VALUE);

		if(TRIM_VALUE==""){
			return "";
		}
		else{
			return TRIM_VALUE;
		}
    }

    function RTrim(VALUE){
		var w_space = String.fromCharCode(32);
		var v_length = VALUE.length;
		var strTemp = "";


		if(v_length < 0){
			return"";
		}
		var iTemp = v_length -1;

		while(iTemp > -1){
			if(VALUE.charAt(iTemp) == w_space){}


			else{
				strTemp = VALUE.substring(0,iTemp +1);
				break;
			}
			iTemp = iTemp-1;
		}
		return strTemp;
    }

    function LTrim(VALUE){
    	var w_space = String.fromCharCode(32);

    	if(v_length < 1){
        		return"";
       	}
        var v_length = VALUE.length;
        var strTemp = "";
        var iTemp = 0;

        while(iTemp < v_length){
        	if(VALUE.charAt(iTemp) == w_space){}
        	else{
        		strTemp = VALUE.substring(iTemp,v_length);
        		break;
        	}
        	iTemp = iTemp + 1;
        }
        return strTemp;
	}
	
	function writeIt(text,id)
	{
		var x;
		if (document.all)
		{
			x = document.all[id];
			if(x){
			x.innerHTML = '';	
			x.innerHTML = text;
			}
		}
		else
		if (document.getElementById)
		{
			x = document.getElementById(id);
			if (x){
			x.innerHTML = '';
			x.innerHTML = text;
			}
		}
		else	
		if (document.layers)
		{
			x = document.layers[id];
			text2 = '<p>' + text + '</p>';
			if (x){
			x.document.open();
			x.document.write(text2);
			x.document.close();
			}
		}
	}
	
	function getElement(psID) {
		if(document.all) {
		   return document.all[psID];
		} else {
			if(document.getElementById) {
				return document.getElementById(psID);
		   }else{
				return false;
		   }
		}
	}
	
	function PageQuery(q) {
		if(q.length > 1) this.q = q.substring(1, q.length);
		else this.q = null;
		
		this.keyValuePairs = new Array();
		if(q) {
			for(var i=0; i < this.q.split("&").length; i++) {
			this.keyValuePairs[i] = this.q.split("&")[i];
			}
		}
		this.getKeyValuePairs = function() { return this.keyValuePairs; }
		this.getValue = function(s) {
			for(var j=0; j < this.keyValuePairs.length; j++) {
				if(this.keyValuePairs[j].split("=")[0] == s)
				return this.keyValuePairs[j].split("=")[1];
			}
			return false;
		}
		this.getParameters = function() {
			var a = new Array(this.getLength());
			for(var j=0; j < this.keyValuePairs.length; j++) {
				a[j] = this.keyValuePairs[j].split("=")[0];
			}
			return a;
		}
		this.getLength = function() { return this.keyValuePairs.length; } 
	}

	function queryString(key){
		var page = new PageQuery(window.location.search); 
		return unescape(page.getValue(key)); 
	}	

	function getxmlhttp() 
	{ 
	    var xmlhttp;
	    var success = false;
	    
	    
        if (!success && typeof XMLHttpRequest!='undefined') {
            try {
                success = true;
	            xmlhttp = new XMLHttpRequest();
            } catch (e) {
	            success = false;
            }
        }
        if (!success && window.createRequest) {
            try {
                success = true;
	            xmlhttp = window.createRequest();
            } catch (e) {
	            success = false;
            }
        }
        if (!success){
            // IE Browsers 
	        var progIDs = ["msxml2.xmlhttp.5.0","msxml2.xmlhttp.4.0","msxml2.xmlhttp.3.0","msxml2.xmlhttp","Microsoft.xmlhttp"]; 
	        for(var currentProgID = 0;currentProgID < progIDs.length;currentProgID++) 
	        { 
	            try 
	            { 
	               xmlhttp = new ActiveXObject(progIDs[currentProgID]); 
	            } 
	            catch(e){} 
	        }  
	    }  
	    return xmlhttp; 
	}
  
  function getxmldoc() 
	{ 
	    var doc;  
	     
	    // IE Browsers 
	    var progIDs = ["msxml2.DOMDocument.5.0","msxml2.DOMDocument.4.0","msxml2.DOMDocument.3.0","msxml2.DOMDocument"]; 
	    for(var currentProgID = 0;currentProgID < progIDs.length;currentProgID++) 
	    { 
	        try 
	        { 
	            doc = new ActiveXObject(progIDs[currentProgID]);       
	            return doc; 
	        } 
	        catch(e){} 
	    } 
	}
	
function InputEnabler(objInput, bEnable) {
	if (bEnable) {
		objInput.disabled = false;
		objInput.style.backgroundColor = "#ffffff";
	}else{
		objInput.disabled = true;
		objInput.style.backgroundColor = "#ddd";
	}
}	


function IsNumeric(sText){
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;  
}

function checkKey(event, objInput)
	{ 	
		var code = 0;
		var bSubmit = false;
								
		if (ns4)
			code = event.which;
		else
			code = event.keyCode;
	
	// Enter key pressed
		if (code==13){
			switch (objInput.name)
			{
				case 'SearchWords':
					bSubmit = true;
					break;
				case 'SearchValue':
					bSubmit = true;
					break;
				case 'email':
					bSubmit = checkEmail(objInput);
					break;	
			}
			if(bSubmit){
				 objInput.form.submit();
			}
		}								
	}

function changeClass(sId,sClassName) {
	var elem = getElement(sId);
	if(elem) elem.className = sClassName;
}

function checkEmail(objEmail) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/.test(objEmail.value)){
		return true;
	}else{
		alert("Invalid E-mail Address! Please re-enter.");
		return false;
	}
}

	
/***********************************************
* Modified from
* Pop-it menu- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

	var PopIt_ie5=document.all && !window.opera;
	var PopIt_ns6=document.getElementById;

	if (PopIt_ie5||PopIt_ns6)
		document.write('<div id="PopIt" onMouseover="clearPopIt();" onMouseout="dynamicHide(event)"></div>');

	function iecompattest(){
		return (document.compatMode && document.compatMode.indexOf("CSS")!=-1)? document.documentElement : document.body;
	}

	function showPopIt(e, which, optWidth){
		if (!document.all&&!document.getElementById)
			return
		clearPopIt();
		PopItobj=PopIt_ie5? document.all.PopIt : document.getElementById("PopIt");
		PopItobj.innerHTML=which;
		PopItobj.style.width=(typeof optWidth!="undefined")? optWidth : 150;
		PopItobj.contentwidth=PopItobj.offsetWidth;
		PopItobj.contentheight=PopItobj.offsetHeight;
		eventX=PopIt_ie5? event.clientX : e.clientX;
		eventY=PopIt_ie5? event.clientY : e.clientY;
		//Find out how close the mouse is to the corner of the window
		var rightedge=PopIt_ie5? iecompattest().clientWidth-eventX : window.innerWidth-eventX;
		var bottomedge=PopIt_ie5? iecompattest().clientHeight-eventY : window.innerHeight-eventY;
		//if the horizontal distance isn't enough to accomodate the width of the context menu
		if (rightedge<PopItobj.contentwidth)
			//move the horizontal position of the menu to the left by it's width
			PopItobj.style.left=ie5? iecompattest().scrollLeft+eventX-PopItobj.contentwidth+"px" : window.pageXOffset+eventX-PopItobj.contentwidth+"px";
		else
			//position the horizontal position of the menu where the mouse was clicked
			PopItobj.style.left=PopIt_ie5? iecompattest().scrollLeft+eventX+8+"px" : window.pageXOffset+eventX+8+"px";
		//same concept with the vertical position
		if (bottomedge<PopItobj.contentheight)
			PopItobj.style.top=PopIt_ie5? iecompattest().scrollTop+eventY-PopItobj.contentheight+"px" : window.pageYOffset+eventY-8-PopItobj.contentheight+"px";
		else
			PopItobj.style.top=PopIt_ie5? iecompattest().scrollTop+event.clientY+"px" : window.pageYOffset+eventY+"px";
		PopItobj.style.visibility="visible";
		return false;
	}

	function contains_ns6(a, b) {
		//Determines if 1 element in contained in another- by Brainjar.com
		while (b.parentNode)
			if ((b = b.parentNode) == a)
				return true;
		return false;
	}

	function hidePopIt(){
		if (window.PopItobj)
			PopItobj.style.visibility="hidden";
	}

	function dynamicHide(e){
		if (PopIt_ie5&&!PopItobj.contains(e.toElement))
			hidePopIt();
		else if (PopIt_ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
			hidePopIt();
	}

	function delayhidePopIt(){
		delayhide=setTimeout("hidePopIt()",500);
	}

	function clearPopIt(){
		if (window.delayhide)
			clearTimeout(delayhide);
	}

	if (PopIt_ie5||PopIt_ns6)
		document.onclick=hidePopIt;

/***********************************************
* end of PopIt
***********************************************/


