$(document).ready(
	function ()
	{
		var heightBoxTeam 	  = $('#height-box-team').height();
		
		var heightBoxIntroQuestion = $('#box-team-intro-question').height();
		
		if (heightBoxTeam >= heightBoxIntroQuestion)
		{
			$('#height-box-team').addClass('style="height:'+heightBoxTeam+'px;"');
		}
		else
		{
			$('#box-team-intro-question').addClass('style="height:'+heightBoxIntroQuestion+'px;"');
		}
		$(".vacancyHeaderText").corner("bevel tr");
		
		// Corner Create CV
		$('.createCvPanel').corner('round 12px');
		
		// Corner Submit your cv
		$('.corner-submit-cv-top').corner('round 12px top');
		$('div.corner-submit-cv-bottom').wrap('<div class="corner-submit-cv-border jobAdBgBorder"></div>');
		$('div.corner-submit-cv-bottom').corner("round 12px bottom").parent().corner("round 12px bottom");
		
		window.setInterval("meetOutTeamUI()", 2000);
	}
	
);

function homeHeightUI()
{
	var home_01 = $('#sys-home-01').height();
	var home_02 = $('#sys-home-02').height();
	if (home_01 > home_02)
	{
		$('#sys-home-02').height(home_01);
	} else {
		$('#sys-home-01').height(home_02);
	}
	
	var home_11 = $('#sys-home-11').height();
	var home_12 = $('#sys-home-12').height();
	if (home_11 > home_12)
	{
		$('#sys-home-12').height(home_11);
	} else {
		$('#sys-home-11').height(home_12);
	}

	var home_21 = $('#sys-home-21').height();
	var home_22 = $('#sys-home-22').height();
	if (home_21 > home_22)
	{
		$('#sys-home-22').height(home_21);
	} else {
		$('#sys-home-21').height(home_22);
	}
	
	var home_left = $('#sys-home-header').height();
	home_left = parseInt(home_left) + parseInt($('#sys-home-header-job').height());
	home_left = parseInt(home_left) + parseInt($('#sys-home-header-job-content').height());
	
	var home_team  = $('#sys-home-team').height();
	var hom_button = $('#sys-home-button').height();
	var hieght_des = parseInt(home_team)- parseInt(home_left) - parseInt(hom_button);
/*	
	if ($('#msie6').val() == 0)
	{
		hieght_des = parseInt(hieght_des) - 30;
	}
	if (hieght_des > 0)
	{
		$('#sys-home-21').height(hieght_des);
		$('#sys-home-22').height(hieght_des);
	}
*/
}

function meetOutTeamUI()
{
	var header_00 = $('#mot-header-00').height();//document.getElementById("mot-header-00").clientHeight;
	var header_01 = $('#mot-header-01').height();//document.getElementById("mot-header-01").clientHeight;
	var header_02 = $('#mot-header-02').height();//document.getElementById("mot-header-02").clientHeight;
	
	setupHeight(header_00, header_01, header_02, 'mot-header-00', 'mot-header-01', 'mot-header-02');
		
	var image_10 = $('#image-meet-our-team-00').height();
	var image_11 = $('#image-meet-our-team-01').height();
	var image_12 = $('#image-meet-our-team-02').height();
	
	setupHeight(image_10, image_11, image_12, 'image-meet-our-team-00', 'image-meet-our-team-01', 'image-meet-our-team-02');
	
	var header_10 = $('#mot-header-10').height();
	var header_11 = $('#mot-header-11').height();
	var header_12 = $('#mot-header-12').height();
	
	setupHeight(header_10, header_11, header_12, 'mot-header-10', 'mot-header-11', 'mot-header-12');

	var header_20 = $('#mot-header-20').height();
	var header_21 = $('#mot-header-21').height();
	var header_22 = $('#mot-header-22').height();
	
	setupHeight(header_20, header_21, header_22, 'mot-header-20', 'mot-header-21', 'mot-header-22');

	var header_30 = $('#mot-header-30').height();
	var header_31 = $('#mot-header-31').height();
	var header_32 = $('#mot-header-32').height();
	
	setupHeight(header_30, header_31, header_32, 'mot-header-30', 'mot-header-31', 'mot-header-32');

}

