function doAjaxRequest(pars, div, callback) {
  jQuery.ajax({
    type: "POST",
    url: "?",
    data: pars,
    success: callback
  });
}

function validateEmail(elementValue) {
  var emailPattern = /^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
  return emailPattern.test(elementValue);
}

jQuery.preloadImages = function() {
	var a = (typeof arguments[0] == 'object')? arguments[0] : arguments;
	for(var i = a.length -1; i > -1; i--) {
		jQuery("<img>").attr("src", a[i]);
	}
}

/*var prelod = ['image1.gif', 'image2.gif'];
$.preloadImages(preload);

$.preloadImages('image1.gif', 'image2.gif');*/

var path = '/site/ceres/images/static/vine/';
var preload = [path + 'left1.png',
               path + 'right1.png',
               path + 'left2.png',
               path + 'right2.png',
               path + 'left3.png',
               path + 'right3.png',
               path + 'left4.png',
               path + 'right4.png',
               path + 'left5.png',
               path + 'right5.png',
               path + 'left6.png',
               path + 'right6.png'];

jQuery.preloadImages(preload);

//$.preloadImages('image1.gif', 'image2.gif');



function updateLeftVine(direction) {
  doAjaxRequest("CoMeT_function=run_module&module=SiteTools&function=vine&action=update_vine&direction=" + direction, '#left', updateLeftVineResponse);
}

function updateRightVine(direction) {
  doAjaxRequest("CoMeT_function=run_module&module=SiteTools&function=vine&action=update_vine&direction=" + direction, '#right', updateRightVineResponse);
}

function updateLeftVineResponse(html) {
  jQuery('#left').fadeIn('slow');
  jQuery('#left').html(html);
}

function updateRightVineResponse(html) {
  jQuery('#right').fadeIn('slow');
  jQuery('#right').html(html);
}




/*jQuery(document).ready(function() {
  setTimeout(letItGrow, 4000);
});

function letItGrow() {

  //left
  var params = ({
    salign: "lt", menu: false, scale: "noscale", wmode: "transparent"
  });
  var attributes = ({
    id: "ceres_grow_left"
  });
  var flashvars = ({});
  swfobject.embedSWF("/site/ceres/flash/ceres_grow_left_175x590.swf", "ceres_grow_left", "175", "590", "9.0.0", 0, flashvars, params, attributes);

  //right
  var params = ({
    salign: "lt", menu: false, scale: "noscale", wmode: "transparent"
  });
  var attributes = ({
    id: "ceres_grow_right"
  });
  var flashvars = ({});
  swfobject.embedSWF("/site/ceres/flash/ceres_grow_right_250x590.swf", "ceres_grow_right", "250", "590", "9.0.0", 0, flashvars, params, attributes);

}*/
