//'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
//	This script is the intellectual property of:
//	ALPHA51 INC.
//	
//	Copyright © 2000 ALPHA51 INC. All rights reserved.
//
//	Written by: Wayne Helman
//
//'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

var ns = (document.layers)? true:false
var ie = (document.all)? true:false
var dom = (document.getElementById)? true:false
var ns6 = (navigator.vendor == ("Netscape6") || navigator.product == ("Gecko"));
var pageht = 0;

var moDir = '/images/layout/';

function swap(img1,ref1,sts1) {
	document.images[img1].src = moDir + ref1 + ".gif";
	s(sts1);
	}

function s(txt) {
	if(txt != "") status = txt;
	else status = "Yorkville Sound";
	}

function popMisc(url,wd,ht) {
	var miscwin = window.open(url,'misc','height='+ht+',width='+wd+',toolbar=0,directories=0,menubar=0,status=0,resizable=1,location=0,scrollbars=1,copyhistory=0');
	}
function popUpPd(url,wd,ht) {
	var topX, leftY;
	topX =  (window.screen.height-ht)/2;
	leftY = (window.screen.width-wd)/2;
	win = window.open(url,'temp','height='+ht+',width='+wd+',toolbar=0,directories=0,menubar=0,status=0,resizable=1,location=0,scrollbars=1,copyhistory=0,screenX='+topX+',screenY='+leftY+',top='+topX+',left='+leftY);
	}

function isblank(s) {
    for(var i = 0; i < s.length; i++) {
        var c = s.charAt(i);
        if ((c != ' ') && (c != '\n') && (c != '\t')) return false;
    }
    return true;
}

function verify(f) {
    var msg;
    var empty_fields = "";
    var errors = "";

    for(var i = 0; i < f.length; i++) {
        var e = f.elements[i];
        if (((e.type == "text") || (e.type == "textarea")) && !e.optional) {
            // first check if the field is empty
            if ((e.value == null) || (e.value == "") || isblank(e.value)) {
				tempName = e.name;
				str = tempName.replace("_"," ")
				empty_fields += "\n          " + str;
                continue;
            }
			if (e.name == "Email") { 
				if (e.value.indexOf ('@',0) == -1 || e.value.indexOf ('.',0) == -1){      
					errors += "- Please format your email address correctly.";      
				} 
			}
        }
    }


    if (!empty_fields && !errors) return true;

    msg  = "______________________________________________________\n\n"
    msg += "The form was NOT submitted due to the following error(s).\n";
    msg += "Please correct the error(s) and re-submit.\n";
    msg += "______________________________________________________\n\n"

    if (empty_fields) {
        msg += "- The following required field(s) are empty:" 
                + empty_fields + "\n";
        if (errors) msg += "\n";
    }
    msg += errors;
    alert(msg);
    return false;
}

function preloadImages() {
  var d=document; if(d.images){ if(!d.p) d.p=new Array();
    var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
}

function getLocation(url,ext) {
	if(ext=='true') {
		window.open(url,'_newWin');
		}
	else {
		location.href = url;
		}
	}
	
function launchViewer(id) {
	if(getCookieValue('done') != 'true') {
		if(confirm('A pop-up window will be launched. Do you want to continue?\nPlease disable any pop-up blocking software.')) {
			setCookieValue('done','true');
			popUpPd('/products_photos.asp?id='+id,'500','400');
			}
		else {
			setCookieValue('done','false');
			}
		}
	else {
		popUpPd('/products_photos.asp?id='+id,'500','400');
		}
	}
	
function setCookieValue(key,val){
	document.cookie = key + " = " + val + "; expires = "
	}

function getCookieValue(name){
	var temp = document.cookie + ";";
	var pos = temp.indexOf("=", temp.indexOf(name + "="));
	if (temp.indexOf(name + "=") == -1) return "";
	return temp.substring(pos + 1, temp.indexOf(";", pos));
	}
	
function mail(un,text,subject) {
	document.write('<a href="mai' + 'lto:' + un + String.fromCharCode(64) + 'york' + 'ville.com?subject=' + subject + '">' + text + '</a>');
	}

function getH() {
    if(BrowserDetect.browser + BrowserDetect.version == 'Firefox3')
    {
        pageht = 0;
    }
	else if (document.all) {
		pageht = document.body.offsetHeight - 238;
		}
	else if (ns6) {
		pageht = window.innerHeight - 215;
		}
	else {
		pageht = window.innerHeight - 240;
		}
	return pageht;
	}


var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();