// JavaScript Document
function changePhoto(str, alt, id, count) {
	// change all to gray
	for($i=1; $i<=count*3; $i++) {
		if(document.getElementById('squarePhoto'+$i)) {
			document.getElementById('squarePhoto'+$i).src = 'images/portfolio/gray14x14.gif';
		}		
	}	
	// set current is blue
	document.getElementById(id).src = 'images/portfolio/blue14x14.gif';
	document.getElementById('photo').src = 'images/web/enlarged/'+str;	
	document.getElementById('photo').alt = alt;	
	document.getElementById('photo').title = alt;	
}

function isValidEmail(emailAddress) {
	var pattern = 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 pattern.test(emailAddress);
  
}


$(document).ready(function(){
	$("#ourPROMISE").click(function() {   
		$("#containerOURpromise").slideToggle("slow");  
    });	
	
	$("#btnCLOSEourPROMISE").click(function() {    		
		$("#containerOURpromise").slideToggle("slow");  
    });
	
	$("#ourPROVEN").click(function() {   
		$("#containerOURproven").slideToggle("slow");  
    });
		
	$("#btnCLOSEourPROVEN").click(function() {    		
		$("#containerOURproven").slideToggle("slow");  
    });
	
	
	$("#ourUNIQUE").click(function() {   
		$("#containerOURunique").slideToggle("slow");  
    });
		
	$("#btnCLOSEourUNIQUE").click(function() {    		
		$("#containerOURunique").slideToggle("slow");  
    });
	
	
	$("#ourEXCLUSIVE").click(function() {   
		$("#containerOURexclusive").slideToggle("slow");  
    });
		
	$("#btnCLOSEourEXCLUSIVE").click(function() {    		
		$("#containerOURexclusive").slideToggle("slow");  
    });
	
	$("#ourSTERLING").click(function() {   
		$("#containerOURsterling").slideToggle("slow");  
    });
		
	$("#btnCLOSEourSTERLING").click(function() {    		
		$("#containerOURsterling").slideToggle("slow");  
    });
	
	
	//validate conversation.php	
	$("#btnSendConversation").click(function() {
		
		var txt = '';							
			if($('#name').val() == ''){
                txt += 'Please input Your Name. \n';
            } 
			
			if($('#phone').val() == ''){
                txt += 'Please input Phone Number. \n';
            } 
			
			
			if($('#email').val() == '' || !isValidEmail($('#email').val())){
                txt += 'Please input Email Address. \n';
            }
			
			if($('#confirmEmail').val() == '' || ($('#email').val() != $('#confirmEmail').val()) || !isValidEmail($('#confirmEmail').val())){
                txt += 'Please input Confirm Email Address. \n';
            }
			
			
			if($('#city').val() == ''){
                txt += 'Please input Your City. \n';
            }			
			
			if(!$('input[type="checkbox"]').is(':checked')){
				txt += 'Please check at least one \"Type of Project \". \n';			 	
			}
			
			if($('#hearAboutUs').val() == 'None selected'){
                txt += 'Please select \"How did you hear about us?\". \n';
            }			
			if($('#recaptcha_response_field').val() == ''){
                txt += 'Please input Captcha. \n';
            } 
			
			if(txt != '') {
                alert(txt);
                return false;
            }
            
            return true;				
    });	// end validate
	
	//validate email subscribe	
	$("#btnEmailSubscribe").click(function() {
		
		var txt = '';							
			
			if($('#emailSubscribe').val() == '' || !isValidEmail($('#emailSubscribe').val())){
                txt += 'Please input Email Address. \n';
            }			
			
			if(txt != '') {
                alert(txt);
                return false;
            }
            
            return true;				
    });	// end validate
	
	
	
});
