var ajax_mail_form_url='';
var Base64 = {



	// private property

	_keyStr : "",



	// public method for encoding

	encode : function (input) {

		var output = "";

		var chr1, chr2, chr3, enc1, enc2, enc3, enc4;

		var i = 0;



		input = Base64._utf8_encode(input);



		while (i < input.length) {



			chr1 = input.charCodeAt(i++);

			chr2 = input.charCodeAt(i++);

			chr3 = input.charCodeAt(i++);



			enc1 = chr1 >> 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;

	}



}















$(document).ready(function(){

//$("h2.txt").addClass("gtitle")





if (!window.XMLHttpRequest){



$("img[src*=.png]").each(function(){

  var blank = imgurl + 'blank.gif';

  var src = $(this).attr("src");

  var filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='image')";

  $(this).css("filter", filter);

  $(this).attr("src", blank);

});



}













$(".description").addClass("vision");

//$("h2.txt").addClass("gtitle");





$("#service-nav a").each(function(){

    //var awidth = $(this).find(".linkText").width();

    //$(this).css("width", awidth + 65 + 'px')

});



    $.fn.exists = function(){

    	return $(this).length>0;

    	return $(this)=obj;

    }

    $.fn.unexists = function(){

    	return $(this).length==0;

    	return $(this)!=obj;

    }



    //Dom Helpers

    $("#nav a").append("<span class='wrap-bg'><span><!-- --></span></span>");

    $("#header").append("<div id='light'></div>");

    var afade = document.createElement("div");

    afade.setAttribute("id", "afade");

    $("#container").append(afade);

    $("#afade").prepend("<span id='isFade'><!-- --></span>");



        var ie6pf = document.createElement('div');

        ie6pf.setAttribute("class", "ie6pf");

        var divs = document.getElementsByName('div');

        /*!!mportant*/

         $(".ie6 .portfolio-box img").after("<div class='ieshespf'><!-- --></div>");



    //$(".portfolio-box:last").after("<div class='portfolio-box-last'><!--/* */--></div>");

    $(".portfolio-box:last").css({"height":"261px", "-overflow":"hidden"});

    $(".portfolio-box:last .portfolio-box-content").css({"height":"261px"});

    $(".portfolio-box:last .ieshespf").css({"height":"261px"});



    var nav_active_left = $("#nav .active").offset().left;

     $("#light").css("left", nav_active_left - 33 + 'px');

    $("#light").animate({top:0}, 1000);





    var navSpeed = 200;

    $("#nav a").hover(function(){

         $(this).find("span span").animate({opacity: 1}, navSpeed)



    }, function(){

          $(this).find("span span").animate({opacity: 0}, navSpeed);



    });



$("#social a").append("<span><!-- --></span>");



$("#social a").hover(function(){

    $(this).find("span").stop();

    $(this).find("span").animate({opacity:1}, 'normal')

}, function(){

    $(this).find("span").stop();

    $(this).find("span").animate({opacity:0}, 'normal')

})



    $(".afterbox:last").addClass("afterboxLast");



    $("#nav a").click(function(){

        itsHref = $(this).attr("href");

        var active_left = $(this).offset().left;

          $("#light").animate({left: active_left - 33}, function(){

            window.location.href = itsHref;

          });

          return false;

     });



     $(".gtitle, #category-136, #category-140, #category-148").append("<span><!--  --></span>");



    $("#service-nav a").hover(function(){

        $(this).addClass("hover");

    }, function(){

        $(this).removeClass("hover");

    });



$("ul.parentN").each(function(){

    twidth = $(this).find("a:first").width();

    $(this).find("ul").css("width", twidth + 12)

});









  /*function keyPressHandler(e){

      var kC  = (window.event)?event.keyCode : e.keyCode;

      var Esc = (window.event)?27 : e.DOM_VK_ESCAPE

      if(kC==Esc){

        alert(1)

      $("#contacts").hide();

		 $(".ie8 ul a").show();

         $("#Alert").hide();

         $("#contacts-overlay").animate({opacity:0}, 500,  function(){

            $("#contacts-overlay").hide();

        });

      }

   } */



   $(window).keydown(function(event){



	var key = event.keyCode;

    if (key=='27'){
              $("#contacts-overlay").click()/*
             $("#contacts").hide();

    		 $(".ie8 ul a").show();

             $("#Alert").hide();

             $("#contacts-overlay").animate({opacity:0}, 500,  function(){

                $("#contacts-overlay").hide();

            }); */

    }





   });



    $(".closeo, #contacts-overlay").click(function(){

         $("#contacts").hide();

		 $(".ie8 ul a").show();

         $("#Alert").hide();

         $("#contacts-overlay").animate({opacity:0}, 500,  function(){

            $("#contacts-overlay").hide();

        });

    });



    $(".formover, .objHomeForm, .worder, .objorderforms").click(function(){

    $("#contacts-overlay").show();

        $("#contacts-overlay").animate({opacity:0.7}, 500,  function(){

			var hhhTop = $(window).scrollTop();

			$("#contacts").css("top", hhhTop + 30);

            $("#contacts").show();

			$(".ie8 ul a").hide();

        });

    })





    $(".ie6 #contacts").append("<div id='contactsbg'><!-- /**/ --></div>");

    $(".ie #fsend").before("<div style='clear:both;height:0;overflow:hidden'><!-- --></div>");





    if (!window.XMLHttpRequest){// MSIE6

       var samp = document.createElement('samp');

       $("#portfolio-previous, #portfolio-next").prepend(samp);

    }





    $(".DropDown").each(function(){

        var DropActiveHTML = $(this).find("li.active").html();

        var DropActiveValue = $(this).find("li.active").attr("title");



        $(this).find("span").html(DropActiveHTML);

        $(this).find("input").val(DropActiveValue);



    });





    $("a[href='#']").attr("href", "javascript:;");



$(".small-images a").each(function(){

    var ax = $(this).attr("href");

    $(this).attr("url", ax)

    $(this).attr("href", "javascript:;");

})

$(".small-images a").click(function(){

    var ahref = $(this).attr("url");

    if(ahref!=$(".TheImage").attr("src")){

            var new_img = new Image();

            new_img.src = ahref;

            new_img.className = 'TheImage TheImageAbs';

            $(".project-main-image").prepend(new_img);

            var Pspeed = 600;

            $(".TheImage:eq(1)").animate({opacity:0}, Pspeed, function(){

                 $(".TheImage:eq(1)").remove();

            });

            $(".TheImage:first").animate({opacity:1}, Pspeed, function(){

                 $(".TheImage").removeClass("TheImageAbs");

                 var back2Top = $("#browser-scrollbar").offset().top - 80;

                 if($.browser.opera){

                     window.scrollTo(0, back2Top);

                     $("#browser-scrollbar").scrollTop(0,0);

                 }

                 else{

                   $("html, body").animate({scrollTop: back2Top}, Pspeed, function(){});

                   $("#browser-scrollbar").animate({scrollTop: 0})

                 }

            });

    }

    else{

         var back2Top = $("#browser-scrollbar").offset().top - 80;

         if($.browser.opera){

             window.scrollTo(0, back2Top);

             $("#browser-scrollbar").scrollTop(0,0);

         }

         else{

           $("html, body").animate({scrollTop: back2Top}, Pspeed, function(){});

           $("#browser-scrollbar").animate({scrollTop: 0}, Pspeed)

         }

    }



    return false;

});





    $("#float-navigation a").click(function(){

        var pf_link_left = $(this).offset().left;

        var pf_left = $("#subheader").offset().left;

        var pf_link_center = $(this).width()/2 - 109/2;

        var pf_link_url = $(this).attr("href");

        $("#floatAct").animate({left: pf_link_left - pf_left + pf_link_center + 3}, function(){

            //$("#portfolio-hover").animate({top:'36px'});

            window.location.href = pf_link_url;

        });

        return false;

    });





     if($("#float-navigation").exists()){

        var pf_link_left = $("#float-navigation li.active a").offset().left;

        var pf_left = $("#subheader").offset().left;

        var pf_link_center = $("#float-navigation li.active a").width()/2 - 109/2;

        $("#floatAct").css({"left": pf_link_left - pf_left + pf_link_center + 3});

     }





$("#portfolio-navigation li li a.active").parent().addClass("active");

$("#portfolio-navigation li li").hover(function(){

    $(this).addClass('hover')

},function(){

    $(this).removeClass('hover')

});



$("#contacts").validate();



$("#contacts").submit(function(){



      var name = $("#contacts input[name='name']").val();

      var email = $("#contacts input[name='email']").val();

      var phone = $("#contacts input[name='phone']").val();

      var message = $("#contacts textarea[name='message']").val();

      var budget = $("#contacts input[name='budget']").val();



    if($("#contacts .required.error").unexists()){
		return true;
		
		}

    //Action



    else{

           $("#contacts_msg").animate({opacity:1});

    }









    return false;



});





//var external = $("#content a[href^='http://']").not("[href^='http://bg.ooyes']");



var external = $("#content a[href^='http://']").not("[href^='http://www.ybweb']");



external.each(function(){

   // var xhref = $(this).attr("href");

   // var xhref_encoded = Base64.encode(xhref);

   // var windowLocation64 = Base64.encode(window.location.href);



   // $(this).attr("href", external_link_browser_url + xhref_encoded+'/goback:'+windowLocation64);

    /*$(this).html(xhref)*/ //msie

$(this).attr("target", "_blank");

});



$(".more").hover(function(){

    $(this).stop();

    $(this).animate({opacity:'0.3'}, 'fast', function(){

        $(this).animate({opacity:'1'}, 'fast')

    })

})



//$("#paging li:nth-child(15n)").after("<div style='height:5px;overflow:hidden;'></div>");



var layActiveUrl = $("#nav a.active").attr("href");

    $("#light").append("<a href='" + layActiveUrl + "' id='lightActive'><!----></a>");

    var ll = parseFloat($("#light").css("left"));

    $(".ie6 #light").after("<a href='" + layActiveUrl + "' id='ie6lightActive'><!----></a>");





$(".bbar-box:last").addClass("bbar-box-last");



$(".cool-list li").prepend("<i><!-- --></i>");

$(".cool-list li").append("<s><!-- --></s>");







$("#AlertMessageOK").click(function(){

    $("#Alert").hide();

    $("#AlertMessage").html("");

    $("#contacts-overlay").animate({opacity:0}, 'fast', function(){

        $("#contacts-overlay").hide();

      })

})





  $(".DropDown").click(function(){

     $(this).find("ul").toggle();

  });

    $(".DropDown").hover(function(){$(this).removeClass("OBJDropDown")}, function(){$(this).addClass("OBJDropDown")});



  $(".DropDown ul li").hover(function(){$(this).addClass("hover")}, function(){$(this).removeClass("hover")});



  $(".DropDown ul li").click(function(){

      var DropItemHTML = $(this).html();

      var DropItemValue = $(this).attr("title");

      $(this).parents(".InputBoxContent").find("input").val(DropItemValue);

      $(this).parents(".InputBoxContent").find("span").html(DropItemHTML);



  });



  $(".Input").click(function(){

    $(this).find("input").focus();

  })



    $("body").click(function(){

     $(".OBJDropDown ul").hide();

  });



 /*var bpw = $(".blog-paging").width()/2;

 $(".blog-paging").css("marginLeft", 830/2 - bpw)*/
    var stumble_cookie = $.cookie("stumble_cookie");
 if (top.location != self.location){

   if(stumble_cookie!="shown"){
      if($(window).width()>800){
          $(".social_networks_visitor_stumble_us").show();
          $.cookie("stumble_cookie", "shown");
      }

   }
 }
 $(".social_networks_visitor_stumble_us").click(function(){
     $(this).hide();
 });

                 //social_networks_visitor_stumble_us
    $.preload = function(){

      for(var i = 0; i<arguments.length; i++){

        $("<img>").attr("src", arguments[i]);

      }

    }

    $.preload(

       imgurl + 'pngsubmit.png',
       imgurl + 'alert.png',
       imgurl + 'why_us_btn_hover.jpg',
       imgurl + 'web_btn_hover.jpg',
       imgurl + 'testimonials_btn_hover.jpg',
       imgurl + 'bullet.jpg',
       imgurl + 'topLeft.png',
       imgurl + 'bottomLeft.png',
       imgurl + 'topRight.png',
       imgurl + 'bottomRight.png',
       imgurl + 'topSentert.jpg',
       imgurl + 'mform.png',
       imgurl + 'alert.png'

    );

    $("textarea").addClass("required")



   //$("form").validate();

   $("#contacts").validate();

   $("#comments-form").validate();

   $("#contactspform").validate();



   ajaxFormOptions = {

	   

	   

	   //url:    ajax_mail_form_url,

       url:    ajax_mail_form_url,

	   type:   'post',

	   resetForm: true,



        beforeSubmit:  ajaxFormBefore,

        success:       ajaxFormSuccess,

        complete:      ajaxFormSuccess

   }



   $("form.ajax").submit(function(){

        activeFormIndex = $("form.ajax").index(this);

        $(this).ajaxSubmit(ajaxFormOptions);

        return false;

   });













$("#testimonials-home").hover(function(){

    $(this).addClass("th_hover");

},

function(){

   $(this).removeClass("th_hover");



});





 $("#phone").hover(function(){

    $(this).addClass("stop")

 }, function(){

    $(this).removeClass("stop")

 })







});//end doc ready





