function Set_Cookie( name, value, expires, path, domain, secure ) {

	var today = new Date();
	today.setTime( today.getTime() );

	if ( expires ) {
		expires = expires * 1000 * 60 * 60 * 24;
	}
	
	var expires_date = new Date( today.getTime() + (expires) );

	document.cookie = name + "=" +escape( value ) +
		( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
		( ( path ) ? ";path=" + path : "" ) +
		( ( domain ) ? ";domain=" + domain : "" ) +
		( ( secure ) ? ";secure" : "" );
}


function Get_Cookie( check_name ) {
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false;

	for ( i = 0; i < a_all_cookies.length; i++ ) {

		a_temp_cookie = a_all_cookies[i].split( '=' );

		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		if ( cookie_name == check_name ) {
			b_cookie_found = true;
			if ( a_temp_cookie.length > 1 ) {
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}

			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found ) {
		return null;
	}
}


$(function(){
	$(".msg").hide();
	$("#msg1").show();
	
	$("#banner ul li a").click(function(){
		$(".msg").hide();
		$($(this).attr('href')).show();
		
		var sr = $(this).attr('href').replace("#","");
		
		$("#banner").removeClass('msg1');
		$("#banner").removeClass('msg2');
		$("#banner").removeClass('msg3');
		$("#banner").removeClass('msg4');
		
		$("#banner").addClass(sr);
		
		$("#banner.grid_12 div.grid_8 ul li a").removeClass('active');
		$(this).addClass('active');
		
		return false;
	});
	
	i = 1;
	
	rotban = setInterval(function(){
		
		i++;
		
		if(i > 4) {
			i = 1;
		}
		
		$(".msg").hide();
		$("#msg"+i).show();
		
		$("#banner").removeClass('msg1');
		$("#banner").removeClass('msg2');
		$("#banner").removeClass('msg3');
		$("#banner").removeClass('msg4');
		
		$("#banner.grid_12 div.grid_8 ul li a").removeClass('active');
		
		$("#banner.grid_12 div.grid_8 ul li a[href=#msg"+i+"]").addClass('active');
		
		
		$("#banner").addClass('msg'+i);
		
	},4500);
	
	$("input[type='text']").placeholder();
	
	$("div#home.container_12 .grid_4").css({"cursor":"pointer"});
	
	$("#generalStrip.container_12 .grid_4").css({"cursor":"pointer"});
	
	$("#wrapper div#home.container_12 .grid_4").click(function(){
		document.location.href = $("a",$(this)).attr('href');
	});
	
	$("#generalStrip.container_12 .grid_4").click(function(){
		document.location.href = $("a",$(this)).attr('href');
	});
	
	$("a.register").click(function(){
		
		Set_Cookie("checkcookie","true",1);
		var ci = Get_Cookie("checkcookie");
		
		if(ci == "true") {

			var c = Get_Cookie("downloadregistered");

			if(c == "allowed") {
				return true;
			} else {

				tb_show("","/register.php?KeepThis=true&TB_iframe=true&width=520&height=260","");

				return false;
			}
		} else {
			alert("Cookies must be enabled fro you to download this file");
			return false;
		}
	
		
		
	});

	var els = $("#footer .grid_4 p");

	if(els.length > 1) {
		$("#footer .grid_4").css({
			"margin-top":"8px"
		});
		
		$("#footer .grid_4:first li").css({
			"margin-left":"8px",
			"list-style-type":"disc",
			"list-style-position":"inside"
		});
	}

	$("#footer .grid_4 p").css({
		"margin-right":"4px",
		"margin-left":"4px"
	});

	$("#footer .grid_4:first p").css({
		"margin-left":"8px"
	});

	$("#footer .grid_4:last p").css({
		"margin-right":"8px"
	});

});
