﻿function TrackSuppliersLinks(supplierLinksNames) {

    var service = new NetMatch.Zoover.Web.Services.Suppliers.SuppliersLinksService();

    service.TrackLinks(supplierLinksNames, OnTrackLinksComplete, OnTrackLinksError);
}

function OnTrackLinksComplete(result) {
}

function OnTrackLinksError(result) {
	// Removed the alert since on FireFox you get an annoying message if the user leaves the page before the 
	// request to the server has executed
	//alert(result.get_message());
}

/* EXPAND-COLLAPSE behaviour for suppliers with pricing info*/
// sid - shader id
// tid - shader text id
function ShowSuppliersShader(sid, tid, msg) {
	var sha = document.getElementById(sid);
	var tex = document.getElementById(tid);
	if (sha) {
		sha.className = "shader-on";
		tex.style.lineHeight = tex.clientHeight + 'px';
		tex.innerHTML = "<span>" + msg + "</span>";
	}
}

// sid - shader id
// tid - shader text id
function HideSuppliersShader(sid, tid) {
	var sha = document.getElementById(sid);
	var tex = document.getElementById(tid);
	if (sha) {
		sha.className = "shader-off";
		tex.innerHTML = "&nbsp;";
	}
}

// sid - shader id
// stid - shader text id
// cid - collapse container id
function ExpandSuppliers(sid, cid, stid, hidden_suppliers_id) {
	//closes supplier links pop-up
	DisableVerticalSupplierLinksWithPublication()

	var sha = document.getElementById(sid);
	var shta = document.getElementById(stid);
	var col = document.getElementById(cid);
	var hidden_suppliers = document.getElementById(hidden_suppliers_id);

	if (sha)
		sha.style.display = "none";
	if (shta)
		shta.style.display = "none";
	if (col)
		col.style.display = "block";
	if (hidden_suppliers)
		hidden_suppliers.style.display = "block"

	// This forces IE 7 to redraw the adlinks panel and position the 3 boxes below the adlinks to the correct position
	sha.parentNode.parentNode.style.display = "none";
	sha.parentNode.parentNode.style.display = "block";
}

// sid - shader id
// stid - shader text id
// cid - collapse container id
function CollapseSuppliers(sid, cid, stid, hidden_suppliers_id) {
	//closes supplier links pop-up
	DisableVerticalSupplierLinksWithPublication()

	var sha = document.getElementById(sid);
	var shta = document.getElementById(stid);
	var col = document.getElementById(cid);
	var hidden_suppliers = document.getElementById(hidden_suppliers_id);

	if (sha)
		sha.style.display = "block";
	if (shta)
		shta.style.display = "block";
	if (col)
		col.style.display = "none";

	if (hidden_suppliers)
		hidden_suppliers.style.display = "none"

	// This forces IE 7 to redraw the adlinks panel and position the 3 boxes below the adlinks to the correct position
	sha.parentNode.parentNode.style.display = "none";
	sha.parentNode.parentNode.style.display = "block";
}

// for IE6 only - as height: 100% does not work on IE6 - we force the shader and the shader text to have it's parent container
function setIE6ShaderHeight(shc, sha, sht) {
	var shcElement = document.getElementById(shc);
	if (shcElement != null) {
		var height = shcElement.offsetHeight;
		var shaElement = document.getElementById(sha);
		var shtElement = document.getElementById(sht);
		if ((shaElement != null) && (shtElement != null)) {
			shaElement.style.height = height;
			shtElement.style.height = height;
		}
	}
}

