/* this prevents dom flickering, needs to be outside of dom.ready event: */
document.documentElement.className += 'js_active';
/*end dom flickering =) */

jQuery.noConflict();

jQuery(document).ready(function(){

	// activates the lightbox page, if you are using a dark color scheme use another theme parameter
	my_lightbox("a[rel^='prettyPhoto'], a[rel^='lightbox']");
	
	
	k_form(); //controls the contact form
	k_menu(); // controls the dropdown menu
	k_form_footer(); //controls the contact form
	
	
});


jQuery(window).load(function(){
	var autorotate = jQuery("meta[name=autorotate]").attr('content');
	var autorotate_duration = jQuery("meta[name=autorotate_duration]").attr('content');
	
	/*image slider (alternate)*/
	var $slide_images = jQuery('#featured_image img');	
	if ($slide_images.length > 0 && autorotate != "2")
	{	
		if(autorotate_duration == '') autorotate_duration = 5;
	
		$slide_images.not('.current_img img').css({display:"none"});
		$slide_images.filter('.current_img img').css({visibility:"visible"});
		// set the automatic image rotation, number is time between transitions in miliseconds
		interval = setInterval(function() { k_fader("#featured_image img",'1'); }, (parseInt(autorotate_duration) * 1000)); 	
	}
});




function k_menu()
{
	jQuery("#nav a, .subnav a").removeAttr('title');
	jQuery(" #nav ul ").css({display: "none"}); // Opera Fix
	
	jQuery("#nav li").each(function()
	{	
		
		var $sublist = jQuery(this).find('ul:first');
		
		jQuery(this).hover(function()
		{	
			$sublist.stop().css({overflow:"hidden", height:"auto", display:"none"}).slideDown(400, function()
			{
				jQuery(this).css({overflow:"visible", height:"auto"});
			});	
		},
		function()
		{	
			$sublist.stop().slideUp(400, function()
			{	
				jQuery(this).css({overflow:"hidden", display:"none"});
			});
		});	
	});
}






function k_fader($items_to_fade, $next_or_prev)
{	
	var $items = jQuery($items_to_fade);
	var $currentitem = $items.filter(":visible");
	var $new_item;
	var $selector;
	
	$items.css('visibility','visible');
	
	if($items.length > 1)
	{
		for(i = 0; i < $items.length; i++)
		{
			if($items[i] == $currentitem[0])
			{	
				$selector = $next_or_prev >= 0 ? i != $items.length-1 ? i+1 : 0 : i == 0 ? $items.length-1 : i-1;
				
				$new_item = jQuery($items[$selector]);
				break;
			}
		}
		
		if( $new_item && $new_item.css("display") == "none" )
			{	
				$currentitem.css({zIndex:2});
				$new_item.css({zIndex:3}).fadeIn(1200, function()
				{
					$currentitem.css({display:"none"});
				});
				
			}
	}
}



function my_lightbox($elements)
{
jQuery('.gallery-item a').attr('rel','lightbox[grouped]');

jQuery($elements).prettyPhoto({
		"theme": 'light_square' /* light_rounded / dark_rounded / light_square / dark_square */																
	});

jQuery($elements).each(function()
{	
	var $image = jQuery(this).contents("img");
	$newclass = 'lightbox_video';
	
	if(jQuery(this).attr('href').match(/(jpg|gif|jpeg|png|tif)/)) $newclass = 'lightbox_image';
		
	if ($image.length > 0)
	{	
		if(jQuery.browser.msie &&  jQuery.browser.version < 7) jQuery(this).addClass('ie6_lightbox');
		
		var $bg = jQuery("<span class='"+$newclass+" ie6fix'></span>").appendTo(jQuery(this));
		
		jQuery(this).bind('mouseenter', function(){
			$height = $image.height();
			$width = $image.width();
			$pos =  $image.position();		
			$bg.css({height:$height, width:$width, top:$pos.top, left:$pos.left});
		});
	}
	
	
	
});	
	
jQuery($elements).contents("img").hover(function(){
		jQuery(this).stop().animate({opacity:0.5},400);
		},function(){
		jQuery(this).stop().animate({opacity:1},400);
		});


}


