function redirect(url){
	if(url){
		url = escape(url);
		ShowLoading();
		location.href = url;
	}
}

function HideLoading(){
	document.getElementById('loading').style.display = 'none';
}

function ShowLoading(){

	var loading = document.getElementById("loading");
	loading.style.display = 'inline';
	loading.style.pixelLeft = document.body.clientWidth - loading.offsetWidth - document.body.scrollLeft;
}

function DrawImage(ImgD , nMaxWidth , nMaxHeight){
	
	var nWidth , nHeight;
	var image = new Image(); 
	image.src = ImgD.src;
	
	nWidth = image.width;
	nHeight = image.height;
	
	if(nWidth <= nMaxWidth && nHeight <= nMaxHeight) return;
	
	switch(nWidth > nHeight){
		
		case true:
			
			ImgD.width = nMaxWidth;
			ImgD.height = (nHeight * nMaxWidth) / nWidth;
			
			break;
		
		case false:
			
			ImgD.height = nMaxHeight;
			ImgD.width = (nWidth * nMaxHeight) / nHeight;
			
			break;
			
	}
	
}

function externallink(){
	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';
	}
}

window.onload = function(){
	InitProductClass();
	externallink();
}