var conciseCms={};
$(document).ready(function(){
	$('.leftMenu').mouseover(function(){var elId=$(this).attr('id').substring(4);$('#leftPic'+elId).css('display','block');});
	$('.leftMenu').mouseout(function(){var elId=$(this).attr('id').substring(4);$('#leftPic'+elId).css('display','none');});
	conciseCms=function(){
		var ajaxReq;
		var timeout=5000;
//***
		function tsekFilter(id,page,urlpart){
			if($('#tsek'+id).attr('disabled')!=true){//kui pole disabletud
				if($('#tsek'+id).attr('checked')==true){
					$('#tsek'+id).attr('checked', false);
				}else{
					$('#tsek'+id).attr('checked', true);
				}
				var mpath=document.location.pathname;
				mpath=mpath.split('/');
				mpath=mpath[1];
				var url=document.location.protocol+'//'+document.location.hostname+'/'+mpath+'/';
				url=urlpart+'/submit_sub/';
				$('#alert').css('display','block');
				$('html').css('opacity','.1');
				var arr=new Array();
				var i=0;
				$('.filter').each(function(){
					if(this.checked==true){
						arr[i]=this.value;
						i++;
					}
				});
				url=url+arr.join('|')+'/';
				if(ajaxReq){ajaxReq.abort();}
				ajaxReq=$.ajax({
					url:url,beforeSend:function(x){if(x && x.overrideMimeType) {x.overrideMimeType("application/j-son;charset=UTF-8");}},type: 'GET',cache:false,data:"{}",dataType:"json",timeout:timeout,
					error:function(r){alert('Proovi uuesti');$('#alert').css('display','none');$('html').css('opacity','1');},
  	  		success:function(res){
  	  			var r=eval(res);
	    			if(r){
  	  				for( var i in r){
	    					$("#frame"+i).attr('src','http://shop.kl24.ee/images/web/yarn/frame'+r[i].i+'.png');
  	  					$("#tsek"+i).attr('disabled',((r[i].d==1)?'disabled':''));
    						$("#tsek"+i).attr('checked',((r[i].c==1)?'checked':''));
    					}
    				}else{
	    				alert('Proovi uuesti!');
  	  			}
	  	  		$('#alert').css('display','none');$('html').css('opacity','1');
	  	  	}
				});
			}
		}
		function submitForm(id){$('#'+id).submit();};
		function fancy(){$("a[rel=fancyImg]").fancybox({'transitionIn':'none','transitionOut':'none','titlePosition':'over','titleFormat':function(title, currentArray, currentIndex, currentOpts) {return '<span id="fancybox-title-over"><span class="left">' + (title.length ? '' + title : '') + '</span><span class="right">' + (currentIndex + 1) + ' / ' + currentArray.length + '</span></span>';}});};
		function fancyIframe(p,x,y,t){
			$.fancybox({
				'width':parseInt(x),
			'height':parseInt(y),
			'margin':0,
			'padding':0,
			'title':t,
				'scrolling':'no',
				'autoScale':false,
			'autoDimensions':false,
			'type':'iframe',
			
			'href':'http://shop.kl24.ee/pic.php?p='+p+'&x='+x+'&y='+y,
			'hideOnContentClick': false ,
			'onClosed': function(){
			}
		});
		};
//***
		function tryBlur(v,i){
			if($("#"+i).val()==''){
				$("#"+i).val(v);
			}
		}
//***
		function tryClick(v,i){
			if($("#"+i).val()==v){
				$("#"+i).val('');
			}
		}
//***
		return {
			tryBlur:function(v,i){tryBlur(v,i);},
			tryClick:function(v,i){tryClick(v,i);},
			submitForm:function(id){submitForm(id);},
			fancy:function(){fancy();},
			fancyIframe:function(p,x,y,t){fancyIframe(p,x,y,t);},
			tsekFilter:function(id,page,u){tsekFilter(id,page,u);}
		}
	}();
	
	$(".sitemap").fancybox({'width':'70%','height':'70%','autoScale':false,'transitionIn':'none','transitionOut':'none','type':'iframe'});
	$(".email").fancybox({'width':'70%','height':'70%','autoScale':false,'transitionIn':'none','transitionOut':'none','type':'iframe'});
	
});
/*
var o=document.getElementsByTagName("object");
for(var i=0;i<o.length;i++){
	o[i].outerHTML=o[i].outerHTML;
}
*/