function vacanciesUI()
{
	var total = parseInt($('#countVacanciesJob').val())+2;
	for (var i=1; i<total; i=i+3)
	{
		header_0 = $('#vacancy-header-'+i).height();
		header_1 = $('#vacancy-header-'+(parseInt(i)+1)).height();
		header_2 = $('#vacancy-header-'+(parseInt(i)+2)).height();

		//setupHeight(header_0, header_1, header_2, 'height-index-bullet-'+i, 'height-index-bullet-'+(parseInt(i)+1), 'height-index-bullet-'+(parseInt(i)+2));
		//setupHeight(header_0, header_1, header_2, 'vacancy-header-'+i, 'vacancy-header-'+(parseInt(i)+1), 'vacancy-header-'+(parseInt(i)+2));

		setupHeight($('#vacancy-header-title-'+i).height(), $('#vacancy-header-title-'+(parseInt(i)+1)).height(), $('#vacancy-header-title-'+(parseInt(i)+2)).height(), 'vacancy-header-title-'+i, 'vacancy-header-title-'+(parseInt(i)+1), 'vacancy-header-title-'+(parseInt(i)+2));
		setupHeight($('#vacancy-header-branch-'+i).height(), $('#vacancy-header-branch-'+(parseInt(i)+1)).height(), $('#vacancy-header-branch-'+(parseInt(i)+2)).height(), 'vacancy-header-branch-'+i, 'vacancy-header-branch-'+(parseInt(i)+1), 'vacancy-header-branch-'+(parseInt(i)+2));
		
		content_0 = $('#vacancy-content-'+i).height();
		content_1 = $('#vacancy-content-'+(parseInt(i)+1)).height();
		content_2 = $('#vacancy-content-'+(parseInt(i)+2)).height();
		
		setupHeight(content_0, content_1, content_2, 'vacancy-content-'+i, 'vacancy-content-'+(parseInt(i)+1), 'vacancy-content-'+(parseInt(i)+2));
	}
}
function setupHeight(height0,height1,height2, nameheight0,nameheight1,nameheight2)
{
	if ((height0 >= height1) && (height0 >= height2))
	{
		$('#'+nameheight1).height(height0);
		$('#'+nameheight2).height(height0);
	} else if ((height1 >= height0) && (height1 >= height2)){
		$('#'+nameheight0).height(height1);
		$('#'+nameheight2).height(height1);
	} else if ((height2 >= height0) && (height2 >= height1)){
		$('#'+nameheight0).height(height2);
		$('#'+nameheight1).height(height2);
	}	
}
function searchCode(baseUrl)
{
	var code = $('#search-code').val()
	if (!isNumeric(code))
	{
		alert('Please enter numeric data');
		return false;
	} else {
		window.location = baseUrl+code+'/?search=code';
	}
}
function checkEnter(e, baseUrl)
{
	var characterCode;
	
	if(e && e.which)
	{ 
		e = e;
		characterCode = e.which; 
	} else {
		e = event;
		characterCode = e.keyCode;
	}
	
	if(characterCode == 13)
	{ 
		searchCode(baseUrl);
		return false
	} else {
		return true
	}
}
function submitEnter(e, baseUrl)
{
	var characterCode;
	
	if(e && e.which)
	{ 
		e = e;
		characterCode = e.which; 
	} else {
		e = event;
		characterCode = e.keyCode;
	}
	
	if(characterCode == 13)
	{ 
		window.location = baseUrl;
		return false
	} else {
		return true
	}
}
function searchClick(baseUrl)
{
	if ($("#keyword").val())
	{
		actionRedirect="/search?keyword="+$('#keyword').val();
	}	
	if ($("#search-code").val())
	{
		actionRedirect="/view/no/"+$("#search-code").val()+"/?search=code";
	}	
	window.location = baseUrl+actionRedirect;
}
function isNumeric(strString)
{
   var strValidChars = "0123456789";
   
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
}
function optionHeightUI()
{
	var option_header_1 = parseInt($('#compare-option-header-1').height());
	var option_header_2 = parseInt($('#compare-option-header-2').height());
	
	if (option_header_1 > option_header_2)
	{
		$('#compare-option-header-2').height(option_header_1);
	} else {
		$('#compare-option-header-1').height(option_header_2);
	}

	var option_body_1 = parseInt($('#compare-option-body-1').height());
	var option_body_2 = parseInt($('#compare-option-body-2').height());
	if (option_body_1 > option_body_2)
	{
		$('#compare-option-body-2').height(option_body_1);
	} else {
		$('#compare-option-body-1').height(option_body_2);
	}	
		
}

function uploadHeightUI()
{
	var box_1 = parseInt($('#box-1').height());
	var box_2 = parseInt($('#box-2').height());
	
	if (box_1 > box_2)
	{
		$('#box-2').height(box_1);
	} else {
		$('#box-1').height(box_2);
	}
	
}

/* Common corner for all page */
function commonCorner()
{
	$("#empl-head").corner("round 2px");
	$("#feature-quote").corner();
	$(".emplQuoteText").corner();
	$(".bulletPoint").corner("10px");
	
	$("#search-content").corner("bottom");
	$(".jobSearchBoxHeader").corner("top");
}

	commonCorner();

/* Home corner */
function homeCorner()
{
	$(".featureJobPanel").corner("bevel tr");
}

/* Page view  */
function pageViewCorner()
{
	$(".featureJobPanel").corner("top");	
	$(".jobAdBgBorder").corner("bottom");
	$("#content-corner").corner("bottom");
}

/* Company profile page */
function companyProfileCorner()
{
	$(".companySnapShot").corner("top");
}

/* Vacancies page */
function vacanciesCorner()
{
	$(".vacancyHeaderText").corner("bevel tr");
}

/* Meet our team corner */
function meetOurTeamCorner()
{
	//commonCorner();	
}

function cvBuilderCorner()
{
	$(".jobApplicationBox").corner("10px");
	$("#apply-corner").corner("10px");
	$("#apply-corner-user").corner("10px");
}

/* Contact corner */
function contactCorner()
{
	$(".contactUs").corner();
	$(".contact-corner").corner();
}
/* Login corner */
function loginCorner()
{
	$(".loginBorder").corner();
	$(".contact-corner").corner();
}
