// JavaScript Document
function showtime(){
	today=new Date();
	thu=today.getDay();
	var thuten=""
	switch (thu)
	{
	case 0:
	thuten="Sunday";
	break;
	case 1:
	thuten="Monday";
	break;
	case 2:
	thuten="Tuesday";
	break;
	case 3:
	thuten="Wednesday";
	break;
	case 4:
	thuten="Thursday";
	break;
	case 5:
	thuten="Friday";
	break;
	default:
	thuten="Satuday";
	break;
	}
	ngay=today.getDate();
	thang=today.getMonth();
	thang=thang+1;
	switch (thang)
	{
	case 1:
	thang="January";
	break;
	case 2:
	thang="February";
	break;
	case 3:
	thang="March";
	break;
	case 4:
	thang="April";
	break;
	case 5:
	thang="May";
	break;
	case 6:
	thang="June";
	break;
	case 7:
	thang="July";
	break;
	case 8:
	thang="August";
	break;
	case 9:
	thang="September";
	break;
	case 10:
	thang="October";
	break;
	case 11:
	thang="November";
	break;
	case 12:
	thang="December";
	break;
	default:
	thang="January";
	break;
	}
	nam=today.getFullYear();
	//inra=thu+','+ngay+' '+thang+','+nam;
	document.write(thuten+',&nbsp;'+thang+'&nbsp;'+ngay+',&nbsp;'+nam);	
}
function ShowForexRate(){
	//vForexs.length - 1
	var sHTML = '';
	sHTML = sHTML.concat('<table border="0px" cellpadding="2px" cellspacing="1px" class="tbl-weather"  width="214" >');
	for(var i=0;i< 6;i++){
		sHTML = sHTML.concat('	<tr>');
		sHTML = sHTML.concat('		<td class="td-weather-title">').concat(vForexs[i]).concat('</td>');
		sHTML = sHTML.concat('		<td class="td-weather-data">').concat(vCosts[i]).concat('</td>');
		sHTML = sHTML.concat('	</tr>');
	}
	sHTML = sHTML.concat('</table>');
	document.write(sHTML);

}
function ShowGoldPrice(){
	var sHTML = '';
	sHTML = sHTML.concat('<div style="text-align:right;color:#8A0000;font:bold 10px arial;">&#272;VT: tr.&#273;/l&#432;&#7907;ng</div>');
	if(vGoldSbjBuy=='{0}' || vGoldSbjSell=='{1}' || vGoldSjcBuy =='{2}' || vGoldSjcSell=='{3}'){
		sHTML = sHTML.concat('<table border="0px" cellpadding="2px" cellspacing="1px" class="tbl-goldprice">');
		sHTML = sHTML.concat('	<tr>');	
		sHTML = sHTML.concat('		<td class="td-weather-title" style="text-align:center;font-size:10px;width:35%;font-weight:bold">D&#7919; li&#7879;u &#273;ang &#273;&#432;&#7907;c c&#7853;p nh&#7853;t</td>');	
		sHTML = sHTML.concat('	</tr>');
		sHTML = sHTML.concat('</table>');
	}
	else{	
		sHTML = sHTML.concat('<table border="0px" cellpadding="2px" cellspacing="1px" class="tbl-goldprice">');
		sHTML = sHTML.concat('	<tr>');
		sHTML = sHTML.concat('		<td class="td-weather-title" style="font-size:10px;width:30%;">Lo&#7841;i</td>');
		sHTML = sHTML.concat('		<td class="td-weather-title" style="text-align:center;font-size:10px;width:35%;">Mua</td>');
		sHTML = sHTML.concat('		<td class="td-weather-title" style="text-align:center;font-size:10px;width:35%;">B&#225;n</td>');
		sHTML = sHTML.concat('	</tr>');
		sHTML = sHTML.concat('	<tr>');
		sHTML = sHTML.concat('		<td class="td-weather-title">SBJ</td>');
		sHTML = sHTML.concat('		<td class="td-weather-data txtr">').concat(vGoldSbjBuy).concat('</td>');
		sHTML = sHTML.concat('		<td class="td-weather-data txtr">').concat(vGoldSbjSell).concat('</td>');
		sHTML = sHTML.concat('	</tr>');
		sHTML = sHTML.concat('	<tr>');
		sHTML = sHTML.concat('		<td class="td-weather-title">SJC</td>');
		sHTML = sHTML.concat('		<td class="td-weather-data txtr">').concat(vGoldSjcBuy).concat('</td>');
		sHTML = sHTML.concat('		<td class="td-weather-data txtr">').concat(vGoldSjcSell).concat('</td>');
		sHTML = sHTML.concat('	</tr>');
		sHTML = sHTML.concat('</table>');	
	}
	document.write(sHTML);
}


function isEmailAddr(txtEmail) {
	var result = false
	var theStr = new String(txtEmail)
	var index = theStr.indexOf("@");
	if (index > 0) {
		var pindex = theStr.indexOf(".", index);
	 	if ((pindex > index + 1) && (theStr.length > pindex + 1))
			result = "1";
		}
	 return result;
}

 function resizeIFrameToItsContent(obj)
        {          
          var the_height=obj.contentWindow.document.body.scrollHeight;
          obj.height=the_height;
        }
		


  function isValidRadio(radio) {
	  var valid = false;
	  for (var i = 0; i < radio.length; i++) {
		  if (radio[i].checked) {
			  return true;
		  }
	  }
	   return false;
  }
  function IsNumeric(sText)

  {
	 var ValidChars = "0123456789.";
	 var IsNumber=true;
	 var Char;
  
   
	 for (i = 0; i < sText.length && IsNumber == true; i++) 
		{ 
		Char = sText.charAt(i); 
		if (ValidChars.indexOf(Char) == -1) 
		   {
		   IsNumber = false;
		   }
		}
	 return IsNumber;
	 
	 }

  function IsEmpty(val){
	  if(val == "") return false
	  else return true
  }
						
function fnsCheckNumAlpha(alpha)
{
var testalpha = /^[A-Za-z0-9]{0,20}$/;
var chkalpha = alpha;
	if (testalpha.test(chkalpha))
		{
		return true;
		}
	else return false;
}

   /* window.onload = function() {
      (document.all && !window.print) ? null : setForm();
    }*/
	$(document).ready(function(){
		$('#langen').click(function(){
			 changerLang(2);
			 document.frmlang.submit();
		})
		$('#langvi').click(function(){
			 changerLang(1);
			 document.frmlang.submit();
		})
		function changerLang(id){
			
			$('#langID').val(id);
		}
		 $('.slideshow').cycle({
				fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
			});
		
		$('#mycarousel').jcarousel({
			auto: 3,
			wrap: 'last',
			initCallback: mycarousel_initCallback
   		 });
		  $("a[rel=example_group]").fancybox({
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'speedIn'		:	600, 
			'speedOut'		:	200, 
			'overlayShow'	:	true,
				'titlePosition' 	: 'over',
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
				}
			});
		//Set default open/close settings
			$('.acc_container').hide(); //Hide/close all containers
			//$('.acc_trigger:first').addClass('active').next().show(); //Add "active" class to first trigger, then show/open the immediate next container
			
			//On Click
			$('.acc_trigger').click(function(){
				if( $(this).next().is(':hidden') ) { //If immediate next container is closed...
					$('.acc_trigger').removeClass('active').next().slideUp(); //Remove all .acc_trigger classes and slide up the immediate next container
					$(this).toggleClass('active').next().slideDown(); //Add .acc_trigger class to clicked trigger and slide down the immediate next container
				}
				return false; //Prevent the browser jump to the link anchor
			});

	})
	 

function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};


