/* 
-----------------------------------------------------------------
	Chromecore CMS
	
	Description: 
 	Contains various CSS helper functions
	This version: 01.02.2009 by AK
	Last Updated: See SVN	
	
-----------------------------------------------------------------
*/
  
  
$(document).ready(function() {
    

	/* CSS HACKS
	   use only for non-critical fixes for non IE browsers
	------------------------------------------------------------- */
	
	if(jQuery.browser.safari) {	
		$('<link rel="stylesheet" type="text/css" href="/booking/resources/styles/browser/safari-all.css" media="screen" />').appendTo("head");
		if(jQuery.browser.version.substr(0,3)<"500") {
		$('<link rel="stylesheet" type="text/css" href="/booking/resources/styles/browser/safari-2down.css" media="screen" />').appendTo("head");
		}
	} else	if(jQuery.browser.opera) {
		$('<link rel="stylesheet" type="text/css" href="/booking/resources/styles/browser/opera-all.css" media="screen" />').appendTo("head");			
	} 
	
	
	/* ZEBRA STRIPES
	------------------------------------------------------------- */
	/* Data tables */
	if($('table tr:even') != null){
	$('table tr:even').addClass('alt');
	}
	
	/* Form CSS helpers */
	$('input:radio,input:checkbox').addClass('radio');
	$('input:text').addClass('long');
	$('input:text').each(function() {
		var inputlength = $(this).attr('size');
		if (inputlength>0) {
			$(this).removeClass('long');
			$(this).addClass('short');
		}
	});
	
	
	/* TABLE HELPERS
	------------------------------------------------------------- */
	if($('td input:checkbox') != null){
	$('td input:checkbox').each(function() {
		$(this).parent('td').addClass('checkbox'); // for checkboxes inside table cells
	});
	}
	/* adding first and last classes */
	if($('tr th:first-child') != null){
	$('tr th:first-child').addClass('first');
	}
	if($('tr td:first-child') != null){
	$('tr td:first-child').addClass('first');
	}
	if($('tbody tr:first-child') != null){
	$('tbody tr:first-child').addClass('first');
	}
	if($('tr th:last-child') != null){
	$('tr th:last-child').addClass('last');
	}
	if($('tr td:last-child') != null){
	$('tr td:last-child').addClass('last');
	}
	if($('tbody tr:last-child') != null){
	$('tbody tr:last-child').addClass('last');
	}
	
	
	/*
	-------------------------------------------------------------*/
	/* Form input(upload) nicifier (recode using jquery please) */
	var W3CDOM = (document.createElement && document.getElementsByTagName);
	
	if (!W3CDOM) return;
	var fakeFileUpload = document.createElement('span');
	fakeFileUpload.className = 'fakefile';
	fakeFileUpload.appendChild(document.createElement('input'));
	var image = document.createElement('img');
	image.src='/resources/images/ui/buttons/advertisers/choose-files.gif';
	fakeFileUpload.appendChild(image);
	var x = document.getElementsByTagName('input');
	for (var i=0;i<x.length;i++) {
	if (x[i].type != 'file') continue;
	if (x[i].parentNode.className != 'fileinputs') continue;
	x[i].className = 'file hidden';
	var clone = fakeFileUpload.cloneNode(true);
	x[i].parentNode.appendChild(clone);
	x[i].relatedElement = clone.getElementsByTagName('input')[0];
	x[i].onchange = x[i].onmouseout = function () {
	this.relatedElement.value = this.value;
	}
	}


	
});

	

