$(document).ready(function(){
	
	/*if (getUrlVarsFrom(document.location.href, false)['testmode'] == 1) {
		maintenanceMode();*/
	/*}*/
		
		// Make the html5 placeholder attr work on lesser browsers
		fixPlaceHolderCompatibility();
		
		
		
		// Call specific functions to each page
		switch (getUrlVarsFrom(document.location.href, true)['tabid']) {
		case undefined:
			
			break;
		case '1':
			
			break;
		
		}
	
	
	
	
})


function maintenanceMode() {
	
	document.styleSheets[0].disabled = true;
	$('a').each(function(index,domEle){
		
		if ($(domEle).attr('href') != null)
		
		if ($(domEle).attr('href').indexOf('?')==-1) {
			$(domEle).attr('href', $(domEle).attr('href') + '?testmode=1');
		} else {
			$(domEle).attr('href', $(domEle).attr('href') + '&testmode=1')
		}
	})

}

// Get variables from the url
function getUrlVarsFrom(url, preventUnwantedVars) {
    var vars = [],
        hash;
    var hashes = url.split('#')[0].slice(url.indexOf('?') + 1).split('&');
    for (var i = 0; i < hashes.length; i++) {
        hash = hashes[i].split('=');
        if (preventUnwantedVars == 1) {
            if (hash[0] != 'lg' && hash[0] != 'objectid' && hash[0] != 'tabindex' && hash[0] != 'page' && hash[0] != 'keyword' && hash[0] != 'mediaid' && hash[0] != 'testmode') {
                if (hash[0] == 'categoryid' && hash[1] == 0) {} else {
                    vars.push(hash[0]);
                    vars[hash[0]] = hash[1];
                }
            }
        } else {
            vars.push(hash[0]);
            vars[hash[0]] = hash[1];
        }
    }
    return vars;
}

// Make the html5 placeholder attribute work in lesser browsers
function fixPlaceHolderCompatibility() {
	if(!Modernizr.input.placeholder){

		$('[placeholder]').focus(function() {
		  var input = $(this);
		  if (input.val() == input.attr('placeholder')) {
			input.val('');
			input.removeClass('placeholder');
		  }
		}).blur(function() {
		  var input = $(this);
		  if (input.val() == '' || input.val() == input.attr('placeholder')) {
			input.addClass('placeholder');
			input.val(input.attr('placeholder'));
		  }
		}).blur();
		$('[placeholder]').parents('form').submit(function() {
		  $(this).find('[placeholder]').each(function() {
			var input = $(this);
			if (input.val() == input.attr('placeholder')) {
			  input.val('');
			}
		  })
		});
	
	}	
}
