
//var X_JS_SERVER_ROOT = "http://xemival";
//var X_JS_ADMIN_SERVER_ROOT = "http://xemival/admin";

var X_JS_SERVER_ROOT = "/";
var X_JS_ADMIN_SERVER_ROOT = "/admin";

//---------------------------------------------------------------------------------------------

function loadImageSizeOptions(formName, elementName, newValue, destinationURL){
	
	
	document.forms[formName].elements[elementName].value = newValue;
	document.forms[formName].submit();	
	//alert("QueryString = " + destinationURL+queryString);
	//window.location.href = destinationURL+queryString;
}

//---------------------------------------------------------------------------------------------


function popWindow(strFileName,strTitle,intWidth,intHeight,strScroll) {

	var intHeight;
	var intWidth;
	
	windowObject = window.open(strFileName,strTitle,"width=" + intWidth + ",height=" + intHeight + ",toolbar=no,location=no,menubar=no,resizable=no,scrollbars=" + strScroll);
	windowObject.focus();

	intHeight = (screen.height / 4);
	intWidth  = (screen.width / 4);
	windowObject.moveTo(intWidth,intHeight);
	
}
//---------------------------------------------------------------------------------------------


function popUploadProductTeaser(fileName){

	strFileName = X_JS_ADMIN_SERVER_ROOT + fileName;
	strTitle    = "Xemival_TeaserUpload";
	intWidth    = "800";
	intHeight   = "600";
	strScroll   = "no";

	popWindow(strFileName,strTitle,intWidth,intHeight,strScroll);
}

//---------------------------------------------------------------------------------------------

function reloadProductList(fileName){

	opener.location.href = X_JS_ADMIN_SERVER_ROOT + fileName;
	self.close();
}


//---------------------------------------------------------------------------------------------

function popPricePlanUIMask(fileName){

	strFileName = X_JS_ADMIN_SERVER_ROOT + fileName;
	strTitle    = "Xemival_Product_Price_Plan";
	intWidth    = "800";
	intHeight   = "900";
	strScroll   = "yes";

	popWindow(strFileName,strTitle,intWidth,intHeight,strScroll);
}

//---------------------------------------------------------------------------------------------


function systemResponseAddPricePlan(editModus, filename){

	opener.location.href = X_JS_ADMIN_SERVER_ROOT + fileName;
	
}

//---------------------------------------------------------------------------------------------


function popViewProductVisual(fileName){

	strFileName = X_JS_SERVER_ROOT + fileName;
	strTitle    = "Xemival_Limited_Edition_Fine_Art_Photography_Print";
	intWidth    = "950";
	intHeight   = "680";
	strScroll   = "no";

	windowObject = window.open(strFileName,strTitle,"width=" + intWidth + ",height=" + intHeight + ",toolbar=no,status=no, hotkeys=no, location=no,menubar=no,resizable=no,scrollbars=" + strScroll);

	tempHeight = (screen.height - 180); 
	tempWidth  = (screen.width - 230);
	
	intHeight = (screen.height - tempHeight);
	intWidth  = (screen.width - tempWidth);

	windowObject.moveTo(intWidth,intHeight);
	windowObject.focus();

}

//---------------------------------------------------------------------------------------------


function popViewBGBVisual(fileName){

	strFileName = X_JS_SERVER_ROOT + fileName;
	strTitle    = "BRITAINS_GOT_BEAUTY";
	intWidth    = "950";
	intHeight   = "680";
	strScroll   = "no";

	windowObject = window.open(strFileName,strTitle,"width=" + intWidth + ",height=" + intHeight + ",toolbar=no,status=no, hotkeys=no, location=no,menubar=no,resizable=no,scrollbars=" + strScroll);

	tempHeight = (screen.height - 180); 
	tempWidth  = (screen.width - 230);
	
	intHeight = (screen.height - tempHeight);
	intWidth  = (screen.width - tempWidth);

	windowObject.moveTo(intWidth,intHeight);
	windowObject.focus();

}


//---------------------------------------------------------------------------------------------

function popPackagingVisual(fileName){

	strFileName = X_JS_SERVER_ROOT + fileName;
	strTitle    = "Xemival_Limited_Edition_Fine_Art_Photography_Print";
	intWidth    = "550";
	intHeight   = "550";
	strScroll   = "no";

	windowObject = window.open(strFileName,strTitle,"width=" + intWidth + ",height=" + intHeight + ",toolbar=no,status=no, hotkeys=no, location=no,menubar=no,resizable=no,scrollbars=" + strScroll);

	tempHeight = (screen.height - 180); 
	tempWidth  = (screen.width - 230);
	
	intHeight = (screen.height - tempHeight);
	intWidth  = (screen.width - tempWidth);

	windowObject.moveTo(intWidth,intHeight);
	windowObject.focus();

}

//---------------------------------------------------------------------------------------------

function processAddToSelectionSubmit(formName, elementName, newValue, resetElementNameOne, resetElementNameTwo){

	//alert("Element: " + document.forms[formName].elements[elementName]);
	document.forms[formName].elements[elementName].value = newValue;
	document.forms[formName].elements[resetElementNameOne].value = 0;
	document.forms[formName].elements[resetElementNameTwo].value = 0;
	document.forms[formName].submit();
}

//---------------------------------------------------------------------------------------------

function processLoginSubmit(formName, elementName, newValue, resetElementNameOne){

	//alert("Element: " + document.forms[formName].elements[elementName]);
	document.forms[formName].elements[elementName].value = newValue;
	document.forms[formName].elements[resetElementNameOne].value = 0;
	document.forms[formName].submit();
}

//---------------------------------------------------------------------------------------------

