$(document).ready(function(){
	$('#news-home').cycle({ 
		fx:      'scrollUp', 
		speed:    3500, 
		timeout:  10000,
		pause:    1,
		sync:     0,
		delay:    0
		});

	$(function() {
		$(this).bind("contextmenu", function(e) {
			e.preventDefault();
		});
	}); 
});

function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    document.MM_returnValue = (errors == '');
} }

function crossfader(src, type, html) { 
	$('#htmlstocrossfade div:last').fadeOut('fast');
	$('#htmlstocrossfade').append('<div>' + html + '</div>');
	$('#htmlstocrossfade div:last').fadeIn('slow');

	if (type == 'swf') {
		if (typeof(imagestocrossfade_counter) == 'undefined') {
			imagestocrossfade_counter = 0;
		}
		imagestocrossfade_counter++;
		$('#imagestocrossfade').append('<div><div id="FlashIDcrossfader' + imagestocrossfade_counter + '"></div></div>');
		var flashvars = {};
		var params = {
			quality: "high",
			wmode: "transparent"
		};
		var attributes = {};
		swfobject.embedSWF(src, 'FlashIDcrossfader' + imagestocrossfade_counter, '460', '650', '9.0.0', 'Scripts/expressInstall.swf', flashvars, params, attributes);
		$('#imagestocrossfade div:last').fadeIn('slow');
		$('#imagestocrossfade div').not(':last').fadeOut('fast');
	} else {
		$('#imagestocrossfade').append('<div><img src="' + src + '" /></div>');
		$('#imagestocrossfade div img:last').load(function() {
			$('#imagestocrossfade div:last').fadeIn('slow', function() {
				$('#imagestocrossfade div').not(':last').fadeOut('fast');
			});
		});
	}
}

function stickynote_open(ID, mID) {
	$('#dialog').dialog('destroy');
	$('#dialog').dialog({
		autoOpen: false,
		width: 450,
		height: 350,
		modal: true
 });
	$('#dialog_src').load('moodboard_notes.php', {
		ID: ID,
		mID: mID
	}, function(){
		//
	});
	$('#dialog').dialog('open');
}

function addtomoodboard(ID) {
	$.ajax({
		type: 'POST',
		url: 'moodboard-ajax.php',
		data: ({action: 'add', ID: ID}),
		dataType: 'json',
		success: function(data){
			//alert(data.result + '|' + data.error);
			if (data.result == 'ok') {
				$('#addtomoodboard_text').html('<p class="red">Added to Scrapbook<br /><a href="moodboard.html">Go to Mood Board Desktop</a></p>');
			} else {
				$('#addtomoodboard_text').html('<p>Error.<br /><a href="#" onclick="addtomoodboard(' + ID + '); return false">Add to Scrapbook</a></p>');
			}
		}
	});
}
