/* This source has been formatted by an unregistered SourceFormatX */
/* If you want to remove this info, please register this shareware */
/* Please visit http://www.textrush.com to get more information    */

function newWindow(mypage, myname, w, h, features){
  if (screen.width){
    var winl = (screen.width-w)/2;
    var wint = (screen.height-h)/2;
  }
  else{
    winl = 0;
    wint = 0;
  }
  if (winl < 0)
    winl = 0;
  if (wint < 0)
    wint = 0;
  var settings = 'height=' + h + ',';
  settings += 'width=' + w + ',';
  settings += 'top=' + wint + ',';
  settings += 'left=' + winl + ',';
  settings += features;
  win = window.open(mypage, myname, settings);
  win.window.focus();
}
function ShowPrice(price, index, active, unit)
{
  var currencies = new Array("vnd", "sjc", "usd");
  for (var i in currencies)
  {
    var obj = document.getElementById(currencies[i] + index);
    if (currencies[i] == active)
      obj.className = "selected " + currencies[i];
    else
      obj.className = currencies[i];
    if (IsNumeric(price))
      document.getElementById("price" + index).innerHTML = price + " <span class='date'>" + unit + "</span>";
    else
      document.getElementById("price" + index).innerHTML = price;
  }
}
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 addbookmark()
{
  bookmarkurl = "http://www.diaocdothi.com/";
  bookmarktitle = "Chuyên trang địa ốc đô thị";
  if (document.all)
    window.external.AddFavorite(bookmarkurl, bookmarktitle);
}

function bookmark(url,title){
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
  window.external.AddFavorite(url,title);
  } else if (navigator.appName == "Netscape") {
    window.sidebar.addPanel(title,url,"");
  } else {
    alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
  }
}

