
//__browser check code from Dynamic Web Coding - www.dyn-web.com
var dom = (document.getElementById) ? true : false;
var ns6 = ((navigator.userAgent.toLowerCase().indexOf("gecko")>-1) && dom) ? true: false;
var ie5 = ((navigator.userAgent.toLowerCase().indexOf("msie")>-1) && dom) ? true : false;
var ns4 = (document.layers && !dom) ? true : false;
var ie4 = (document.all && !dom) ? true : false;
var nodyn = (!ns6 && !ns4 && !ie4 && !ie5) ? true : false;
var windows = (navigator.userAgent.toLowerCase().indexOf("windows")>-1) ? true : false;
var mac = (navigator.userAgent.toLowerCase().indexOf("mac")!=-1) ? true: false;
var safari = (typeof document.childNodes!="undefined" && typeof document.all=="undefined" && typeof navigator.taintEnabled=="undefined") ? true: false;
var current_page = location.href;

//__ Adobe Rollover Script
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = true;
function preloadImages() {
	if (document.images) {
		shopping_basket_over = newImage("/miva/images/layout/shopping_basket-over.gif");
		top__basket_portion_06_over = newImage("/miva/images/layout/top__basket-portion_06-over.gif");
		home_over = newImage("/miva/images/layout/home-over.gif");
		games_over = newImage("/miva/images/layout/games-over.gif");
		repair_over = newImage("/miva/images/layout/repair-over.gif");
		consignment_over = newImage("/miva/images/layout/consignment-over.gif");
		rental_over = newImage("/miva/images/layout/rental-over.gif");
		faqs_over = newImage("/miva/images/layout/faqs-over.gif");
		testimonials_over = newImage("/miva/images/layout/testimonials-over.gif");
		links_over = newImage("/miva/images/layout/links-over.gif");
		contact_over = newImage("/miva/images/layout/contact-over.gif");
		login_over = newImage("/miva/images/layout/login-over.gif");
		instruments_over = newImage("/miva/images/layout/instruments-over.gif");
		strings_over = newImage("/miva/images/layout/strings-over.gif");
		bows_over = newImage("/miva/images/layout/bows-over.gif");
		cases_over = newImage("/miva/images/layout/cases-over.gif");
		accessories_over = newImage("/miva/images/layout/accessories-over.gif");
		gifts_over = newImage("/miva/images/layout/gifts-over.gif");
		music_over = newImage("/miva/images/layout/music-over.gif");
		books_over = newImage("/miva/images/layout/books-over.gif");
		specials_over = newImage("/miva/images/layout/specials-over.gif");
		teach_yourself_over = newImage("/miva/images/layout/teach_yourself-over.gif");
		preloadFlag = true;
	}
}


//__ Popup Window Scripts

var flashwin=null;
function popup(url,target,w,h){
	LeftPosition=(screen.width)?(screen.width-w)/2:100;
	TopPosition=(screen.height)?(screen.height-h)/2:100;

	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes';

	flashwin=window.open(url,target,settings);
}

var flashwin2=null;
function popup2(url,target,w,h){
	LeftPosition=(screen.width)?(screen.width-w)/2:100;
	TopPosition=(screen.height)?(screen.height-h)/2:100;

	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,location=no,directories=no,status=yes,menubar=no,toolbar=no,resizable=yes';

	flashwin2=window.open(url,target,settings);
}


//__ Function that confirms cancelling your order and logging you out

function confirm_cancel(){
	var logout_url = "http://www.violinshop.ca/miva/merchant.mvc?Action=LOGO&Screen=CTGY&Category_Code=_HOME";
	var cancel_message = "Are you sure you want to cancel your order and logout?\nThis will also erace your shopping basket contents.";

	var response = window.confirm(cancel_message);

	if(response) {
		top.location.href=logout_url;
	}
	else {
		return;
	}
}





///////////////////////////// MACROMEDIA DHTML LAYERS FUNCTIONS ///////////////////////////

//__ The MM_ functions are copyright Macromedia

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

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

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


//////////////////////////////////// MORE DHTML LAYER FUNCTIONS ///////////////////////////////

function dd_hide_selects() {
	var cp_selects = document.getElementsByTagName("select");
	var number_to_hide = 0;
	if (windows && ie5) {
		if (cp_selects.length > 4) {
			number_to_hide = 4;
		}
		else {
			number_to_hide = cp_selects.length;
		}
		for (var i=0; i<number_to_hide; i++) {
			cp_selects[i].style.visibility = "hidden";
		}
	}
}

function dd_show_selects() {
	var cp_selects = document.getElementsByTagName("select");
	var number_to_hide = 0;
	if (windows && ie5) {
		if (cp_selects.length > 4) {
			number_to_hide = 4;
		}
		else {
			number_to_hide = cp_selects.length;
		}
		for (var i=0; i<number_to_hide; i++) {
			cp_selects[i].style.visibility = "visible";
		}
	}
}

function dd_hide_show_selects(the_action) {
	var cp_selects = document.getElementsByTagName("select");
	var number_to_hide = 0;
	var number_needed_hidden = 4;  // 4 was the number of selects I needed to hide

	if (windows && ie5) {
		if (cp_selects.length > number_needed_hidden) {
			number_to_hide = number_needed_hidden;
		}
		else {
			number_to_hide = cp_selects.length;
		}
		for (var i=0; i<number_to_hide; i++) {
			cp_selects[i].style.visibility = the_action;
		}
	}
}

function DD_images_to_normal() {
  changeImages('home','images/layout/home.gif', 'games','images/layout/games.gif', 'repair','images/layout/repair.gif', 'consignment','images/layout/consignment.gif', 'rental','images/layout/rental.gif', 'faqs','images/layout/faqs.gif', 'testimonials','images/layout/testimonials.gif', 'links','images/layout/links.gif', 'contact','images/layout/contact.gif', 'login','images/layout/login.gif', 'instruments','images/layout/instruments.gif', 'strings','images/layout/strings.gif', 'bows','images/layout/bows.gif', 'cases','images/layout/cases.gif', 'accessories','images/layout/accessories.gif', 'gifts','images/layout/gifts.gif', 'music','images/layout/music.gif', 'books','images/layout/books.gif', 'specials','images/layout/specials.gif', 'teach_yourself','images/layout/teach_yourself.gif');
}


function DD_hide_all_layers() {
  MM_showHideLayers('hider1','','hide', 'hider2','','hide', 'divs_instruments','','hide', 'divs_instruments_beginners','','hide', 'divs_strings_violin','','hide', 'divs_strings_viola','','hide', 'divs_strings_cello','','hide', 'divs_strings_bass','','hide', 'divs_strings','','hide', 'divs_cases','','hide', 'divs_access','','hide', 'divs_access_stands','','hide', 'divs_access_endpins','','hide', 'divs_music_cds','','hide', 'divs_gifts','','hide', 'divs_music','','hide', 'divs_music_violin','','hide', 'divs_music_cello','','hide', 'divs_books','','hide', 'divs_specials','','hide', 'divs_repair','','hide', 'divs_rental','','hide', 'divs_faqs','','hide', 'divs_contact','','hide');
}


