var myWidth;
var myHeight;

function fiximg(){
	
	myWidth=$(window).width();
    myHeight=$(window).height();

    ele = document.getElementById('head_bg');
    ele.width = myWidth;
    ele.height = myHeight / 4.347;
    
    elebg = document.getElementById('bigbg');
    elebg.width = myWidth;
    elebg.height = myHeight;
    
    elef = document.getElementById('footer_logo');
    elef.width = myWidth;
    elef.height = myHeight / 7.14;

    elec = document.getElementById('footer_curve');
    elec.height = myHeight / 7.14;
    elec.width = myHeight * 0.06;
    elec.style.left = (myWidth-elec.width)/2+'px';
    
    logo = document.getElementById('logo');
    logo.height = myHeight / 4.347;
    logo.width = myHeight * 0.4828;
    logo.style.left = (myWidth-logo.width)/2+'px';
    
    $('.shadowimg').width($('#contact').width());
    //shad.height = myHeight / 12.5;  
     $('.viewport').height((parseInt($('.box').height())-14)+'px');
     		if($(window).width()>1366){
			$('.viewport').css('font-size', '16px'); 
			$('#footer_text').css('font-size', '16px');
			$('#msg').attr('cols','51');
		}
		else if($(window).width()>1024){
			if($(window).width()>1280){
				$('#msg').attr('cols','50');
				}
				else if($(window).width()>1152){
				$('#msg').attr('cols','46');
				}
				else if($(window).width()>1100){
				$('#msg').attr('cols','40');
				}
				else{
					$('#msg').attr('cols','39');
					}
			$('.viewport').css('font-size', '12px'); 
			$('#footer_text').css('font-size', '14px');
			
		}
		else if($(window).width()>800){
			$('.viewport').css('font-size', '10px'); 
			$('#footer_text').css('font-size', '11px');
			$('#msg').attr('cols','27');
			if($(window).width()>920){
			$('#msg').attr('cols','29');
			}
		}
		else{
			$('.viewport').css('font-size', '9px'); 
			$('#footer_text').css('font-size', '10px');
			$('#msg').attr('cols','25'); 
			$('#name').attr('size','20');
			$('#email').attr('size','20'); 
		}
    
	}
function doinitanim(){
$('#about').animate({
    left: '37%'
}, 'fast');
$('#contact').animate({
    left: '3%'
}, 'fast');
$('#why').animate({
    left: '59%'
}, 'fast', function() {
    $('#contact').css({
        'z-index': '49'
    });
});

$('#about').animate({
    left: '31%'
});
$('#contact').animate({
    left: '7%'
});
$('#why').animate({
    left: '55%'
});
$('#about').animate({
    left: '25%'
}, 'fast');
$('#contact').animate({
    left: '3%'
}, 'fast');
$('#why').animate({
    left: '59%'
}, 'fast', function() {
    $('#why').css({
        'z-index': '50'
    });
});

$('#about').animate({
    left: '31%'
});
$('#contact').animate({
    left: '7%'
});
$('#why').animate({
    left: '55%'
});	
$('#contact').animate({
    left: '1%'
}, 'fast');
$('#why').animate({
    left: '61%'
}, 'fast', function() {
    $('#about' ).css({
        'z-index': '51'
    });
});

$('#contact').animate({
    left: '7%'
});
$('#why').animate({
    left: '55%'
});

	
	}
	
	
$(document).ready(function() {

	fiximg();
	

	$(window).resize(function(){

		fiximg();
	});

    $('.box').mouseover(function() {
		if (!$(this).is(":animated")) {
        var clickedid = $(this).attr('id');
        var topz = $(this).css('z-index');
        var count = 0;
        $('#container > div').each(function() {
            if ($(this).attr('id') != clickedid && $(this).css('z-index') > topz) {
                topz = $(this).css('z-index');
                count++;
            }
        });
        topz = parseInt(topz) + 1;
        if (count > 0) {
            switch (clickedid) {
            case "contact":
                if ($(this).css('z-index') < $('#about').css('z-index')) {
                    $('#about').animate({
                        left: '37%'
                    }, 'fast');
                    $('#contact').animate({
                        left: '3%'
                    }, 'fast');
                    $('#why').animate({
                        left: '59%'
                    }, 'fast', function() {
                        $('#' + clickedid).css({
                            'z-index': topz
                        });
                    });

                    $('#about').animate({
                        left: '31%'
                    });
                    $('#contact').animate({
                        left: '7%'
                    });
                    $('#why').animate({
                        left: '55%'
                    });
                }
                break;

            case "about":
                $('#contact').animate({
                    left: '1%'
                }, 'fast');
                $('#why').animate({
                    left: '61%'
                }, 'fast', function() {
                    $('#' + clickedid).css({
                        'z-index': topz
                    });
                });

                $('#contact').animate({
                    left: '7%'
                });
                $('#why').animate({
                    left: '55%'
                });
                break;

            case "why":
                if ($(this).css('z-index') < $('#about').css('z-index')) {
                    $('#about').animate({
                        left: '25%'
                    }, 'fast');
                    $('#contact').animate({
                        left: '3%'
                    }, 'fast');
                    $('#why').animate({
                        left: '59%'
                    }, 'fast', function() {
                        $('#' + clickedid).css({
                            'z-index': topz
                        });
                    });

                    $('#about').animate({
                        left: '31%'
                    });
                    $('#contact').animate({
                        left: '7%'
                    });
                    $('#why').animate({
                        left: '55%'
                    });
                }
                break;
            }

        } 
	}
    });
    $(".submit").click(function() {
        $('.error').hide();
        var name = $("#name").val();
        if (name == "") {
            alert('Enter your name');
            $("input#name").focus();
            return false;
        }
        var msg = $("#msg").val();
        if (msg == "") {
            alert('Enter something to send');
            $("input#msg").focus();
            return false;
        }
        var email = $("#email").val();
        if (email == "") {
            alert('Please provide your email ID');
            $("#email").focus();
            return false;
        }
        var cap = $("input#txtCaptcha").val();
        if (cap == "") {
            alert('Enter the letter shown in the figure');
            $("input#txtCaptcha").focus();
            return false;
        }
        var dataString = 'msg=' + msg + '&email=' + email + '&capt=' + cap+'&name='+name;
        $.ajax({
            type: "GET",
            url: "contact.php",
            data: dataString,
            cache: false,
            success: function(r) {
                if (r == '1') {
					alert("Thank you. Your message has been sent and an Aslan Corporation representative will contact you soon.");
                    window.location = "index.php";
                }
                else {
                    alert(r);
                }
            }
        });
        return false;
    });
    setInterval(fiximg,1000);
});



