// CONFIGURATION

// AJAX Configuration
var Base_URL = "http://www.disco.bg/NewSite/index.php/";
//var Base_URL = "http://213.91.244.17/Rumen_New/index.php/";

function getPageSize() {
	        
     var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	
	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}

	return [pageWidth,pageHeight];
}
	
// ----------------------------------------------------------------

function PopupOpen(type, extra, extra_parametters) {

	switch(type) {

		case "html":
			$('popup_window').innerHTML=extra;
		break;
	
		case "ajax":
		
			new Ajax.Updater('popup_window', extra, {parameters: extra_parametters , evalScripts: true});
			
		break;

	}



	// open the popup
	$('popup_window').style.display='block';
	$('fade').style.display='block'

	// stretch overlay to fill page and fade in
    var arrayPageSize = getPageSize();
    $('fade').setStyle({ width: arrayPageSize[0] + 'px', height: arrayPageSize[1] + 'px' });


}



function PopupClose() {
	$('popup_window').style.display='none';
	$('fade').style.display='none';
	
	// Stopping the party images popup slideshow if existing
	if (mySlideshow!=undefined) {
		mySlideshow.Stop();
	}
}

// ----------------------------------------------------------------



function PartyImageOpen(_party_image_id, _party_image_index) {
	
	PopupOpen('ajax',Base_URL+'parties/popup/'+_party_image_id, {_party_image_index: _party_image_index});
	//PopupOpen('html','TEST');

}	


function SendPartyEcard(_party_image_id, _from_email, _from_name, _to_email, _to_name, _pozdrav, not_to_close) {

	
	if ((_from_email!="") && (_from_name!="") && (_to_email!="") && (_to_name!="")) {
		
		new Ajax.Request(Base_URL+'actions/SendPartyEcard', {parameters: {_party_image_id:_party_image_id, _from_email:_from_email, _from_name:_from_name, _to_email:_to_email, _to_name:_to_name, _pozdrav:_pozdrav} , evalScripts: true});
		
		
		if (not_to_close==undefined) {
		$('send_to_friend_holder').hide(); 
		mySlideshow.Playing=1;
		}	
		
		
	} else {
		
		alert('Моля попълнете нужните полета във формуляра.');
		
	}




}

function Slideshow_btnPlayNext() {
	mySlideshow.btnPlayNext();
}

function Slideshow_btnPlayPrev() {
	mySlideshow.btnPlayPrev();
}
