var css = "big";
var winW=0;
var cc = new CookieHandler();

if (document.body && document.body.offsetWidth) {
 winW = document.body.offsetWidth;
}
if (document.compatMode=='CSS1Compat' &&
    document.documentElement &&
    document.documentElement.offsetWidth ) {
 winW = document.documentElement.offsetWidth;
}
if (window.innerWidth && window.innerHeight) {
 winW = window.innerWidth;
}

if(winW > 1220){
	changeStyleSheet('big');
}else{
	changeStyleSheet('small');
}
cc.setCookie('winW', winW, 3600);

function changeStyleSheet(sss) {
	//$('#log').html(bgTop);
    if(sss == css)
        return;
    var sel = document.getElementById('ss_'+sss);
    var cur = document.getElementById('ss_'+css);
    if(!sel) {
        sel = cur.cloneNode(true);
        sel.id = "ss_"+sss;
        sel.setAttribute("href",cur.getAttribute("href").replace(new RegExp(css),sss));
    }
    cur.setAttribute("rel","stylesheet1");
    sel.setAttribute("rel","stylesheet");
    document.getElementsByTagName('head')[0].appendChild(sel);
    css = sss;
}

jQuery.noConflict();
(function($) { 
	changeStyleSheet(css);
	$(window).resize(function() {
	
		if (document.body && document.body.offsetWidth) {
		 winW = document.body.offsetWidth;
		}
		if (document.compatMode=='CSS1Compat' &&
			document.documentElement &&
			document.documentElement.offsetWidth ) {
		 winW = document.documentElement.offsetWidth;
		}
		if (window.innerWidth && window.innerHeight) {
		 winW = window.innerWidth;
		}
		
		if(winW > 1220){
			changeStyleSheet('big');
		}else{
			changeStyleSheet('small');
		}

	});

	
	$(function() {
		$('#pop').hide();	   
		$('.pop').click(function() {					 
			$('#pop').append('<div id="pop_content">');								 
			url = 'http://www.zimmermannstore.com/'+this.id;					 
			$('#pop_content').append("<iframe id='cboxIframe' scrolling='no'" + " name='iframe_"+new Date().getTime()+"' frameborder=0 src='"+url+"' " + (isIE ? "allowtransparency='true'" : '') + " class='rempop' width='100%' />");
			$('#pop').height($(document).height()-100);
			
			$('#pop').fadeIn();					 
		});	
		
		$('.popClose').click(function() {
			$('#pop_content').remove();
			$('#pop').fadeOut(); 					 
		});								 
		$(document).keyup(function(e) {
			if (e.keyCode == 27) {
				$('#pop_content').remove();
				$('#pop').fadeOut(); 
			};
		});
	});
})(jQuery);

function CookieHandler() {

	this.setCookie = function (name, value, seconds) {
 
		if (typeof(seconds) != 'undefined') {
			var date = new Date();
			date.setTime(date.getTime() + (seconds*1000));
			var expires = "; expires=" + date.toGMTString();
		}
		else {
			var expires = "";
		}
 
		document.cookie = name+"="+value+expires+"; path=/";
		
	}
 
	this.getCookie = function (name) {
 
		name = name + "=";
		var carray = document.cookie.split(';');
 
		for(var i=0;i < carray.length;i++) {
			var c = carray[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
		}
 
		return null;
	}
 
	this.deleteCookie = function (name) {
		this.setCookie(name, "", -1);
	}
 
}
