
function jsMessage(message, input){
	if (message) alert(message);
	if (input){
		input.select();
		input.focus();
	}
}

///Usable scripts for CatalogPage:

function setValue(name, value){//Èõæâïâþíêþâåæ òðíå öðôîý.
	F= document.forms['CatalogPageForm'];
	if (!F) return false;
	F[name].value=value;	
}

function submitForm(){//Ðæòôâþíóåæ öðôîè
	F= document.forms['CatalogPageForm'];
	F.submit();
}

function setOffset(offset, limit){
	setValue('offset', offset);
	setValue('limit', limit);	
	submitForm();
}

function setAction(value){
	setValue('action', value);	
	submitForm();
}

var selectColorFilters= new Array();;

function showColors(product_id){	
	F= document.forms['CatalogPageForm'];
	url="/catalog/colors.phtml?"+product_id;	
	for (i=0; i<selectColorFilters[product_id].length; i++){		
		SelectName='product_'+product_id+'_filter_'+selectColorFilters[product_id][i];		
		Tmp=F[SelectName].value;		
		url+='&filter['+selectColorFilters[product_id][i]+']='+Tmp;		
	}	
	window.open(url, 'color', 'width=510,height=400');
}

function setCookie (name, value, expires, path, domain, secure) {
      document.cookie = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

function checkCookie(name){
	return document.cookie.indexOf(name);
}



function onChangeColor(product_id, filter_id, select){
	setCookie("color["+product_id+"]["+filter_id+"]", select.value);
}
/**
ïÔËÒÙ×ÁÅÔ ÏËÎÏ Ó ÉÚÏÂÒÁÖÅÎÉÅÍ
*/
function showImage(name, width, height){
	if (!name) return;
	width=width*1;
	height=height*1;
		
	if (width)  window_w=width+30;
	else window_w=640;	
	if (height) window_h=height+30;
	else window_h=480;
		
	window.open('/image.php?image='+name+'&width='+width+'&height='+height, 'image', 'width='+window_w+',height='+window_h+',scrollbars=no');
}

