/**
 * print to console
 * @param {string} msg
 */
function clog(msg) {
	console.log(msg);
}

/**
 * Get the string-representation of a variable.
 * This only handles one-level arrays / objects.
 * @param {} mixed
 */
function parseJSONtoPHP(mixed) {
	type = typeof(mixed);
	switch(type) {
		case 'string':
		case 'number':
		case 'float':
			ret = mixed;
			break;
		case 'array':
			ret = '[' + mixed.join(',') + ']';
			break;
		case 'object':
			var ret = new Array();
			ret.push('{');
			for (i in mixed) {
				ret.push("'" + i + "': " + parseJSON(mixed[i]));
			}
			ret.push('}');
			break;
	}
	return ret;
}

/**
 * Call to the email check in PHP
 * @param {string} email
 * @return {Boolean}
 */
function email_valid_ajax(email) {
	if (!email.length || email.length <= 0)
		return false;
	
	$.ajax({
		type: "POST",
		url: sSiteRoot + 'include/ajaxhelpers.php',
		data: {
			'function': 'email_valid',
			'args': email
		},
		dataType: "json",
		success: function(data) {
			return data.data;
		},
		error: function(data) {
			alert(data.data);
			return false;
		}
	})
}

function windowSize()
{
	var w = 0;
	var h = 0;

	//IE
	if(!window.innerWidth)
	{
		//strict mode
		if(!(document.documentElement.clientWidth == 0))
		{
			w = document.documentElement.clientWidth;
			h = document.documentElement.clientHeight;
		}
		//quirks mode
		else
		{
			w = document.body.clientWidth;
			h = document.body.clientHeight;
		}
	}
	//w3c
	else
	{
		w = window.innerWidth;
		h = window.innerHeight;
	}
	return {width:w,height:h};
}
	
/**
 * Extend jQuery's html() to include the wrapper element
 * @return {jQuery}
 */
$.fn.htmlIncludeSelf = function() {
	return $('<div/>').append($(this).clone()).remove().html();
}
