﻿function css_browser_selector(u) { var ua = u.toLowerCase(), is = function (t) { return ua.indexOf(t) > -1; }, g = 'gecko', w = 'webkit', s = 'safari', o = 'opera', h = document.getElementsByTagName('html')[0], b = [(!(/opera|webtv/i.test(ua)) && /msie\s(\d)/.test(ua)) ? ('ie ie' + RegExp.$1) : is('firefox/2') ? g + ' ff2' : is('firefox/3.5') ? g + ' ff3 ff3_5' : is('firefox/3') ? g + ' ff3' : is('gecko/') ? g : is('opera') ? o + (/version\/(\d+)/.test(ua) ? ' ' + o + RegExp.$1 : (/opera(\s|\/)(\d+)/.test(ua) ? ' ' + o + RegExp.$2 : '')) : is('konqueror') ? 'konqueror' : is('chrome') ? w + ' chrome' : is('iron') ? w + ' iron' : is('applewebkit/') ? w + ' ' + s + (/version\/(\d+)/.test(ua) ? ' ' + s + RegExp.$1 : '') : is('mozilla/') ? g : '', is('j2me') ? 'mobile' : is('iphone') ? 'iphone' : is('ipod') ? 'ipod' : is('mac') ? 'mac' : is('darwin') ? 'mac' : is('webtv') ? 'webtv' : is('win') ? 'win' : is('freebsd') ? 'freebsd' : (is('x11') || is('linux')) ? 'linux' : '', 'js']; c = b.join(' '); h.className += ' ' + c; return c; }; css_browser_selector(navigator.userAgent);
(function (d) { var k = d.scrollTo = function (a, i, e) { d(window).scrollTo(a, i, e) }; k.defaults = { axis: 'xy', duration: parseFloat(d.fn.jquery) >= 1.3 ? 0 : 1 }; k.window = function (a) { return d(window)._scrollable() }; d.fn._scrollable = function () { return this.map(function () { var a = this, i = !a.nodeName || d.inArray(a.nodeName.toLowerCase(), ['iframe', '#document', 'html', 'body']) != -1; if (!i) return a; var e = (a.contentWindow || a).document || a.ownerDocument || a; return d.browser.safari || e.compatMode == 'BackCompat' ? e.body : e.documentElement }) }; d.fn.scrollTo = function (n, j, b) { if (typeof j == 'object') { b = j; j = 0 } if (typeof b == 'function') b = { onAfter: b }; if (n == 'max') n = 9e9; b = d.extend({}, k.defaults, b); j = j || b.speed || b.duration; b.queue = b.queue && b.axis.length > 1; if (b.queue) j /= 2; b.offset = p(b.offset); b.over = p(b.over); return this._scrollable().each(function () { var q = this, r = d(q), f = n, s, g = {}, u = r.is('html,body'); switch (typeof f) { case 'number': case 'string': if (/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)) { f = p(f); break } f = d(f, this); case 'object': if (f.is || f.style) s = (f = d(f)).offset() } d.each(b.axis.split(''), function (a, i) { var e = i == 'x' ? 'Left' : 'Top', h = e.toLowerCase(), c = 'scroll' + e, l = q[c], m = k.max(q, i); if (s) { g[c] = s[h] + (u ? 0 : l - r.offset()[h]); if (b.margin) { g[c] -= parseInt(f.css('margin' + e)) || 0; g[c] -= parseInt(f.css('border' + e + 'Width')) || 0 } g[c] += b.offset[h] || 0; if (b.over[h]) g[c] += f[i == 'x' ? 'width' : 'height']() * b.over[h] } else { var o = f[h]; g[c] = o.slice && o.slice(-1) == '%' ? parseFloat(o) / 100 * m : o } if (/^\d+$/.test(g[c])) g[c] = g[c] <= 0 ? 0 : Math.min(g[c], m); if (!a && b.queue) { if (l != g[c]) t(b.onAfterFirst); delete g[c] } }); t(b.onAfter); function t(a) { r.animate(g, j, b.easing, a && function () { a.call(this, n, b) }) } }).end() }; k.max = function (a, i) { var e = i == 'x' ? 'Width' : 'Height', h = 'scroll' + e; if (!d(a).is('html,body')) return a[h] - d(a)[e.toLowerCase()](); var c = 'client' + e, l = a.ownerDocument.documentElement, m = a.ownerDocument.body; return Math.max(l[h], m[h]) - Math.min(l[c], m[c]) }; function p(a) { return typeof a == 'object' ? a : { top: a, left: a} } })(jQuery);

