﻿//nasavietnam@gmail.com
//http://xomnet.org

//function Popup(url,name,width,height) {
//  var winX = 0;
//  var winY = 0;
//  var w = width;
//  var h = height;
//  // only set new values if 4.0 browser
//  if (parseInt(navigator.appVersion) >= 4) {
//    winX = (screen.availWidth - w)*.5;
//    winY = (screen.availHeight - h)*.5;
//  }
//  popupWin = window.open(url, name, 'scrollbars=auto,resizable=yes, width=' + w + ',height=' + h + ',left=' + winX + ',top=' + winY);
//}

//////
//var maxW,maxH,fromX,fromY,toX,toY,adjX,adjY,zBox,zStep=0,zLink,zNew;
//var winX = 0;
//var winY = 0;
// tox=0;
// toy=0;
//function zoomBox(evt,zlink,maxw,maxh) {

//  var w = maxw;
//  var h = maxh;
//  // only set new values if 4.0 browser
//  if (parseInt(navigator.appVersion) >= 4) {
//    winX = (screen.availWidth - w)*.5;
//    winY = (screen.availHeight - h)*.5;
//  }

//if (arguments.length > 2) zNew=1;scrollH=(window.pageYOffset!=null)?window.pageYOffset:document.body.scrollTop;maxW=maxw?maxw:window.innerWidth?innerWidth:document.body.clientWidth;maxH=maxh?maxh:window.innerHeight?innerHeight:document.body.clientHeight;toX=tox?tox:0;toY=(toy?toy:0)+scrollH;fromX=evt.pageX?evt.pageX:evt.clientX;fromY=(evt.pageY?evt.pageY:evt.clientY)+(document.all?scrollH:0);adjX=toX+evt.screenX-fromX;adjY=toY+evt.screenY-fromY;if (document.createElement && document.body.appendChild && !zBox) {	zBox=document.createElement("div");	zBox.style.position="absolute";	document.body.appendChild(zBox);} else if (document.all && !zBox) {	document.all[document.all.length-1].outerHTML+='<div id="zBoxDiv" style="position:absolute"></div>';	zBox=document.all.zBoxDiv;} else if (document.layers && !zBox) {	zBox=new Layer(maxW);	zBox.style=zBox;	}zLink=zlink;doZoom();}
//function doZoom() {
//zStep+=1;zPct=(10-zStep)/10
//if (document.layers) {
//	zBox.moveTo(toX+zPct*(fromX-toX),toY+zPct*(fromY-toY));
//	zBox.document.open();
//	zBox.document.write("<table width='"+maxW*(1-zPct)+"' height="+maxH*(1-zPct)+" border=2 cellspacing=0><tr><td></td></tr></table>");
//	zBox.document.close();
//	} else {
//	zBox.style.border="1px solid #0099ff";
//	zBox.style.left=toX+zPct*(fromX-toX);
//	zBox.style.top=toY+zPct*(fromY-toY);
//	zBox.style.width=maxW*(1-zPct);
//	zBox.style.height=maxH*(1-zPct);
//	}
//zBox.style.visibility="visible";
//if (zStep < 10) setTimeout("doZoom("+fromX+","+fromY+","+toX+","+toY+")",30);
//else {
//	zBox.style.visibility='hidden';
//	zStep=0;
//	if (zLink && !zNew) location.href=zLink.href;
//	else if (zLink && zNew) {
//	
//		var w=window.open(zLink.href,'','width='+maxW+',height='+maxH+',left='+winX+',top='+winY+',scrollbars,resizable');


//		zNew=null;
//		}
//	}
//}


//////////////////////////////////////////