function k_form(){
	var my_error;
	var url = jQuery("meta[name=temp_url]").attr('content');
	jQuery(".ajax_form #send").bind("click", function(){
											 
	my_error = false;
	jQuery(".ajax_form #name, .ajax_form #message, .ajax_form #email ").each(function(i)
	{
				
				
				var value = jQuery(this).attr("value");
				var check_for = jQuery(this).attr("id");
				var surrounding_element = jQuery(this).parent();
				if(check_for == "email"){
					if(!value.match(/^\w[\w|\.|\-]+@\w[\w|\.|\-]+\.[a-zA-Z]{2,4}$/)){
						
						surrounding_element.attr("class","").addClass("error");
						
						my_error = true;
						}else{
						surrounding_element.attr("class","").addClass("valid");	
						}
					}
				
				if(check_for == "name" || check_for == "message"){
					if(value == ""){
						
						surrounding_element.attr("class","").addClass("error");
						
						my_error = true;
						}else{
						surrounding_element.attr("class","").addClass("valid");	
						}
					}
						   if(jQuery(".ajax_form #name, .ajax_form #message, .ajax_form #email").length  == i+1){
								if(my_error == false){
									jQuery(".ajax_form").slideUp(400);
									
									var $datastring = "ajax=true";
									jQuery(".ajax_form input, .ajax_form textarea, .ajax_form radio, .ajax_form select").each(function(i)
									{
										var $name = jQuery(this).attr('name');	
										var $value = encodeURIComponent(jQuery(this).attr('value'));
										$datastring = $datastring + "&" + $name + "=" + $value;
									});
																		
									
									jQuery(".ajax_form #send").fadeOut(100);	
									
									jQuery.ajax({
									   type: "POST",
									   url: url+"/send.php",
									   data: $datastring,
									   success: function(response){
									   jQuery(".ajax_form").before("<div class='ajaxresponse' style='display: none;'></div>");
									   jQuery(".ajaxresponse").html(response).slideDown(400); 
									   jQuery(".ajax_form #send").fadeIn(400);
									   jQuery(".ajax_form #name, .ajax_form #message, .ajax_form #email , .ajax_form #website").val("");
										   }
										});
									} 
							}
					});
			return false;
	});
}

function k_form_footer(){
	var my_error;
	var url = jQuery("meta[name=temp_url]").attr('content');
	jQuery(".ajax_form_footer #send").bind("click", function(){
											 
	my_error = false;
	jQuery(".ajax_form_footer #name, .ajax_form_footer #message, .ajax_form_footer #email ").each(function(i)
	{
				
				
				var value = jQuery(this).attr("value");
				var check_for = jQuery(this).attr("id");
				var surrounding_element = jQuery(this).parent();
				if(check_for == "email"){
					if(!value.match(/^\w[\w|\.|\-]+@\w[\w|\.|\-]+\.[a-zA-Z]{2,4}$/)){
						
						surrounding_element.attr("class","").addClass("error");
						
						my_error = true;
						}else{
						surrounding_element.attr("class","").addClass("valid");	
						}
					}
				
				if(check_for == "name" || check_for == "message"){
					if(value == ""){
						
						surrounding_element.attr("class","").addClass("error");
						
						my_error = true;
						}else{
						surrounding_element.attr("class","").addClass("valid");	
						}
					}
						   if(jQuery(".ajax_form_footer #name, .ajax_form_footer #message, .ajax_form_footer #email").length  == i+1){
								if(my_error == false){
									jQuery(".ajax_form_footer").slideUp(400);
									
									var $datastring = "ajax=true";
									jQuery(".ajax_form_footer input, .ajax_form_footer textarea, .ajax_form_footer radio, .ajax_form_footer select").each(function(i)
									{
										var $name = jQuery(this).attr('name');	
										var $value = encodeURIComponent(jQuery(this).attr('value'));
										$datastring = $datastring + "&" + $name + "=" + $value;
									});
																		
									
									jQuery(".ajax_form_footer #send").fadeOut(100);	
									
									jQuery.ajax({
									   type: "POST",
									   url: url+"/send.php",
									   data: $datastring,
									   success: function(response){
									   jQuery(".ajax_form_footer").before("<div class='ajaxresponse' style='display: none;'></div>");
									   jQuery(".ajaxresponse").html(response).slideDown(400); 
									   jQuery(".ajax_form_footer #send").fadeIn(400);
									   jQuery(".ajax_form_footer #name, .ajax_form_footer #message, .ajax_form_footer #email , .ajax_form_footer #website").val("");
										   }
										});
									} 
							}
					});
			return false;
	});
}

