/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
jQuery(document).ready(function() {
    jQuery('.athens').click(function () {
        jQuery('#form_to_show').fadeOut(800,function(){
           jQuery('#form_to_show').html(jQuery('#athens_form').html());
           jQuery('#form_to_show').fadeIn(1200);
        });
    });

    jQuery('.thessaloniki').click(function () {
        jQuery('#form_to_show').fadeOut(800,function() {
           jQuery('#form_to_show').html(jQuery('#thessaloniki_form').html());
           jQuery('#form_to_show').fadeIn(1200);
        });
    });
    
    jQuery('.rest_of_greece').click(function () {
        jQuery('#form_to_show').fadeOut(800,function() {
           jQuery('#form_to_show').html(jQuery('#rest_of_greece_form').html());
           jQuery('#form_to_show').fadeIn(1200);
        });
    });

    jQuery('.road_help').click(function () {
        jQuery('#form_to_show').fadeOut(800,function() {
           jQuery('#form_to_show').html(jQuery('#road_help_form').html());
           jQuery('#form_to_show').fadeIn(1200);
        });
    });

    //When page loads...
    jQuery(".tab_content").hide(); //Hide all content
    jQuery("ul.tabs li:first").addClass("active").show(); //Activate first tab
    jQuery(".tab_content:first").show(); //Show first tab content

    //On Click Event
    jQuery("ul.tabs li").click(function() {

            jQuery("ul.tabs li").removeClass("active"); //Remove any "active" class
            jQuery(this).addClass("active"); //Add "active" class to selected tab
            jQuery(".tab_content").hide(); //Hide all tab content

            var activeTab = jQuery(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
            jQuery(activeTab).fadeIn(); //Fade in the active ID content
            return false;
    });

    if (jQuery('.wpsc-current-cat').parent().parent().attr('class') == 'wpsc_categorisation_group') {
        jQuery('.wpsc-current-cat').parent().parent().css({
           'background':'#759fd0'
        });
    } else {
        jQuery('.wpsc-current-cat').parent().parent().parent().parent().css({
           'background':'#759fd0'
        });
    }

    if ((document.URL == 'http://www.orthostatical.gr/') || (document.URL == 'http://orthostatical1.gr/')){
        jQuery('.vote_button_value').val(' Ψήφισε ');
    } else {
        jQuery('.vote_button_value').val(' Vote ');
    }

    if ((document.URL == 'http://www.orthostatical.gr/') || (document.URL == 'http://orthostatical1.gr/')){
        jQuery('.view_results_text_value').html(' Αποτελέσματα ');
    } else {
        jQuery('.view_results_text_value').html(' View Results ');
    }

    if (jQuery('#qtranslate-chooser').find('li').attr('class') == 'lang-EL active') {
        jQuery('#qtranslate-chooser').find('.lang-en').hide();
    } else {
        jQuery('#qtranslate-chooser').find('.lang-EL').hide();
    }

    jQuery('#lang_sel').mouseover(function () {
        if (jQuery('#qtranslate-chooser').find('li').attr('class') == 'lang-EL active') {
            jQuery('#qtranslate-chooser').find('.lang-en').show();
        } else {
            jQuery('#qtranslate-chooser').find('.lang-EL').show();
        }
    });

    jQuery('#lang_sel').mouseout(function () {
        if (jQuery('#qtranslate-chooser').find('li').attr('class') == 'lang-EL active') {
            jQuery('#qtranslate-chooser').find('.lang-en').hide();
            jQuery('#qtranslate-chooser').find('.lang-EL').show();
        } else {
            jQuery('#qtranslate-chooser').find('.lang-EL').hide();
            jQuery('#qtranslate-chooser').find('.lang-en').show();
        }
    });


    /* Products Slider Functions  */

  var total_ul_width_p = 210 * (jQuery('.wpsc_products_slide').find('li').length);
  var total_sliding_p = (210 * ((jQuery('.wpsc_products_slide').find('li').length))) - 800;
  var right_val_p = jQuery('.wpsc_products_slide').css('right');
  jQuery('.wpsc_products_slide').css({
      'width' : total_ul_width_p+'px'
  });

  if (parseInt(right_val_p) == 0) {
      jQuery('#left_sliding_p').css('visibility','hidden');
  } else {
      jQuery('#left_sliding_p').css('visibility','visible');
  }

  if ((parseInt(right_val_p)+800) > total_sliding_p) {
      jQuery('#right_sliding_p').css('visibility','hidden');
  } else {
      jQuery('#right_sliding_p').css('visibility','visible');
  }

    jQuery('#left_sliding_p').click(function() {
        right_val_p = jQuery('.wpsc_products_slide').css('right');
        right_val_p = right_val_p.split('px');
        if (parseInt(right_val_p) > 0) {
            jQuery('#right_sliding_p').css('visibility','visible');
            if ((parseInt(right_val_p)-211) < 0) {
                jQuery('#left_sliding_p').css('visibility','hidden');
            }
            jQuery('.wpsc_products_slide').animate({"right": "-=210px"}, 800);
        }
    });

    jQuery('#right_sliding_p').click(function() {
        right_val_p = jQuery('.wpsc_products_slide').css('right');
        right_val_p = right_val_p.split('px');
        if ((parseInt(right_val_p) + 210) < parseInt(total_sliding_p)) {
            jQuery('#left_sliding_p').css('visibility','visible');
            if ((parseInt(right_val_p) + 420) > total_sliding_p) {
                jQuery('#right_sliding_p').css('visibility','hidden');
            }
            jQuery('.wpsc_products_slide').animate({"right": "+=210px"}, 800);
        }
    });

});