$(function () {

    $(this).find('.slide-n ul li img').click(function () {
        var URL = $(this).attr('alt');
        $('.up-slide').empty().append('<img src="' + URL + '" alt="" />');
        return false;
    });

    $('.soc-lin .soc5').click(function () {
        $('.h-pup').css('display', 'block');
        $('.sttr ').css('display', 'block');
        return false;
    });

    $('.sttr').click(function () {
        $('.h-pup').css('display', 'none');
        $('.sttr ').css('display', 'none');
        return false;
    });

    $('.indtabs a').click(function () {
        var gh = $(this).attr('href');
        $('.tabact').removeClass('tabact'); $('.indtabs li').removeClass('tabact');
        $(this).parent().addClass('tabact');
        $('.indtab ').css('display', 'none');
        $(gh).css('display', 'block');
        return false;
    });

    $('span.add').attr('rel', '10').click(function () {
        var num = parseInt($(this).attr('rel')) - 1;
        if (num > 0) {
            $(this).attr('rel', num);
            var tr = $(this).closest('table').parent().parent().prev();
            tr.clone().insertAfter(tr);
        }
    });

    $('span.addloc').click(function () {
        var tbody = $(this).closest('table').find('tbody.addressblock:first');
        tbody.clone().find('input').val('').end().insertBefore($(this).closest('tbody'));
    });
  
    $('input.validate').each(function () {

        $(this).closest('form').submit(function (e) {
            e.stopImmediatePropagation();
            var valid = true;
            var errMess = '';
            fstVal = false;

            if($(this).find('input.chbox_select').length) {
                if(!$(this).find('input.chbox_select:checked').length) {
                    valid = false;
                    errMess += '<div>The job type isn\'t selected</div>';
                }
            }

            $(this).find('.need').each(function () {
                if ($(this).val().length < 3) {
                    valid = false;
                    if ($(this).attr('title'))
                        errMess += '<div>' + $(this).attr('title') + ' is not filled</div>';
                    else
                        errMess += '<div>' + $(this).attr('name') + ' is not filled</div>';
                    $(this).addClass('error');
                }
            });
            $(this).find('input[class*=min]').each(function () {
                var min = parseInt($(this).attr('class').replace('min-', ''));
                if ($(this).val().length < min) {
                    valid = false;
                    if ($(this).attr('title'))
                        errMess += '<div>' + $(this).attr('title') + ' has to be at least ' + min + ' characters long</div>';
                    else
                        errMess += '<div>' + $(this).attr('name') + ' has to be at least ' + min + ' characters long</div>';
                    $(this).addClass('error');
                }
            });
      
            $(this).find('input[class*=noless]').each(function () {
                var min = parseInt($(this).attr('class').replace('noless-', ''));
                if ($(this).val().length && $(this).val().length < min) {
                    valid = false;
                    if ($(this).attr('title'))
                        errMess += '<div>' + $(this).attr('title') + ' has to be at least ' + min + ' characters long</div>';
                    else
                        errMess += '<div>' + $(this).attr('name') + ' has to be at least ' + min + ' characters long</div>';
                    $(this).addClass('error');
                }
            });
            $(this).find('textarea').each(function () {
                if ($(this).val().length >= 22000) {
                    valid = false;
                    errMess += '<div>Description is too long</div>';
                    $(this).addClass('error');
                }
            });

            $(this).find('input[class*=max]').each(function () {
                var min = parseInt($(this).attr('class').replace('max-', ''));
                if ($(this).val().length < min) {
                    valid = false;
                    if ($(this).attr('title'))
                        errMess += '<div>' + $(this).attr('title') + ' has to have no less then ' + min + ' characters</div>';
                    else
                        errMess += '<div>' + $(this).attr('name') + ' has to have no less then ' + min + ' characters</div>';
                    $(this).addClass('error');
                }
            });
            $(this).find('.dec').each(function () {
                if (!(/^(\d+([,\.]\d*)?)$/m).test($(this).val())) {
                    valid = false;
                    if ($(this).attr("title"))
                        errMess += '<div>' + $(this).attr("title") + ' value is not decimal</div>';
                    else
                        errMess += '<div>' + $(this).attr("name") + ' value is not decimal</div>';
                    $(this).addClass('error');
                    return;
                }
            });
            $(this).find('.time').each(function () {
                if (!(/^(\d\d:\d\d)$/m).test($(this).val())) {
                    valid = false;
                    if ($(this).attr("title"))
                        errMess += '<div>' + $(this).attr("title") + ' is not valid</div>';
                    else
                        errMess += '<div>' + $(this).attr("name") + ' is not valid</div>';
                    $(this).addClass('error');
                    return;
                }
            });
            $(this).find('.date').each(function () {
                if (!(/\d\d\/\d\d\/\d{4}/).test($(this).val())) {
                    valid = false;
                    if ($(this).attr("title"))
                        errMess += '<div>' + $(this).attr("title") + ' is not valid</div>';
                    else
                        errMess += '<div>' + $(this).attr("name") + ' is not valid</div>';
                    $(this).addClass('error');
                    return;
                }
            });
            $(this).find('.url').each(function () {        
                if ($(this).val() && !(/^http\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?$/).test($(this).val())) {

                    valid = false;
                    if ($(this).attr("title"))
                        errMess += '<div>' + $(this).attr("title") + ' is not valid</div>';
                    else
                        errMess += '<div>' + $(this).attr("name") + ' is not valid</div>';
                    $(this).addClass('error');
                    return;
                }
            });

            $(this).find('input.confpassword').each(function () {
                if ($(this).val() != $(this).closest('table').find('input.password').val()) {
                    valid = false;
                    errMess += '<div>' + 'Confirm password is not filled correctly</div>';
                    $(this).addClass('error');
                }
            });
            $(this).find('input.email').each(function () {
                function isValidEmail(email) {
                    email = email.replace(/^\s+|\s+$/g, '');
                    return (/^([a-z0-9_\-]+\.)*[a-z0-9_\-]+@([a-z0-9][a-z0-9\-]*[a-z0-9]\.)+[a-z]{2,4}$/i).test(email);
                }
                if (!isValidEmail($(this).val())) {
                    valid = false;
                    errMess += '<div>' + 'A valid Email is required</div>';
                    $(this).addClass('error');
                }
            });
          
          
          // required start
          
          
$(this).find('textarea.rtitle').each(function () {
  if ($(this).val().length == '') {
    valid = false;
    errMess += '<div>Review Title is required</div>';
    $(this).addClass('error');
  }
});
          
$(this).find('textarea#message-form-text').each(function () {
  if ($(this).val().length == '') {
    valid = false;
    errMess += '<div>Review Text is required</div>';
    $(this).addClass('error');
  }
});
          
var ratev = 0;
$('input#ReviewRate ').each(function () {
  if ($(this).val() == '') {
    valid = false;
    errMess += '<div>Rate is required</div>';
    $(this).addClass('error');
  }
});


          
          // required end


            if (!valid) {
                $('<div class="wrn">' + errMess + '</div>').prependTo($(this));
                $(this).click(function () {
                    $(this).find('>div.wrn').remove().end().find('.error').removeClass('error');
                });
                return false
            }

        });
    });
  
// #########################################################

    $('div.tabs').each(function () {
        var tb = $(this);
        tb.find('>ul a').click(function () {
            tb.find('div.par >div').hide();
            $($(this).attr('href')).show();
            $(this).parent().parent().find('li').removeClass('active').end().end().addClass('active');
            return false
        });
        tb.find('>ul li').click(function () {
            $(this).find('a').click();
        });
        tb.find('>ul li:first').addClass('active');
        tb.find('>div.par > div:not(:first)').hide();
    });
  
// ---------------------------------------------------------

    $('#gallery_image').each(function () {
  
        function g_init() {
            var url = $('#gallery_image').next().find('.active').attr('rel');
            $('<img src="' + url + '" />').appendTo('#gallery_image');
        }
        g_init();
    
// ---------------------------------------------------------

        $(this).next().find('span.item').click(function () {
            if (!$(this).hasClass('active')) {
                var url = $(this).attr('rel');
                $('<img src="' + url + '" />').appendTo($('#gallery_image').empty());
                $(this).parent().find('span').removeClass('active').end().end().addClass('active');

                if ($(this).parent().find('span.item:first').hasClass('active')) {
                    $(this).parent().find('span.prev').addClass('disable');
                } else {
                    $(this).parent().find('span.prev').removeClass('disable');
                }

                if ($(this).parent().find('span.item:last').hasClass('active')) {
                    $(this).parent().find('span.next').addClass('disable');
                } else {
                    $(this).parent().find('span.next').removeClass('disable');
                }
            }
        });

        $(this).next().find('span.next').click(function () {
            if (!$(this).hasClass('disable')) {
                $(this).parent().find('.active').next().click();
            }
        });
    
        $(this).next().find('span.prev').click(function () {
            if (!$(this).hasClass('disable')) {
                $(this).parent().find('.active').prev().click();
            }
        });

// ---------------------------------------------------------

    var myInterval = setInterval(gonext, 10000);
    var $this = $(this);
    function gonext() {
      var nx = $this.next().find('span.next');
      if(!nx.hasClass('disable')){
      nx.click();
      } else {
      nx.parent().find('span.item:first').click();
      }
    }
  
    });
  
// #########################################################

    $('span.rateBar').mouseleave(function () {
        $(this).find('ins').text('');
    }).find('a').mouseenter(function () {
        $(this).parent().find('ins').text($(this).attr('title'));
    }).click(function () {
        $(this).siblings().removeClass('active');
        $(this).addClass('active');

        var val = parseInt($(this).attr('class').replace('active', '').replace('r', ''));
        $(this).parent().prev().val(val);

        return false
    });

    $('tr.sort td > span a').click(function () {
        if (!$(this).parent().hasClass('selectable')) {
            $(this).parent().siblings().removeClass('selectable').end().addClass('selectable');
        }
        return false
    });

    $("#rewSlider").slider({
        slide: function (event, ui) {
            $('#sldop').text('(more than ' + ui.value + ' reviews)');
        },
        min: 0,
        max: 20
    });

    $("#rangeSlider").slider({
        range: true,
        values: [1, 500],
        slide: function (event, ui) {
            $('#rangeSlider').parent().find('input.minimum').val(ui.values[0]);
            $('#rangeSlider').parent().find('input.maximum').val(ui.values[1]);
        },
        min: 1,
        max: 500,
        create: function (event, ui) {
            $('#rangeSlider a:first').addClass('afirst');
            $('#rangeSlider a:last').addClass('alast');
        }

    });
    $("input.datep").datepicker({
        showOn: "button",
        buttonImage: "/template/pngonline/binaryresource/theme/default/i/datep.gif",
        buttonImageOnly: true
    });

    $('div.islider').each(function () {
        var par = $(this);
        $(this).find('span.item').click(function () {
            if (!$(this).hasClass('active')) {
                var num = parseInt($(this).attr('rel')) * 582;

                par.next().scrollTo({ top: 0, left: num }, 400);

                $(this).parent().find('span').removeClass('active').end().end().addClass('active');

                if ($(this).parent().find('span.item:first').hasClass('active')) {
                    $(this).parent().find('span.prev').addClass('disable');
                } else {
                    $(this).parent().find('span.prev').removeClass('disable');
                }

                if ($(this).parent().find('span.item:last').hasClass('active')) {
                    $(this).parent().find('span.next').addClass('disable');
                } else {
                    $(this).parent().find('span.next').removeClass('disable');
                }
            }
        });

        $(this).find('span.next').click(function () {
            if (!$(this).hasClass('disable')) {
                $(this).parent().find('.active').next().click();
            }
        });
        $(this).find('span.prev').click(function () {
            if (!$(this).hasClass('disable')) {
                $(this).parent().find('.active').prev().click();
            }
        });
    
    var myInterval = setInterval(gonext, 5000);
    var $this = $(this);
    function gonext() {
      var nx = $this.find('span.next');
      if(!nx.hasClass('disable')){
      nx.click();
      } else {
      nx.parent().find('span.item:first').click();
      }
    }
       
    });


});

