﻿
//function gup(name) {
//    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
//    var regexS = "[\\?&]" + name + "=([^&#]*)";
//    var regex = new RegExp(regexS);
//    var results = regex.exec(window.location.href);
//    if (results == null)
//        return "";
//    else
//        return results[1];
//}

//var res_param = gup('res');

//if (scrWidth <= 1024) {
//    if (res_param == "") {

//        top.location.href = "../Listing/Sell.html?res=0";

//    }

//}

var scrWidth = screen.width;
var timeout = 60 * 60 * 24;
var d = new Date();
var expiry_date = d.getDate() + 30;
var curr_month = d.getMonth();
var curr_year = d.getFullYear();

if (get_cookie("CREResChk") == null) {
    set_cookie("CREResChk", scrWidth, curr_year, curr_month, expiry_date);

    window.location.reload(true);

} else {

if (get_cookie("CREResChk") != scrWidth) {
    set_cookie("CREResChk", scrWidth, curr_year, curr_month, expiry_date);

    window.location.reload(true);
}
    
}

function get_cookie(cookie_name) {
    var results = document.cookie.match('(^|;) ?' + cookie_name + '=([^;]*)(;|$)');

    if (results)
        return (unescape(results[2]));
    else
        return null;
}

function set_cookie(name, value, exp_y, exp_m, exp_d, path, domain, secure) {
    var cookie_string = name + "=" + escape(value);

    if (exp_y) {
        var expires = new Date(exp_y, exp_m, exp_d);
        cookie_string += "; expires=" + expires.toGMTString();
    }

    if (path)
        cookie_string += "; path=" + escape(path);

    if (domain)
        cookie_string += "; domain=" + escape(domain);

    if (secure)
        cookie_string += "; secure";

    document.cookie = cookie_string;
}