function ImgChange(strImgId, strPathSmall, strAId, strPathLarge)
{
  document.getElementById(strImgId).src = strPathSmall;
  document.getElementById(strAId).title = "cssbody=[dvbdy2] cssheader=[dvhdr1] header=[] body=[<img src=\"" + strPathLarge + "\" style=\"width:356px;height:308px\">]"
}
function FormatNumber(str){
  var strTemp = GetNumber(str);
  if (strTemp.length <= 3)
    return strTemp;
  strResult = "";
  for (var i = 0; i < strTemp.length; i++)
    strTemp = strTemp.replace(",", "");
  for (var i = strTemp.length; i >= 0; i--)
  {
    if (strResult.length > 0 && (strTemp.length-i-1) % 3 == 0)
      strResult = "," + strResult;
    strResult = strTemp.substring(i, i + 1) + strResult;
  }
  return strResult;
}
function GetNumber(str)
{
  for (var i = 0; i < str.length; i++)
  {
    var temp = str.substring(i, i + 1);
    if (!(temp == "," || temp == "." || (temp >= 0 && temp <= 9)))
    {
      alert("Vui lòng nhập số (0-9)!");
      return str.substring(0, i);
    }
    if (temp == " ")
      return str.substring(0, i);
  }
  return str;
}
function IsNumberInt(str)
{
  for (var i = 0; i < str.length; i++)
  {
    var temp = str.substring(i, i + 1);
    if (!(temp == "," || temp == "." || (temp >= 0 && temp <= 9)))
    {
      alert("Vui lòng nhập số (0-9)!");
      return str.substring(0, i);
    }
    if (temp == " " || temp == ",")
      return str.substring(0, i);
  }
  return str;
}
function ConvertPriceText(strTemp)
{
  strTemp = strTemp.replace(/, /g, "");
  var priceTy = parseInt(strTemp/1000000000, 0)
  var priceTrieu = parseInt((strTemp % 1000000000)/1000000, 0)
  var priceNgan = parseInt(((strTemp % 1000000000)) % 1000000/1000, 0)
  var priceDong = parseInt(((strTemp % 1000000000)) % 1000000 % 1000, 0)
  var strTextPrice = ""
  if (priceTy > 0 && parseInt(strTemp, 0) > 900000000)
  strTextPrice = strTextPrice + "<b>" + priceTy + "</b> tỷ "
    if (priceTrieu > 0)
  strTextPrice = strTextPrice + "<b>" + priceTrieu + "</b> triệu "
      if (priceNgan > 0)
  strTextPrice = strTextPrice + "</b>" + priceNgan + "</b> ngàn "
  if (document.getElementById("tiente").value == "0")
  {
    if (priceTy > 0 || priceTrieu > 0 || priceNgan > 0 || priceDong > 0)
    strTextPrice = strTextPrice + "<b>VNĐ</b>"
  }
  if (document.getElementById("tiente").value == "1")
  {
    if (priceDong > 0)
    strTextPrice = strTextPrice + priceDong 
      if (priceTy > 0 || priceTrieu > 0 || priceNgan > 0 || priceDong > 0)
    strTextPrice = FormatNumber(strTemp) + "<b> lượng SJC</b>"
  }
  if (document.getElementById("tiente").value == "2")
  {
    if (priceDong > 0)
    strTextPrice = strTextPrice + priceDong 
      if (priceTy > 0 || priceTrieu > 0 || priceNgan > 0 || priceDong > 0)
    strTextPrice = FormatNumber(strTemp) + "<b> USD</b>"
  }
  document.getElementById("priceText").innerHTML = strTextPrice 
}
// Kiểm tra tính hợp lệ của email
function isEmail(str) {
  var filter=/^.+@.+\..{2,3}$/
  return filter.test(str);
} 
// Mở một của sổ mới
function new_window(url, width, height){
  window.open(url, "new_window", "width=" + width + ", height=" + height + ", resizable=1,scrollbars=yes");
}
function viewsign(id){
  window.open("viewsign.php?id=" + id, "new_window", "width=350,height=300,resizable=1,scrollbars=yes");
}
function openLarge(URL, W, H){
  hWindow = window.open("popup.php?" + URL, "Large", "toolbar=no,width=" + W + ",height=" + H + ",status=no,scrollbars=auto,resize=yes,menubars=no");
}
function display(file){
  document.getElementById("display_img").src = file;
  document.getElementById("display_image").href = file;
  document.getElementById("display_image1").href = file;
}
//Highlight image script- By Dynamic Drive
function makevisible(cur, which){
  strength = (which == 0) ? 0.6 : 1 
  if (cur.style.MozOpacity)
  cur.style.MozOpacity = strength 
  else if (cur.filters)
  cur.filters.alpha.opacity = strength*100 
}
/***********************************************
 * AnyLink Drop Down Menu- © Dynamic Drive (www.dynamicdrive.com)
 * This notice MUST stay intact for legal use
 * Visit http://www.dynamicdrive.com/ for full source code
 ***********************************************/
//Contents for menu 1
var menu = new Array()
menu[0] = '<a href="company_personal.php?iVIP=2">Doanh nghiệp</a>'
menu[1] = '<a href="company_personal.php?iVIP=3">Cá nhân</a>'
var menuwidth = '165px' //default menu width
var menubgcolor = 'lightyellow' //menu bgcolor
var disappeardelay = 250  //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick = "yes" //hide menu when user clicks within menu?
/////No further editting needed
var ie4 = document.all 
var ns6 = document.getElementById && !document.all 
  if (ie4 || ns6)
