/*
  JavaScript resource
  
  Copyright (c) 2008 Negeso Ukraine
 
  This software is the confidential and proprietary information of Negeso
  ("Confidential Information").  You shall not disclose such Confidential 
  Information and shall use it only in accordance with the terms of the 
  license agreement you entered into with Negeso.
 
  
  Just a popup banner for SITA (SITA-275)
  Depends on:
  - JQuery 1.2.6
  - JQuery UI Core 1.5.2
  - JQuery UI Draggable 1.5.2
 
  @version		2008.07.16
  @author		Andriy Halyasovskyy
*/

var showPopup = false;
var showFadeCurtain = true;
var animateFadeCurtain = true;
var shouldUseHTMLFile = false;
var replaceWholePopupWithHTMLFile = false;
var htmlFilePath = "/media/picture_frame/test.html";
// ------------------------------------------------------
animateFadeCurtain = animateFadeCurtain && !isIE6();
//Cancel animation if browser is IE6

$(window).load(function () {
	if (showPopup) {
		if(showFadeCurtain) {
			if (animateFadeCurtain) {
				$("#popupCurtain").fadeIn("slow", function () {
					popupBannerOnLoad();
				});
			}else{
				$("#popupCurtain").css( {display: "block"} );
				popupBannerOnLoad();
			}
		}else{
			popupBannerOnLoad();
		}
	}
});

function popupBannerOnLoad(){
	$("#popupFrame").css({ left: Math.round(document.body.clientWidth/2) - Math.round($("#popupFrame").width()/2) + "px" });
	$("#popupFrame").css({ top: Math.round(document.body.clientHeight/2) - Math.round($("#popupFrame").height()/2) + "px" });
	$("#popupFrame").draggable({cursor: "move"});
	if (shouldUseHTMLFile){
		if (replaceWholePopupWithHTMLFile){
			$("#popupFrame").load(htmlFilePath);
		}else{
			$("#popupBannerBody").load(htmlFilePath);
		}
	}
	if (isIE6()) {
		$("SELECT").css({ visibility:"hidden" });
	}
	openPopup();
}

function setOverColor(){
	$("#closePopupBtn").css({ color:"#FFB98B" });
}

function setDefaultColor(){
	$("#closePopupBtn").css({ color:"white" });
}

function closePopup(){
	$("#popupFrame").css({ display:"none" });
	$("#popupCurtain").css({ display:"none" });
	if (isIE6()) {
		$("SELECT").css({ visibility: "visible" });
	}
}

function openPopup(){
	$("#popupFrame").css({ display:"block", visibility:"visible" });
}

function isIE6(){
	return navigator.userAgent.indexOf("MSIE 6") > -1;
}
