$(document).ready(function() {
	//Hover list
	$("#ads_table tr").each(function(i){
		this.onmouseover =  function() {
				if (this.className == "premium")
					$(this).addClass("hover");
				if (this.className == "common")
					$(this).css("background-color", "#EBF3CE");			
		};
			
		this.onmouseout = function() {
				if (this.className == "premium hover")
					$(this).removeClass("hover");
				if (this.className == "common")
					$(this).css("background-color", "");		
		};
	});
	
	//Hover gallery
	$("#ads_list_gallery > .large_view").each(function(i){
		this.onmouseover =  function() {
				if (this.className == "premium_is")
					$(this).addClass("hover");
				else
					$(this).css("background-color", "#EBF3CE");			
		};
			
		this.onmouseout = function() {
				if (this.className == "premium_is")
					$(this).removeClass("hover");
				else
					$(this).css("background-color", "");		
		};
	});
	
	//Hover in CMS
	$("#global > div").each(function(i){
		this.onmouseover =  function() {
				if (this.className == "page_content")
					$(this).css("hover");	
		};
			
		this.onmouseout = function() {
				if (this.className == "page_content")
					$(this).removeClass("hover");		
		};
	});
	
	
	$.each($.browser, function(i, val) {
		//For IE 6.0
		if(i=="msie" && $.browser.version.substr(0,3)=="6.0"){
			//Error Headler
			$('.errors li').css("color", "#cf2c0c").css("width", "25em").css("font-size", "11px").css("font-weight", "bold");
			$('.error').css("background-color", "red");
			//Entrust
			$('#confierbiencontent').css("margin-right", "10px");
			//CMS Login
			$('#login_form').css("padding-bottom", "1px");
			$('#cms_login_form span').css("height", "54px");
			if(_controller == "entrust") {
				$('.button').css("margin-right", "5px");
				$('.dropbox .required').css({"width": "145px","margin-left": "3px"});
				$('.left .agTextBordered').css("width", "150px");
			}
			if(_controller == "contactus") {
				$('.button').css("margin-right", "0px");
				//$('#stat').css({"width": "51%"});
			}	
			if(_action == "details"){
				$('#agencycard .agTextareaBordered .left').css("height", "82px");
				$("#mail_agency").css("margin-right", "0px");
			}	
			
			//My Selection
			$("#myselectioncontent").css({"margin-top": "-3px"});
			
			//Tooltip
			$("#map_rail div, .tooltip div").css({"background": ""});
			$("#map_rail div.top, .tooltip div.title").css({"background": "url(/images/tooltips/background.png) top left"});
			$("#map_rail div.bottom, .tooltip div.bottom").css({"background": "url(/images/tooltips/background.png) bottom left"});
			
			//Count of ad on page
			$("td.counter .linkselectLink").css("width", "10px");
			//District Select
			$("#district_loc .linkselectLink").css("width", "149px");
			
			var tmp;
			tmp = $("#contentlistofcities #point").css("margin-left");
			if(tmp)
			{
				tmp = parseInt(tmp.replace("px", "")) / 2;
				$("#contentlistofcities #point").css({"margin-left": tmp+"px"});
				tmp = $("#contentlistofcities #mapInCity").css("margin-left");
				tmp = parseInt(tmp.replace("px", "")) / 2;
				$("#contentlistofcities #mapInCity").css({"margin-left": tmp+"px"});
			}
			
			// Autoselect on map
			tmp = $("#cityform").css("margin-left");
			if(tmp)
			{
				tmp = parseInt(tmp.replace("px", "")) / 2;
				$("#cityform").css({"margin-left": tmp+"px"});
			}
		}
		
		if(i=="msie" && $.browser.version.substr(0,3)=="7.0"){
			//Error Headler
			$('#global').css("padding-bottom", "10px");		
			if(_controller == "entrust")
			{
				$('.agTextarea').css("width", "484px").css("height", "78px");
				$('.dropbox label').css("margin-left", "6px");
			}	
		}
		
		//For IE 6.0 and 7.0
		if(i=="msie" && ($.browser.version.substr(0,3)=="6.0" || $.browser.version.substr(0,3)=="7.0")) {
			//Input type="text"
			$('.agTextBordered').css("margin-top", "-1px");
			$('.lefttext').css("padding-right", "28px");
			//Textarea
			if(_controller == "entrust")
			{
				$('.agTextarea').css("width", "484px").css("height", "78px");
			}
			if(_controller == "contactus")
				$('.agTextarea').css("width", "552px").css("height", "78px");
				
			/*$(".NormalAdText").css("width", "215px");*/
			$("#search_top #search_top_right").css("margin-top", "-3px");
			$("#search_top #search_left").css("margin-top", "-3px");
			$("#search_top #search_results").css("margin-top", "-3px");
			
			//$("div").css("border", "1px dotted red");
			//$("#search_left > div").css("padding", "0px");
			
		}
		
		//Firefox 2.0
		if($.browser.mozilla && $.browser.version.substr(0,3) == "1.8") {
			$('.pagin .cont').css("width", "160px");
			if(_controller == "entrust" && _action == "agencies")
				$('.linkselectContainer .scrollable').css({"margin": "0 85px 0 -85px"});


		}
		
		//For Safari
		if($.browser.safari) {
			$("a[id='nextstep']").click(function(){
				$("label[class='error']").css("width", "250px");
			});
			$("#search_right #pond").css({"margin": "-10px 0 0 60px"});  
		}
		
		
		
	})
});
