function switchlang(current, language, target, action){
	// Run a action before run others
	
	if(action != undefined){
		action();
	}
	pathofsite = document.location.href.split('/');
	indexoflang = pathofsite.indexOf(current);
	if(indexoflang == -1){
		return;
	}
	pathofsite[indexoflang] = language;
	newpath = pathofsite.join('/');
	if (target == 'blank'){
		window.open(newpath);
	}else{
		self.location.href = newpath;
	}			
}
function checklang(ava_lang){
	pathofsite = document.location.pathname.split('/');
	for(i=0; i<ava_lang.length; i++){
		indexoflang = pathofsite.indexOf(ava_lang[i]);
		if(indexoflang != -1){
			return ava_lang[i];
		}
	}
}
function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }}

function resizeImage(){
        $A(document.images).each(function(img){
				if (img.src.split('/').last() == "128"){
					if(img.height > img.width){
	                        img.width = img.width *92 / img .height;
	                }else{
	                        img.height = img.height *92/img.width;
	                }
				}
                
        });
		if ($A($$('.prod_image')).length < 0){
			
		}else{
			$A($$('.prod_image')).each(function(div){
	                div.setStyle({
	                        height: '92px',
	                        width:'92px'
	                });
	        });	
		}
        if ($A($$('.prodItem')).length < 0){
			
		}else{
			$A($$('.prodItem')).each(function(div){
	                div.setStyle({
	                        height:'140px',
	                        margin: '10px 5px',
				overflow: 'hidden'
	                });
	        });
			if ($('prodHolder')){
	        	$('prodHolder').setStyle({
		                padding: '0 0 0 65px'
		        });
			}
		}        
		
		if ($A($$('.lightwindow')).length<0){
			
		}else{
			$A($$('.lightwindow')).each(function(a){
			    a.setStyle({
			        height: '92px',
			        width: '92px'
			    });
			});
			if ($('thumbContainer')){
				$('thumbContainer').setStyle({
				    padding: '0 0 0 65px'
				});
			}
		}
}
function blockcontextmenu (){
	if (Prototype.Browser.IE){
		$('lightwindow_iframe').contentWindow.document.oncontextmenu = function(){ return false;}
		$('lightwindow_iframe').contentWindow.document.images[0].galleryimg = 'no';
		var ow = $('lightwindow_iframe').contentWindow.document.images[0].width;
		var oh = $('lightwindow_iframe').contentWindow.document.images[0].height;
		var src = $('lightwindow_iframe').src;
		var bg = 'url('+src+')';
		var att = 'width:'+ow+'px;height:'+oh+'px;background-images:url('+src+');';

		$('lightwindow_iframe').contentWindow.document.getElementsByTagName('body')[0].innerHTML = "";
		//$('lightwindow_iframe').contentWindow.document.images[0].visibility = "hidden";
		var divholder = $('lightwindow_iframe').contentWindow.document.createElement('div');
		divholder.id = "div";
		;
		$('lightwindow_iframe').contentWindow.document.getElementsByTagName('body')[0].appendChild(divholder);
		//var att = 'width:'+ow+'px;height:'+oh+'px;background-images:url('+src+');';
		
		$('lightwindow_iframe').contentWindow.document.getElementById('div').style.setAttribute("width", ow);
		$('lightwindow_iframe').contentWindow.document.getElementById('div').style.setAttribute("height", oh);
		$('lightwindow_iframe').contentWindow.document.getElementById('div').style.setAttribute("backgroundImage", bg);
		//alert($('lightwindow_iframe').contentWindow.document.getElementById('div'));
		$('lightwindow_iframe').stopObserving();
		//$('lightwindow_iframe').contentWindow.document.images[0].setAttribute("onmouseover", "killgalleryimg()");
		//if($('lightwindow_iframe').contentWindow.document.images[0].galleryimg == 'undefined'){blockcontextmenu();}

		
//var meta = $('lightwindow_iframe').contentWindow.document.createElement('meta');
//meta.httpEquiv = 'imagetoolbar';
//meta.content = 'no';
//$('lightwindow_iframe').contentWindow.document.getElementsByTagName('head')[0].appendChild(meta);		


	}else{
		$('lightwindow_iframe').contentDocument.oncontextmenu = function(){return false;}

	}
	//$('lightwindow_iframe').contentDocument.oncontextmenu = function(){return false;}
	//$('lightwindow_iframe').contentWindow.document.oncontextmenu = function(){return false;

}

function killgalleryimg(){
	
	$('lightwindow_iframe').contentWindow.document.images[0].galleryimg = 'no';
	$('lightwindow_iframe').contentWindow.document.images[0].vspace ="300";
	$('lightwindow_iframe').contentWindow.document.images[0].vspace="0";
	$('lightwindow_iframe').contentWindow.document.images[0].setAttribute("onmouseover", "");
}
