﻿if (top.frames.length > 0)
{
 top.location=self.location;
}

function emptyField(textobj) 
{
	if (textobj.value.length == 0) return true

	for (var i = 0; i < textobj.value.length; ++i) 
	{
			var ch = textobj.value.charAt(i)
			if (ch != ' ' && ch != '\t') return false
	}
	return true
}



function COMenu(obj1,obj2)
{
	var el1 = document.getElementById(obj1);
	var el2= document.getElementById(obj2);
	var ar = document.getElementById("cont").getElementsByTagName("img");
		if(el1.style.display == "block"){
//			for (var i=0; i<ar.length; i++){
			for (var i=0; i<2; i++){
				if (ar[i].id!="new")
				{
				ar[i].src="images/plus.gif";
				}
			}
			el2.src = "images/minus.gif";
		}else{
			el2.src = "images/plus.gif";
		}
}
function SwitchMenu(obj){
	if(document.getElementById){
	var el = document.getElementById(obj);
	var ar = document.getElementById("cont").getElementsByTagName("DIV");
		if(el.style.display == "none"){
			for (var i=0; i<ar.length; i++){
				ar[i].style.display = "none";
			}
			el.style.display = "block";
		}else{
			el.style.display = "none";
		}
	}
	
}
function ChangeClass(menu, newClass) { 
	 if (document.getElementById) { 
	 	document.getElementById(menu).className = newClass;
	 } 
} 


function ChangeClass(menu, newClass) 
{ 
	 if (document.getElementById) 
	 { 
	 	document.getElementById(menu).className = newClass;
	 } 
} 

function ValidateSendMail()
{
	
	if (emptyField(SendMail.txtContactname))
	{
		document.SendMail.txtContactname.focus();
		document.SendMail.txtContactname.select();
		alert("Please enter your name");
		return false;
	}
	if ((SendMail.txtEmail.value.indexOf(".")==-1)	 || (SendMail.txtEmail.value.indexOf("@")==-1))
	{
		alert("Invalid email address!");
		document.SendMail.txtEmail.focus();
		return false;
	}
	if (emptyField(SendMail.txtSubject))
	{
		document.SendMail.txtSubject.focus();
		document.SendMail.txtSubject.select();
		alert("Please enter subject");
		return false;
	}
	
	if (emptyField(SendMail.txtContent))
	{
		document.SendMail.txtContent.focus();
		document.SendMail.txtContent.select();
		alert("Please enter Content");
		return false;
	}
	return true;
}
function Validate()
{
	if (emptyField(frmLogin.txtUserName))
	{
		document.frmLogin.txtUserName.focus();
		document.frmLogin.txtUserName.select();
		alert("Please enter User Name");
		return false;
	}
	if (emptyField(frmLogin.txtPassword))
	{
		document.frmLogin.txtPassword.focus();
		document.frmLogin.txtPassword.select();
		alert("Please enter Password");
		return false;
	}
	return true;
}
function setOnFocus(field)
{
	if(field.value=='Từ khoá')
	{
		field.value = '';
	}
}

function setOnBlur(field)
{
	if(emptyField(field))
	{
		field.value='Từ khoá'
	}
}
function searchCheck()
{
	if(emptyField(frmSearch.keyWord) || (frmSearch.keyWord.value=='Từ khoá'))
	{
	  alert("Please enter keyword for searching");
	  frmSearch.keyWord.focus();
	  return false;
	}
	frmSearch.submit()
}
function add2Cart(ProdID,intQty,PageNumber)
{
window.location.replace('AddCart.asp?GroupID=<%=request("GroupID")%>&ProdID=' + ProdID + '&Qty=' + intQty + '&PageNumber='+PageNumber)
}

