/*-----------------------------------------------------------------------------
| |
| shared.js |
| |
| Think Computer Corporation |
| Web Site 9.0 |
| JavaScript Library |
| |
| Copyright � 2001-2006 Think Computer Corporation. All Rights Reserved. |
| |
-----------------------------------------------------------------------------*/
var path = "/";
var shared = "/shared/";
var id = 0;
var handler = shared + 'javascript/handler.js?id=0';
// Based on code from http://homepage.ntlworld.com/bobosola
function correctPNG()
{
for(var i = 0; i < document.images.length; i++) {
var img = document.images[i]
var imgName = img.src.toUpperCase()
if (imgName.substring(imgName.length-3, imgName.length) == "PNG") {
var imgID = (img.id) ? "id='" + img.id + "' " : "";
var imgClass = (img.className) ? "CLASS='" + img.className + "' " : "";
var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
var imgStyle = "display:inline-block;" + img.style.cssText;
if (img.align == "left")
imgStyle = "float:left;" + imgStyle;
if (img.align == "right")
imgStyle = "float:right;" + imgStyle;
if (img.parentElement.href)
imgStyle = "cursor:hand;" + imgStyle;
var strNewHTML = "";
img.outerHTML = strNewHTML;
i = i - 1;
}
}
}
function preload(img)
{
var a = new Image();
a.src = img;
return a;
}
function defaultState()
{
if (hover) {
for (i = 0; i < areas.length; i++) {
eval("document['" + areas[i] + "'].src=" + areas[i] + "1.src;");
}
}
}
function rollover(image, value)
{
if (hover)
eval('document[\'' + image + '\'].src = ' + value + '.src;');
}
function generate_address(username, domain, extension, display) {
var atsign = "@";
var addr = username + atsign + domain + "." + extension;
document.write("<" + "a" + " " + "href=" + "mail" + "to:" + addr + ">"
+ display + "<\/a>");
}
function generate_self_address(username, domain, extension) {
var atsign = "@";
var addr = username + atsign + domain + "." + extension;
document.write("<" + "a" + " " + "href=" + "mail" + "to:" + addr + ">"
+ addr + "<\/a>");
}
// Pop-Up Windows
function openWindow(path, name, width, height, format)
{
window.open(path, name, "width=" + width + ",height=" + height + format);
}
// DIV Visibility
function showID(id)
{
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById(id).style.display = 'block';
} else {
if (document.layers) { // Netscape 4
document.id.display = 'block';
} else { // IE 4
document.all.id.style.display = 'block';
}
}
}
function hideID(id)
{
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById(id).style.display = 'none';
} else {
if (document.layers) { // Netscape 4
document.id.display = 'none';
} else { // IE 4
document.all.id.style.display = 'none';
}
}
}
function showTR(id)
{
if (ie) {
showID(id);
return;
}
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById(id).style.display = 'table-row';
} else {
if (document.layers) { // Netscape 4
document.id.display = 'table-row';
} else { // IE 4
document.all.id.style.display = 'table-row';
}
}
}
function hideTR(id)
{
if (ie) {
hideID(id);
return;
}
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById(id).style.display = 'none';
} else {
if (document.layers) { // Netscape 4
document.id.display = 'none';
} else { // IE 4
document.all.id.style.display = 'none';
}
}
}
function ajax_error(error)
{
var text = '';
text += "\n";
text += "\n";
text += "" + error + "\n\n";
return text;
}
// Buy
function copyBillTo(formName)
{
fields = new Array("salutation", "firstname", "lastname", "title", "organization", "address1", "address2", "city", "stateprovince", "postalcode", "country");
for (i = 0; i < fields.length; i++) {
if (document.forms[formName].elements['copy'].checked) {
document.forms[formName].elements['shipto' + fields[i]].value = document.forms[formName].elements['billto' + fields[i]].value;
} else {
document.forms[formName].elements['shipto' + fields[i]].value = '';
}
}
}
// Zoom
function initDialogue(shade, level)
{
if (typeof window.innerWidth != 'undefined') {
viewportwidth = window.innerWidth;
viewportheight = window.innerHeight;
} else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) {
viewportwidth = document.documentElement.clientWidth;
viewportheight = document.documentElement.clientHeight;
} else {
viewportwidth = document.getElementsByTagName('body')[0].clientWidth;
viewportheight = document.getElementsByTagName('body')[0].clientHeight;
}
newwidth = parseInt(viewportwidth * .9);
newheight = parseInt(viewportheight * .9);
if (navigator.vendor == 'Apple Computer, Inc.')
document.getElementById('zoomcontainer').style.left = (viewportwidth - newwidth) / 2;
document.getElementById('zoomcontainer').style.top = (viewportheight - newheight) / 2;
if (navigator.vendor == 'Apple Computer, Inc.') {
document.getElementById('zoomtable').attributes[0].value = parseInt(viewportwidth * .9);
document.getElementById('zoomtable').attributes[1].value = parseInt(viewportheight * .9);
}
document.getElementById('zoomtable').style.width = parseInt(viewportwidth * .9);
document.getElementById('zoomtable').style.height = parseInt(viewportheight * .9);
$('.dialogue .fullpage').width($(document).width());
$('.dialogue .fullpage').height($(document).height());
if (shade == 'light')
$('.dialogue .lightshade').css({opacity: level});
if (shade == 'dark')
$('.dialogue .darkshade').css({opacity: level});
}
function zoomIn(sourceid)
{
if (navigator.appName != 'Microsoft Internet Explorer') {
initDialogue('dark', 0.6);
var url = shared + 'javascript/handler.js?method=zoomIn';
var data = {'sourceid': sourceid};
$.get(url, data, function(response) {
eval('var response = ' + response);
if (! response) {
alert('There was no response from the server. Please check your network connection.');
} else {
if (response.error) {
alert('There was a problem with the server request. Please make sure your link is valid.');
} else {
document.getElementById('zoom').innerHTML = response;
}
initDialogue('light', 0.9);
showID('expand');
}
});
} else {
openWindow('/shared/javascript/zoom.html?sourceid=' + sourceid, 'zoomwindow', 960, 720, 'scrollbars=yes,resizable=yes');
}
}
function zoomOut()
{
hideID('expand');
document.getElementById('zoom').innerHTML = '';
}
// Sources
function addSource(sourceid, page)
{
var url = shared + 'javascript/handler.js?method=addSource';
var data = {'sourceid': sourceid, 'page': page};
$.get(url, data, function(response) {
eval('var response = ' + response);
if (! response) {
alert('There was no response from the server. Please check your network connection.');
} else {
if (response.error) {
alert('There was a problem with the server request. Please make sure your link is valid.');
} else {
alert('The source was added successfully.');
}
}
});
}
// Rollovers
netscape = navigator.appName == "Netscape";
netscape4 = netscape && parseInt(navigator.appVersion) <= 4;
ie = navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) >= 4;
opera = navigator.appName == "Opera";
hover = netscape || ie || opera;
if (ie)
window.attachEvent('onload', correctPNG);