/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
function display()
            {
                $('.light11').delay(0).animate({
                    opacity: 0
                  }, 1000, function() {
                        $('.light11').animate({
                            opacity: .5
                          }, 100, function() {
                              $('.light11').delay(0).animate({
                                    opacity: 0
                                  }, 80, function() {
                                      $('.light11').delay(0).animate({
                                            opacity: .5
                                          }, 60, function() {
                                              $('.light11').animate({
                                                opacity: 0
                                              }, 200, function() {

                                            }).delay(3000);
                                        });
                                });
                        });
                  });

                  $('.light44').delay(0).animate({
                    opacity: 0
                  }, 1000, function() {
                        $('.light44').animate({
                            opacity: .5
                          }, 100, function() {
                              $('.light44').delay(0).animate({
                                    opacity: 0
                                  }, 50, function() {
                                      $('.light44').delay(0).animate({
                                            opacity: .5
                                          }, 60, function() {
                                              $('.light44').animate({
                                                opacity: 0
                                              }, 1200, function() {

                                            }).delay(3000);
                                        });
                                });
                        });
                  });
                  $('.light33').animate({
                    opacity: 0
                  }, 1000, function() {
                        $('.light33').animate({
                            opacity: .5
                          }, 50, function() {
                              $('.light33').delay(0).animate({
                                    opacity: 0
                                  }, 100, function() {
                                      $('.light33').delay(0).animate({
                                            opacity: .5
                                          }, 50, function() {
                                              $('.light33').animate({
                                                opacity: 0
                                              }, 1000, function() {

                                            }).delay(2000);
                                        });
                                });
                        });
                  });
                   $('.light22').delay(0).animate({
                    opacity: 0
                  }, 1000, function() {
                        $('.light22').animate({
                            opacity: .6
                          }, 50, function() {
                              $('.light22').delay(0).animate({
                                    opacity: 0
                                  }, 100, function() {
                                      $('.light22').delay(0).animate({
                                            opacity: .5
                                          }, 50, function() {
                                              $('.light22').animate({
                                                opacity: 0
                                              }, 1000, function() {

                                            }).delay(2500);
                                        });
                                });
                        });
                  });
                setTimeout("display()",2000);
            }

            function startLight()
            {
                $('.light11').show().animate({
                    opacity: .7
                  }, 1200, function() {
                        $('.light1').show().animate({
                        opacity: .7
                        }, 100, function() {});
                        $('.light22').show().animate({
                        opacity: .7
                        }, 1200, function() {
                            $('.light2').show().animate({
                                opacity: .7
                            }, 300, function() {

                            });
                        });
                        $('.light33').delay(200).show().animate({
                                   opacity: .7
                              }, 500, function() {
                              $('.light3').show().animate({
                                   opacity: .7
                              }, 1000, function() {
                              });
                        });
                       $('.light44').show().animate({
                                    opacity: .7
                                }, 500, function() {
                                    $('.light4').show().animate({
                                        opacity: .7
                                    }, 1000, function() {
                                    });
                                });
                    });
            }
            function preloadImages(id)
            {
		var c = new Array();
		$(id+' img').each( function(j) {
		c[j] = new Image();
		c[j].src = this.src;
		if ( $.browser.msie )
                {
                    this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true',sizingMethod='image',src='"+ this.src +"')";
		}
		});

            }
            $(function () {
                //alert('ok');
                preloadImages('.light1');preloadImages('.light11');preloadImages('.light2');preloadImages('.light22');preloadImages('.light3');preloadImages('.light33');preloadImages('.light4');preloadImages('.light44');preloadImages('.facebook');preloadImages('.twitter');
                preloadImages('#company-logo');
                //var img_class = new Array('.light1','.light11','.light2','.light22','.light3','.light33','.light4','.light44','.mc-image','#company-logo');
		/*for(images in img_class)
		{
                 //   preloadImages(img_class[images]);
		}*/
               $('#about-us').show().animate({
                opacity: 1,
                bottom: '+=30'
                }, 10, function(){
                    $('#about-us').css('z-index','1');
                });

               $('#contact-us').show().animate({
                opacity: 1,
                bottom: '+=30'
                }, 10, function(){
                   // startLight();

                });

                startLight();
                $('#about-us p').click(function() {
                    $('.vabout').val('1');
                    var display_contactus = $('.vcontact').val();
                    if(display_contactus == 1)
                    {
                          $('.vcontact').val('0');
                          $('.contact-us-content').animate({
                               opacity: 0.0,
                               right: '-=1620'
                            }, 200, function() {
                                $('#email-message')[0].reset();
                                $('label.error').remove();
                                $('#contact-us').show().animate({
                                     opacity: 1,
                                     right: '+=1400'
                                }, 100, function() {
                                        show_about_us_window();
                                    });
                          });
                    }
                    else
                    {
                        show_about_us_window();
                    }
            });
            function show_about_us_window()
            {
                $('#about-us').animate({
                    opacity: 0,
                    left: '-=1400'

                  }, {
                      duration: 80,
                        specialEasing: {
                        width: 'easeOutElastic',
                        height: 'easeInQuint'
                    },
                    complete: function() {

                        $('.about-us-content').show().animate({
                            opacity: 1,
                            left: '+=1570'

                            }, 100, function() {

                        });
                    }
                  });
            }
            $('.close-about-us').click(function() {
                close_about_us_window();
            });
            function close_about_us_window()
            {
                  $('.vabout').val('0');
                  $('.about-us-content').animate({
                    opacity: 0,
                    left: '-=1570'

                  }, 100, function() {

                        $('#about-us').animate({
                            opacity: 1,
                            left: '+=1400'

                            }, 80, function() {

                        });
                  });
            }
            $('#contact-us').click(function() {
                $('.vcontact').val('1');
                var about_display = $('.vabout').val();
                if(about_display == 1)
                {
                     $('.vabout').val('0');
                      $('.about-us-content').animate({
                        opacity: 0,
                        left: '-=1570'

                      }, 100, function() {

                            $('#about-us').animate({
                                opacity: 1,
                                left: '+=1400'

                                }, 80, function() {
                                    show_contact_us_window();
                            });
                      });
                }
                else
                {
                    show_contact_us_window();
                }
            });
            function show_contact_us_window()
            {
                $('#contact-us').animate({
                        opacity: 0,
                        right: '-=1400'

                      }, 100, function() {

                        $('.contact-us-content').show().animate({
                                opacity: 1,
                                right: '+=1620'
                                }, 80, function() {
                        });
               });
            }
            $('.close-contact-us').click(function() {
                  $('.vcontact').val('0');
                    $('.contact-us-content').animate({
                            opacity: 0.0,
                            right: '-=1620'
                       }, 200, function() {
                            $('#email-message')[0].reset();
                            $('label.error').remove();
                            $('#contact-us').show().animate({
                                opacity: 1,
                                right: '+=1400'
                                }, 100, function() {
                                });
                           });
            });

                /**** Form Validation ****/
                var loader = jQuery('<div id="loader"><img src="<?php echo base_url();?>images/loading.gif" alt="loading..." /></div>')
			.css({position: "relative", top: "1em", left: "25em"})
			.appendTo("body")
			.hide();
		jQuery().ajaxStart(function() {
			loader.show();
		}).ajaxStop(function() {
			loader.hide();
		}).ajaxError(function(a, b, e) {
			throw e;
		});

                 var v = jQuery("#email-message").validate({
                    submitHandler: function(form) {
                                    jQuery(form).ajaxSubmit({
                                            target: "#result",
                                            success: function(data) {
                                                $(':input','#email-message')
                                                .not(':button, :submit, :reset, :hidden')
                                                .val('');

                                            }
                                    });
                            },
                    rules: {

                            name: {
                                    required: true,
                                    minlength: 5
                            },
                            email: {
                                    required: true,
                                    email: true
                            },
                            subject: {
                                    required: true
                            },
                            message: {
                                    required: true,
                                    minlength: 3
                            }

                    },
                    messages: {

                            name: {
                                required: "Please enter your name.",
                                minlength: "Your username must consist of at least 4 characters."
                            },
                            email: {
                                required: "Please enter a mail address."
                            },
                            subject: {
                                required: "Please enter the subject of mail."
                            },
                            message: {
                                required: "Please enter some text in the messege box."
                            }

                    }
                });
                $('#company-logo').delay(1200).show().animate({
                            opacity:1,
                            bottom: 100
                        }, 800, function(){
                           display();
                        }
                );
                $('#testimonial').animate({
                    left: '+=2000',
                    opacity:1
                    },{
                        duration: 3000,
                        easing: 'easeOutBounce',
                        complete: function() {
                            //$('#contact-us').css('z-index','2');
                            $('#lofslidecontent45').lofJSidernews({
                                interval:5000,
                                easing:'easeOutBounce',
                                duration:1500,
                                auto:true
                            });
                        }
                });
                $('#works').animate({
                    right: '+=2000',
                    opacity:1
                    },{
                        duration: 3000,
                        easing: 'easeOutBounce',
                        complete: function() {
                            //$('#contact-us').css('z-index','2');
                        }
                });
                $('#images').css('color','red');
                $('#videos').click(function(){
                   $('.img_vid_opt').val('2');
                   $(this).css('color','red');
                   $('#images').css('color','#FFFFFF');
                   $('#msg_slideshow').remove();
                   $('#right-content').text('Loading ........');
                   $('#right-content').load('loadVideos');

                });
                $('#images').click(function(){
                   $('.img_vid_opt').val('1');
                   $(this).css('color','red');
                   $('#videos').css('color','#FFFFFF');
                   $('.vzaar_media_player').remove();

                  $('#right-content').load('loadImages');
                });
                $('#right-content').load('loadImages');
            });