function ChangeClass(menu, newClass) 
{ 
	 if (document.getElementById) 
	 { 
	 	document.getElementById(menu).className = newClass;
	 } 
} 

 var WWTC_WeekDay;
    var WWTC_ClockOn, WWTC_ClockId;

    // Get GMT time
    function WWTC_getGMT() {
      var dateNow=new Date();
      var msLocal=dateNow.getTime();
      var msOffset=dateNow.getTimezoneOffset()*60*1000;
      var dateGMT=new Date(msLocal+msOffset);
      return(dateGMT);
    }

    // Get time by GMT offset
    function WWTC_getT(hOffset) {
      var dateGMT=WWTC_getGMT();
      var msGMT=dateGMT.getTime();
      var msOffset=hOffset*60*60*1000;
      var dateT=new Date(msGMT+msOffset);
      return(dateT);
    }

    // Show time in text box
    function WWTC_showT(hOffset, boxDate, boxTime) {
      if (hOffset==99) var dateT=new Date();
      else var dateT=WWTC_getT(hOffset);
      var y=dateT.getYear();if (y<1000) y+=1900;
      var m=dateT.getMonth()+1;
      var d=dateT.getDate();
      var dd=dateT.getDay();
      var hh=dateT.getHours();
      var mm=dateT.getMinutes();
      var ss=dateT.getSeconds();
      var ap=(hh<12?"AM":"PM");

      m=(m>=10?m:"0"+m);
      d=(d>=10?d:"0"+d);
      hh=(hh<=12?hh:hh-12);
      hh=(hh>=10?hh:" "+hh);
      mm=(mm>=10?mm:"0"+mm);
      ss=(ss>=10?ss:"0"+ss);

      boxDate.value=WWTC_WeekDay[dd]+" "+d+"/"+m+"/"+y;
      boxTime.value=hh+":"+mm+":"+ss+" "+ap;
    }

    // Stop clock
    function WWTC_stopClock() {
      if (WWTC_ClockOn) {
        clearTimeout(WWTC_ClockId);
        WWTC_ClockOn=false;
      }
    }

    // Start clock
    function WWTC_startClock() {
      // Show local, GW & SG times
      // WWTC_showT(99, document.WWTC_fLocal.tDate, document.WWTC_fLocal.tTime);
      // WWTC_showT(0, document.WWTC_fGW.tDate, document.WWTC_fGW.tTime);
      WWTC_showT(+7, document.WWTC_fSG.tDate, document.WWTC_fSG.tTime);
      
      // Set next update
      WWTC_ClockId=setTimeout("WWTC_startClock()", 1000);
      WWTC_ClockOn=true;
    }

    // Init clock
    function WWTC_initClock() {
      WWTC_WeekDay=new Array();
      WWTC_WeekDay[0]="Chủ nhật,";
      WWTC_WeekDay[1]="Thư hai,";
      WWTC_WeekDay[2]="Thứ ba,";
      WWTC_WeekDay[3]="Thứ tư,";
      WWTC_WeekDay[4]="Thứ năm,";
      WWTC_WeekDay[5]="Thứ sáu,";
      WWTC_WeekDay[6]="Thứ bảy,";

      WWTC_ClockOn=false;
      WWTC_ClockId=null;

      WWTC_stopClock();
      WWTC_startClock();
    }

    // ======================= //
    // End WorldWide TextClock //
    // ======================= //
var timerID = null;
var timerRunning = false;

function stopclock (){
        if(timerRunning)
                clearTimeout(timerID);
        timerRunning = false;
}