function showVisual(divElementName, tempTeaserName, newpic){

	if (document.images) {
		document.images[tempTeaserName].src = newpic;
	}

	//document.getElementById(tempTeaserName).style.backgroundImage="url(" + newpic + ")";
	document.getElementById(divElementName).style.visibility = "visible";
}

//---------------------------------------------------------------------------------------------

function toggleImages(picName, newPic){

	if (document.images) {
		document.images[picName].src = newPic;
	}

}
//---------------------------------------------------------------------------------------------

function hideVisual(divElementName){

	document.getElementById(divElementName).style.visibility = "hidden";
}
 
//---------------------------------------------------------------------------------------------

function updateProductPrice(updatePrice, formName, elementName){
	
	if(updatePrice == "1"){
		document.forms[formName].elements[elementName].value = 1;
	}

	document.forms[formName].submit();

}

//---------------------------------------------------------------------------------------------

function popOrderSummary(fileName){

	strFileName = X_JS_SERVER_ROOT + fileName;
	strTitle    = "Xemival_Order_Summary";
	intWidth    = "730";
	intHeight   = "700";
	strScroll   = "yes";

	windowObject = window.open(strFileName,strTitle,"width=" + intWidth + ",height=" + intHeight + ",toolbar=no,status=no, hotkeys=no, location=no,menubar=no,resizable=no,scrollbars=" + strScroll);

	tempHeight = (screen.height - 180); 
	tempWidth  = (screen.width - 230);
	
	intHeight = (screen.height - tempHeight);
	intWidth  = (screen.width - tempWidth);

	windowObject.moveTo(intWidth,intHeight);
	windowObject.focus();
}

//---------------------------------------------------------------------------------------------

function initiatePrintJob(){

	window.print();
}


//###############################################################


//$(jQuery).fn.center = function () {
//   this.css("position","absolute");
//    this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
//    this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
//    return this;
//}

//#################################################################


//---------------------------------------------------------------------------------------------

function XMVAJAX_LoadProductVisuals(jsEvent){

	if(jsEvent){
		
		jsEvent.preventDefault();

		var clickedURL = $(jsEvent.target).closest("a.pop_visual_link").attr("href");
		var startIndex = (clickedURL.indexOf('?') + 1);
		var endIndex = clickedURL.length;
		var extractedQueryString = clickedURL.substring(startIndex, endIndex);
			
								
		$.ajax({
			type: "GET",
			url: "/galleries/view_product_visuals.php",
			dataType: 'html',	
			data: extractedQueryString,
			success: displayProductVisualPanel
		});
	
	}

	return false;

}


//-------------------------------------------------------------

function displayProductVisualPanel(ajaxResponseText){

	var productDisplayContainer = $("#productDisplayContainer");

	
	productDisplayContainer.html(ajaxResponseText);
	productDisplayContainer.css({'z-index' : '100'});

	$(window).scrollTo(0,0);
	$("body").css('background-color', '#000000');
	
	$("#opacityControlLayer").fadeTo(2000, 0.4);
	productDisplayContainer.fadeTo(2000, 1);
	$("#ButtonCloseVisualWindow").click(hideProductVisualPanel); // bind close button
	$("a.pop_interior_link").click(XMVAJAX_loadProductInterior);

	return false;
}

//-------------------------------------------------------------

function hideProductVisualPanel(jsEvent){
	
	
	$("#productDisplayContainer").hide().css({'z-index' : '-1'});
	$("#opacityControlLayer").fadeTo(1000, 1);
	$("body").css('background-color', '#333333');

	return false;
}

//-------------------------------------------------------------

function XMVAJAX_loadProductInterior(jsEvent){

	//alert("Load Interior has been triggered");

	if(jsEvent){
		
		jsEvent.preventDefault();

		var clickedURL = $(jsEvent.target).closest("a.pop_interior_link").attr("href");
		var startIndex = (clickedURL.indexOf('?') + 1);
		var endIndex = clickedURL.length;
		var extractedQueryString = clickedURL.substring(startIndex, endIndex);
	
		$.ajax({
			type: "GET",
			url: "/galleries/view_product_visuals.php",
			dataType: 'html',	
			data: extractedQueryString,
			success: displayProductInteriorPanel
		});
	}

	return false;
}

//-------------------------------------------------------------

function displayProductInteriorPanel(ajaxResponseText){

	$("#productDisplayContainer").html(ajaxResponseText);
	$("#ButtonCloseVisualWindow").click(hideProductVisualPanel); // bind close button
	$("a.pop_interior_link").click(XMVAJAX_loadProductInterior);

}

//-------------------------------------------------------------

function toggleInputFieldStyles(){

	$("input, textarea").focusin(function(){
		$(this).css({"color":"#ffffff", "border":"2px solid #ffffff", "background-color":"#444444"});
	});

	$("input, textarea").focusout(function(){
		$(this).css({"color":"#333333", "border":"2px solid #666666", "background-color":"#ffffff"});
	});

}

//-------------------------------------------------------------

function toggleTwittItemStyles(){

	var subMenuContainerID = $(".twitterSubmenuContainer");
	
	$(".twittContainer").hover(
		function(){	
			$(this).css({"background-color":"#FAE9ED"});		
			//$(".twittContainer > .twitterSubmenuContainer").css({"visibility":"visible"});
			subMenuContainerID.css({"visibility":"visible"});
		},
		function(){		
			$(this).css({"background-color":"#FFFFFF"});	 
			//$(".twittContainer > .twitterSubmenuContainer").css({"visibility":"hidden"});
			subMenuContainerID.css({"visibility":"hidden"});

		}
	);
	
}


//-------------------------------------------------------------