function printPage(){
	if (window.print)
  	window.print()
  else
		alert("Your browser probably does't support Javascript");
}
var windowNote;
function showPic(title, pic, colorBack, wid, hei, idee)
{
	var idee = idee|| "default";
	windowNote = window.open('','Note'+ idee,'top=5, left=5, toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,copyhistory=no,width=' + wid + ',height='+ hei);
	image = '<a href="javascript:window.close()"><img src="'+ pic +'" width="'+ wid +'" height="'+ hei +'" border="0" alt="X"></a>';
	text = "<html><head><META HTTP-EQUIV=\"imagetoolbar\" CONTENT=\"no\"><title>"+ title + "</title></head><body bgcolor=\"#" + colorBack +"\" leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\">" + image + "</body></html>";
	windowNote.document.write(text);
	windowNote.focus();
	windowNote.document.close();
	return false;
}
var type = "IE";
BrowserSniffer();
function BrowserSniffer()
{
	if (navigator.userAgent.indexOf("Opera")!=-1 && document.getElementById) type="OP";	//Opera
	else if (document.all) type="IE";							//Internet Explorer e.g. IE4 upwards
	else if (document.layers) type="NN";							//Netscape Communicator 4
	else if (!document.all && document.getElementById) type="MO";				//Mozila e.g. Netscape 6 upwards
	else type = "IE";									//I assume it will not get here
}
function hide_div(div_name)
{
	if (type=="IE") eval("document.all."+div_name+".style.display='none'");
	if (type=="NN") eval("document."+div_name+".display='none'");
	if (type=="MO" || type=="OP") eval("document.getElementById(div_name).style.display='none'");
}
function showhide_div(div_name)
{
	if (type=="IE")
	{
		if(eval("document.all."+div_name+".style.display")!='none')
		{
			eval("document.all."+div_name+".style.display='none'");
		}
		else
		{
			eval("document.all."+div_name+".style.display='block'");
		}
	}
	if (type=="NN")
	{
		if(eval("document."+div_name+".display")!='none')
		{
			eval("document."+div_name+".display='none'");
		}
		else
		{
			eval("document."+div_name+".display='block'");
		}
	}
	if (type=="MO" || type=="OP")
	{
		if(eval("document.getElementById(div_name).style.display")!='none')
		{
			eval("document.getElementById(div_name).style.display='none'");
		}
		else
		{
			eval("document.getElementById(div_name).style.display='block'");
		}
	}
}
function submit_form()
{
	document.getElementById('vorm').submit();
}
function reset_form()
{
	document.getElementById('vorm').reset();
}
function change_basket()
{
	var selObj = document.getElementById('basket_color_id');
	var selIndex = selObj.selectedIndex;
	document.getElementById('colorpic').src=colorpics[selObj.options[selIndex].value];
	document.getElementById('price').value=colorprice[selObj.options[selIndex].value];

	if (document.layers)
    document['colorpic'].background.src = colorpics[selObj.options[selIndex].value] == 'none' ? null : colorpics[selObj.options[selIndex].value];
	else if (document.all)
    document.all['colorpic'].style.backgroundImage = colorpics[selObj.options[selIndex].value] == 'none' ? 'none' 
: 'url(' + colorpics[selObj.options[selIndex].value] + ')';
	else if (document.getElementById)
    document.getElementById('colorpic').style.backgroundImage = colorpics[selObj.options[selIndex].value] == 
'none' ? 'none' : 'url(' + colorpics[selObj.options[selIndex].value] + ')';
}

function concise(){}
concise.g=function(i){
	if(document.getElementById(i)){
		return document.getElementById(i);
	}else{
		return false
	}
}



