(function($) {
	$(function() {
		
		/*FIXIG HEIGHT*/
		var rightHeight = $('.contentRight').height(),
			leftHeight = $('.contentLeft').height(),
			textpage = $('#textPageTop').height();
			
		if($('#grayLineContentTop').length){
			leftHeight += parseInt($('#grayLineContentTop').height()) + parseInt(2);
		}
		
		if($('#footerWeeklySite').length){
			if($('#footerWeeklySite').html().length < 30){
				$('#footerWeeklySite').height(0);
			}
		}
		
			
		if(rightHeight > leftHeight){
			$('#contentWindow').height(rightHeight);
			$('.contentWindow').height(rightHeight);

		}else if(rightHeight < leftHeight){
			$('#footerStat').height(leftHeight-parseInt(364));
		}
//		if(textpage > leftHeight)
//		{
//			$('#contentWindow').height(textpage);
//			$('.contentWindow').height(textpage);
//		}
		
		$('#clientsLogin').bind('click', function(){
			var boxTitle = $(this).text();
			$('#loginWindowTitle').html(boxTitle);
			$('#loginWrapper').show();
			 $('#loginWrapper').animate({
			    right: "300px",
			    top: "300px"
			  }, 1200, 'linear' );
		});
		
		if ($.browser.msie) {
  			$('input:radio[name="method"]').bind('click',function(){
  				var val = $(this).val();
				changeFormAction(val);	
  			});
		}
		else
		{
			$('input:radio[name="method"]').bind('change',function(){
			var val = $(this).val();
			changeFormAction(val);	
			});
		}
		
		$('#closeLoginWindow').bind('click', function(){
			$('#loginWrapper').css('margin', '0 0 0 0');
			$('#loginWindowTitle').html('');
			$('#loginWrapper').hide();
		});
		/*
		function change_login_box(url, type, checked){
			$.post("/_ajax/boxibox.ajax.php", { 'url': url, 'type': type },
			   function(data){
			     $('#loginWrapperInner').html(data);
			     $('#'+checked).attr('checked', 'checked');
			   });
		}
		
		$('input[name="method"]').bind('change', function(){
			if($(this).attr('id') == 'cPanelSel'){
				$('#loginForm').attr('action', 'https://cpanel1.secured.co.il:2083/login/');
			}else if($(this).attr('id') == 'cPanelSelResel'){
				$('#loginForm').attr('action', 'https://cpanel1.secured.co.il:2087/login/');
			}else{
				$('#loginForm').attr('action', 'https://cp.secured.co.il:8443/psoft/servlet/psoft.hsphere.CP');
			}
		});
		*/
		$('input[name="BillingLikeClient"]').bind('change', function(){
			if($(this).val()=='yes'){
				var newHeightLeft = $('#footerStat').height()+parseInt(364)-parseInt(389),	
				    newHeightRight = $('#footerStat').height()-parseInt(389);
				    
				$('#contentWindow').height(newHeightLeft);
				$('.contentWindow').height(newHeightLeft);
				$('#footerStat').height(newHeightRight); 
			}else{
				var newHeightLeft = $('#footerStat').height()+parseInt(364)+parseInt(389),	
				    newHeightRight = $('#footerStat').height()+parseInt(389);
				    	
				$('#contentWindow').height(newHeightLeft);
				$('.contentWindow').height(newHeightLeft);
				$('#footerStat').height(newHeightRight);
			}
		});
	});
	function changeFormAction(choice){
		
			if(choice == "cpanel"){
				$("#loginForm").attr("action","https://cpanel1.secured.co.il:2083/login/");
				$("#clientUsername").attr("name","user");
				$("#clientPassword").attr("name","pass");
			}
			else if(choice == "cpanelReseller"){
				$("#loginForm").attr("action","https://cpanel1.secured.co.il:2087/login/");
				$("#clientUsername").attr("name","user");
				$("#clientPassword").attr("name","pass");
			}
			else{
				$("#loginForm").attr("action","https://cp.secured.co.il:8443/psoft/servlet/psoft.hsphere.CP");
				$("#clientUsername").attr("name","login");
				$("#clientPassword").attr("name","password");
			}
	}



}(jQuery));


