var infolayer;
// INIT LAYER
function initLayer(){
$('body').append('
');
};
// CENTER LAYER HORIZONTAL
function centerLayer($l) {
contentWidth = $('body').width();
contentHeight = $('body').height();
lwidth=$l.width();
lheight=$l.height();
nh=Math.round((contentHeight-lheight-80)/2);
if (nh<0) nh=0;
$l.css('left',Math.round((contentWidth-lwidth)/2)+'px');
$l.css('top',nh+'px');
};
// REMOVE LAYER
function closeLayer(type){
if(type=='reset'){
infolayer = false;
}
$('#layer, .layer').remove();
$('.eternity_options').removeAttr('style');
};
function getGeo(type){
//alert(type);
$.ajax({
url: 'includes/geo/geo.php',
async: false,
dataType: 'json',
data: ({save : 'true'}),
success: function(data){
// set preselected jeweler
if(data['stores'][0] == null) return true;
var nearestStore = ''+data['stores'][0]['store']+' '+data['stores'][0]['strasse']+' '+data['stores'][0]['plz']+' '+data['stores'][0]['ort']+' Phone: '+data['stores'][0]['telefon']+' '+'E-Mail: '+data['stores'][0]['email']+' Website: '+data['stores'][0]['homepage']+' ';
var nearestStores = [];
var activeStoreId = data['stores'][0]['id'];
var de = false;
var ch = false;
var ca = false;
var at = false;
var uk = false;
var ie = false;
var us = false;
var be = false;
var ua = false;
var ru = false;
if(data['activecountry'] == 'DE'){
var activecountry = "GERMANY";
}else if(data['activecountry'] == 'CA'){
var activecountry = "CANADA";
}else if(data['activecountry'] == 'CH'){
var activecountry = "SWITZERLAND";
}else if(data['activecountry'] == 'AU'){
var activecountry = "AUSTRIA";
}else if(data['activecountry'] == 'UK'){
var activecountry = "UK";
}else if(data['activecountry'] == 'IE'){
var activecountry = "IRELAND";
}else if(data['activecountry'] == 'US'){
var activecountry = "USA";
}
else if(data['activecountry'] == 'BE'){
var activecountry = "Belgium";
}
else if(data['activecountry'] == 'RU'){
var activecountry = "Russian Federation";
}
else if(data['activecountry'] == 'UA'){
var activecountry = "Ukraine";
}
// APPEND ACTIVE COUNTRY STORES FIRST
$.each(data['stores'], function(i,item){
if(data['stores'][0] !== item){
if(item['country'] == data['activecountry']){
// CHECK COUNTRIES AND SET LIST HEADERS
if(item['country'] == 'DE' && de == false){
nearestStores = nearestStores+('GERMANY zip areas: Addresses worldwide ');
de = true;
}
if(item['country'] == 'CH' && ch == false){
nearestStores = nearestStores+('SWITZERLAND Addresses worldwide ');
ch = true;
}
if(item['country'] == 'CA' && ca == false){
nearestStores = nearestStores+('CANADA Addresses worldwide ');
ca = true;
}
if(item['country'] == 'AT' && at == false){
nearestStores = nearestStores+('AUSTRIA Addresses worldwide ');
at = true;
}
if(item['country'] == 'UK' && uk == false){
nearestStores = nearestStores+('UK Addresses worldwide ');
uk = true;
}
if(item['country'] == 'IE' && ie == false){
nearestStores = nearestStores+('IRELAND Addresses worldwide ');
ie = true;
}
if(item['country'] == 'US' && us == false){
nearestStores = nearestStores+('USA Addresses worldwide ');
us = true;
}
if(item['country'] == 'RU' && ru == false){
nearestStores = nearestStores+('Russian Federation Addresses worldwide ');
us = true;
}
if(item['country'] == 'UA' && ua == false){
nearestStores = nearestStores+('Ukraine Addresses worldwide ');
ua = true;
}
if(item['country'] == 'BE' && be == false){
nearestStores = nearestStores+('Belgium Addresses worldwide ');
be = true;
}
// FILL STORES
if(data['stores'][0]['isset'] == null){
if(item['country'] == 'DE'){
nearestStores = nearestStores+(' ');
}else{
nearestStores = nearestStores+(''+item['store']+' '+item['strasse']+' '+item['plz']+' '+item['ort']+' Phone: '+item['telefon']+' '+'E-Mail: '+item['email']+' Website: '+item['homepage']+' Select this jeweler ');
}
}else{
if(activeStoreId !== item['id']){
if(item['country'] == 'DE'){
nearestStores = nearestStores+(' ');
}else{
nearestStores = nearestStores+(''+item['store']+' '+item['strasse']+' '+item['plz']+' '+item['ort']+' Phone: '+item['telefon']+' '+'E-Mail: '+item['email']+' Website: '+item['homepage']+' Select this jeweler ');
}
}else{
if(item['country'] == 'DE'){
nearestStores = nearestStores+(' ');
}else{
nearestStores = nearestStores+(''+item['store']+' '+item['strasse']+' '+item['plz']+' '+item['ort']+' Phone: '+item['telefon']+' '+'E-Mail: '+item['email']+' Website: '+item['homepage']+' Currently selected jeweler ');
}
}
}
}
}
});
// APPEND THE OTHER COUNTRIES STORES
var othercountries = false;
$.each(data['stores'], function(i,item){
if(data['stores'][0] !== item){
if(item['country'] != data['activecountry']){
// CHECK COUNTRIES AND SET LIST HEADERS
if(item['country'] == 'DE' && de == false){
if(othercountries == false){
nearestStores = nearestStores+('GERMANY zip areas: '+activecountry+' ');
othercountries == true;
}else{
nearestStores = nearestStores+('GERMANY zip areas: '+activecountry+' ');
}
de = true;
}
if(item['country'] == 'CA' && ca == false){
if(othercountries == false){
nearestStores = nearestStores+('CANADA '+activecountry+' ');
othercountries == true;
}else{
nearestStores = nearestStores+('CANADA '+activecountry+' ');
}
ca = true;
}
if(item['country'] == 'CH' && ch == false){
if(othercountries == false){
nearestStores = nearestStores+('SWITZERLAND '+activecountry+' ');
othercountries == true;
}else{
nearestStores = nearestStores+('SWITZERLAND '+activecountry+' ');
}
ch = true;
}
if(item['country'] == 'AT' && at == false){
if(othercountries == false){
nearestStores = nearestStores+('AUSTRIA '+activecountry+' ');
othercountries == true;
}else{
nearestStores = nearestStores+('AUSTRIA '+activecountry+' ');
}
at = true;
}
if(item['country'] == 'UK' && uk == false){
if(othercountries == false){
nearestStores = nearestStores+('UK '+activecountry+' ');
othercountries == true;
}else{
nearestStores = nearestStores+('UK '+activecountry+' ');
}
uk = true;
}
if(item['country'] == 'IE' && ie == false){
if(othercountries == false){
nearestStores = nearestStores+('IRELAND '+activecountry+' ');
othercountries == true;
}else{
nearestStores = nearestStores+('IRELAND '+activecountry+' ');
}
ie = true;
}
if(item['country'] == 'US' && us == false){
if(othercountries == false){
nearestStores = nearestStores+('USA '+activecountry+' ');
othercountries == true;
}else{
nearestStores = nearestStores+(''+activecountry+' ');
}
us = true;
}
if(item['country'] == 'BE' && be == false){
if(othercountries == false){
nearestStores = nearestStores+('Belgium '+activecountry+' ');
othercountries == true;
}else{
nearestStores = nearestStores+(''+activecountry+' ');
}
be = true;
}
if(item['country'] == 'RU' && ru == false){
if(othercountries == false){
nearestStores = nearestStores+('Russian Federation '+activecountry+' ');
othercountries == true;
}else{
nearestStores = nearestStores+(''+activecountry+' ');
}
ru = true;
}
if(item['country'] == 'UA' && ua == false){
if(othercountries == false){
nearestStores = nearestStores+('Ukraine '+activecountry+' ');
othercountries == true;
}else{
nearestStores = nearestStores+(''+activecountry+' ');
}
ua = true;
}
// FILL STORES
if(data['stores'][0]['isset'] == null){
if(item['country'] == 'DE'){
nearestStores = nearestStores+(' ');
}else{
nearestStores = nearestStores+(''+item['store']+' '+item['strasse']+' '+item['plz']+' '+item['ort']+' Phone: '+item['telefon']+' '+'E-Mail: '+item['email']+' Website: '+item['homepage']+' Select this jeweler ');
}
}else{
if(activeStoreId !== item['id']){
if(item['country'] == 'DE'){
nearestStores = nearestStores+(' ');
}else{
nearestStores = nearestStores+(''+item['store']+' '+item['strasse']+' '+item['plz']+' '+item['ort']+' Phone: '+item['telefon']+' '+'E-Mail: '+item['email']+' Website: '+item['homepage']+' Select this jeweler ');
}
}else{
if(item['country'] == 'DE'){
nearestStores = nearestStores+(' ');
}else{
nearestStores = nearestStores+(''+item['store']+' '+item['strasse']+' '+item['plz']+' '+item['ort']+' Phone: '+item['telefon']+' '+'E-Mail: '+item['email']+' Website: '+item['homepage']+' Currently selected jeweler ');
}
}
}
}
}
});
//append nearest jeweler and jeweler list
if(data['stores'][0]['isset'] == null){
$('#jewelerlist').html(nearestStores);
$('#nearestStore div.store').html('You currently have no selected jeweler!
').css('height', '130px');
}else{
$('#nearestStore div.store').html(nearestStore).css('height', '130px');
$('#jewelerlist').html(nearestStores);
$('#jeweler').val(data['stores'][0]['email']);
$('#submitButton').show();
}
// CHECK GERMAN ZIP CODES
var firstzipcode = true;
var zipcode = new Array();
zipcode[0] = false;
zipcode[1] = false;
zipcode[2] = false;
zipcode[3] = false;
zipcode[4] = false;
zipcode[5] = false;
zipcode[6] = false;
zipcode[7] = false;
zipcode[8] = false;
zipcode[9] = false;
$.each(data['stores'], function(i,item){
if(data['stores'][0] !== item){
if(item['country'] == 'DE'){
if(item['plz']){
var zipcodearea = item['plz'].substr(0,1);
if(zipcode[zipcodearea] == false){
if(firstzipcode == true) {
$('#jewelerlist #store_'+item['id']).append(''+zipcodearea+' ');
$('#jewelerlist #zipcodes').append(''+zipcodearea+' ');
firstzipcode = false;
} else {
$('#jewelerlist #store_'+item['id']).append(''+zipcodearea+' ');
$('#jewelerlist #zipcodes').append(''+zipcodearea+' ');
}
zipcode[zipcodearea] = true;
}
}
}
}
});
}
});
}
function getGeoSupplier(){
$.ajax({
url: 'includes/geo/geo.php',
async: false,
dataType: 'json',
data: ({save : 'true'}),
success: function(data){
// set preselected jeweler
if(data['stores'][0] == null) return true;
var nearestStore = ''+data['stores'][0]['store']+' '+data['stores'][0]['strasse']+' '+data['stores'][0]['plz']+' '+data['stores'][0]['ort']+' Phone: '+data['stores'][0]['telefon']+' '+'E-Mail: '+data['stores'][0]['email']+' Website: '+data['stores'][0]['homepage']+' ';
var nearestStores = [];
var activeStoreId = data['stores'][0]['id'];
var de = false;
var ca = false;
var ch = false;
var at = false;
var uk = false;
var ie = false;
var us = false;
var ru = false;
var ua = false;
var be = false;
if(data['activecountry'] == 'DE'){
var activecountry = "GERMANY";
}else if(data['activecountry'] == 'CA'){
var activecountry = "CANADA";
}else if(data['activecountry'] == 'CH'){
var activecountry = "SWITZERLAND";
}else if(data['activecountry'] == 'AU'){
var activecountry = "AUSTRIA";
}else if(data['activecountry'] == 'UK'){
var activecountry = "UK";
}else if(data['activecountry'] == 'IE'){
var activecountry = "IRELAND";
}else if(data['activecountry'] == 'US'){
var activecountry = "USA";
}else if(data['activecountry'] == 'RU'){
var activecountry = "Russian Federation";
}else if(data['activecountry'] == 'UA'){
var activecountry = "Ukraine";
}else if(data['activecountry'] == 'BE'){
var activecountry = "Belgium";
}
// APPEND ACTIVE COUNTRY STORES FIRST
$.each(data['stores'], function(i,item){
if(data['stores'][0] !== item){
if(item['country'] == data['activecountry']){
// CHECK COUNTRIES AND SET LIST HEADERS
if(item['country'] == 'DE' && de == false){
nearestStores = nearestStores+('GERMANY zip areas: Addresses worldwide ');
de = true;
}
if(item['country'] == 'CA' && ca == false){
nearestStores = nearestStores+('CANADA Addresses worldwide ');
ca = true;
}
if(item['country'] == 'CH' && ch == false){
nearestStores = nearestStores+('SWITZERLAND Addresses worldwide ');
ch = true;
}
if(item['country'] == 'AT' && at == false){
nearestStores = nearestStores+('AUSTRIA Addresses worldwide ');
at = true;
}
if(item['country'] == 'UK' && uk == false){
nearestStores = nearestStores+('UK Addresses worldwide ');
uk = true;
}
if(item['country'] == 'IE' && ie == false){
nearestStores = nearestStores+('IRELAND Addresses worldwide ');
ie = true;
}
if(item['country'] == 'US' && us == false){
nearestStores = nearestStores+('USA Addresses worldwide ');
us = true;
}
if(item['country'] == 'BE' && be == false){
nearestStores = nearestStores+('Belgium Addresses worldwide ');
us = true;
}
if(item['country'] == 'UA' && ua == false){
nearestStores = nearestStores+('Ukraine Addresses worldwide ');
ua = true;
}
if(item['country'] == 'RU' && ru == false){
nearestStores = nearestStores+('Russian Federation Addresses worldwide ');
ru = true;
}
// FILL STORES
if(data['stores'][0]['isset'] == null){
if(item['country'] == 'DE'){
nearestStores = nearestStores+(' ');
}else{
nearestStores = nearestStores+(''+item['store']+' '+item['strasse']+' '+item['plz']+' '+item['ort']+' Phone: '+item['telefon']+' '+'E-Mail: '+item['email']+' Website: '+item['homepage']+' Request appointment ');
}
}else{
if(activeStoreId !== item['id']){
if(item['country'] == 'DE'){
nearestStores = nearestStores+(' ');
}else{
nearestStores = nearestStores+(''+item['store']+' '+item['strasse']+' '+item['plz']+' '+item['ort']+' Phone: '+item['telefon']+' '+'E-Mail: '+item['email']+' Website: '+item['homepage']+' Request appointment ');
}
}else{
if(item['country'] == 'DE'){
nearestStores = nearestStores+(' ');
}else{
nearestStores = nearestStores+(''+item['store']+' '+item['strasse']+' '+item['plz']+' '+item['ort']+' Phone: '+item['telefon']+' '+'E-Mail: '+item['email']+' Website: '+item['homepage']+' Request appointment ');
}
}
}
}
}
});
// APPEND THE OTHER COUNTRIES STORES
var othercountries = false;
$.each(data['stores'], function(i,item){
if(data['stores'][0] !== item){
if(item['country'] != data['activecountry']){
// CHECK COUNTRIES AND SET LIST HEADERS
if(item['country'] == 'DE' && de == false){
if(othercountries == false){
nearestStores = nearestStores+('GERMANY zip areas: '+activecountry+' ');
othercountries == true;
}else{
nearestStores = nearestStores+('GERMANY zip areas: '+activecountry+' ');
}
de = true;
}
if(item['country'] == 'CA' && ca == false){
if(othercountries == false){
nearestStores = nearestStores+('CANADA '+activecountry+' ');
othercountries == true;
}else{
nearestStores = nearestStores+('CANADA '+activecountry+' ');
}
ca = true;
}
if(item['country'] == 'CH' && ch == false){
if(othercountries == false){
nearestStores = nearestStores+('SWITZERLAND '+activecountry+' ');
othercountries == true;
}else{
nearestStores = nearestStores+('SWITZERLAND '+activecountry+' ');
}
ch = true;
}
if(item['country'] == 'AT' && at == false){
if(othercountries == false){
nearestStores = nearestStores+('AUSTRIA '+activecountry+' ');
othercountries == true;
}else{
nearestStores = nearestStores+('AUSTRIA '+activecountry+' ');
}
at = true;
}
if(item['country'] == 'UK' && uk == false){
if(othercountries == false){
nearestStores = nearestStores+('UK '+activecountry+' ');
othercountries == true;
}else{
nearestStores = nearestStores+('UK '+activecountry+' ');
}
uk = true;
}
if(item['country'] == 'IE' && ie == false){
if(othercountries == false){
nearestStores = nearestStores+('IRELAND '+activecountry+' ');
othercountries == true;
}else{
nearestStores = nearestStores+('IRELAND '+activecountry+' ');
}
ie = true;
}
if(item['country'] == 'US' && us == false){
if(othercountries == false){
nearestStores = nearestStores+('USA '+activecountry+' ');
othercountries == true;
}else{
nearestStores = nearestStores+(''+activecountry+' ');
}
us = true;
}
if(item['country'] == 'RU' && ru == false){
if(othercountries == false){
nearestStores = nearestStores+('Russian Federation '+activecountry+' ');
othercountries == true;
}else{
nearestStores = nearestStores+(''+activecountry+' ');
}
ru = true;
}
if(item['country'] == 'UA' && ua == false){
if(othercountries == false){
nearestStores = nearestStores+('Ukraine '+activecountry+' ');
othercountries == true;
}else{
nearestStores = nearestStores+(''+activecountry+' ');
}
ua = true;
}
if(item['country'] == 'BE' && be == false){
if(othercountries == false){
nearestStores = nearestStores+('Belgium '+activecountry+' ');
othercountries == true;
}else{
nearestStores = nearestStores+(''+activecountry+' ');
}
be = true;
}
// FILL STORES
if(data['stores'][0]['isset'] == null){
if(item['country'] == 'DE'){
nearestStores = nearestStores+(' ');
}else{
nearestStores = nearestStores+(''+item['store']+' '+item['strasse']+' '+item['plz']+' '+item['ort']+' Phone: '+item['telefon']+' '+'E-Mail: '+item['email']+' Website: '+item['homepage']+' Request appointment ');
}
}else{
if(activeStoreId !== item['id']){
if(item['country'] == 'DE'){
nearestStores = nearestStores+(' ');
}else{
nearestStores = nearestStores+(''+item['store']+' '+item['strasse']+' '+item['plz']+' '+item['ort']+' Phone: '+item['telefon']+' '+'E-Mail: '+item['email']+' Website: '+item['homepage']+' Request appointment ');
}
}else{
if(item['country'] == 'DE'){
nearestStores = nearestStores+(' ');
}else{
nearestStores = nearestStores+(''+item['store']+' '+item['strasse']+' '+item['plz']+' '+item['ort']+' Phone: '+item['telefon']+' '+'E-Mail: '+item['email']+' Website: '+item['homepage']+' Currently selected jeweler ');
}
}
}
}
}
});
//append nearest jeweler and jeweler list
if(data['stores'][0]['isset'] == null){
$('#jewelerlistbig').html(nearestStores);
$('#nearestStore div.store').html('You currently have no selected jeweler!
').css('height', '130px');
}else{
$('#nearestStore div.store').html(nearestStore).css('height', '130px');
$('#jewelerlistbig').html(nearestStores);
$('#jeweler').val(data['stores'][0]['email']);
$('#submitButton').show();
}
// CHECK GERMAN ZIP CODES
var firstzipcode = true;
var zipcode = new Array();
zipcode[1] = false;
zipcode[2] = false;
zipcode[3] = false;
zipcode[4] = false;
zipcode[5] = false;
zipcode[6] = false;
zipcode[7] = false;
zipcode[8] = false;
zipcode[9] = false;
$.each(data['stores'], function(i,item){
if(data['stores'][0] !== item){
if(item['country'] == 'DE'){
if(item['plz']){
var zipcodearea = item['plz'].substr(0,1);
if(zipcode[zipcodearea] == false){
if(firstzipcode == true) {
$('#jewelerlistbig #store_'+item['id']).append(''+zipcodearea+' ');
$('#jewelerlistbig #zipcodesbig').append(''+zipcodearea+' ');
firstzipcode = false;
} else {
$('#jewelerlistbig #store_'+item['id']).append(''+zipcodearea+' ');
$('#jewelerlistbig #zipcodesbig').append(''+zipcodearea+' ');
}
zipcode[zipcodearea] = true;
}
}
}
}
});
}
});
}
/* HANDLERS */
$(document).ready(function(){
/* ORDERINFO LAYER IF NOT LOGED IN */
$('#orderinfo').live('click', function(){
infolayer = true;
initLayer();
$('body').append('');
centerLayer($('#orderinfolayer'));
$('#orderinfolayer .sinner').load('includes/orderinfo.php', function(){
getGeo('layer');
$('fieldset[class~=jqTrans]').jqTransform({imgPath:'styles/img/jqtransformplugin/'});
});
});
$('#showJewelerList').live('click', function(){
$('.form').hide();
$('.jewelerlist').show();
});
$('#backToForm').live('click', function(){
$('.jewelerlist').hide();
$('.form').show();
});
$('#jewelerlist li a.btn_submit').live('click', function(){
var store = $('input', this).val();
$.ajax({
url: 'includes/geo/geo.php',
async: false,
dataType: 'json',
data: ({store : $('input', this).val()}),
success: function(data){
$('.form').show();
$('.jewelerlist').hide();
getGeo('layer');
}
});
});
$('#jewelerlistbig li a.btn_opensubmit').live('click', function(){
var store = $('input', this).val();
initLayer();
$('body').append('');
centerLayer($('#orderinfolayer'));
$('#orderinfolayer .sinner').load('includes/orderinfo.php', function(){
$.ajax({
url: 'includes/geo/geo.php',
async: false,
dataType: 'json',
data: ({store : store}),
success: function(data){
infolayer = true;
//$('.form').show();
//$('.jewelerlist').hide();
getGeo('layer');
}
});
$('fieldset[class~=jqTrans]').jqTransform({imgPath:'styles/img/jqtransformplugin/'});
});
});
})