var sfHover = function() {
  var sfEls = document.getElementById("navigation").getElementsByTagName("LI");
  for (var i=0; i<sfEls.length; i++) {
    sfEls[i].onmouseover=function() {
      this.className+=" sfhover";
    }
    sfEls[i].onmouseout=function() {
      this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
    }
  }
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

var isFading = false;

function thumbDetails(lmnt,state) {
  $(lmnt).stop();
  if(state == 1) { 
    $(lmnt).fadeTo(500, 1, function(){
      $(lmnt).next().fadeTo('fast', 0.50);
      $(lmnt).next().next().fadeIn();
			$(lmnt).parent().css("z-index","50");
    });
  } else { 
    $(lmnt).next().fadeTo('fast' ,1 );  
    $(lmnt).next().next().fadeOut('fast',function(){
			$(lmnt).parent().css("z-index","5");
		});  
  }
}

function loadVideo(movPath,callback,container,playOnLoad) { 
	framePath = movPath.replace("flv","jpg");
	randNum = Math.random();
  var flashVars = {
      videoPath: movPath,
			framePath: framePath,
			autoStart: playOnLoad,
      loaderColor: "0xFFFFFF",
      displayColor: "0xFFFFFF",
      backFillColor: "0x000000",
      backFillAlpha: "0.60",
      displayPlayPause: "true",
      displayVolume: "true",
      displayTimeline: "true",
      displayTimeClock: "true",
      displayFullScreen: "true",
      finishFunction: callback
  };
  var flashParams = {
      wmode: "transparent",
      allowFullScreen: "true"
  };
  var flashAttributes = {
      id: "rauvideo",
      name: "rauvideo"
  };

  swfobject.embedSWF("/flash/gen_flv_player.swf?" + randNum, container, "512", "288", "9.0.0","/flash/expressInstall.swf", flashVars, flashParams, flashAttributes);
}

function videoCallback(a,b) { 
 alert(a + b);
}


var clearField = function(val) {
  val.value = '';
}

var activeFont = 12;
var changeFont = function(size) {
  $("#text"+activeFont).removeClass('active');
  $("#text"+size).addClass('active');
  $(".fontsize").css("font-size",size+"px");
  activeFont = size;
  makeCookie('fontsize',size,100);
}

// stop bubbling
var stopbubble = function(e){
  if (!e) var e = window.event;
  e.cancelBubble = true;
  if (e.stopPropagation) e.stopPropagation();
}

// create a cookie
var makeCookie = function(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else var expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}




//--------------------------------------------------------------------------------------------------------
// Z-Fade v. 1.01
// Copyright 2008 by Zaneray Inc.
// Written by: Flori Seeger
//--------------------------------------------------------------------------------------------------------
var zfade_active = false;
var zfade_speedmulti = 1;
var zfade = function (element, start, end, duration, init, callback) {
  if (element == null) {
    //alert('element to fade is null');
    return;
  }
  if (init == true){
		var date1 = new Date();
		element.startTime = date1.getTime();
    
		zfade_active = true;
    if (start < end){
      element.direction = 'in';
    }
    if (start > end){
      element.direction = 'out';
    }
    if (start == end){
      clearTimeout(element.fade);
      return;
    }
    element.speed = Math.round(100 / (duration / 33) * zfade_speedmulti);
    element.timeout = Math.round(duration / 100);
    clearTimeout(element.fade);
  }
  element.opacity = start;
  element.fire = false;
  switch (element.direction){
    case 'in':
      if ((element.opacity + element.speed) >= end){
        element.fire = false;
      }
      else {
        element.opacity = element.opacity + element.speed;
        element.fire = true;
      }
    break;
    case 'out':
      if (element.opacity - element.speed <= end){
        element.fire = false;
      }
      else {
        element.opacity = element.opacity - element.speed;
        element.fire = true;
      }
    break;
  }
  element.zopacity = function (opacity,element) {
    //alert(opacity);
    element.style.filter = "alpha(opacity=" + opacity + ")";
    element.style.opacity = (opacity / 100);
  }
  if (element.fire == true){
    element.zopacity (element.opacity, element);
    element.fade = setTimeout(function () { zfade(element, element.opacity, end, duration,false,callback);}, element.timeout);
  }
  else {
    element.zopacity(end,element);
    clearTimeout(element.fade);
		var date2 = new Date();
		var finish = date2.getTime();
		var newspeed = (finish-element.startTime)/duration;
		if ( newspeed > zfade_speedmulti) {
		  zfade_speedmulti = (finish-element.startTime)/duration;
		}
		// set minimum multip
		/* if (element.speedmulti < 1){
			element.speedmulti = 1;
		}
		*/
    if (!isEmpty(callback)){
      if ( callback.indexOf("(") > 0 ) {
        eval(callback);
      }
      else {
        eval(callback + "();");
      }
    }
  }
}

// enable fade
var setactivestate = function(){
  zfade_active = false;
}

//standard zaneray isEmpty
function isEmpty(v) {
  if (v == null) { return true; }
  if (typeof v == 'undefined') { return true; }
  if (v == undefined) { return true; }
  if (v == "") { return true; }
  return false;
}

function makeMovementArray(lft,pct,onlyEvens) {
  var updnAr = new Array();
  var noJumps = 15;
  var start = 0;
  if (onlyEvens) start++;
  var nxt = start;
  var lftOvr = ( lft % 2 );
  lft = parseInt((parseInt(lft) / 2) - 1);
  var nextInt = start;
  updnAr[0] = start;
  var done = false;
  var k = 1;
       
  while (!done) {
    nxt = nxt * pct;
    nextInt = parseInt(nxt);
    if (onlyEvens) {
      if ( ( nextInt % 2) == 1 ) {
        nextInt++;
      }
    }
    if (nextInt < lft) {
      updnAr[k] = nextInt;
    }
    else {
      if (lft < updnAr[k-1] ) {
        updnAr[k-1] = updnAr[k-1] + lft;
      }
      else {
        updnAr[k] = lft;
      }
      done = true; 
    }
    lft = lft - nextInt;
    k++;
  }
  var g = updnAr.length;
  for (var w=(updnAr.length-1); w > -1; w--) {
    updnAr[g] = updnAr[w];
    if (lftOvr == 1) { 
      updnAr[w] = updnAr[w] + 1;
      lftOvr = 0;
    }
    g++;
  }
  return updnAr;
}

//--------------------------------------------------
// paging logic for slides
// v.0.1
// written by: Flori Seeger
//--------------------------------------------------
var paging_logic = function(slide_position, slidesct, slides_num_display, clickFunction, containerElement, pre_html, post_html){
  //alert("slide_position:" + slide_position);
  // reset all html containers
  var left_html = '';
  var right_html = '';
  var output_html = ''
  var inner_html = '';
  
  // numbner display logic, build exceptions
  if (slide_position < 1){
    slide_position = 1;
  }
  if ( slide_position > slidesct ) {
    slide_position = slidesct; 
  }
  if (slide_position > 2 && slidesct > 4) {
    left_html = '<div onclick="'+clickFunction+'(';
    if  ((slide_position - slides_num_display) < 1 ) {
      left_html += '1';
    }
    else {
      left_html += '' + (slide_position - slides_num_display);
    }
    left_html += ')">&hellip;</div> ';
  }
   
  if ( ( slide_position + 1 ) >= slidesct ) {
    var stepback = 3 - (slidesct - slide_position); 
  }
  else {
    var stepback = 1;
  }
  if ( slide_position > 1 ) { 
    var startx = slide_position - stepback; 
  }
  else {
    var startx = slide_position;
  }
  if ( startx < 1 ) startx = 1; 
  
  if ((startx - 1) + slides_num_display < slidesct){
    right_html = ' <div onclick="'+clickFunction+'('+ (startx + slides_num_display) +')">&hellip;</div>';
  }
  // calculate center position
  var centerpos = Math.floor(slides_num_display / 2) + 1;

  // loop on available numbers
  var positioning = 0;
  //alert( "slide_position: " + slide_position + " - start position:" +startx + " slidesct:" +slidesct);  
  for (x = startx ; x < startx + slides_num_display; x++){
    if (x <= slidesct) {
      var inner_html = inner_html + ' <div id="switch' + x + '" onclick="'+clickFunction+'('+ x +')">' + x + '</div> ';
    }
  }
  // build data pool
  var output_html = left_html + inner_html +  right_html;
  // out put compiled data
  document.getElementById(containerElement).innerHTML = pre_html + output_html + post_html;
}

//--------------------------------------------------------------------------------------------------------
// Show Lightbox, infuse content
// Copyright 2008 by Zaneray Inc.
// Written by: Flori Seeger
//--------------------------------------------------------------------------------------------------------

// light box close
var show_light_box = function(path, alt){
  setprocessingheight();
	var imageToLoad = new Image();
	imageToLoad.src = path;
	
	if(imageToLoad.complete){
		imageIsLoaded();
	}
	else {
		imageToLoad.onload = imageIsLoaded;
	}
  img_assembly = '<img src="' + path + '" />';
	if (typeof alt != 'undefined'){
  	alt_assembly = '<br><br>' + alt;
	}
	else {
		alt_assembly = '';
	}
  
}

var show_light_box_article = function(article){
	setprocessingheight();
	document.getElementById('processing').style.display = 'block';
	document.getElementById('processingdisp').style.display = 'block';
	document.getElementById('processingdisp').innerHTML = '<img src="/images/common/ajax-loader.gif" />';
	var myformelements = "refid=" + article;
	$.post("/za/RAU/includes/load_article.jsp", myformelements,
		function(response){
			response = '<div id="close_button" onclick="close_light_box()"><img src="/images/zoom/close.png" /></div>' + response;
			document.getElementById('processingdisp').innerHTML = response;
			setprocessingheight();
		}
	);
}

var show_light_box_file = function(pathfile,headerlabel){
	setprocessingheight();
	document.getElementById('processing').style.display = 'block';
	document.getElementById('processingdisp').style.display = 'block';
	document.getElementById('processingdisp').innerHTML = '<img src="/images/common/ajax-loader.gif" />';
	var myformelements = '';
	$.post("/includes/request_a_phone_call.jsp", myformelements,
		function(response){
			response = '<div id="close_button" onclick="close_light_box()"><img src="/images/zoom/close.png" /></div><h3>'+headerlabel+'</h3><br>' + response;
			document.getElementById('processingdisp').innerHTML = response;
			setprocessingheight();
		}
	);
}

var imageIsLoaded = function(){
	var content_assembly = img_assembly + alt_assembly;
  document.getElementById('processing').style.display = 'block';
  document.getElementById('processingdisp').style.display = 'block';
	content_assembly = '<div id="close_button" onclick="close_light_box()"><img src="/images/zoom/close.png" /></div>' + content_assembly;
  document.getElementById('processingdisp').innerHTML = content_assembly;
  setprocessingheight();
}

// light box close
var close_light_box = function(){
  document.getElementById('processing').style.display = 'none';
  document.getElementById('processingdisp').style.display = 'none';
}
var reshow_light_box = function(){
  document.getElementById('processing').style.display = 'block';
  document.getElementById('processingdisp').style.display = 'block';
}

// ----------------------------------
// Z-Lightbox v. 1.0
// Copyright 2008 by Zaneray Inc.
// Written by: Flori Seeger
// ----------------------------------

function setprocessingheight() {
  if ($('processingdisp')){
    var xscroll = 0;
    var yscroll = 0;
    var xtotalscroll = 0;
    var ytotalscroll = 0;
    var xwindow = 0;
    var ywindow = 0;
    var xdiv = 0;
    var ydiv = 0;
    
    // how far scrolled in x and y directions
    xscroll = window.pageXOffset ||
              document.body.scrollLeft ||
              document.documentElement.scrollLeft;
  
    yscroll = window.pageYOffset ||
              document.body.scrollTop ||
              document.documentElement.scrollTop;
  
    // browser window width and height
    xwindow = self.innerWidth ||
              document.documentElement.clientWidth ||
              document.body.clientWidth;
              
    ywindow = self.innerHeight ||
              document.documentElement.clientHeight ||
              document.body.clientHeight;
    
    // total possible scroll x and y directions
    xtotalscroll = xwindow + window.scrollMaxX ||
                   document.body.scrollWidth ||
                   document.body.offsetWidth;
    
    ytotalscroll = ywindow + window.scrollMaxY ||
                   document.body.scrollHeight ||
                   document.body.offsetHeight;
    
    // get display container width and height       
    xdiv = document.getElementById('processingdisp').offsetWidth;
    ydiv = document.getElementById('processingdisp').offsetHeight;  
    
    //$('processing').style.width = xwindow + (xscroll - 20) + 'px'; //disabled and replaced with 100% width in css
    document.getElementById('processing').style.height = ywindow + yscroll + 'px';
    
    if (xwindow <= xdiv){
      document.getElementById('processingdisp').style.left = "0px";
    }
    else {
      document.getElementById('processingdisp').style.left = ((xwindow + xscroll*2) / 2) - (xdiv / 2) + "px"; //half the width of processingdisp
    }
  
    if (ywindow <= ydiv){
      document.getElementById('processingdisp').style.top = "0px";
    }
    else {
      document.getElementById('processingdisp').style.top = ((ywindow + yscroll*2) / 2) - (ydiv / 2) + "px"; //half the height of processingdisp
    }
  }
}


/*********************
 * ZrStatus object
 * 
 * Object that builds a status bar with given params, and steps to complete.
 * 
 */

ZrStatus = { 
    
    init: function (container,steps,wid,bcolor,ecolor) {
      statSteps = steps;
      width = wid;
      endColor = ecolor;
      bgColor = bcolor;
      cont = document.getElementById(container);
      cont.style.position = 'relative';
      cont.style.overflow = 'hidden';
      cont.style.backgroundColor = bgColor;
      innerBar = document.createElement('div');
      innerBar.style.position = 'absolute';
      innerBar.style.top = '0px';
      innerBar.style.left = '-' + wid + 'px';
      innerBar.style.width = wid + 'px';
      cont.appendChild(innerBar);
    },
    
    reinit: function() {
      innerBar.style.left = '-' + width + 'px';
      innerBar.style.filter='alpha(opacity=100)';
      innerBar.style.opacity=(1);
      cont.style.backgroundColor = bgColor;
    },
    
    step: function (idx) {
      if (idx >= statSteps) {
        innerBar.style.left = '0px';
        setTimeout("ZrStatus.complete()",100); 
      }
      else if (idx == 0) {
        ZrStatus.reinit();
      }
      else {
        innerBar.style.left = Math.round( ( width * ( idx / statSteps ) ) - width ) + 'px';
      }
    },
    
    complete: function() {
      cont.style.backgroundColor = endColor;
      var x = 100;
      for ( var g = 100; g>0; g=g-5) {
        setTimeout("innerBar.style.filter='alpha(opacity="+g+")'",x);
        setTimeout("innerBar.style.opacity=("+g+"/100)",x);
        x = x + 25;
      }
      setTimeout("innerBar.style.filter='alpha(opacity=0)'",x);
      setTimeout("innerBar.style.opacity=(0)",x);
    }
    
  } 


ZrLoadingDotDotDot = {
    
    init: function(ele,txt) {
      loadingDDText = txt;
      loadingDDContain = document.getElementById(ele);
      loadingDDStep = 0;
      ZrLoadingDotDotDot.animate();
    },
    
    setText: function(txt) {
      loadingDDText = txt;
    },
    
    //animates the ... at the end of the text 
    animate: function () {
      var outText = loadingDDText; 
      if ( loadingDDContain != undefined && loadingDDContain != null ) {
        for (var k=0; k<loadingDDStep; k++) { 
          outText += ".";
        }
        if ( loadingDDStep > 2 ) {
          loadingDDStep = 0;
        }
        else {
          loadingDDStep + 1;
        }
        loadingDDContain.innerHTML = outText;
        setTimeout("ZrLoadingDotDotDot.animate()",333);
      }
    }
    
  }
	
// ---------------------------------------------------
// form validation and basic email address check
// serialize form and store in zinformer
// ---------------------------------------------------
var zrGenericValidate = function(mandatoryvalues, formtosubmit, responsecontainer, hidebutton, postURL, callBack, optionhandler){
	// setup array with mandatory fields
	var mandatory = mandatoryvalues.split(',');
	// loop on mandatory fields and alert alt messages
	var mandatory_error = false;
	for (a = 0; a < mandatory.length; a++){
		if (document.getElementById(mandatory[a]).value == ''){
			alert(document.getElementById(mandatory[a]).alt);
			return;
		}
		else {
			if (mandatory[a].match('email') != null){
				if(document.getElementById(mandatory[a]).value.match('@') == null){
					alert ('Please enter a valid Email Address.');
					return;
				}
			}
		}
	}
	
	document.getElementById(hidebutton).style.display = 'none';
	document.getElementById(hidebutton + "loading").style.display = 'block';
	if (document.getElementById('rminfooption')){
		document.getElementById('rminfooption').value = optionhandler;
	}
	myformelements = $("#" + formtosubmit).serialize();
	
	if (postURL != ''){
		$.post(postURL, myformelements,
			function(response){
				eval(callBack + "('" + responsecontainer +"')");
				return false;
			}
		);
	}
	else {
		$.post("/", myformelements,
			function(response){
				eval(callBack + "('" + responsecontainer +"')");
				return false;
			}
		);
	}
}

var rmfajaxisdone = function(responsecontainer){
	if (document.getElementById('infoemailsignup').value == 'YES'){
		zrSendCustomerInfoEmail(document.getElementById('infofirstname').value,document.getElementById('infoemail').value,'Email Signup','/za/RAU/includes/send-customer-info-email.jsp');
		var signupstr = "OPTION=ZINFORMER_EMAILSIGNUP";
		signupstr += "&zin_save=1";
		signupstr += "&zin_type=EMAIL_SIGNUP";
		signupstr += "&zin_fields=FIRST_NAME,LAST_NAME,EMAIL,EMAIL_CONFIRM,ZIP,REFERRER";
		signupstr += "&zin_value_FIRST_NAME-1=" + document.getElementById('infofirstname').value;
		signupstr += "&zin_value_LAST_NAME-1=" + document.getElementById('infolastname').value;
		signupstr += "&zin_value_EMAIL-1=" + document.getElementById('infoemail').value;
		signupstr += "&zin_value_EMAIL_CONFIRM-1=";
		signupstr += "&zin_value_ZIP-1=" + document.getElementById('infozip').value;
		signupstr += "&zin_value_REFERRER-1=";
    $.post("/", signupstr,
			function(response){
				document.getElementById(responsecontainer).innerHTML = "<p>Thank you for your inquiry! We have received your request and you are now signed up for our Email News. We will respond as quickly as possible. Remember, you can also call us toll free at 1.866.349.0705 Monday through Saturday from 9:00 a.m. until 5:00 p.m. CST and one of our sales consultants will be happy to assist you. We look forward to serving you.</p><div class=\"closeform\" onclick=\"showForm('" + responsecontainer + "');\">Close [X]</div><div class=\"clear\"></div>";
				loadGoogleConversion(1061357274,"SM3jCPaT5QEQ2o2M-gM",0);
				loadGoogleConversion(1061357274,"au7iCP6S5QEQ2o2M-gM",0);
				return false;
			}
		);
	}
	else {
		document.getElementById(responsecontainer).innerHTML = "Thank you for your inquiry! We will respond as quickly as possible. Remember, you can also call us toll free at 1.866.349.0705 Monday through Saturday from 9:00 a.m. until 5:00 p.m. CST and one of our sales consultants will be happy to assist you. We look forward to serving you.<br><br><div class=\"closeform\" onclick=\"showForm('" + responsecontainer + "');\">Close [X]</div><div class=\"clear\"></div>";
		loadGoogleConversion(1061357274,"SM3jCPaT5QEQ2o2M-gM",0);		
	}	
}

var ajaxisdone = function(responsecontainer){
	document.getElementById(responsecontainer).innerHTML = "<p>Thank you. Your request for a phone call has been received. We look forward to speaking with you.</p><div class=\"closeform\" onclick=\"showForm('" + responsecontainer + "');\">Close [X]</div><div class=\"clear\"></div>";
	loadGoogleConversion(1061357274,"9UitCOaV5QEQ2o2M-gM",0);
}

var ajaxisdonefriend = function(responsecontainer){
	document.getElementById(responsecontainer).innerHTML = "<p>Thank you very much! Your Email to a Friend has been sent.</p><div class=\"closeform\" onclick=\"showForm('" + responsecontainer + "');\">Close [X]</div><div class=\"clear\"></div>";
	loadGoogleConversion(1061357274,"J9lMCN6W5QEQ2o2M-gM",0);
}



var show_light_box_article = function(article){
	setprocessingheight();
	document.getElementById('processing').style.display = 'block';
	document.getElementById('processingdisp').style.display = 'block';
	document.getElementById('processingdisp').innerHTML = '<img src="/images/common/ajax-loader.gif" />';
	var myformelements = "refid=" + article;
	$.post("/za/RAU/includes/load_article.jsp", myformelements,
		function(response){
			response = '<div id="close_button" onclick="close_light_box()"><img src="/images/zoom/close.png" /></div>' + response;
			document.getElementById('processingdisp').innerHTML = response;
			setprocessingheight();
		}
	);
}

var hideButton = function(id){
	btnWidth = $('#'+id+'').width();
	if( $('#'+id+'').attr('class') == 'formbutton') { 
		btnLt = $('#'+id+'').css('padding-left').replace('px','');
		btnRt = $('#'+id+'').css('padding-right').replace('px','');
		btnTotalPad = parseInt(btnLt) + parseInt(btnRt);
		btnTotal = btnTotalPad + btnWidth;
	} else { 
		btnTotal = btnWidth;
	}
	loaderPad = (btnTotal - 16) / 2;
	$('#'+id+'').css('display','none');
	loaderHTML = '<img class="loadingmini" height="16" width="16" style="display: inline; padding: 6px ' + loaderPad + 'px;" src="/images/common/ajax-loader-mini.gif"/>';
	$('#'+id+'').after(loaderHTML);
}


var catalogRequestDone = function(responsecontainer){
	if ($('#emailsignupcheckbox').attr('checked')) {
    $.get("/includes/blank.jsp?zin_save=1&zin_type=EMAIL_SIGNUP&zin_fields=FIRST_NAME,LAST_NAME,EMAIL,EMAIL_CONFIRM,ZIP,REFERRER&OPTION=ZINFORMER_EMAILSIGNUP&zin_value_FIRST_NAME-1=" + $('#catalogfirstname').val() + "&zin_value_LAST_NAME-1=" + $('#cataloglastname').val() + "&zin_value_EMAIL-1=" + $('#catalogemail').val() +"&zin_value_EMAIL_CONFIRM-1=&zin_value_ZIP-1=" + $('#catalogzip').val() + "&zin_value_REFERRER-1=CATALOG_REQUEST");
    loadGoogleConversion(1061357274,"au7iCP6S5QEQ2o2M-gM",0);
	}
	document.getElementById('catformwrapper').innerHTML = '<div class="landingthanks">Thank you for your request. You will receive your complimentary catalog and art stationery within 2 - 4 weeks. Stationery card art may vary.</div>';
	loadGoogleConversion(1061357274,"TGAhCJaKgAIQ2o2M-gM",0);
}

var personalShopperDone = function(responsecontainer) {
	if ($('#emailsignupcheckbox2').attr('checked')) {
    $.get("/includes/blank.jsp?zin_save=1&zin_type=EMAIL_SIGNUP&zin_fields=FIRST_NAME,LAST_NAME,EMAIL,EMAIL_CONFIRM,ZIP,REFERRER&OPTION=ZINFORMER_EMAILSIGNUP&zin_value_FIRST_NAME-1=" + $('#shopperfirstname').val() + "&zin_value_LAST_NAME-1=" + $('#shopperlastname').val() + "&zin_value_EMAIL-1=" + $('#shopperemail').val() + "&zin_value_EMAIL_CONFIRM-1=&zin_value_ZIP-1=&zin_value_REFERRER-1=PERSONAL_SHOPPER");
    loadGoogleConversion(1061357274,"au7iCP6S5QEQ2o2M-gM",0);
	}
	document.getElementById('contentshopper').innerHTML = '<div class="landingthanks">Thank you. Your request has been submitted. An M.S. Rau Sales Consultant will contact you shortly with your personalized suggestions.</div>';
}

var ticketRequestDone = function(responsecontainer) {
	if ($('#tixcontactme').attr('checked')) {
    $.get("/includes/blank.jsp?zin_save=1&zin_type=EMAIL_SIGNUP&zin_fields=FIRST_NAME,LAST_NAME,EMAIL,EMAIL_CONFIRM,ZIP,REFERRER&OPTION=ZINFORMER_EMAILSIGNUP&zin_value_FIRST_NAME-1=" + $('#tixfirstname').val() + "&zin_value_LAST_NAME-1=" + $('#tixlastname').val() + "&zin_value_EMAIL-1=" + $('#tixemail').val() + "&zin_value_EMAIL_CONFIRM-1=&zin_value_ZIP-1=&zin_value_REFERRER-1=TICKETS_REQUEST");
    loadGoogleConversion(1061357274,"au7iCP6S5QEQ2o2M-gM",0);
	}
	$('#ticketrequestcont').html($('#ticketrequestsubmitted').html());
	$CVO.trackEvent('ticket_download');
	loadGoogleConversion(1061357274,"WKMOCL7R_gEQ2o2M-gM",0);	
}

var loadGoogleConversion = function(cid,label,value){
  var h = window.location.protocol;
  if (typeof h === 'undefined'){ h = "http:"; }
  $("body").append('<img height="1" width="1" border="0" src="'+h+'//www.googleadservices.com/pagead/conversion/'+cid+'/?value='+value+'&amp;label='+label+'&amp;script=0"/>');
};

var emailsignupdone = function(responsecontainer){
	zrSendCustomerInfoEmail(document.getElementById('signupfirstname').value,document.getElementById('signupemail').value,'Email Signup','/za/RAU/includes/send-customer-info-email.jsp');
	
	setprocessingheight();
	document.getElementById('processing').style.display = 'block';
	document.getElementById('processingdisp').style.display = 'block';
	document.getElementById('processingdisp').innerHTML = '<img src="/images/common/ajax-loader.gif" />';
	var myformelements = "refid=EMAIL-TO-PROFILE";
	var acctParms = "afn=" + $("#signupfirstname").val();
	acctParms = acctParms + "&aln=" + $("#signuplastname").val();
	acctParms = acctParms + "&ae=" + $("#signupemail").val();
	acctParms = acctParms + "&az=" + $("#signupzip").val();
	$.post("/za/RAU/includes/load_article.jsp", myformelements,
		function(response){
			response = '<div id="close_button" onclick="close_light_box()"><img src="/images/zoom/close.png" /></div>' + response;
			document.getElementById('processingdisp').innerHTML = response + '<p style="text-align: center; padding-top: 20px;"><a href="/account/create-account.jsp?'+ acctParms +'" class="formbutton">Create an Account Now</a>';
			setprocessingheight();
		}
	);
	pageTracker._trackEvent('Email Signup','SUBMIT_EmailSignup',document.getElementById('signupzip').value,zrDateTime());
	document.getElementById(responsecontainer).innerHTML = "<p style='padding-left: 20px; width: 650px;'>Thank you for subscribing to M.S. Rau Antiques. You will be hearing from us soon. To make sure our email updates are delivered to your in box, please add info@rauantiques.com to your email address book or safe list. If you\'d also like to receive our award-winning catalog, please subscribe today.</p><div class=\"clear\"></div>";
}

var zrSendCustomerInfoEmail = function(name, email, subject, PostURL){
	var CustomerInfoEmailParam = "customername=" + name;
	CustomerInfoEmailParam += "&customeremail=" + email;
	CustomerInfoEmailParam += "&subject=" + subject;
	if (PostURL == ''){
		$.post("includes/send-customer-info-email.jsp", CustomerInfoEmailParam,
			function(response){
				return false;
			}
		);
	}
	else {
		$.post(PostURL, CustomerInfoEmailParam,
			function(response){
				return false;
			}
		);
	}
}

var active_tab = 'sa_assoc_prod1';
var zrTabLogic = function(element, e){
	if (e.type == 'click' && element.id != active_tab){
		document.getElementById(active_tab).className = '';
		document.getElementById(active_tab + "_content").style.display = 'none';
		document.getElementById(element.id + "_content").style.display = 'block';
		element.className = 'activetab';
		active_tab = element.id;
	}
}

var openTab = '';

var setTab = function(tab,tabContents) { 
	if (openTab == '') { 
		openTab = $('div.open:first').attr('id');
	}
	$('.activetab').removeClass();
	$(tab).addClass('activetab');
	$('#'+openTab).removeClass('open');
	$('#'+tabContents).addClass('open');
	openTab = tabContents;
}	



var zrSendSharedCollectionEmail = function(name, email, comments, wishlistid, wishlistname){
	if (name == ''){
		alert ('Please enter your friends name');
		return false;
	}
	if (email == ''){
		alert ('Please enter your friends email');
		return false;
	}
	var ShareCollectionEmailParam = "friendsname=" + name;
	ShareCollectionEmailParam += "&friendsemail=" + email;
	ShareCollectionEmailParam += "&sharecomment=" + comments;
	ShareCollectionEmailParam += "&wishlistid=" + wishlistid;
	ShareCollectionEmailParam += "&wishlistname=" + wishlistname;
	document.getElementById('sharesubmit_' + wishlistid).style.display = 'none';
	document.getElementById('sharesubmitloading_' + wishlistid).style.display = 'inline';
	$.post("/za/RAU/includes/send-shared-collection-email.jsp", ShareCollectionEmailParam,
		function(response){
			document.getElementById('sharecollectionform_' + wishlistid).innerHTML = '<p style="width: 250px;">Your collection has been shared with your friend.</p>';
		}
	);
}

var activeForm = '';
var busy = false;

var showForm = function(formId) { 
	if(busy == false) { 
		busy = true;
		switch (activeForm) {
			case formId:
				$("#"+formId).slideToggle('normal', function(){
					activeForm = '';
					busy = false;
				});
			break;
			case '':
				$("#"+formId).children('form .textfield:first').focus();
				$("#"+formId).slideToggle('normal', function(){
					activeForm = formId;
					busy = false;
				});
			break;
			default:
				$("#"+activeForm).slideToggle('normal', function(){
					$("#"+formId).slideToggle('normal', function(){
						activeForm = formId;
						busy = false;
					});
				});
		}
	}
}

	// Zaneray Ajax v 0.1
	var zrAajax = function (url, parameters, container){
		var request;
		try{ 
			request = new XMLHttpRequest();
			if (request.overrideMimeType) {
				request.overrideMimeType('text/xml');
			}
		}
		catch (e){
			try {
				request = new ActiveXObject("Msxml2.XMLHTTP");
			}
  		catch (e){
				try {
					request = new ActiveXObject("Microsoft.XMLHTTP");
				}
    		catch (e){
					alert('I give up!');
					return false;
				}
			}
		}
  	request.onreadystatechange = function(){
			if(request.readyState == 4){
      	if (request.status == 200) {
					if (container != ''){
						document.getElementById(container).innerHTML = request.responseText;
					}
				}
				else {
					alert('There was a problem with the request.');
				}
      }
    }
  	request.open("GET",url + parameters,true);
  	request.send(null);
	}
	
	//
	var zrScriptTagAjax = function (url, parameters, container){
		
		var header = document.getElementsByTagName("head").item(0);
		var randNumber = Math.random();
		
		if ($('ajaxjavascript')){
			var elementtofind = document.getElementsByTagName('script');
			for (var e = 0; e < elementtofind.length; e++){
				if (elementtofind[e].id == 'ajaxjavascript'){
					header.removeChild(elementtofind[e]);
				}
			}
		}
			
		ajaxScript = document.createElement('script');
		ajaxScript.id = 'ajaxjavascript';
		ajaxScript.type = 'text/javascript';
		ajaxScript.src = url + "?rn=" + randNumber;
		header.appendChild(ajaxScript);
	
	}
	
	var zrBreadStripper = function(){
		var strippedBread = document.getElementById('breadcrumbs').innerHTML;
		strippedBread = strippedBread.replace(/(<([^>]+)>)/ig,""); 
		strippedBread = strippedBread.replace(/\r|\n|\r\n/g, "");
		return "'" + strippedBread + "'";
	}
	
	var zrDateTime = function(){
		var currentTime = new Date()
		var month = currentTime.getMonth() + 1
		var day = currentTime.getDate()
		var year = currentTime.getFullYear()
		var currentTime = new Date()
		var hours = currentTime.getHours()
		var minutes = currentTime.getMinutes()
		if (minutes < 10){
			minutes = "0" + minutes;
		}
		var dateTime = month + day + year + hours + minutes;
		return dateTime;
	}


var swapIn = function(lmnt) { 
		srcImg = $(lmnt).attr("src");
		imgExt = srcImg.split(".");
		imgExt = "."+imgExt.pop();
		srcImg = srcImg.replace(imgExt,"-on"+imgExt);
		$(lmnt).attr("src",srcImg);
}

var swapOut = function(lmnt) { 
	srcImg = srcImg.replace("-on"+imgExt,imgExt);
	$(lmnt).attr("src",srcImg);
}


// fix Hayer Item Numbers

var fixHaynesItemNum = function(inum){
	var itemNumber = inum.substr(0,2);
	
	if (IsNumeric(itemNumber) == true){
		document.getElementById('productIdReplace_' + inum).innerHTML = inum;
	}
	else {
		itemNumber = inum.substr(2,inum.length);
		itemNumber = "29-" + itemNumber;
		document.getElementById('productIdReplace_' + inum).innerHTML = itemNumber;
	}
}
	
	
function IsNumeric(strString){
	var strValidChars = "0123456789-";
	var strChar;
	var blnResult = true;
	for (i = 0; i < strString.length && blnResult == true; i++){
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1){
			 blnResult = false;
		}
	}
 return blnResult;
 }

	
