// JavaScript Document
/*Document Ready*/
$(document).ready(function() {
	
	$(".menu a").hover(function(){DD="#dd"+$(this).attr("class").substr(2); if($(DD).children().length>0){$(DD).show(); $(DD).hover(function(){$(this).show();}, function(){$(this).hide();});}}, function(){$(DD).hide();});
	
});
/*END OF Document Ready*/
userImages=Array();
/*Easy Show/Hide Images*/
function chPics(blockId, imgsSrcs){
	if(!imgsSrcs){imgsSrcs=Array("/aqualung/img/img-h.jpg");}/*images urls*/
	if(!blockId){blockId="chPics";}/*ID of DOM obj, that includes Image*/
	chpicsDelay=5;/*seconds*/
	chpicsSpeed=3;/*show/hide speed (0-100)*/
/*!parametrs finished!*/
	total=imgsSrcs.length-1;
//	for(i=0; i<total; i++){document.createElement("img").src=imgsSrcs[i];}
	imgAct=0; preLoad=true;
	insto=document.getElementById(blockId).style;
	img=document.getElementById(blockId).getElementsByTagName("img")[0];
	chpicsLoop = setInterval(function(){
		imgAct++;
		if(imgAct==total){imgAct=0; preLoad=false;}
		if(preLoad){(new Image()).src=imgsSrcs[imgAct];}
		opc=1;
		dwn = setInterval(function(){
			insto.opacity=opc;
			insto.filter="alpha(opacity="+opc*100+")";/*for IE*/
			opc-=chpicsSpeed/100;
			if(opc<=0){
				img.src=imgsSrcs[imgAct];
				opc=0;
				up = setInterval(function(){
					insto.opacity=opc;
					insto.filter="alpha(opacity="+opc*100+")";/*for IE*/
					opc+=chpicsSpeed/100;
					if(opc>=1){clearInterval(up);}
				}, 10);
				clearInterval(dwn);
			}
		}, 10);
	}, chpicsDelay*1000);
}
/*END OF Easy Show/Hide Images*/
/*Shop cityes order and onselect*/
function sc_order(form_ID){
	sels=document.getElementById(form_ID).getElementsByTagName("select");
	for(i=0; i<sels.length; i++){
		opts=sels[i].getElementsByTagName("option");
		emptyOpt=sels[i].firstChild;
		for(j=0; j<opts.length; j++){
			if(opts[j].title=="Москва" || opts[j].title=="Московская область" || opts[j].title=="Санкт-Петербург"){
				dropper=opts[j];
				sels[i].removeChild(dropper);
				sels[i].insertBefore(dropper, emptyOpt);
			}
		}
	}
}

function submitSearch(obj){
	selects=obj.parentNode.getElementsByTagName("select");
	for(i=0; i<selects.length; i++){
		if(selects[i]!=obj){
			opts=selects[i].getElementsByTagName("option");
			for(j=0; j<opts.length; j++){
				if(opts[j].value==""){opts[j].selected=true;}else{opts[j].selected=false;}
			}
		}
	}
	obj.form.submit();
}
/*END OF Shop cityes order and onselect*/
function showSheme(obj){
	image=obj.parentNode.getElementsByTagName('img')[0].style;
	if(image.display=='none'){image.display='block';}else{image.display='none';}
}
function delimiter(actNum, claName){
	rnd=Math.random(); act=1;
	document.write("<span id='me_"+rnd+"'></span>");
	divs=document.getElementById("me_"+rnd).parentNode.getElementsByTagName("span");
	for(i=0; i<divs.length; i++){if(act==actNum){act=1; divs[i].className+=claName;}else{act++;}}
}