document.write('<div id="dropmenudiv" style="visibility:hidden;width:' + menuwidth + ';background-color:' + menubgcolor + '" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')
function getposOffset(what, offsettype){
  var totaloffset = (offsettype == "left") ? what.offsetLeft : what.offsetTop;
  var parentEl = what.offsetParent;
  while (parentEl != null){
    totaloffset = (offsettype == "left") ? totaloffset + parentEl.offsetLeft: totaloffset + parentEl.offsetTop;
    parentEl = parentEl.offsetParent;
  }
  return totaloffset;
}
function showhide(obj, e, visible, hidden, menuwidth){
  if (ie4 || ns6)
  dropmenuobj.style.left = dropmenuobj.style.top = "-500px"
  if (menuwidth != ""){
    dropmenuobj.widthobj = dropmenuobj.style 
    dropmenuobj.widthobj.width = menuwidth 
  }
  if (e.type == "click" && obj.visibility == hidden || e.type == "mouseover")
  obj.visibility = visible 
  else if (e.type == "click")
  obj.visibility = hidden 
}
function iecompattest(){
  return (document.compatMode && document.compatMode != "BackCompat") ? document.documentElement : document.body 
}
function clearbrowseredge(obj, whichedge){
  var edgeoffset = 0 
  if (whichedge == "rightedge"){
    var windowedge = ie4 && !window.opera ? iecompattest().scrollLeft + iecompattest().clientWidth-15: window.pageXOffset + window.innerWidth-15 
    dropmenuobj.contentmeasure = dropmenuobj.offsetWidth 
    if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
    edgeoffset = dropmenuobj.contentmeasure-obj.offsetWidth 
  }
  else{
    var topedge = ie4 && !window.opera ? iecompattest().scrollTop: window.pageYOffset 
    var windowedge = ie4 && !window.opera ? iecompattest().scrollTop + iecompattest().clientHeight-15: window.pageYOffset + window.innerHeight-18 
    dropmenuobj.contentmeasure = dropmenuobj.offsetHeight 
    if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){
      //move up?
      edgeoffset = dropmenuobj.contentmeasure + obj.offsetHeight 
      if ((dropmenuobj.y-topedge) < dropmenuobj.contentmeasure)
      //up no good either?
      edgeoffset = dropmenuobj.y + obj.offsetHeight-topedge 
    }
  }
  return edgeoffset 
}
function populatemenu(what){
  if (ie4 || ns6)
  dropmenuobj.innerHTML = what.join("")
}

function dropdownmenu(obj, e, menucontents, menuwidth){
  if (window.event)
  event.cancelBubble = true 
  else if (e.stopPropagation)
  e.stopPropagation()
  clearhidemenu()
  dropmenuobj = document.getElementById ? document.getElementById("dropmenudiv"): dropmenudiv 
  populatemenu(menucontents)
  if (ie4 || ns6){
    showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
    dropmenuobj.x = getposOffset(obj, "left")
    dropmenuobj.y = getposOffset(obj, "top")
    dropmenuobj.style.left = dropmenuobj.x-clearbrowseredge(obj, "rightedge") + "px"
    dropmenuobj.style.top = dropmenuobj.y-clearbrowseredge(obj, "bottomedge") + obj.offsetHeight + "px"
  }
  return clickreturnvalue()
}
function clickreturnvalue(){
  if (ie4 || ns6)
  return false 
  else
  return true 
}
function contains_ns6(a, b){
  while (b.parentNode)
    if ((b = b.parentNode) == a)
      return true;
  return false;
}
function dynamichide(e){
  if (ie4 && !dropmenuobj.contains(e.toElement))
  delayhidemenu()
  else if (ns6 && e.currentTarget != e.relatedTarget && !contains_ns6(e.currentTarget, e.relatedTarget))
  delayhidemenu()
}
function hidemenu(e){
  if (typeof dropmenuobj != "undefined"){
    if (ie4 || ns6)
    dropmenuobj.style.visibility = "hidden"
  }
}
function delayhidemenu(){
  if (ie4 || ns6)
  delayhide = setTimeout("hidemenu()", disappeardelay)
}
function clearhidemenu(){
  if (typeof delayhide != "undefined")
  clearTimeout(delayhide)
}
  if (hidemenu_onclick == "yes")
document.onclick = hidemenu
