/*
/*	Dynamic design functions and onLoad events
/*	----------------------------------------------------------------------
/* 	Creates added dynamic functions and initializes loading. 
/*	For editing, use source file located in "js/source" folder.
*/
jQuery(document).ready(function($){if(jQuery.browser.msie&&parseInt(jQuery.browser.version,10)<7){$j("ul.sf-menu").superfish({delay:400,animation:{height:"show"},speed:275})}else{$j("ul.sf-menu").supersubs({minWidth:12,maxWidth:27,extraWidth:0}).superfish({delay:400,animation:{height:"show"},speed:275})}jQuery('a[href$="#popup"]').addClass("zoom iframe").each(function(){jQuery(this).attr("href",this.href.replace("#popup",""))});jQuery('a[href$="#login"]').addClass("login").each(function(){theHref=jQuery(this).attr("href");if(theHref=="#login"){theHref=themePath+"login.html"}jQuery(this).attr("href",theHref.replace("#login",""))});jQuery("a.zoom[href*='http://www.youtube.com/watch?']").each(function(){jQuery(this).addClass("fancyYouTube").removeClass("zoom").removeClass("iframe")});jQuery("a.zoom[href*='http://www.vimeo.com/'], a.zoom[href*='http://vimeo.com/']").each(function(){jQuery(this).addClass("fancyVimeo").removeClass("zoom").removeClass("iframe")});var overlayColor=jQuery("#fancybox-overlay").css("background-color")||"#2c2c2c";jQuery("a.zoom").fancybox({padding:12,overlayOpacity:0.2,overlayColor:overlayColor,onComplete:modalStart});jQuery("a.login").fancybox({padding:12,overlayOpacity:0.2,overlayColor:overlayColor,showCloseButton:false,frameWidth:400,frameHeight:208,scrolling:"no",titleShow:false,hideOnContentClick:false,callbackOnShow:modalStart});jQuery("a.fancyYouTube").click(function(){jQuery.fancybox({padding:12,overlayOpacity:0.2,overlayColor:overlayColor,onComplete:modalStart,title:this.title,href:this.href.replace(new RegExp("watch\\?v=","i"),"v/"),type:"swf",swf:{wmode:"transparent",allowfullscreen:"true"}});return false});jQuery("a.fancyVimeo").click(function(){jQuery.fancybox({padding:12,overlayOpacity:0.2,overlayColor:overlayColor,onComplete:modalStart,title:this.title,href:this.href.replace(new RegExp("([0-9])","i"),"moogaloop.swf?clip_id=$1"),type:"swf"});return false});$j('.topReveal, a[href$="#topReveal"]').click(function(){$j("#ContentPanel").slideToggle(800,"easeOutQuart");$j.scrollTo("#ContentPanel");return false});$j("a.img").hover(function(){if(jQuery.browser.msie&&parseInt(jQuery.browser.version,10)<=8){$j(this).stop(false,true).toggleClass("imgHover")}else{$j(this).stop(false,true).toggleClass("imgHover",200)}});$j("input[type='text']:not(.noStyle), input[type='password']:not(.noStyle)").each(function(){$j(this).addClass("textInput")});if($(".portfolio-description").length>0){var pi=$(".portfolio-description");pi.each(function(i,val){if(pi[i].scrollHeight>120){pi.css("height",pi[i].scrollHeight+"px");return false}})}$j("label.overlabel").overlabel();searchInputEffect();buttonStyles();if(!jQuery.browser.msie){$j("a.img, div.img, .pagination a, .textInput, input[type='text'], input[type='password'], textarea").addClass("rounded");roundCorners()}});function searchInputEffect(){searchFocus=false,searchHover=false,searchCtnr=$j("#Search"),searchInput=$j("#SearchInput"),searchSubmit=$j("#SearchSubmit");if(searchCtnr.length>0){searchCtnr.hover(function(){if(!searchFocus){$j(this).addClass("searchHover")}searchHover=true},function(){if(!searchFocus){$j(this).removeClass("searchHover")}searchHover=false}).mousedown(function(){if(!searchFocus){$j(this).removeClass("searchHover").addClass("searchActive")}}).mouseup(function(){searchInput.focus();searchSubmit.show();searchFocus=true});searchInput.blur(function(){if(!searchHover){searchCtnr.removeClass("searchActive");searchSubmit.hide();searchFocus=false}})}}function buttonStyles(){jQuery("button:not(:has(span),.noStyle), input[type='submit']:not(.noStyle), input[type='button']:not(.noStyle)").each(function(){var b=jQuery(this),tt=b.html()||b.val();if(!b.html()){b=(jQuery(this).attr("type")=="submit")?jQuery('<button type="submit">'):jQuery("<button>");b.insertAfter(this).addClass(this.className).attr("id",this.id);jQuery(this).remove()}b.text("").addClass("btn").append(jQuery("<span>").html(tt))});var styledButtons=jQuery(".btn");styledButtons.hover(function(){jQuery(this).addClass("submitBtnHover")},function(){jQuery(this).removeClass("submitBtnHover")})}function roundCorners(){jQuery(".rounded, .ui-corner-all").css({"-moz-border-radius":"4px","-webkit-border-radius":"4px","border-radius":"4px"})};

