/*
############################################################
* Origin: www.voiptalk.org
* Name: tariffs.js
* Description Tariff page AJAX execution file
* Autor: Piotr Dziembor, Telappliant Ltd.
* Version: 1.0
* Modified: 16:30 18/09/2009
* Copyright: Telappliant Ltd.
############################################################
*/
var noflags = false;
var ctariff = '2';
onload = function() {
showregion('EU');
var gethash = parent.location.hash;
if (gethash == "#silver" || gethash == "#standard" || gethash == "#goldroute") {
gethash = gethash.replace('#','');
swap_tariff(gethash);
} else swap_tariff('silver');
$('search_tip').fade('out');
}
function checkforenter() {
if (event.keyCode == 13) searchcoutry();
}
function searchtip(status) {
document.getElementById('search_tip').style.display = 'block';
if (status == "show") $('search_tip').fade('in');
else if (status == "hide") $('search_tip').fade('out');
else $('search_tip').fade('out');
}
function swap_tariff(tname) {
parent.location.hash = tname;
if (tname == "standard") ctariff = '1';
else if (tname == "goldroute") ctariff = '28';
else ctariff = '2';
document.getElementById('tariff_silver').className = 'tariff_button_top';
document.getElementById('tariff_standard').className = 'tariff_button_top';
document.getElementById('tariff_goldroute').className = 'tariff_button_top';
document.getElementById('tariff_'+tname).className = 'tariff_button_top_active';
document.getElementById('div_silver').style.display = 'none';
document.getElementById('div_standard').style.display = 'none';
document.getElementById('div_goldroute').style.display = 'none';
document.getElementById('div_'+tname).style.display = 'block';
$('div_silver').fade('out');
$('div_standard').fade('out');
$('div_goldroute').fade('out');
$('div_'+tname).fade('in');
document.getElementById('download_silver').style.display = 'none';
document.getElementById('download_standard').style.display = 'none';
document.getElementById('download_goldroute').style.display = 'none';
document.getElementById('download_'+tname).style.display = 'block';
$('download_silver').fade('out');
$('download_standard').fade('out');
$('download_goldroute').fade('out');
$('download_'+tname).fade('in');
$('scountrylist').fade('out');
$('ajaxresult').fade('out');
$('prefsearch').fade('out');
$('loading_scountrylist').fade('out');
$('loading_ajaxresult').fade('out');
$('loading_prefsearch').fade('out');
document.getElementById('scountrylist').style.display = 'none';
document.getElementById('loading_scountrylist').style.display = 'none';
document.getElementById('scountrylist_top').style.display = 'none';
document.getElementById('scountrylist_bottom').style.display = 'none';
new Fx.Slide('scountrylist_bottom').hide();
document.getElementById('tariffs_container_searchbox_bottom').style.display = 'block';
setTimeout("document.getElementById('scountrylist').innerHTML = '';", 400);
setTimeout("document.getElementById('ajaxresult').innerHTML = '';", 350);
setTimeout("document.getElementById('prefsearch').innerHTML = '';", 300);
setTimeout("$('scountrylist').fade('in');", 600);
setTimeout("$('ajaxresult').fade('in');", 600);
setTimeout("$('prefsearch').fade('in');", 600);
document.getElementById('download_loading').style.display = 'none';
document.getElementById('div_loading').style.display = 'none';
document.getElementById('EU').value = '';
document.getElementById('AS').value = '';
document.getElementById('AF').value = '';
document.getElementById('NA').value = '';
document.getElementById('SA').value = '';
document.getElementById('OC').value = '';
if (/MSIE (5\.5|6)/.test(navigator.userAgent)) {
document.getElementById('scountrylist').innerHTML = '';
document.getElementById('ajaxresult').innerHTML = '';
document.getElementById('prefsearch').innerHTML = '';
}
}
function showfullwindow (destination,code,tariff) {
closeWin();
newWin = window.open('includes/modules/ccp/show_full_list.php?dest='+destination+'&code='+code+'&tariff='+tariff, 'destlist', 'resizable,scrollbars,location,height=640,width=805');
}
function showregion(code) {
document.getElementById('AF').style.display = 'none';
document.getElementById('AS').style.display = 'none';
document.getElementById('NA').style.display = 'none';
document.getElementById('SA').style.display = 'none';
document.getElementById('EU').style.display = 'none';
document.getElementById('OC').style.display = 'none';
document.getElementById(code).style.display = 'inline';
}
function ajaxcheck(code)
{
if (document.getElementById(code).value != "")
{
new Fx.Slide('scountrylist_bottom').hide();
document.getElementById('prefsearch').innerHTML = '';
document.getElementById('scountrylist').innerHTML = '';
document.getElementById('coutrysearch').value = "Search for a country, number or prefix...";
var elementid = 'ajaxresult';
var url = "includes/modules/ccp/search_destination.php?q=" + ctariff + "|" + document.getElementById(code).value + "&sid=" + Math.random();
var item = document.getElementById(code).selectedIndex;
var loading_bar = '
Please wait while loading data for ' + document.getElementById(code).options[item].text + '.<\/div>'
noflags = true;
ajaxexecute(url,elementid,loading_bar);
}
}
function ajaxcheck_int(code)
{
document.getElementById('prefsearch').innerHTML = '';
var elementid = 'ajaxresult';
var url = "includes/modules/ccp/search_destination.php?q=" + code + "&sid=" + Math.random();
var loading_bar = '
Please wait while loading data.<\/div>'
ajaxexecute(url,elementid,loading_bar);
}
function showprefix(pstr)
{
var elementid = 'prefsearch';
var url = "includes/modules/ccp/search_prefix.php?pref=" + pstr + "&tariff=" + ctariff + "&sid=" + Math.random();
var loading_bar = '
Please wait while loading data.<\/div>'
ajaxexecute(url,elementid,loading_bar);
}
function searchcoutry()
{
var elementid = 'scountrylist';
var countryname = document.getElementById('coutrysearch').value;
var url = "includes/modules/ccp/search_country.php?countryname=" + ctariff + "|" + countryname + "|&sid=" + Math.random();
var loading_bar = '
Please wait while loading data.<\/div>