//window.onload = setScreenClass;
window.onresize = setScreenClass;
$(document).ready(function()
{
	setScreenClass();
});
	
	//  Following transition classes will be declared:
	//
	//	classname		  screenwidth
	//	------------------------------------------
	//	pda_v			  240px			
	//	pda_h			  320px			
	//	ultralow		  320px -  640px	
	//	screen_lo		  640px -  800px	
	//	screen_med		  800px - 1024px	
	//	screen_high		 1024px - 1260px	
	//	screen_wide				> 1260px			

function setScreenClass()
{
	var fmt = document.documentElement.clientWidth;
	
	setCookie("swidth",fmt,null);
	
//		var cls = (fmt<=240)?'pda_ver':(fmt>240&&fmt<=320)?'pda_hor':(fmt>320&&fmt<=640)?'screen_ultralow':(fmt>640&&fmt<=800)?'screen_low':(fmt>800&&fmt<=1024)?'screen_med':(fmt>1024&&fmt<=1260)?'screen_high':'screen_wide';
	
	var cls = (fmt<=600)?'screen_lo':
		(fmt>600&&fmt<=750)?'screen_lo640':
		(fmt>750&&fmt<=990)?'screen_med':
		(fmt>990&&fmt<=1200)?'screen_high':'screen_wide';

	//var cls = 'screen_high';
	//var cls = 'screen_wide';
	//document.getElementById('res').innerHTML=fmt+'px -> '+cls;
	document.body.className=cls;
	
	//setTimeout(function() { $('#mebelinilogo').ifixpng(); }, (3000));
	$('#shop').ifixpng();
	
	
	
	$('#p2').ifixpng();
	$('#p3').ifixpng();
	$('#cars').ifixpng();
	
	$('#arrow').ifixpng();
	$('#mask').ifixpng();
	
	$('#shad1').ifixpng();
	$('#shad1>img').ifixpng();
	$('#shad2').ifixpng();
	$('#shad2>div').ifixpng();
	
	$('#p21').ifixpng();
	$('#p22').ifixpng();
	$('#p23').ifixpng();

	$('#p5').ifixpng();
	$('#p6').ifixpng();
	
	//$('.png').ifixpng();

	$('img[src$=.png]').ifixpng();
	if (cls == 'screen_wide')
	{
		$('#p1').ifixpng();
		$('#flag').ifixpng();
		
		$('#mebelinilogo').css('background','url("/img/logo.png") right no-repeat');
		$('#mebelinilogo').ifixpng();
		$('#p1').show();
		$('#flag').show();
	}
	else if (cls == 'screen_high' || cls == 'screen_med')
	{
		$('#mebelinilogo').css('background','url("/img/1024/logo.png") left no-repeat');
		$('#mebelinilogo').ifixpng();
		$('#p1').hide();
		$('#flag').hide();
	}
	else if (cls == 'screen_lo')
	{
		$('#mebelinilogo2').css('background','url("/img/240/logo.jpg") right no-repeat');
	}

	if ($.browser.msie && $.browser.version < 7)
	{
		$("#mmain>#down>#bg").css('background','url("")');
		$("#mmain>#up>#bg").css('background','url("")');
	}
	
	rd(cls);
	
//	alert(getCookie('swidth'));
}

function setCookie(c_name,value,expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(c_name)
{
	if (document.cookie.length>0)
	{
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1)
		{ 
			c_start=c_start + c_name.length+1; 
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) 
				c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
		} 
	}
	return "";
}