//function SendFriend()
//{
//    var fromName=document.getElementById("_FromName");
//    var fromEmail=document.getElementById("_FromEmail");
//    var toEmail=document.getElementById("_ToEmail");
//    var subject=document.getElementById("_Subject");
//    var message= document.getElementById("_Message");
//    
//    if(fromName.value=="")
//    {
//        alert("Vui lòng nhập tên của bạn / Please, enter your name ");
//        fromName.focus();
//        return false;
//    }
//    if(fromEmail.value=="")
//    {
//        alert("Vui lòng nhập Email của bạn / Please, enter your e-mail ");
//        fromEmail.focus();
//        return false;
//    }
//    
//    if(validateEmail(fromEmail.value))
//    {
//        alert("Địa chỉ mail không đúng / E-mail is incorrect ");
//        fromEmail.focus();
//        return false;
//    }
//    
//    if(toEmail.value=="")
//    {
//        alert("Vui lòng nhập Email của người nhận / Please, enter friend's e-mail ");
//        toEmail.focus();
//        return false;
//    }
//    
//    if(validateEmail(toEmail.value))
//    {
//        alert("Địa chỉ mail người nhận không đúng / E-mail is incorrect ");
//        toEmail.focus();
//        return false;
//    }
//    
//    if(subject.value=="")
//    {
//        alert("Vui lòng nhập tiêu đề mail / Please, enter subject ");
//        subject.focus();
//        return false;
//    }
//    else
//    {
//        //alert("ok ");
//        SendFriendCallback.Callback(fromName.value,fromEmail.value,toEmail.value,subject.value,message.value);
//        //SendFriendCallback.Callback("HUY",'nasavietnam@gmail.com','huy_htc@yahoo.com','NASA','Test');
//       // SendFriendCallback.Callback("HUY","nasavietnam@gmail.com","huy_htc@yahoo.com","NASA","Test");
//    }
//      
//    
//}

/*                       Invite Email                     */
function inviteEmail()
    {
        mail=document.getElementById("email").value;
        
        if(!validateEmail(mail) && mail!="friend@gmail.com")
        {
            _InviteEmail.Callback(mail);
          
        }
        else
        {
            alert("Nhập địa chỉ E-mail chưa đúng! / E-mail is incorrect ");
            document.getElementById("email").value="";
            document.getElementById("email").focus();
            
        }     
      
       
    }
    function validateEmail(emailad) {

		var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
		var check=/@[\w\-]+\./;
		var checkend=/\.[a-zA-Z]{2,3}$/;
		
			if(((emailad.search(exclude) != -1)||(emailad.search(check)) == -1)||(emailad.search(checkend) == -1)){
				return true;
			}
			else {
				return false;
			}
		}
// end invite

var _old_url='';
function LoadUrl()
{
    var _url=window.location.href;
   
    try
        {
             if(_url!=_old_url && _url.indexOf("#")>0)
                {
                    _old_url=_url;
                    _url=_url.split('#');
                    _url=_url[1];                
                    _url=_url.split('/');                                             
                    S3IContent.Callback(_url); 
                    scroll(0,0); 
                                                            
                                     
                }            
           
        }
        catch (e)
        {
            //alert(e);
            //S3IContent.Callback('');      
            
        }    
                               
        setTimeout("LoadUrl()",500);    
      
    }


//function OnCallback(sender, eventArgs)
//{
//    
//    scroll(0,0);
//    var _loading=document.getElementById("loading");
//    _loading.style.width=(screen.availWidth-20)+"px";
//    _loading.style.height=screen.availHeight+"px";    
//    _loading.style.display='block';
//    
//}
//function OnCallbackComplate(sender, eventArgs)
//{
//   // alert("Ok");
//    document.getElementById("loading").style.display='none';
//}

//function enterkey(event) 
//{
//  if (window.event && window.event.keyCode == 13)
//    CheckSearch();    
// 
//}
//function CheckSearch()
//{
//    var _txt=document.getElementById("txt");
//    if(_txt.value!="" && _txt.value!="Tìm kiếm nhanh")
//        location='#/search/'+_txt.value+"/";    
//    else
//    {
//        alert("Nhập từ khoá cần tìm !");
//        _txt.focus();
//    }
//}