/*!
 * Haunted Site jQuery Plugin | Random Ghost Pop-up Elements
 *	Preview Page Ghosts Generator
 *
 * Copyright © 2010-2011, Alessio Caporale
 * Twitter: @Alex_Workshop
 * E-mail: ale887it@hotmail.it
 * 
 * Includes jQuery 1.4+
 * http://jquery.com/
 *
 * The plugin is NOT freeware, the license to use it is sold only at http://codecanyon.net/
 * Further information on how to buy it can be found at http://codecanyon.net/user/AlexBay
 */

  /*
   * Sample Ghost Content Definitions
   */
  var loremGhost	= "Lorem ipsum dolor sit amet, consectetur adipisicing elit,sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.<br />Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.<br />Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.<br />Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",

	  imageGhost	= "<a href=\"sylwester.html\"><img src=\"sample_assets/test.jpg\"/> </a>",

	  mixGhost		= "<img src=\"sample_assets/scottwills_riverbank.jpg\" alt=\"Image\" style=\"float: left; margin-right: 20px;\" />Lorem ipsum dolor sit amet, consectetur adipisicing elit,sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.<br />Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.<br />Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.<br />Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.<br />Lorem ipsum dolor sit amet, consectetur adipisicing elit,sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.<br />Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.<br />Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.<br />Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.<br />Lorem ipsum dolor sit amet, consectetur adipisicing elit,sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.<br />Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.",

	  triggerGhost = "trigger",

  /*
   * Samples Properties Definitions
   */
  	  greyTextS 	= {	'minDuration'	:	7,
						'maxDuration'	:	10,
						'minInterval'	:	11,
						'maxInterval'	:	15,
						'istant'		:	true	},

	  blackTextS	= {	'minDuration'	:	7,
						'maxDuration'	:	10,
						'minInterval'	:	11,
						'maxInterval'	:	15,
						'istant'		:	true,
						'style'			:	2 		},

	  blueTextS		= {	'minDuration'	:	7,
						'maxDuration'	:	10,
						'minInterval'	:	11,
						'maxInterval'	:	15,
						'istant'		:	true,
						'style'			:	3 		},

	  redTextS		= {	'minDuration'	:	7,
						'maxDuration'	:	10,
						'minInterval'	:	11,
						'maxInterval'	:	15,
						'istant'		:	true,
						'style'			:	4		},

	  greenTextS	= {	'minDuration'	:	7,
						'maxDuration'	:	10,
						'minInterval'	:	11,
						'maxInterval'	:	15,
						'istant'		:	true,
						'style'			:	5 		},

	  pinkTextS		= {	'minDuration'	:	7,
						'maxDuration'	:	10,
						'minInterval'	:	11,
						'maxInterval'	:	15,
						'istant'		:	true,
						'style'			:	6 		},

	  floatTextS	= {	'minDuration'	:	7,
						'maxDuration'	:	10,
						'minInterval'	:	11,
						'maxInterval'	:	15,
						'float'			:	true,
						'istant'		:	true	},

	  staticTextS	= {	'minDuration'	:	7,
						'maxDuration'	:	10,
						'minInterval'	:	11,
						'maxInterval'	:	15,
						'static'		:	true,
						'istant'		:	true	},

	  posDefinedS	= {	'minDuration'	:	7,
						'maxDuration'	:	10,
						'minInterval'	:	11,
						'maxInterval'	:	15,
						'static'		:	true,
						'left'			:	100,
						'top'			:	100,
						'istant'		:	true	},

	  bottRightS	= {	'minDuration'	:	7,
						'maxDuration'	:	10,
						'minInterval'	:	11,
						'maxInterval'	:	15,
						'static'		:	true,
						'left'			:	"right",
						'top'			:	"bottom",
						'istant'		:	true	},

	  noSwingS		= {	'minDuration'	:	7,
						'maxDuration'	:	10,
						'minInterval'	:	11,
						'maxInterval'	:	15,
						'swing'			:	0,
						'istant'		:	true	},

	  bigSwingS		= {	'minDuration'	:	7,
						'maxDuration'	:	10,
						'minInterval'	:	11,
						'maxInterval'	:	15,
						'swing'			:	30,
						'istant'		:	true	},

	  slowS			= {	'minDuration'	:	15,
						'maxDuration'	:	25,
						'minInterval'	:	30,
						'maxInterval'	:	40,
						'istant'		:	true	},

	  fastS			= {	'minDuration'	:	2,
						'maxDuration'	:	5,
						'minInterval'	:	6,
						'maxInterval'	:	10,
						'istant'		:	true	},

	  delayedS		= {	'minDuration'	:	7,
						'maxDuration'	:	10,
						'minInterval'	:	11,
						'maxInterval'	:	15		},

	  horizCenterS	= {	'minDuration'	:	7,
						'maxDuration'	:	10,
						'minInterval'	:	11,
						'maxInterval'	:	15,
						'static'		:	true,
						'left'			:	"center",
						'top'			:	1100,
						'istant'		:	true	},

	  vertCenterS	= {	'minDuration'	:	7,
						'maxDuration'	:	10,
						'minInterval'	:	11,
						'maxInterval'	:	15,
						'static'		:	true,
						'left'			:	100,
						'top'			:	"center",
						'istant'		:	true	},

	  fullCenterS	= {	'minDuration'	:	7,
						'maxDuration'	:	10,
						'minInterval'	:	11,
						'maxInterval'	:	15,
						'static'		:	true,
						'left'			:	"center",
						'top'			:	"center",
				
						'istant'		:	true	},

	  imageS		= {	'minDuration'	:	7,
						'maxDuration'	:	10,
						'minInterval'	:	11,
						'maxInterval'	:	15,
						'istant'		:	true,
						'style'			:	0		},

	  mixS			= {	'minDuration'	:	7,
						'maxDuration'	:	10,
						'minInterval'	:	11,
						'maxInterval'	:	15,
						'istant'		:	true,
						'style'			:	3		},

	  modalS		= {	'minDuration'	:	7,
						'maxDuration'	:	10,
						'minInterval'	:	11,
						'maxInterval'	:	15,
						'modal'			:	true,
						'istant'		:	true,
						'style'			:	0		},

	  callerId = 0,		//Caller id for sleeping ghosts
	  ghostNum = 0;		//Generated ghosts number

 /*
  *	@param	html	the ghost content
  *	@param	options	ghostify options
  */
  function GhostGen(html, options) {

	if (ghostNum > 10) {		//Remove ghosts after 10 have been spawned
		clearGhosts();
	}

	var newGhost = document.createElement('div');		//Create new one

	if (html == "trigger") {			//Trigger is more complex

		newGhost.innerHTML = "<strong>Click or Close Me to Awake the Sleeping Ghost!</strong>";

		document.body.appendChild(newGhost);		//Add ghost
		ghostNum++;

		$newG = $(newGhost);
		var caller = "caller_" + callerId;

		$newG.ghostify(options);		//Ghostify it!
		$newG.parent()[0].setAttribute("id", caller);			//Give wrapper the proper id

		var triggerS		= {	'minDuration'	:	7,
								'maxDuration'	:	10,
								'minInterval'	:	11,
								'maxInterval'	:	15,
								'trigger'		:	caller,
								'istant'		:	true,
								'priority'		:	1	};

		callerId++;

		GhostGen(loremGhost, triggerS);				//Create callback ghost

	}
	else {								//Normal ghost

		newGhost.innerHTML = html;

		document.body.appendChild(newGhost);		//Add ghost
		ghostNum++;

		$(newGhost).ghostify(options);		//Ghostify it!

	}

  }

 /*
  * Function to remove all generated ghosts
  */
  function clearGhosts() {

	$(".closeGhost").trigger("click");		//Click all X buttons

	ghostNum = 0;
	modalGhosts = 0;

  }