function ajaxFormBefore(){

    var TF = true;

    if($("form.ajax:eq(" + activeFormIndex + ") textarea.error").exists() || $("form.ajax:eq(" + activeFormIndex + ") input.error").exists()){

        TF = false;

        Alert('Please, fill out the required fields!');

    }



    if(TF != false){



   var capcha = $("form.ajax:eq(" + activeFormIndex + ") input[name='cptch']").val();



   $.post(ajax_mail_form_url_validate, { cptch: capcha},

  function(data){

    //alert("Data Loaded: " + data);

    if(data == 'no'){

            TF = false;

    }



  });







    }

















    return TF;

}



function ajaxFormSuccess(){

     $(".loader").hide();

     Alert('Message has been successfuly send. <br />Thank You!');
	 google_analytics_track_mail_form();

}



$(window).resize(function(){

    var nav_active_left = $("#nav .active").offset().left;

    $("#light").animate({left: nav_active_left - 33});



});



$(window).load(function(){

   $("#slider ul").animate({left: '0px'}, 2500, function(){

         $("#theslider").css("opacity", "1");

         $("#slider-loading").hide();

    });



    if($("#paging").hasClass("parentMode")){

       $("#paging").css("marginLeft", "0px");

    }

    else{

        halfPagingWidth = $("#paging").width()/2 ;

        $("#paging").css("marginLeft", -(halfPagingWidth + 55));

    }

   setTimeout("hideStumble()", 90000);

});

