﻿function simplePreload()
{ 
  var args = simplePreload.arguments;
  document.imageArray = new Array(args.length);
  for(var i=0; i<args.length; i++)
  {
    document.imageArray[i] = new Image;
    document.imageArray[i].src = args[i];
  }
}

function switchImage(imgName, imgSrc) 
{
  if (document.images)
  {
    if (imgSrc != "none")
    {
      document.images[imgName].src = imgSrc;
    }
  }
}

function selectTab(tabLink, tabName)
{
    var tab = findObj(tabName);
    var lnk = findObj(tabLink);
	lnk.onmouseover = "";
	lnk.onmouseout = ""; 
    switch(tabName)
    {   
        case 'tabHome':
			tab.src = 'images/home_selected.jpg';
			break;
		case 'tabAbout':
			tab.src = 'images/about_selected.jpg';
			break;
		case 'tabService':
			tab.src = 'images/service_selected.jpg';
			break;
		case 'tabContact':
		    tab.src = 'images/contact_selected.jpg';
		    break;
        case 'tabLinks':
            tab.src = 'images/links_selected.jpg';
            break;
        case 'tabCart':
            tab.src = 'images/cart_selected.jpg';
            break;                        	    		    
    }
}

// Example: obj = findObj("image1");
function findObj(theObj, theDoc)
{
  var p, i, foundObj;
  
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  
  return foundObj;
}

function showCoupon()
{
    popWindow('coupon.aspx');
}

function popWindow(url) {
	var winURL;
	LeftPos = (screen.width)?(screen.width-410)/2:100;
	TopPos = (screen.height)?(screen.height-260)/2:100;
	winURL = window.open(url,'popup','width=410,height=260,left='+LeftPos+',top='+TopPos)
	if (window.focus) {winURL.focus()}
}
