﻿/**
 * Common JS Function
 * 
 * http://awas.com.vn
 * http://awas.vn
 * 
 * Copyright (c) 2010 AWAS JSC - NGUYEN DUC KHANH
 *
 */
function popup (name,width,height) { 
     var options = "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width="+width+",height="+height; 
     Cal2=window.open(name,"popup",options); 
}

function popup2 (name,width,height) { 
     var options = "toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1, width="+width+",height="+height; 
     Cal2=window.open(name,"popup",options); 
}

function _showGroup(id, c_show, c_hide)
{
	_showElement(id)
	_showElement(c_hide)
	_hideElement(c_show)
}

function _hideGroup(id, c_show, c_hide)
{
	_hideElement(id)
	_hideElement(c_hide)
	_showElement(c_show)
}

function _showElement(id)
{
	var element = document.getElementById(id);
	if(!element) return;
	var style = element.style;
	if(!style) return;
	style.display = "";
}

function _hideElement(id)
{
	var element = document.getElementById(id);
	if(!element) return;
	var style = element.style;
	if(!style) return;
	style.display = "none";
}

function to_delete_url(url)
{
    if(confirm('do you really want to delete?'))
        window.location.href=url;
}

// drag - drop
function portletsInZone(zoneid)
{
    var zone = document.getElementById(zoneid);
    if(zone){
        var children = "";
        var els = zone.getElementsByTagName("DIV");
        var elsLen = els.length;
        for (i = 0, j = 0; i < elsLen; i++) {
            if (els[i].className == "itemHeader" ) {
                var n = els[i].innerHTML.split("_");
                children += n[1] + ",";
            }
        }
        return children;
    }
    
    return "";
}

function searching()
{
    var kw = document.getElementById("tukhoa");
    document.location.href = "/search.aspx?w=" + kw.value;
}

function thanglong1000()
{
    today=new Date();
    var thanglong = new Date(today.getFullYear(), 9, 10) //Month is 0-11 in JavaScript
    if (today.getMonth()==9 && today.getDate()>10) //if Christmas has passed already
        thanglong.setFullYear(thanglong.getFullYear()+1); //calculate next year's Christmas
    //Set 1 day in milliseconds
    var one_day=1000*60*60*24;
    //Calculate difference btw the two dates, and convert to days
    document.write(Math.ceil((thanglong.getTime()-today.getTime())/(one_day)));
}