//START Team page 
jQuery(document).ready(function() {
	 // hides the slickbox as soon as the DOM is ready
	 // (a little sooner than page load)
	  jQuery("#slickbox1").hide();
	  jQuery("#slickbox2").hide();
	  jQuery("#slickbox3").hide();
	  jQuery("#slickbox4").hide();
	  jQuery("#slickbox5").hide();
	  jQuery("#slickbox6").hide();
	 // toggles the slickbox on clicking the noted link
	  jQuery("a#slick-toggle1").click(function() {
		jQuery("#slickbox1").toggle("slow");
		jQuery("a#slick-toggle1").text((jQuery("a#slick-toggle1").text() == 'Read more') ? 'Close' : 'Read more');
		return false;
	  });
	  jQuery("a#slick-toggle2").click(function() {
		jQuery("#slickbox2").toggle("slow");
		jQuery("a#slick-toggle2").text((jQuery("a#slick-toggle2").text() == 'Read more') ? 'Close' : 'Read more');
		return false;
	  });
	  jQuery("a#slick-toggle3").click(function() {
		jQuery("#slickbox3").toggle("slow");
		jQuery("a#slick-toggle3").text((jQuery("a#slick-toggle3").text() == 'Read more') ? 'Close' : 'Read more');
		return false;
	  });
	  jQuery("a#slick-toggle4").click(function() {
		jQuery("#slickbox4").toggle("slow");
		jQuery("a#slick-toggle4").text((jQuery("a#slick-toggle4").text() == 'Read more') ? 'Close' : 'Read more');
		return false;
	  });
	  jQuery("a#slick-toggle5").click(function() {
		jQuery("#slickbox5").toggle("slow");
		jQuery("a#slick-toggle5").text((jQuery("a#slick-toggle5").text() == 'Read more') ? 'Close' : 'Read more');
		return false;
	  });
	  jQuery("a#slick-toggle6").click(function() {
		jQuery("#slickbox6").toggle("slow");
		jQuery("a#slick-toggle6").text((jQuery("a#slick-toggle6").text() == 'Read more') ? 'Close' : 'Read more');
		return false;
	  });
	});
//END Team page 

//START open FAQs 
jQuery(document).ready(function() {
	 // hides the slickbox as soon as the DOM is ready
	 // (a little sooner than page load)
	  jQuery("#faqs").hide();
	 // toggles the slickbox on clicking the noted link
	  jQuery("a#btn_faqs").click(function() {
		jQuery("#faqs").toggle("slow");
		jQuery("a#btn_faqs").text((jQuery("a#btn_faqs").text() == 'View Frequently Asked Questions') ? 'Close Frequently Asked Questions' : 'View Frequently Asked Questions');
		return false;
	  });
	});
//END open FAQs 
//START open website packages 
jQuery(document).ready(function() {
	 // hides the slickbox as soon as the DOM is ready
	 // (a little sooner than page load)
	  jQuery("#basic").hide();
	  jQuery("#cms").hide();
	  jQuery("#cart").hide();
	 // toggles the slickbox on clicking the noted link
	  jQuery("a#btn_basic").click(function() {
		jQuery("#basic").toggle("slow");
		jQuery("a#btn_basic").text((jQuery("a#btn_basic").text() == 'View Basic Features') ? 'Close Basic Features' : 'View Basic Features');
		return false;
	  });
	  jQuery("a#btn_cms").click(function() {
		jQuery("#cms").toggle("slow");
		jQuery("a#btn_cms").text((jQuery("a#btn_cms").text() == 'View CMS/Blog Features') ? 'Close CMS/Blog Features' : 'View CMS/Blog Features');
		return false;
	  });
	  jQuery("a#btn_cart").click(function() {
		jQuery("#cart").toggle("slow");
		jQuery("a#btn_cart").text((jQuery("a#btn_cart").text() == 'View Cart Features') ? 'Close Cart Features' : 'View Cart Features');
		return false;
	  });
	});
