/* */

var arAbas = new Array();
arAbas[0] = new stAba('Ppost', 'prodPost');
arAbas[1] = new stAba('Pstats', 'prodStats');
arAbas[2] = new stAba('Pinfo', 'prodDescription');

var arAbas_02 = new Array();
arAbas_02[0] = new stAba_02('linkUpcoming', 'tabUpcoming');
arAbas_02[1] = new stAba_02('linkPastFlings', 'tabPastFlings');
arAbas_02[2] = new stAba_02('linkWidget', 'tabWidget');

function stAba(menu, conteudo) {
	this.menu = menu;
	this.conteudo = conteudo;
}

function stAba_02(menu, conteudo) {
	this.menu = menu;
	this.conteudo = conteudo;
}

function AlternarAbas(menu, conteudo) {
	for (i = 0; i < arAbas.length; i++) {
		m = document.getElementById(arAbas[i].menu);
		m.className = '';
		c = document.getElementById(arAbas[i].conteudo)
		c.style.display = 'none';
	}
	m = document.getElementById(menu)
	m.className = 'prodActive';
	c = document.getElementById(conteudo)
	c.style.display = '';
}


function AlternarAbas_02(menu, conteudo) {
	for (i = 0; i < arAbas_02.length; i++) {
		y = document.getElementById(arAbas_02[i].menu);
		y.className = '';
		t = document.getElementById(arAbas_02[i].conteudo)
		t.style.display = 'none';
	}
	y = document.getElementById(menu)
	y.className = 'tabActive';
	t = document.getElementById(conteudo)
	t.style.display = '';
}

function FlingMeHome(url) {
	var quantity = document.getElementById('quantitySelected');
	document.location = url + 'quantity=' + quantity.value;
}

function OnChangeImage(link, path, url, title, windowProperties) {
	var img1 = document.getElementById('Image1');
	var img2 = document.getElementById('Image2');
	var img3 = document.getElementById('Image3');

	if (img1 != null) { img1.className = ""; }
	if (img2 != null) { img2.className = ""; }
	if (img3 != null) { img3.className = ""; }

	link.className = "tabOn";

	var img = document.getElementById('ActualImage');
	img.src = path;
	//img.parentNode.href = "javascript:WindowOpen('"+url+"','"+title+"','"+windowProperties+"');";
	img.parentNode.href = url;
}

function WindowOpen(url, name, features) {
	window.open(url, name, features);
}

function toggleLayer(whichLayer) {
	var elem, vis;
	if (document.getElementById) // this is the way the standards work
		elem = document.getElementById(whichLayer);
	else if (document.all) // this is the way old msie versions work
		elem = document.all[whichLayer];
	else if (document.layers) // this is the way nn4 works
		elem = document.layers[whichLayer];
	vis = elem.style;
	// if the style.display value is blank we try to figure it out here
	if (vis.display == '' && elem.offsetWidth != undefined && elem.offsetHeight != undefined)
		vis.display = (elem.offsetWidth != 0 && elem.offsetHeight != 0) ? 'block' : 'none';
	vis.display = (vis.display == '' || vis.display == 'block') ? 'none' : 'block';
}

function changeLayerState(whichLayer, display) {
	var elem, vis;
	if (document.getElementById) // this is the way the standards work
		elem = document.getElementById(whichLayer);
	else if (document.all) // this is the way old msie versions work
		elem = document.all[whichLayer];
	else if (document.layers) // this is the way nn4 works
		elem = document.layers[whichLayer];
	vis = elem.style;
	// if the style.display value is blank we try to figure it out here
	vis.display = (display == 0) ? 'none' : 'block';
}

jQuery.WebService = function(servicePage, fn, useSsl, successFn, errorFn) {
	// Initialize the page path. (Current page if we have the 
	// pagepath in the pathname, or "default.aspx" as default.
	var pagePath = window.location.pathname;

	pagePath = pagePath.substring(0, pagePath.lastIndexOf('/'));
	pagePath = pagePath + "/" + servicePage;

	if (useSsl) {
		pagePath = "https://" + location.host + pagePath;
	}

	// Check to see if we have any parameter list to pass to web method. 
	// if so, serialize them in the JSON format: {"paramName1":"paramValue1","paramName2":"paramValue2"} 
	var jsonParams = '';
	var paramLength = arguments.length;
	if (paramLength > 5) {
		for (var i = 5; i < paramLength - 1; i += 2) {
			if (jsonParams.length != 0) jsonParams += ',';
			jsonParams += '"' + arguments[i] + '":"' + arguments[i + 1] + '"';
		}
	}
	jsonParams = '{' + jsonParams + '}';
	
	return jQuery.PageMethodToPage(pagePath, fn, successFn, errorFn, jsonParams);
};

jQuery.PageMethod = function(fn, useSsl, successFn, errorFn) {
	// Initialize the page path. (Current page if we have the 
	// pagepath in the pathname, or "default.aspx" as default.
	var pagePath = window.location.pathname;
	if (pagePath.lastIndexOf('/') == pagePath.length - 1) {
		pagePath = pagePath + "default.aspx";
	}

	if (useSsl) {
		pagePath = "https://" + location.host + pagePath;
	}

	// Check to see if we have any parameter list to pass to web method. 
	// if so, serialize them in the JSON format: {"paramName1":"paramValue1","paramName2":"paramValue2"} 
	var jsonParams = '';
	var paramLength = arguments.length;
	if (paramLength > 4) {
		for (var i = 4; i < paramLength - 1; i += 2) {
			if (jsonParams.length != 0) jsonParams += ',';
			jsonParams += '"' + arguments[i] + '":"' + arguments[i + 1] + '"';
		}
	}
	jsonParams = '{' + jsonParams + '}';
	return jQuery.PageMethodToPage(pagePath, fn, successFn, errorFn, jsonParams);
};

jQuery.PageMethodToPage = function(pagePath, fn, successFn, errorFn, jsonParams) {

	//alert("PagePath = [" + pagePath + "] Function = [" + fn + "] Params = [" + jsonParams + "]");

	//Call the page method 
	jQuery.ajax({
		type: "POST",
		url: pagePath + "/" + fn,
		contentType: "application/json; charset=utf-8",
		data: jsonParams,
		/*
		dataFilter: function(data) {
		var msg; 
    if (typeof (JSON) !== 'undefined' && 
        typeof (JSON.parse) === 'function')
      msg = JSON.parse(data);
    else
      msg = eval('(' + data + ')'); 
    if (msg.hasOwnProperty('d'))
      return msg.d;
    else
      return msg;
		},*/		
		dataType: "json",
		success: successFn,
		error: errorFn
	});
};