$(document).ready(function() {
$('#changeLang').click(function() {
if ($('#lang').val()=='new language') {
//from src/Gui/Translater.js
addLangWindow();
}else{
CSC(global_main_url+'CSC/?param=site¤Site¤changeLang¤'+$('#lang').val(), function(data) {
window.location.reload();
});
};
});
//check input fields
checkRequiredFields();
});
function checkRequiredFields(browerFixHeight){
$('.form_div form span').children('input:text, input:password, textarea').each(function(index) {
$(this).unbind();
$(this).change(function() {
var name=$(this).attr('name');
var value=$(this).val();
var id=$(this).attr('id');
if (name.indexOf('_required')>(-1) || $(this).attr('class').indexOf('required')>(-1)) {
if ($.trim(value)=='') {
formDialog('This field is required.',id);
}else{
formDialog('',id);
if (name.indexOf('email')>(-1) || name.indexOf('e-mail')>(-1)) {
if(value.indexOf('.')<3 || value.indexOf('.')==value.length-1 || value.indexOf('@')<1 || value.length<3 || value.indexOf('@')>value.indexOf('.')){
formDialog('Please enter a valid email address.',id);
}else{
formDialog('',id);
};
};
};
if (browerFixHeight!=undefined) {
$('#fancy_outer').css('height',$('#contactpp').height()+browerFixHeight);
$('#fancy_inner').css('height',$('#fancy_div').height()+browerFixHeight);
};
};
});
$(this).blur(function() {
var name=$(this).attr('name');
var value=$(this).val();
var id=$(this).attr('id');
if (name.indexOf('_required')>(-1) || $(this).attr('class').indexOf('required')>(-1)) {
if ($.trim(value)=='') {
formDialog('This field is required.',id);
}else{
formDialog('',id);
if (name.indexOf('email')>(-1) || name.indexOf('e-mail')>(-1)) {
if(value.indexOf('.')<3 || value.indexOf('.')==value.length-1 || value.indexOf('@')<1 || value.length<3 || value.indexOf('@')>value.indexOf('.')){
formDialog('Please enter a valid email address.',id);
}else{
formDialog('',id);
};
};
};
if (browerFixHeight!=undefined) {
$('#fancy_outer').css('height',$('#contactpp').height()+browerFixHeight);
$('#fancy_inner').css('height',$('#fancy_div').height()+browerFixHeight);
};
};
});
});
}
function errorAlert(string){
if ( $('#contacterrorr').html() == null ) {
$('body').append('
');
$('#contacterrorr').lightbox_me({
centered: true,
destroyOnClose: true,
zIndex:980
});
$('#contacterrorr .close').click(function() {
//$('.lb_overlay').click();
$('#contacterrorr').remove();
var found1 = $("body").find("div.wind");
var found2 = $("body").find("div.lb_overlay");
if ( found1.lenth < found2.length ){
$('.lb_overlay:first').remove();
}
});
$('#contacterrorr').keydown (fcheckForEnter);
};
function fcheckForEnter (event) {
if (event.keyCode == 13) {
//$('.lb_overlay').click();
$('#contacterrorr').remove();
var found1 = $("body").find("div.wind");
var found2 = $("body").find("div.lb_overlay");
if ( found1.lenth < found2.length ){
$('.lb_overlay:first').remove();
}
}
}
}
function loaderAlert(string){
if ( $('#contactloader').html() == null ) {
$('body').append('');
$('#contactloader').lightbox_me({
centered: true,
destroyOnClose: true,
zIndex:999
});
$('#contactloader .close').click(function() {
//$('.lb_overlay').click();
$('#contactloader').remove();
var found1 = $("body").find("div.wind");
var found2 = $("body").find("div.lb_overlay");
if ( found1.lenth < found2.length ){
$('.lb_overlay:first').remove();
}
});
};
}
function successAlert(string){
if ( $('#contactpsuccess').html() == null ) {
$('body').append('');
$('#contactpsuccess').lightbox_me({
centered: true,
destroyOnClose: true,
zIndex:950
});
$('#contactpsuccess .close').click(function() {
//$('.lb_overlay').click();
$('#contactpsuccess').remove();
var found1 = $("body").find("div.wind");
var found2 = $("body").find("div.lb_overlay");
if ( found1.lenth < found2.length ){
$('.lb_overlay:first').remove();
}
});
$('#contactpsuccess').keydown (fcheckForEnter);
};
function fcheckForEnter (event) {
if (event.keyCode == 13) {
//$('.lb_overlay').click();
$('#contactpsuccess').remove();
var found1 = $("body").find("div.wind");
var found2 = $("body").find("div.lb_overlay");
if ( found1.lenth < found2.length ){
$('.lb_overlay:first').remove();
}
}
}
}
function formDialog(string,id){
var input=$('#'+id);
var dialog=''+string+'
';
input.parent().children('.dialog').remove();
if ($.trim(string)!='') {
input.parent().append(dialog);
};
};
function alert(data){
data=$.trim(data);
if (data.indexOf('error|')>-1) {
errorAlert(data.substring('error|'.length));
}else{
if (data.indexOf('loader|')>-1) {
loaderAlert(data.substring('loader|'.length));
}else{
successAlert(data);
}
}
}
function confirm(string,yfg,nfg){
//paramter type: string, " nuku
if(!yfg){
yfg='';
}else{
yfg.replace("'","\'");
yfg.replace('"',"\'");
}
if(!nfg){
nfg='';
}else{
nfg.replace("'","\'");
nfg.replace('"',"\'");
}
if ( $('#contactpconfirm').html() == null ) {
$('body').append('');
$('#contactpconfirm').lightbox_me({
centered: true,
destroyOnClose: true,
zIndex:950
});
};
$('#contactpconfirm .close').click(function() {
//$('.lb_overlay').click();
$('#contactppwindow').remove();
var found1 = $("body").find("div.wind");
var found2 = $("body").find("div.lb_overlay");
if ( found1.lenth < found2.length ){
$('.lb_overlay:first').remove();
}
});
$("#yes").focus();
$('#yes').keydown (fcheckForEnter);
function fcheckForEnter (event) {
if (event.keyCode == 13) {
$("#yes").click();
}
}
}
function openWindow(string, w, h){
if ( $('#contactppwindow').html() == null ) {
$('body').append('');
if (!w) {
}else{
$('#contactppwindow').css('width',w);
}
if (!h) {
}else{
$('#contactppwindow').css('height',h);
}
$('#contactppwindow').lightbox_me({
centered: false,
destroyOnClose: true,
zIndex:920
});
$('#contactppwindow .close').click(function() {
//$('.lb_overlay').click();
$('#contactppwindow').remove();
var found1 = $("body").find("div.wind");
var found2 = $("body").find("div.lb_overlay");
if ( found1.lenth < found2.length ){
$('.lb_overlay:first').remove();
}
});
};
}
function htmlEscape(s) {
var a=new Array(
"&","&",
"#","#",
";",";",
"#;","#",
"™","™",
"€","€",
"!","!",
'"',""",
"$","$",
"%","%",
"'","'",
"(","(",
")",")",
"*","*",
"+","+",
",",",",
"-","-",
".",".",
"/","/",
":",":",
"<","<",
"=","=",
">",">",
"?","?",
"@","@",
"[","[",
"]","]",
"^","^",
"_","_",
"`","`",
"{","{",
"|","|",
"}","}",
"~","~",
"¡","¡",
"¢","¢",
"£","£");
for(var i=0;i",">",
"?","?",
"@","@",
"[","[",
"]","]",
"^","^",
"_","_",
"`","`",
"{","{",
"|","|",
"}","}",
"~","~",
"¡","¡",
"¢","¢",
"£","£");
for(var i=0;i> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;
if (isNaN(chr2)) {
enc3 = enc4 = 64;
} else if (isNaN(chr3)) {
enc4 = 64;
}
output = output +
this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
}
return output;
},
// public method for decoding
decode : function (input) {
var output = "";
var chr1, chr2, chr3;
var enc1, enc2, enc3, enc4;
var i = 0;
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
while (i < input.length) {
enc1 = this._keyStr.indexOf(input.charAt(i++));
enc2 = this._keyStr.indexOf(input.charAt(i++));
enc3 = this._keyStr.indexOf(input.charAt(i++));
enc4 = this._keyStr.indexOf(input.charAt(i++));
chr1 = (enc1 << 2) | (enc2 >> 4);
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
chr3 = ((enc3 & 3) << 6) | enc4;
output = output + String.fromCharCode(chr1);
if (enc3 != 64) {
output = output + String.fromCharCode(chr2);
}
if (enc4 != 64) {
output = output + String.fromCharCode(chr3);
}
}
output = Base64._utf8_decode(output);
return output;
},
// private method for UTF-8 encoding
_utf8_encode : function (string) {
string = string.replace(/\r\n/g,"\n");
var utftext = "";
for (var n = 0; n < string.length; n++) {
var c = string.charCodeAt(n);
if (c < 128) {
utftext += String.fromCharCode(c);
}
else if((c > 127) && (c < 2048)) {
utftext += String.fromCharCode((c >> 6) | 192);
utftext += String.fromCharCode((c & 63) | 128);
}
else {
utftext += String.fromCharCode((c >> 12) | 224);
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
utftext += String.fromCharCode((c & 63) | 128);
}
}
return utftext;
},
// private method for UTF-8 decoding
_utf8_decode : function (utftext) {
var string = "";
var i = 0;
var c = c1 = c2 = 0;
while ( i < utftext.length ) {
c = utftext.charCodeAt(i);
if (c < 128) {
string += String.fromCharCode(c);
i++;
}
else if((c > 191) && (c < 224)) {
c2 = utftext.charCodeAt(i+1);
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
i += 2;
}
else {
c2 = utftext.charCodeAt(i+1);
c3 = utftext.charCodeAt(i+2);
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
i += 3;
}
}
return string;
}
};
/*
* jQuery pager plugin
* Example at: http://jonpauldavies.github.com/JQuery/Pager/PagerDemo.html
*
*/
(function($) {
$.fn.pager = function(options) {
var opts = $.extend({}, $.fn.pager.defaults, options);
return this.each(function() {
// empty out the destination element and then render out the pager with the supplied options
$(this).empty().append(renderpager(parseInt(options.pagenumber), parseInt(options.pagecount), options.buttonClickCallback));
// specify correct cursor activity
$('.pages li').mouseover(function() { document.body.style.cursor = "pointer"; }).mouseout(function() { document.body.style.cursor = "auto"; });
});
};
// render and return the pager with the supplied options
function renderpager(pagenumber, pagecount, buttonClickCallback) {
// setup $pager to hold render
var $pager = $('');
// add in the previous and next buttons
$pager.append(renderButton('Elsõ', pagenumber, pagecount, buttonClickCallback)).append(renderButton('Elõzõ', pagenumber, pagecount, buttonClickCallback));
// pager currently only handles 10 viewable pages ( could be easily parameterized, maybe in next version ) so handle edge cases
var startPoint = 1;
var endPoint = 9;
if (pagenumber > 4) {
startPoint = pagenumber - 4;
endPoint = pagenumber + 4;
}
if (endPoint > pagecount) {
startPoint = pagecount - 8;
endPoint = pagecount;
}
if (startPoint < 1) {
startPoint = 1;
}
// loop thru visible pages and render buttons
for (var page = startPoint; page <= endPoint; page++) {
var currentButton = $('' + (page) + '');
page == pagenumber ? currentButton.addClass('pgCurrent') : currentButton.click(function() { buttonClickCallback(this.firstChild.data); });
currentButton.appendTo($pager);
}
// render in the next and last buttons before returning the whole rendered control back.
$pager.append(renderButton('Következõ', pagenumber, pagecount, buttonClickCallback)).append(renderButton('Utolsó', pagenumber, pagecount, buttonClickCallback));
return $pager;
}
// renders and returns a 'specialized' button, ie 'next', 'previous' etc. rather than a page number button
function renderButton(buttonLabel, pagenumber, pagecount, buttonClickCallback) {
var $Button = $('' + buttonLabel + '');
var destPage = 1;
// work out destination page for required button type
switch (buttonLabel) {
case "first":
destPage = 1;
break;
case "Elsõ":
destPage = 1;
break;
case "prev":
destPage = pagenumber - 1;
break;
case "Elõzõ":
destPage = pagenumber - 1;
break;
case "next":
destPage = pagenumber + 1;
break;
case "Következõ":
destPage = pagenumber + 1;
break;
case "last":
destPage = pagecount;
break;
case "Utolsó":
destPage = pagecount;
break;
}
// disable and 'grey' out buttons if not needed.
if (buttonLabel == "first" || buttonLabel == "prev" || buttonLabel == "Elsõ" || buttonLabel == "Elõzõ") {
pagenumber <= 1 ? $Button.addClass('pgEmpty') : $Button.click(function() { buttonClickCallback(destPage); });
}
else {
pagenumber >= pagecount ? $Button.addClass('pgEmpty') : $Button.click(function() { buttonClickCallback(destPage); });
}
return $Button;
}
// pager defaults. hardly worth bothering with in this case but used as placeholder for expansion in the next version
$.fn.pager.defaults = {
pagenumber: 1,
pagecount: 1
};
})(jQuery);