function hideStumble(){
    $(".social_networks_visitor_stumble_us").hide();
}

function slide(){

      var slider = $("#slide-list");

      var slider_height = slider.height();

      var slider_top = $("#slide-list").css("top");

      var step = parseFloat($("#slide-list li:first").height());

      var slider_top_value = parseFloat(slider_top);

      if($("#testimonials-home").hasClass("th_hover")){/**/}

      else{

           if(slider_top_value < (-slider_height + (80 + 20))){

             slider.animate({top: 0});

          }

          else{

             slider.animate({top: slider_top_value - step - 10}, function(){

                a = 1;

                var i = a++;

                $("#modal").html(i)

             });

          }

      }



}

setInterval( "slide()", 2000);







function portfolioFade(){

    var pfade = $("#isFade");

    var pwidth = $(window).width();

    pfade.animate({left: pwidth}, 3000, function(){

         pfade.css({"left":"-302px"})

    });

    if($("html").hasClass("ie")){

       /*  */

    }

	else if($("html").hasClass("chrome")){

		$("#afade").css({opacity: "1"});

	}

    else{

      $("#afade").animate({opacity: "1"}, 1270, function(){

          $("#afade").animate({opacity: "0"}, 1270, function(){

              $("#afade").css("opacity", "0");

          });

      });

    }

}