// #########################################################
      
$(function () {
    var tabContainers = $('div.indtab1-wrapper > div');
    tabContainers.hide().filter(':first').show();
    $('div.indtab1-wrapper ul.tabsnav a').click(function () {
        tabContainers.hide();
        tabContainers.filter(this.hash).show();
        $('div.indtab1-wrapper ul.tabsnav a').removeClass('active1');
        $(this).addClass('active1');
      $('div.indtab1-wrapper ul.tabsnav li').removeClass('active1');
        $(this).parent().addClass('active1');
        return false
    }).filter(':first').click();
});
      
      
      $(function() {
  
        var txar = $("#message-form-text");  
        txar.keydown(function(event) {
          if (event.keyCode == '13') {
            txar.val( txar.val() + "<br />");
          }
        });
        
      });
    
// clean input value on focus

$(function() {

  function hideValue() {
     
        var elem = $('.change-val');
        if (elem.size() > 0) {
            elem.each(function () {
                var defaultVal = $(this).val();
                $(this).focus(function () {
                    if ($(this).val() == defaultVal) {
                        $(this).val('');
                    }
                }).blur(function () {
                    if ($(this).val() == '') {
                        $(this).val(defaultVal);
                    }
                });
            });
        }
     
    }

    jQuery(document).ready(function () {   
        hideValue();
    });
  
});