function showtime () {
        var now = new Date();
        var hours = now.getHours();
        var minutes = now.getMinutes();
        var seconds = now.getSeconds()
        var timeValue = "" + ((hours >12) ? hours -12 :hours)
        timeValue += ((minutes < 10) ? ":0" : ":") + minutes
        timeValue += ((seconds < 10) ? ":0" : ":") + seconds
        if ((hours>0)&&(hours<=11))
        {
        timeValue += " A.M - OSEDC Việt Nam - Chào buổi sáng!"
        }
        else if (hours<=18)
        {
        timeValue += " P.M - OSEDC Việt Nam - Chào buổi chiều!"
        }
        else
        {
        timeValue += " P.M - OSEDC Việt Nam - Chào buổi tối!"
        }
        window.status = timeValue;
        timerID = setTimeout("showtime()",1000);
        timerRunning = true;
}
function startclock () {
        stopclock();
        showtime();
        setTimeout("startclock()",0)
}

	function movePrev()
	{
	document.WWTC_fSG.MoveAmount.value = -1
	document.WWTC_fSG.submit()
	}
	function moveNext()
	{
	document.WWTC_fSG.MoveAmount.value = 1
	document.WWTC_fSG.submit()
	}	



		arrow1= new Image
		arrow1.src="images/b1.gif"
		arrow2= new Image
		arrow2.src="images/b2.gif"
		function m_overs(name)
		{	
			eval('document.all.'+name).src=arrow2.src}
		function m_outs(name)
		{	
			eval('document.all.'+name).src=arrow1.src}
		function m_ins()
		{	
			event.srcElement.style.color="#000000"}
		function m_ots()
		{	
			event.srcElement.style.color="#0000B8"}

var tmpURL = window.location.href;
function TellAFriend(url) 
{
		wName = "h" + url.length;

		if (tmpURL.indexOf('localhost/osedcvn')!=-1)	
		{
		var href = "/osedcvn/Email2Friend.aspx?url=" + url
		}
		else
		{
		var href = "/Email2Friend.aspx?url=" + url
		}	
		opt = "left=" + (screen.availWidth-500)/2 + ",top=" + (screen.availHeight-350)/2
		opt += ",height=350,width=500"
		window.open(href,wName,opt)		
}
//For News Details
function Feedback(id) 
{

		if (tmpURL.indexOf('localhost/osedcvn')!=-1)	
		{
		var href = "/osedcvn/NewsFeedback.aspx?NewsPK=" + id
		}
		else
		{
		var href = "/NewsFeedback.aspx?NewsPK=" + id
		}

		opt = "left=" + (screen.availWidth-500)/2 + ",top=" + (screen.availHeight-400)/2
		opt += ",height=400,width=500"
		window.open(href,"NewsFeedback",opt)		
}

// Detail
function FeedbackDetail(id) 
{
		if (tmpURL.indexOf('localhost/osedcvn')!=-1)	
		{
		var href = "/osedcvn/NewsFeedback.aspx?ItemPK=" + id
		}
		else
		{
		var href = "/NewsFeedback.aspx?ItemPK=" + id
		}
		opt = "left=" + (screen.availWidth-500)/2 + ",top=" + (screen.availHeight-400)/2
		opt += ",height=400,width=500"
		window.open(href,"NewsDetail",opt)		
}


//document.oncontextmenu=new Function("return false")

// JavaScript Document
nereidFadeObjects = new Object();
nereidFadeTimers = new Object();
function nereidFade(object, destOp, rate, delta){
if (!document.all)
return
    if (object != "[object]"){  //do this so I can take a string too
        setTimeout("nereidFade("+object+","+destOp+","+rate+","+delta+")",0);
        return;
    }
    clearTimeout(nereidFadeTimers[object.sourceIndex]);
    diff = destOp-object.filters.alpha.opacity;
    direction = 1;
    if (object.filters.alpha.opacity > destOp){
        direction = -1;
    }
    delta=Math.min(direction*diff,delta);
    object.filters.alpha.opacity+=direction*delta;
    if (object.filters.alpha.opacity != destOp){
        nereidFadeObjects[object.sourceIndex]=object;
        nereidFadeTimers[object.sourceIndex]=setTimeout("nereidFade(nereidFadeObjects["+object.sourceIndex+"],"+destOp+","+rate+","+delta+")",rate);
    }
}

function startTrans(a,fname)

{
		a.filters[0].Apply();
		a.src = "imageproducts/" + fname;
		a.filters[0].Play()
}


