/**
 * Harmos Festival
 *
 * @version 1
 * @author  Rolling Mill, http://www.rolling-mill.pt
 * @created 2010-09-10
 * @updated 2010-11-30
 * @link    http://www.harmos.com
 */

	String.prototype.trim = function() {
		return this.replace(/^\s+|\s+$/g,"");
	}

	
	function createAd(lang, area, image, itemID, type, url, adMediaType, imageFolder)
	{
		//self.status = 'Ready to save node ' + nodeText + ' which is a sub item of ' + parentId;
		// Use an ajax method here to save this new node. example below:

		fldType = document.getElementById(type);
		fldURL = document.getElementById(url);
		
		
		var img = image;
		var adType = fldType.value;
		var adURL = fldURL.value;
		
		ajaxObjectArray[ajaxObjectArray.length] = new sack();
		var ajaxIndex = ajaxObjectArray.length-1;
		ajaxObjectArray[ajaxIndex].setVar('adType', adType);
		ajaxObjectArray[ajaxIndex].setVar('adMediaURL', img);
		ajaxObjectArray[ajaxIndex].setVar('adURL', adURL);
		//ajaxObjectArray[ajaxIndex].setVar('adMediaType', adMediaType);
		ajaxObjectArray[ajaxIndex].setVar('adArea', area);
		ajaxObjectArray[ajaxIndex].setVar('adItemID', itemID);
		ajaxObjectArray[ajaxIndex].requestFile = siteURL+'backend/admin/ads/createAd.cfm';
		ajaxObjectArray[ajaxIndex].onCompletion = function() { 
			location.reload(true);
			//self.status = 'New node has been saved';
			//alert(ajaxObjectArray[ajaxIndex].response);
			//switchDIV('frmNews')
			//getMedia('showcase', lang, area, itemID, imageFolder);
		};	// Specify function that will be executed after file has been found	
		
		ajaxObjectArray[ajaxIndex].runAJAX();		// Execute AJAX function
				
	}
	
	function removeAd(itemID)
	{
		//self.status = 'Ready to save node ' + nodeText + ' which is a sub item of ' + parentId;
		// Use an ajax method here to save this new node. example below:
		ajaxObjectArray[ajaxObjectArray.length] = new sack();
		var ajaxIndex = ajaxObjectArray.length-1;
		ajaxObjectArray[ajaxIndex].setVar('adID', itemID);
		ajaxObjectArray[ajaxIndex].requestFile = siteURL+'backend/admin/ads/removeAd.cfm';
		ajaxObjectArray[ajaxIndex].onCompletion = function() { 
			//self.status = 'New node has been saved';
			//alert(ajaxObjectArray[ajaxIndex].response);
			//getMedia('showcase', lang, area, itemID, imageFolder);
			location.reload(true);
			callbackRemove = function() {
				
			}
			//getNews('news', edition, lang);
		};	// Specify function that will be executed after file has been found	
		
		ajaxObjectArray[ajaxIndex].runAJAX();		// Execute AJAX function
				
	}
	
	function getAds(div, lang, area, itemID, imageFolder)
	{
		//self.status = 'Ready to save node ' + nodeText + ' which is a sub item of ' + parentId;
		// Use an ajax method here to save this new node. example below:
		var el = document.getElementById(div);
		//alert(animateID);
		ajaxObjectArray[ajaxObjectArray.length] = new sack();
		var ajaxIndex = ajaxObjectArray.length-1;
		ajaxObjectArray[ajaxIndex].requestFile = siteURL+'backend/admin/ads/getAd.cfm?lang='+lang+'&area='+area+'&itemID='+itemID+'&imageFolder='+imageFolder;
		ajaxObjectArray[ajaxIndex].onCompletion = function() { 
			//self.status = 'New node has been saved';
			//alert(ajaxObjectArray[ajaxIndex].response);
			el.innerHTML = ajaxObjectArray[ajaxIndex].response;
			prepareGallery();
			callback = function(){
				//switchDIV('frmNews')
			}
			
		};	// Specify function that will be executed after file has been found	
		
		ajaxObjectArray[ajaxIndex].runAJAX();		// Execute AJAX function
				
	}