//END open website packages 
//START open footer-contact 
jQuery(document).ready(function() {
	 // hides the slickbox as soon as the DOM is ready
	 // (a little sooner than page load)
	  jQuery("#footer-contact-form").hide();
	 // toggles the slickbox on clicking the noted link
	  jQuery("a#slick-toggle-footer-contact").click(function() {
		jQuery("#footer-contact-form").toggle("slow");
		return false;
	  });
	   jQuery("a#big-button").click(function() {
		jQuery("#footer-contact-form").toggle("slow");
		return false;
	  });
	});
//END open footer-contact  
 // CONTACT MAP - Elite Venture 


				  function  initialize() {
              
				 var  latlng = new google.maps.LatLng(42.6501247, -73.7523064);
                 var  settings = {
                     zoom: 16,
                     center: latlng,
                     mapTypeControl: true,
                     mapTypeControlOptions: {style:  google.maps.MapTypeControlStyle.DROPDOWN_MENU},
                     navigationControl: true,
                     navigationControlOptions: {style:  google.maps.NavigationControlStyle.DEFAULT},
                     mapTypeId: google.maps.MapTypeId.ROADMAP};
                 var  map = new google.maps.Map(document.getElementById("map_canvas"),  settings);
            
  
 // Company marker starts here - Elite Venture 
            
                 var  companyImage = new  google.maps.MarkerImage('http://www.eliteventuremedia.com/wp-content/uploads/2010/07/evm.png',
                     new google.maps.Size(28,28),
                     new google.maps.Point(0,0),
                     new google.maps.Point(28,28)
                 );
 
 
                 var  companyPos = new google.maps.LatLng(42.6501247, -73.7523064);
 
                 var  companyMarker = new google.maps.Marker({
                     position: companyPos,
                     map: map,
                     icon: companyImage,
                     title:"Elite Venture Media",
                     zIndex: 7});
             
               var infoWindow =  new google.maps.InfoWindow();
                var  company='<div>'+
                     '<p id="firstHeading"  class="firstHeading">Elite Venture Media</p>'+
                     '<div id="bodyContent1">'+
                     '<p><img src="http://www.eliteventuremedia.com/wp-content/uploads/2010/07/evm.png"  style="float:left;">11 N. Pearl Street, Suite 1106<BR>Albany, NY 12207<br>(518) 595-9393'+
                     '<br><a href="http://maps.google.com/maps?saddr=&daddr=11+N.+Pearl+Street,+Albany,+NY+12207" target=_blank >Get Directions</a></p>'+
                     '</div>'+
                     '</div>';
					google.maps.event.addListener(companyMarker,  'click',  function() {
					infoWindow.setContent(company);
                   
			
				   infoWindow.open(map,  companyMarker);
                   });
 


 //  Parking 1  marker starts here - Pepsi Arena Parking Garage 
                         
                var trainImage = new  google.maps.MarkerImage('http://www.eliteventuremedia.com/wp-content/uploads/2010/07/parking.png',
                     new google.maps.Size(28,28),
                     new google.maps.Point(0,0),
                     new google.maps.Point(28,28)
                 );
 
                 var  trainPos = new google.maps.LatLng(42.6492021, -73.7556219);
                 var  trainMarker = new google.maps.Marker({
                     position: trainPos,
                     map: map,
                     icon: trainImage,
                     title:"Pepsi Arena Parking Garage",
                     zIndex: 6});          
 
                 var  infoWindow = new google.maps.InfoWindow();
                 var   train='<div>'+
                     '<p id="firstHeading"  class="firstHeading">Pepsi Arena Parking Garage</p>'+
                     '<div id="bodyContent1">'+
                     '<p><img src="http://www.eliteventuremedia.com/wp-content/uploads/2010/07/parking.png"  style="float:left;">100 Beaver Street<BR>Albany, NY 12207<BR>(518) 427-5066'+
                     '<BR><a href="http://maps.google.com/maps?saddr=&daddr=Pepsi+Arena+Parking+Garage+100+Beaver+Street+Albany,+NY+12207-1536" target=_blank >Get Directions</a></p>'+
					 '</div>'+
                     '</div>';
                  google.maps.event.addListener(trainMarker,  'click', function() {
                  infoWindow.setContent(train);
                  infoWindow.open(map,  trainMarker);
                  });
                        
 // Parking 2 marker starts here - 80 State Street Parking Garage
                                         
                var  parkingImage = new  google.maps.MarkerImage('http://www.eliteventuremedia.com/wp-content/uploads/2010/07/parking.png',
                     new google.maps.Size(28,28),
                     new google.maps.Point(0,0),
                     new google.maps.Point(28,28)
                 );
 
 
                 var  parkingPos = new google.maps.LatLng(42.6493643, -73.7526798);
 
                 var  parkingMarker = new google.maps.Marker({
                     position: parkingPos,
                     map: map,
                     icon: parkingImage,
                      title:"80 State Street Parking Garage",
                     zIndex: 5
                 });
                 
                 var  infoWindow = new google.maps.InfoWindow();
                 var  parking='<div>'+
                      '<p id="firstHeading"  class="firstHeading">80 State Street Parking Garage</p>'+
                      '<div id="bodyContent1">'+
                      '<p><img src="http://www.eliteventuremedia.com/wp-content/uploads/2010/07/parking.png"  style="float:left;">80 State Street<BR>Albany, NY 12207<BR>(518) 462-5626'+
					  '<BR><a href="http://maps.google.com/maps?saddr=&daddr=80+State+Street+Parking+Garage+80+State+Street+Albany,+NY+12207-2543" target=_blank >Get Directions</a></p>'+
                      '</div>'+
                      '</div>';
                   google.maps.event.addListener(parkingMarker,  'click', function() {
                   infoWindow.setContent(parking);
                   infoWindow.open(map,  parkingMarker);
                   });

// Parking 3 marker starts here - Wellington Garage
                                         
                var  parkingImage1 = new  google.maps.MarkerImage('http://www.eliteventuremedia.com/wp-content/uploads/2010/07/parking.png',
                     new google.maps.Size(28,28),
                     new google.maps.Point(0,0),
                     new google.maps.Point(28,28)
                 );
 
 
                 var  parkingPos1 = new google.maps.LatLng(42.649726, -73.755641);
 
                 var  parkingMarker1 = new google.maps.Marker({
                     position: parkingPos1,
                     map: map,
                     icon: parkingImage1,
                      title:"Wellington Garage",
                     zIndex: 4
                 });
                 
                 var  infoWindow = new google.maps.InfoWindow();
                 var  parking1='<div>'+
                      '<p id="firstHeading"  class="firstHeading">Wellington Garage</p>'+
                      '<div id="bodyContent1">'+
                      '<p><img src="http://www.eliteventuremedia.com/wp-content/uploads/2010/07/parking.png"  style="float:left;">54 Howard Street<BR>Albany, NY 12207<BR>(518) 434-1660'+
					  '<BR><a href="http://maps.google.com/maps?saddr=&daddr=Wellington+Garage+54+Howard+Street+Albany,+NY+12207-1607" target=_blank >Get Directions</a></p>'+
                      '</div>'+
                      '</div>';
                   google.maps.event.addListener(parkingMarker1,  'click', function() {
                   infoWindow.setContent(parking1);
                   infoWindow.open(map,  parkingMarker1);
                   });


// Parking 4 marker starts here - Albany Parking Authority
                                         
                var  parkingImage2 = new  google.maps.MarkerImage('http://www.eliteventuremedia.com/wp-content/uploads/2010/07/parking.png',
                     new google.maps.Size(28,28),
                     new google.maps.Point(0,0),
                     new google.maps.Point(28,28)
                 );
 
 
                 var  parkingPos2 = new google.maps.LatLng(42.6513092, -73.7499308);
 
                 var  parkingMarker2 = new google.maps.Marker({
                     position: parkingPos2,
                     map: map,
                     icon: parkingImage2,
                      title:"Albany Parking Authority",
                     zIndex: 3
                 });
                 
                 var  infoWindow = new google.maps.InfoWindow();
                 var  parking2='<div>'+
                      '<p id="firstHeading"  class="firstHeading">Albany Parking Authority</p>'+
                      '<div id="bodyContent1">'+
                      '<p><img src="http://www.eliteventuremedia.com/wp-content/uploads/2010/07/parking.png"  style="float:left;">524 Broadway<BR>Albany, NY 12207<BR>(518) 434-8998'+
                      '<BR><a href="http://maps.google.com/maps?saddr=&daddr=Albany+Parking+Authority+524+Broadway+Albany,+NY+12207-2740" target=_blank >Get Directions</a></p>'+
					  '</div>'+
                      '</div>';
                   google.maps.event.addListener(parkingMarker2,  'click', function() {
                   infoWindow.setContent(parking2);
                   infoWindow.open(map,  parkingMarker2);
                   });

// Parking 5 marker starts here - Maiden Lane
                                         
                var  parkingImage3 = new  google.maps.MarkerImage('http://www.eliteventuremedia.com/wp-content/uploads/2010/07/parking.png',
                     new google.maps.Size(28,28),
                     new google.maps.Point(0,0),
                     new google.maps.Point(28,28)
                 );
 
 
                 var  parkingPos3 = new google.maps.LatLng(42.6483, -73.7506426);
 
                 var  parkingMarker3 = new google.maps.Marker({
                     position: parkingPos3,
                     map: map,
                     icon: parkingImage3,
                      title:"Maiden Lane",
                     zIndex: 2
                 });
                 
                 var  infoWindow = new google.maps.InfoWindow();
                 var  parking3='<div>'+
                      '<p id="firstHeading"  class="firstHeading">Maiden Lane</p>'+
                      '<div id="bodyContent1">'+
                      '<p><img src="http://www.eliteventuremedia.com/wp-content/uploads/2010/07/parking.png"  style="float:left;">410 Broadway<Br>Albany, NY 12207<BR>(518) 465-8108'+
                      '<BR><a href="http://maps.google.com/maps?saddr=&daddr=Maiden+Lane,+410+Broadway+Albany,+NY+12207" target=_blank >Get Directions</a></p>'+
					  '</div>'+
                      '</div>';
                   google.maps.event.addListener(parkingMarker3,  'click', function() {
                   infoWindow.setContent(parking3);
                   infoWindow.open(map,  parkingMarker3);
                   });

// Parking 6 marker starts here - Crown Plaza Hotel Parking Operations
                                         
                var  parkingImage4 = new  google.maps.MarkerImage('http://www.eliteventuremedia.com/wp-content/uploads/2010/07/parking.png',
                     new google.maps.Size(28,28),
                     new google.maps.Point(0,0),
                     new google.maps.Point(28,28)
                 );
 
 
                 var  parkingPos4 = new google.maps.LatLng(42.6512839,-73.753034);
 
                 var  parkingMarker4 = new google.maps.Marker({
                     position: parkingPos4,
                     map: map,
                     icon: parkingImage4,
                      title:"Crown Plaza Hotel Parking Operations",
                     zIndex: 1
                 });
                 
                 var  infoWindow = new google.maps.InfoWindow();
                 var  parking4='<div>'+
                      '<p id="firstHeading"  class="firstHeading">Crown Plaza Hotel Parking Operations</p>'+
                      '<div id="bodyContent1">'+
                      '<p><img src="http://www.eliteventuremedia.com/wp-content/uploads/2010/07/parking.png"  style="float:left;">16 Lodge Street<BR>Albany, NY 12207<BR>(518) 915-1616'+
					  '<BR><a href="http://maps.google.com/maps?saddr=&daddr=Crown+Plaza+Hotel+Parking+Operations+16+Lodge+Street+Albany,+NY+12207" target=_blank >Get Directions</a></p>'+
                      '</div>'+
                      '</div>';
                   google.maps.event.addListener(parkingMarker4,  'click', function() {
                   infoWindow.setContent(parking4);
                   infoWindow.open(map,  parkingMarker4);
                   });

         }
       
	   
//cufon fonts
Cufon.replace('h2');
Cufon.replace('h3');
Cufon.replace('h4');