/*
* jQuery Watermark Plugin (v1.0.0)
*   http://updatepanel.net/2009/04/17/jquery-watermark-plugin/
*
* Copyright (c) 2009 Ting Zwei Kuei
*
* Dual licensed under the MIT and GPL licenses.
*   http://www.opensource.org/licenses/mit-license.php
*   http://www.opensource.org/licenses/gpl-3.0.html
*/
(function($) {
    $j.fn.updnWatermark = function(options) {
        options = $j.extend({}, $j.fn.updnWatermark.defaults, options);
        return this.each(function() {
            var $jinput = $j(this);
				// Checks to see if watermark already applied.
            var $jwatermark = $jinput.data("updnWatermark");
            // Only create watermark if title attribute exists
            if (!$jwatermark && this.title) {
				// Inserts a span and set as positioning context
                var $jwatermark = $j("<span/>")
					.addClass(options.cssClass)
                    .insertBefore(this)
                    .hide()
					.bind("show", function() {
                        $j(this).children().fadeIn("fast");
                    })
                    .bind("hide", function() {
                        $j(this).children().hide();
                    });
				// Positions watermark label relative to positioning context
				$j("<label/>").appendTo($jwatermark)
                    .text(this.title)
                    .attr("for", this.id);
				// Associate input element with watermark plugin.
                $jinput.data("updnWatermark", $jwatermark);
            }
			
				// Hook up blur/focus handlers to show/hide watermark.
            if ($jwatermark) {
                $jinput
                    .focus(function(ev) {
                        $jwatermark.trigger("hide");
                    })
                    .blur(function(ev) {
                        if (!$j(this).val()) {
                            $jwatermark.trigger("show");
                        }
                    });
                // Sets initial watermark state.
                if (!$jinput.val()) {
                    $jwatermark.show();
                }
            }
        });
    };
    $j.fn.updnWatermark.defaults = {
        cssClass: "updnWatermark"
    };
    $j.updnWatermark = {
        attachAll: function(options) {
			$j("input:text[title!=''],input:password[title!=''],textarea[title!='']").updnWatermark(options);
        }
    };
})(jQuery);




/* sinapsa - internet solutions */
var current;

	// Sycling between quotes
	function sycle(){
		$j('.q' + current).hide();
		current++;
		
		if( current > $j('div.quote-widget').size() ){
			current = 1;
		}
		
		$j('.q' + current).animate( {height: $j('.q' + current).height() + 'px' }, 4000 );
		$j('.q' + current).show().animate({top:"0px"},4000,function(){sycle();});
	}
	
	// Validates email addresss
	function validate(email){
		var r = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
		return email.match(r);
	}
	
