//Global JavaScript for Central Coast Gallery
//©2004 Ventura Educational Systems
<!--
if (document.all) {
}
else if (document.getElementById) { 
    document.captureEvents(Event.MOUSEDOWN)
}
else if (document.layers) {
    document.captureEvents(Event.MOUSEDOWN)
}

document.onmousedown = mousedown_handler

function mousedown_handler(mouse_event) {

    // This is the message that will appear
    var no_right_click = "These images are copyrighted by the Central Coast Gallery and the respective artists."
    
    if (document.all) {

        //Probably Internet Explorer 4 and later
        if (event.button == 2 || event.button == 3) {
            alert(no_right_click)
            return false
        }
    }
    else if (document.getElementById) { 

        // Probably Netscape 6 and later
        if (mouse_event.which == 3) {
            alert(no_right_click)
            return false
        }
    }
    else if (document.layers) {

        // Probably Netscape 4
        if (mouse_event.which == 3) {
            alert(no_right_click)
            return false
        }
    }
}


//-->



function openWindow(whichImage)
{
	winURL = "http://www.centralcoastgallery.com/images/"
	winURL += whichImage
	settings = "toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,"
	/*
  settings += "resizable=0,width=352,height=524"
  give it a little more room -- jv
  */
  settings += "resizable=0,width=660,height=575"
  
	newWin = window.open(winURL, "CloseUp", settings)
	
}

function openWindowJP(whichImage)
{
	winURL = "http://www.classicdesignsbyjanet.com/images/"
	winURL += whichImage
	settings = "toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,"
	/*
  settings += "resizable=0,width=352,height=524"
  give it a little more room -- jv
  */
  settings += "resizable=0,width=660,height=575"
  
	newWin = window.open(winURL, "CloseUp", settings)
	
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}

function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

function deleteCookie(name, path, domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" + 
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}



cartURL = "https://www.venturaes.com/secure/store/shopping_cart_ccg.asp"
settings = "toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,"
settings += "resizable=0,width=500,height=500"

function addToCart(SKU)
{
	url = cartURL + "?add=" + SKU + "&ref=" + document.URL
	cartWin = window.open(url, "Cart", settings)	
}

function showCart()
{
	cartWin = window.open(cartURL, "Cart", settings)
}

//JavaScript Banner Ad Rotator

var ImageFolder = "../images/features/"; //Folder containing images

var ImageFileNames = new Array(
 'fv_autumn_moon.jpg',
 'hs_strawberries.jpg',
 'mv_girl_with_cat.jpg',
 'ss_teapot.jpg',
 'kd_tulips.jpg'
); //List of images to use

var ImageURLs = new Array(
 'fv_a.html',
 'hs_wc.html',
 'mv_g.html',
 'ss_c.html',
 'kd_wc.html'
); //List of hyperlinks associated with the list of images

//Default hyperlink for the Banner Ad
var DefaultURL = 'fv_a.html';

var DisplayInterval = 10; //Number of seconds to wait before the next image is displayed
var TargetFrame = ""; //Name of the frame to open the hyperlink into

//Internal variables (do not change these unless you know what you are doing)
var IsValidBrowser = false;
var BannerAdCode = 0;
var BannerAdImages = new Array(NumberOfImages);
var DisplayInterval = DisplayInterval * 1000;
var NumberOfImages = ImageFileNames.length;

//Add a trailing forward slash to the ImageFolder variable if it does not already have one
if (ImageFolder.substr(ImageFolder.length - 1, ImageFolder.length) != "/" && ImageFolder != "")
{   ImageFolder += "/";
}

if (TargetFrame == '') {
   var FramesObject = null;
} else {
   var FramesObject = eval('parent.' + TargetFrame);
}

//Function runs when this page has been loaded and does the following:
//1. Determine the browser name and version
// (since the script will only work on Netscape 3+ and Internet Explorer 4+).
//2. Start the timer object that will periodically change the image displayed
// by the Banner Ad.
//3. Preload the images used by the Banner Ad rotator script
function InitialiseBannerAdRotator() {

   //Determine the browser name and version
   //The script will only work on Netscape 3+ and Internet Explorer 4+
   var BrowserType = navigator.appName;
   var BrowserVersion = parseInt(navigator.appVersion);

   if (BrowserType == "Netscape" && (BrowserVersion >= 3)) {
      IsValidBrowser = true;
   }

   if (BrowserType == "Microsoft Internet Explorer" && (BrowserVersion >= 4)) {
      IsValidBrowser = true;
   }

   if (IsValidBrowser) {
//      TimerObject = setTimeout("ChangeImage()", DisplayInterval);
      BannerAdCode = 0;

      for (i = 0; i < NumberOfImages; i++) {
         BannerAdImages[i] = new Image();
         BannerAdImages[i].src = ' ' + ImageFolder + ImageFileNames[i];
      }
   		ChangeImage()
   }

}

//Function to change the src of the Banner Ad image
function ChangeImage() {

   if (IsValidBrowser) {
	BannerAdCode = Math.floor(Math.random() * NumberOfImages)
     	BannerAdCode = BannerAdCode + 1;
      
      if (BannerAdCode == NumberOfImages) {
         BannerAdCode = 0;
      }
   
     window.document.bannerad.src = BannerAdImages[BannerAdCode].src;
     	TimerObject = setTimeout("ChangeImage()", DisplayInterval);
   }
}

//Function to redirect the browser window/frame to a new location,
//depending on which image is currently being displayed by the Banner Ad.
//If Banner Ad is being displayed on an old browser then the DefaultURL is displayed
function ChangePage() {

   if (IsValidBrowser) {
      
      if (TargetFrame != '' && (FramesObject)) {
         FramesObject.location.href = ImageURLs[BannerAdCode];
      } else {
         document.location = ImageURLs[BannerAdCode];
      }
      
   } else if (!IsValidBrowser) {
      document.location = DefaultURL;
   }

}