setInterval("portfolioFade()", 7000);



function phones(){

      if($("#phone").hasClass("stop")){}

      else{

          $("#phoneSlide").animate({'left':'-145px'}, 'slow', function(){

              var firstPhone = $("#phone #phoneSlide span:first").html();

              $("#phone #phoneSlide span:first").remove();

              $("#phone #phoneSlide").append("<span>" + firstPhone + "</span>");

              $("#phone #phoneSlide").css({"left":"0px"})

          });

      }



}

setInterval("phones()", 5000);



function Alert(Atext){

      $("#AlertMessage").html(Atext);

      var AlertTop = $(window).scrollTop();

      $("#Alert").css("top", AlertTop + 120);

      $("#contacts-overlay").show();

      $("#contacts-overlay").animate({opacity:0.8}, 'fast', function(){

                $("#Alert").show();

                $("#AlertMessageOK").focus();

      });



}



function scrollto(p){

   var scrollTo = $(p).offset().top;

   $("html, body").animate({scrollTop: scrollTo}, 700);

}







function chat(theURL){

    var chat_left = ($(window).width()/2) - 305;

	window.open(theURL, '', 'fullscreen=no, scrollbars=no, resizable=no, statusbar=no, toolbar=no, menubar=no, height=50, width=615').moveTo(chat_left, 100);

}



function createTip(tipClass, tTop, tLeft){

    var tipElem = document.createElement('span');

    tipElem.className = 'universalToolTip ' + tipClass;

    tipElem.style.top = tTop;

    tipElem.style.left = tLeft;

    document.body.appendChild(tipElem);

}

function alertContacts(){

    Alert('<p class="pp">We are available to answer your questions, make proposals and help your business future.</p><span class="usp">+1 (310) 878 9051</span> <span class="enp">+44 (208) 123 4781</span><span class="bgp">+359 (878) 984 143</span>');

}







function newWindowRedirect ($the_url)

{

hide_referer = window.open ("", "newWindowRedirect", "");

hide_referer.document.open ();

hide_referer.document.writeln ('<html>');

hide_referer.document.writeln ('<head>');

hide_referer.document.writeln ('<meta http-equiv="refresh" content="0;url='+ $the_url +'">');

hide_referer.document.writeln ('</head>');

hide_referer.document.writeln ('<body>');

hide_referer.document.writeln ('</body>');

hide_referer.document.writeln ('</html>');

hide_referer.document.close ();

}