jQuery(document).ready(function(){ 
	jQuery('#MainMenu #menu-item-713 a').addClass('contact');
	jQuery('#Showcase .showcase-area-right').click(function(){ window.location = 'http://www.wizardui.com/about/why-wizard-ui-consulting/'; });
	jQuery('#Showcase .showcase-area-middle').click(function(){ window.location = 'http://www.wizardui.com/portfolio/'; });
	jQuery('#Showcase .showcase-area-left').click(function(){ window.location = 'http://www.wizardui.com/services/user-interface-design/'; });

	/* Quotes Animation */
	var x = 1;
	$j('div.quote-widget').each(function(){ 
		$j(this).addClass('q'+x).hide();
		x++;
	});
	
	$j('div.quote-widget p.details').append('<br/><a href="http://www.wizardui.com/about/customers-testimonials/" target="_top" title="More Testimonials">להמלצות נוספות &raquo;</a>');
	current = 1;
	sycle();
	
	/* Footer Mini form */
	$j('#submitMiniForm').click(function(){ 
		
		$j('#customFormSmall .err').hide();
		var eml = $j('#ContactEmailSmall').val();
		var msg = $j('#ContactCommentSmall').val();

		if( validate(eml)){
			$j('#customFormSmall .form').fadeOut(300);
			setTimeout('$j("#customFormSmall .msg").fadeIn()',300);
			
			$j.post('http://www.wizardui.com/bl_con.php', { e: eml, c: msg, l: 'he' }, function(data){ 

				if( true || data != '' && data.indexOf('@V') > -1 ){ 
					//$j('#customFormSmall .form').fadeOut(300);
					jQuery.fancybox({
						autoDimensions: false,
						autoScale: false,
						transitionIn: 'elastic',
						transitionOut: 'elastic',
						width: 414,
						height: 370,
						href: 'http://www.wizardui.com/contact_sent.php',
						'hideOnContentClick': false,
						ajax : {
							type: "POST",
							data: 'mydata=test'
						}
					});
					$j("#customFormSmall .msg").fadeOut(300);
					//setTimeout('$j("#customFormSmall .msg").html("ההודעה נשלחה בהצלחה")',300);
					//$j("#customFormSmall .msg").fadeIn(300);
					//setTimeout('$j("#customFormSmall .msg").html("ההודעה נשלחה בהצלחה")',300);
					//alert('OK');
					//$j('#customForm .message').hide().html('<h3>ההודעה נשלחה בהצלחה</h3>').fadeIn('slow');
				}else{ 
					//alert('@F');
					//$j('#customForm .message').hide().html('<h3>השליחה נכשלה</h3>').fadeIn('slow');
				}
			});
		} else {
			 $j('#customFormSmall .err').show();
			 setTimeout('$j("#customFormSmall .err").fadeOut("slow")',1000);
		}
	});
	
	$j.updnWatermark.attachAll();
	
	/* Pop-Up Contact Form  */
	$j('a.contact,.openPopup').click(function(){

		jQuery.fancybox({
			autoDimensions: false,
			autoScale: false,
			transitionIn: 'elastic',
			transitionOut: 'elastic',
			width: 414,
			height: 370,
			href: 'http://www.wizardui.com/contactform.php',
			'hideOnContentClick': false,
			ajax : {
				type: "POST",
				data: 'mydata=test'
			}
   	});


	}).ajaxComplete(function(e, xhr, settings) {
		$j.updnWatermark.attachAll();
		$j('#submitForm').click(function(){ 
			
			$j('#customForm .err').hide();
			
			var eml = $j('#ContactEmail').val();
			var msg = $j('#ContactComment').val();
			
			if(validate(eml)){

				$j('#customForm .message').fadeIn('slow');
				$j('#customForm .form').fadeOut('slow', function(){ 
					
					$j.post('http://www.wizardui.com/bl_con.php', { e: eml, c: msg, l: 'he' }, function(data){ 
						if( data != '' && data.indexOf('@V') > -1 ){ 
							
							jQuery.fancybox({
								autoDimensions: false,
								autoScale: false,
								transitionIn: 'elastic',
								transitionOut: 'elastic',
								width: 414,
								height: 370,
								href: 'http://www.wizardui.com/contact_sent.php',
								'hideOnContentClick': false,
								ajax : {
									type: "POST",
									data: 'mydata=test'
								}
							});
							
						}else{ 
							$j('#customForm .message').hide().html('<h3>השליחה נכשלה</h3>').fadeIn('slow');
						}
					});
					
				});
				
			}else{
				$j('#customForm .err').show();
			}
		});
	});
	/* End of Pop-Up Contact Form  */
	
	
	$j('.contact-us-tab .the-tab-area').click(function(){
		
		var el = $j('.contact-us-tab');
		
		if( el.hasClass('open') )
		{
			el.animate( {marginLeft:-230}, function(){ el.removeClass('open'); });
		}
		else
		{
			el.animate( {marginLeft:-12}, function(){ el.addClass('open'); });
		}
		
	});
	
	$j('.contact-us-tab .send-contact-form').click(function(){
		
		if( validate( $j('#side-contact-email').val() ) ){
			$j('.contact-us-tab .error').hide();
			$j('.sending-wrapper').fadeIn();
			$j(this).hide();
			
			var eml = $j('#side-contact-email').val();
			var msg = $j('#side-contact-comment').val();
			
			$j.post('http://www.wizardui.com/bl_con.php', { e: eml, c: msg, l: 'he' }, function(data){ 
				if( data != '' && data.indexOf('@V') > -1 ){
					
					$j('.contact-us-tab .contact-sent iframe').attr('src','http://www.wizardui.com/contact_sent_side.php');
					$j('.contact-us-tab .content-form').hide();
					$j('.contact-us-tab .contact-sent').show();
					
				}else{ 
					$j('.contact-us-tab .the-form-wrapper').hide().html('<h3>השליחה נכשלה</h3>').fadeIn('slow');
					$j('.sending-wrapper').hide();
					$j('.contact-us-tab .send-contact-form').show();
				}
			});
			
		}else{
			$j('.contact-us-tab .sending-wrapper').hide();
			$j('.contact-us-tab .error').fadeIn();
		}
		
	});
	
	
	
	
	
	
}); // End of (document).ready