/*
function PriceInfo(name, price){
	var _Name = name;
	var _Price = price;
	
	this.getName = function() { return _Name; }
	this.getPrice = function() { return _Price; }
}

function PriceInfoToolTip(){
	this.PriceInfoArray = new Array();
}

PriceInfoToolTip.prototype.Length = function(){
	return this.PriceInfoArray.length;
}

PriceInfoToolTip.prototype.InfoAtIndex = function(index){
if (index < this.PriceInfoArray.length) {
	return this.PriceInfoArray[index];
	}
	return null;
}

PriceInfoToolTip.prototype.AddPriceInfo = function(priceInfo) {
	this.PriceInfoArray[this.PriceInfoArray.length] = priceInfo;
}

function HoverTooltips(){
	this.HoverInfo = new Array();
	this.Codes = new Array();
	this.DurationTitle = "";
	this.PriceTitle = "";
	this.HoverTitle = "";
	this.ParentsTitle = "";
}

HoverTooltips.prototype.AddPriceInfo = function(code, name, price) {
	var lExistingInfo = this.GetObjectForCode(code);
	if (lExistingInfo == null) {
		var lPriceInfo = new PriceInfoToolTip();
		lPriceInfo.AddPriceInfo(new PriceInfo(name, price));
		this.HoverInfo[this.HoverInfo.length] = lPriceInfo;
		this.Codes[this.Codes.length] = code;
	}
	else {
		lExistingInfo.AddPriceInfo(new PriceInfo(name, price));
	}
}

// The method that returns the current object for the current code if it exists and null if it doesn't exist

HoverTooltips.prototype.GetObjectForCode = function(code) {
	for (var i = 0; i < this.Codes.length; i++) {
		if (this.Codes[i] == code) {
			return this.HoverInfo[i];
		}
	}
	return null;
}

HoverTooltips.prototype.SetDurationTitle = function(value) {
	this.DurationTitle = value;
}

HoverTooltips.prototype.GetDurationTitle = function() {
	return this.DurationTitle;
}

HoverTooltips.prototype.SetPriceTitle = function(value) {
	this.PriceTitle = value;
}

HoverTooltips.prototype.GetPriceTitle = function() {
	return this.PriceTitle;
}

HoverTooltips.prototype.SetAccommodationTitle = function(value) {
	this.HoverTitle = value;
}

HoverTooltips.prototype.GetAccommodationTitle = function() {
	return this.HoverTitle;
}

HoverTooltips.prototype.SetParentsTitle = function(value) {
	this.ParentsTitle = value;
}

HoverTooltips.prototype.GetParentsTitle = function() {
	return this.ParentsTitle;
}

HoverTooltips.prototype.GetHtmlForCode = function(code, div, containerName, widthOffset) {
	var lInfo = this.GetObjectForCode(code);
	div.style.color = "#4C9EDB";
	var lContainer = document.getElementById(containerName);
	if (lInfo != null && lContainer != null) {
		var lParent = this.GetAccommodationTitle().length + this.GetParentsTitle().length;
		var lRatio = lInfo.Length() > 6 ? 22 : 24;
		if (lInfo.Length() < 3 && lParent < 80) {
			lRatio += 5;
		}
		var lExtra = lParent > 80 ? 40 : 31;
		if (lParent > 80) {
			lRatio += 2;
			if (lInfo.Length() > 6) {
				lRatio -= 2;
			}
		}
		var lHeight = lInfo.Length() * lRatio + (lParent / 50) * lExtra + 22;
		var lTop = div.offsetTop + 19;
		var lLeft = div.offsetLeft + parseInt(widthOffset) + 10;
		if (navigator.userAgent.toLowerCase().indexOf('msie 6') != -1 || navigator.userAgent.toLowerCase().indexOf('msie 7') != -1) {
			lTop = div.parentNode.offsetTop + 18;
			lLeft += 6;
			if (navigator.userAgent.toLowerCase().indexOf('msie 6') != -1) {
				lLeft += 12;
			}
		}

		if (lInfo.Length() < 3 && lParent > 70) {
			lHeight += 30;
		}

		var lStyle = "height:" + lHeight + "px;top:" + lTop + "px;left:" + lLeft + "px";
		var lHtml = "<div class=\"hoverContainer\" style=\"" + lStyle + "\"><div class=\"hoverAccoTitle\">" + this.GetAccommodationTitle()
			+ "<span class=\"parentsTitle\">" + this.ParentsTitle + "</span></div>";
		var lFirstDiv = "<div class=\"durationContainer\"><span class=\"priceTitle\">" + this.GetDurationTitle() + "</span><br/>";
		var lSecondDiv = "<div class=\"priceContainer\"><span class=\"priceTitle\">" + this.GetPriceTitle() + "</span><br/>";
		for (var i = 0; i < lInfo.Length(); i++) {
			var lObj = lInfo.InfoAtIndex(i);
			if (lObj != null) {
				lFirstDiv += "<span>" + lObj.getName() + "</span><br/>";
				lSecondDiv += "<span>" + lObj.getPrice() + "</span><br/>";
			}
		}
		lFirstDiv += "</div>";
		lSecondDiv += "</div>";
		lHtml += lFirstDiv + lSecondDiv + "</div>";
		lContainer.innerHTML = lHtml;
		lContainer.style.display = "block";
	}
}

HoverTooltips.prototype.HideHtmlCode = function(div, containerName) {
	div.style.color = "#FF5D10";
	var lContainer = document.getElementById(containerName);
	if (lContainer != null) {
		lContainer.style.display = "none";
	}
}

var HoverTooltipsAccos = new HoverTooltips();

*/

/* --END-- SUPPLIERS FOR PRICING INFO */

