﻿/*  AdCom.LibraryJS.Javascript
    Developer: Nguyen Xuan Hoang
    Fpt Telecom - 48 Van Bao - Ngoc Khanh - Ba Dinh - Ha Noi
    Mobile: 84-983251124
    Email: hoangnx.fpt@gmail.com
    --------------------------------------------------------
*/
function MM_preloadImages() { //v3.0
    var d=document; 
    if(d.images)
    { 
        if(!d.MM_p) 
            d.MM_p=new Array();
        var i,j=d.MM_p.length,a=MM_preloadImages.arguments; 
        for(i=0; i<a.length; i++)
            if (a[i].indexOf("#")!=0)
            { 
                d.MM_p[j]=new Image; 
                d.MM_p[j++].src=a[i];
            }
    }
}
function MM_swapImgRestore() { //v3.0
    var i,x,a=document.MM_sr; 
    for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) 
        x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
    var p,i,x;  
    if(!d) 
        d=document; 
    if((p=n.indexOf("?"))>0&&parent.frames.length) 
    {
        d=parent.frames[n.substring(p+1)].document; 
        n=n.substring(0,p);
    }
    if(!(x=d[n])&&d.all) 
        x=d.all[n]; 
    for (i=0;!x&&i<d.forms.length;i++) 
        x=d.forms[i][n];
    for(i=0;!x&&d.layers&&i<d.layers.length;i++) 
        x=MM_findObj(n,d.layers[i].document);
    if(!x && d.getElementById) 
        x=d.getElementById(n); 
    return x;
}
function MM_swapImage() { //v3.0
    var i,j=0,x,a=MM_swapImage.arguments; 
    document.MM_sr=new Array; 
    for(i=0;i<(a.length-2);i+=3)
        if ((x=MM_findObj(a[i]))!=null)
        {
            document.MM_sr[j++]=x; 
            if(!x.oSrc) 
                x.oSrc=x.src; 
            x.src=a[i+2];
        }
}
//-----------------------------------------------
function OpenServey(id)
{
	var value = '-1';
	if (id==0)
	{
	    var sur = document.getElementsByName('optSurvey');
	    for (i=0;i<sur.length;i++)
	    {
	        if (sur[i].checked)
		        value=sur[i].value;
        }
        if (value == '-1')
        {
            alert('Bạn chưa bỏ phiếu bình chọn..!');
            return;
        }
	}
	//----------------
    var leftPos = (screen.availWidth-480) / 2;
	var topPos = (screen.availHeight-440) / 2;
	window.open('/Survey/AdResultSurvey.aspx?value=' + value,'','width=480,height=440,scrollbars=no,resizable=no,titlebar=0,top=' + topPos + ',left=' + leftPos);
}
//-----------------------------------------------
function SearchClick()
{
//    var txtSearch = AdFindObjectID('txtSearch').value;
//    if (txtSearch!='')
//    {
//        	var domainName = location.protocol + '//' + location.host;  
//            Location = '/AdResult.aspx?domains=' + domainName; 
//            Location += '&q=' + txtSearch;
//            Location += '&sitesearch=';
//            Location += '&sa=Google+Search';
//            Location += '&client=ca-test';
//            Location += '&forid=1';
//            Location += '&ie=UTF-8';
//            Location += '&oe=UTF-8';
//            Location += '&cof=GALT%3A%23008000%3BGL%3A1%3BDIV%3A%23336699%3BVLC%3A663399%3BAH%3Acenter%3BBGC%3AFFFFFF%3BLBGC%3A336699%3BALC%3A0000FF%3BLC%3A0000FF%3BT%3A000000%3BGFNT%3A0000FF%3BGIMP%3A0000FF%3BFORID%3A11';
//            Location += '&hl=en';
//            //document.write(Location);
//			//----------------
//		    var w = screen.availWidth-10;
//			var h = screen.availHeight-10;
//			window.open(Location,'','width=' + w + ',height=' + h + ',scrollbars=yes,resizable=yes,titlebar=1,top=0,left=0');
//    }
//    else
//    {
//        checkEmail();
//    }
    var txtSearch = AdFindObjectID('txtSearch').value;
    if (txtSearch!='')
    {
        window.open("http://www.google.com/search?hl=en&output=FPT_Telecom&q=" + txtSearch); 
    }
    else
    {
        checkEmail();
    }
}
//-----------------------------------------------
function checkEmail()
{
    var username = AdFindObjectID('mailbox').value;
    var ext = AdFindObjectID("cboLoc").value;
    if (username!='username'&&username!='')
    {
        if (ext=='@fpt.vn')
            window.open("http://isp-mail.fpt.vn/exchange/logonFrm.asp?isnewwindow=0&mailbox=" + username + ext); 
        else
            window.open("http://isp-mail.hcm.fpt.vn/exchange/logonFrm.asp?isnewwindow=0&mailbox=" + username + ext); 
    }
}
//-----------------------------------------------
function SetBlockAd2(strName)
{
    var arrAdTabSub = new Array('NhacSo','Iptv','Mobione','PhimAnh');
    for(it=0;it<4;it++)
    {
        AdFindObjectID("Tab" + arrAdTabSub[it]).style.display = "none";
        try
        {
            AdFindObjectID("Div" + arrAdTabSub[it]).style.display = "none";
            AdFindObjectID(arrAdTabSub[it]).className = "tabgrey"; 
        }
        catch(error)
        {}
    }
    //-----------------
    AdFindObjectID("Tab" + strName).style.display = "block";
    try
    {
        AdFindObjectID("Div" + strName).style.display = "block";
        AdFindObjectID(strName).className = "tabgreen";
    }
    catch(error)
    {}
}
//-----------------------------------------------
var itCurrent = Math.floor(Math.random() * 4);
function SetBlockMasterAdRandom()
{
    SetBlockMasterAd2(itCurrent);
}
//-----------------------------------------------
function SetBlockMasterAd2(ArrayInt)
{
    var arrAdTabSub = new Array('NhacSo','Iptv','Mobione','PhimAnh');
    SetBlockAd2(arrAdTabSub[ArrayInt]);
}
//-----------------------------------------------
function SetBlockMaster(count)
{
    if (itCurrent==3 && count==1)
        itCurrent = -1;
    else if (itCurrent==0 && count==-1)
        itCurrent = 4;
    itCurrent += count;
    SetBlockMasterAd2(itCurrent);
}