jQuery(document).ready(
      function () {

var userAgent = navigator.userAgent.toString().toLowerCase();
if (((userAgent.indexOf('safari') != -1) && !(userAgent.indexOf('chrome') != -1)) || (userAgent.indexOf('linux') != -1))
{
	jQuery(".footer_menu").css('font-size','10px');
//	jQuery(".promo_title").css('font-size','30px');
//	jQuery(".promo_txt").css('font-size','12px');
	
	
} 


jQuery('.addres').children("#showmore").click(function(){jQuery(this).parent().children('#moretext').show();  jQuery(this).hide(); return false;});
jQuery('.right').children("#closemore").click(function(){jQuery(this).parent().parent().parent().children('#moretext').hide(); jQuery(this).parent().parent().parent().children('#showmore').show(); return false;});
      
jQuery(".open_a").click(function(){jQuery('.faq_row').children("#answer").hide(); jQuery(this).parent().parent().parent().children('#answer').show();  return false;});
jQuery('#answer > a.close').click(function(){jQuery(this).parent().parent().hide();  return false;});
jQuery('.answer > a.close').click(function(){jQuery(this).parent().parent().hide();  return false;});

jQuery('.main_menu ul li').each(
function()
{
	if (!jQuery(this).hasClass('sel'))
	{
		jQuery(this).children('ul').css('left','7px');
	}
}
);
if (jQuery('.page-item-118').hasClass('sel'))
{
	jQuery('.main_menu ul li').each(
	function()
	{

			jQuery(this).removeClass('sel');
	});
	jQuery('.page-item-118').addClass('sel');
}
if (jQuery('.page-item-120').hasClass('sel'))
{
	jQuery('.main_menu ul li').each(
	function()
	{
			jQuery(this).removeClass('sel');
	});
	jQuery('.page-item-120').addClass('sel');
}
if (jQuery('.page-item-124').hasClass('sel'))
{
	jQuery('.main_menu ul li').each(
	function()
	{
			jQuery(this).removeClass('sel');
	});
	jQuery('.page-item-124').addClass('sel');
}


jQuery('.main_menu ul li').hover(
function()
{
	jQuery(this).addClass('sel1');
},

function()
{
	jQuery(this).removeClass('sel1');
}

);

jQuery('.sub-menu').hover(
function()
{
	jQuery(this).parent().addClass('sel1');
},

function()
{
	jQuery(this).parent().removeClass('sel1');
}


);

jQuery('.sub-menu li').css('cursor','pointer');
jQuery('.sub-menu li').click(
function()
{
	hr = jQuery(this).children('a').first().attr('href');
	if (hr.length>0) {location.href=hr; return true;}
	else {return false;}
}
);



         var tAllowToSubmit = false;
         fIds=["your-name",  "your-lastname",  "your-phone","your-email", "your-comment"];
         
	jQuery('.thankyou').empty().hide();
         setTimeout(function () { tAllowToSubmit = true; }, 1000);

         var tCheckSubmitPromotionalFormTimeout = false;
         function lkCheckSubmitPromotionalForm(fForm) {
	         jQuery('#ffsub').hide();
            jQuery('form.js-contact-us-form .preloader').stop(false, true).fadeIn(500);
            
            if (tCheckSubmitPromotionalFormTimeout)
               clearTimeout(tCheckSubmitPromotionalFormTimeout);
            if (tAllowToSubmit == false)
               tCheckSubmitPromotionalFormTimeout = setTimeout(function () { lkCheckSubmitPromotionalForm(fForm) }, 1000);
            else
               lkSubmitPromotionalForm(fForm);
            return false;
         }
         function lkSubmitPromotionalForm(fForm) {
         okflg=true;
         for (i=0; i<fIds.length; i++)
         {
         	myid=fIds[i];
         	v = jQuery("#"+myid).val();
         	//alert(myid+' -> '+jQuery("#"+myid).val());
         	if (v.length<1)
         	{
         		okflg=false;
         		jQuery("#"+myid).css('border','1px red dotted');
         	}
         	else
         	{
         		jQuery("#"+myid).css('border','');
         	}
         }
         
	    
	if (okflg == false) 
	{
		jQuery('form.js-contact-us-form .preloader').stop(false, true).fadeOut(500).hide();
		jQuery('#ffsub').show();
		
		return false;
	}
	
        jQuery.ajax({
               url: fForm.action,
               cache: false,
               dataType: 'json',
               data: jQuery('form.js-contact-us-form').serialize(),
               type: 'POST',
               beforeSend: function () { },
               complete: function () { jQuery('form.js-contact-us-form .preloader').stop(false, true).fadeOut(500); },
               success: function (fData) {
                  jQuery('form.js-contact-us-form .field-validation-error').text('');
//alert(fData);
                  if (fData.success === true) {
//		    jQuery("#hiddenframe").load("/thankyou.html");
                     //jQuery('#thank-you iframe').attr('src', '/thank-you/');
                     //showPopupBySelector('#thank-you');
           // alert('OK');         

                     jQuery('.thankyou').empty().append('Thank You!');
                     //document.write('<div style="display:none;visibility:hidden"><scr'+'ipt>document.write("<ifr'+'ame src=/thankyou.html name=thankifr></if'+'rame>");</scr'+'ipt></div>');
                     
                     jQuery('form.js-contact-us-form').children().hide();
		    jQuery('.thankyou').show();
//		     _gaq.push(['_trackEvent', 'Form submit', 'Submit Clicked', '']);


		    var ts=setTimeout("jQuery('form.js-contact-us-form').each(function(){this.reset();}); jQuery('form.js-contact-us-form').children().show();jQuery('.thankyou').empty().hide();jQuery(document).ready();jQuery('form.js-contact-us-form .preloader').stop(false, true).fadeOut(500);",5000);
                  } else if (fData.errors) {
  // alert('errors');
                     for (var tC in fData.errors) {
                        jQuery('#validation-message-' + fData.errors[tC].PropertyName).text(fData.errors[tC].ErrorMessage);
                        //alert(fData.errors[tC].ErrorMessage);
                     }
                  } else if (fData.fatalerrors) {
//alert('fatalerrors');
                     var tErr = '';
                     for (var tC in fData.fatalerrors) {
                        tErr += fData.fatalerrors[tC] + '\n';
                     }
                     alert(tErr);
                  }
               },
               error: function(jqXHR, textStatus, errorThrown){ alert(textStatus) }
            });

            return false;
         }

        jQuery('form.js-contact-us-form').submit(function () 
	{ 
//	    _gaq.push(['_trackEvent', 'Form submit', 'Submit Clicked', '']);
//	    document.getElementById("psm").innerHTML = '<iframe src="/thankyou.html" style="border:none;width:1px;height:1px;" marginheight="0" marginwidth="0" frameborder="0"></iframe>';
	    lkCheckSubmitPromotionalForm(this); return false; 
	});

	jQuery("#ffsub").click(function()
	{
	    lkCheckSubmitPromotionalForm(document.getElementById('fform'));
	    return false;
	}
	);


      }
   );

