/////////////////load jquery///////////////////
jQuery(document).ready(function(){

	jQuery(".sendmesage form").submit(function(){
		prov=1;								  
		var elements=jQuery(this).find("input, select, textarea");
		tempprov=0;
		tempgr=0;
		for(var i=0;i<elements.length-1;i++){
			thisclass=elements.eq(i).attr("class");
			thisvalue=elements.eq(i).attr("tempvalue");
			thistype=elements.eq(i).attr("type");
			elements.eq(i).removeClass("error");
			groups=elements.eq(i).attr("groupa");
			if((thisclass.indexOf("important")>-1)&&(thistype!="submit")){
				if((elements.eq(i).val()=="")||(elements.eq(i).val()==thisvalue)){
					if(groups!="group"){
						prov=0;
						elements.eq(i).addClass("error");
					}	
				}
				if((groups=="group")&&(elements.eq(i).val()!="")&&(elements.eq(i).val()!=thisvalue)){
						tempprov=1;
				}
			}
		}
		if(tempprov==0){
			for(var i=0;i<elements.length-1;i++){
				groups=elements.eq(i).attr("groupa");
				if((groups=="group")&&((elements.eq(i).val()=="")||(elements.eq(i).val()==thisvalue))){
						elements.eq(i).addClass("error");
				}
			}
			prov=0;
		}
		spamproverka=jQuery(this).find(".spamproverka").val();
		spam=jQuery(this).find(".spam").val();
		jQuery(this).find(".spam").removeClass("error");
		if(spam!=spamproverka){
			jQuery(this).find(".spam").addClass("error");
			prov=0;
		}
		if(prov==0){
			alert("Проверьте все поля");
			return false;
		}
		
	});

	
	elements=jQuery(".sendmesage input, .sendmesage textarea");
	for(var i=0;i<elements.length;i++){
		thistempvalue=elements.eq(i).attr("tempvalue");
		if(thistempvalue!=""){
			elements.eq(i).click(function(){
				thistempvalue=jQuery(this).attr("tempvalue");
				thisvalue=jQuery(this).val();
				if(thisvalue==thistempvalue){
					jQuery(this).val("");
				}
			});
			elements.eq(i).blur(function(){
				thistempvalue=jQuery(this).attr("tempvalue");
				thisvalue=jQuery(this).val();
				if(thisvalue==""){
					jQuery(this).val(thistempvalue);
				}
			});
		}
	}
	
	
	jQuery("#topmenu li").click(function(){
		jQuery("#topmenu li").removeClass("current");
		jQuery(this).addClass("current");
		jQuery("#conteiner .blocks").slideUp(150);
		index=jQuery("#topmenu li").index(this);
		jQuery("#conteiner .blocks").eq(index).slideDown(300);
		if(index==1){
		setTimeout("loadmap()",300);
		}
		return false;
	});
	
	
	


});


function loadmap(){
		document.getElementById("YMapsID").innerHTML="";
        var map = new YMaps.Map(document.getElementById("YMapsID"));   
        map.setCenter(new YMaps.GeoPoint(47.479819,56.099564), 11, YMaps.MapType.MAP);
        map.addControl(new YMaps.Zoom());
        map.addControl(new YMaps.ToolBar());
        map.addControl(new YMaps.TypeControl());        
        var s = new YMaps.Style();
        s.iconStyle = new YMaps.IconStyle();
        s.iconStyle.offset = new YMaps.Point(-8,-27);
        s.iconStyle.href = "http://api-maps.yandex.ru/i/0.3/placemarks/pmywm.png";
        s.iconStyle.size = new YMaps.Point(28,29);
        YMaps.Styles.add("wizard#lbmPoint", s);
			
	var placemark1 = new YMaps.Placemark(new YMaps.GeoPoint(47.50986,56.095822), {style: "wizard#lbmPoint", balloonOptions: {maxWidth: 500}});
     	map.addOverlay(placemark1);
	placemark1.setBalloonContent("ЗАО НПП 'Спектр'<br>429950, Россия, г. Новочебоксарск,<br>ул. Промышленная, 75 М.");
	placemark1.openBalloon();				
 				
}



