/**************************************************
*      Digital Trend Commerce                     *
*   www.dtcreative.net ¦ landier@dtcreative.net   *
**************************************************/

var MESSDEF='';

function classid(EID,newClass)
{
  if(document.getElementById(EID))
  {
    document.getElementById(EID).className=newClass;
  }
}

//email cloak
function hiddenmail(EID,ADDR)
{
  if(document.getElementById(EID))
  {
    var ADDR=ADDR.replace(/_/,'@');
    document.getElementById(EID).innerHTML='<a href="mailto:'+ADDR+'">Contact</a>';
  }
}

//registration form states
function reg_form_cntry(COUNTRY,EID)
{
  if((COUNTRY=='AU') || (COUNTRY=='CA') || (COUNTRY=='IN') || (COUNTRY=='US'))
  {
    document.getElementById(EID).disabled=false;
    document.getElementById(EID).className='';
    
    load_ajax(EID,'states.php?cntry='+COUNTRY);
  }
  else
  {
    document.getElementById(EID).disabled=true;
    document.getElementById(EID).className='dis';
    document.getElementById(EID).innerHTML='';
  }
}

function se_form_cntry(COUNTRY,EID)
{
  if((COUNTRY=='AU') || (COUNTRY=='CA') || (COUNTRY=='IN') || (COUNTRY=='US'))
  {
    document.getElementById(EID).disabled=false;
    document.getElementById(EID).className='';
    
    load_ajax(EID,'states1.php?cntry='+COUNTRY);
  }
  else
  {
    document.getElementById(EID).disabled=true;
    document.getElementById(EID).className='dis';
    document.getElementById(EID).innerHTML='';
  }
}

function toggle_show(EID)
{
  if(document.getElementById('w'+EID).style.display=='none')
  {
    document.getElementById('w'+EID).style.display='block';
    document.getElementById('t'+EID).className='wish_titleo';
  }
  else
  {
    document.getElementById('w'+EID).style.display='none';
    document.getElementById('t'+EID).className='wish_title';
  }
}

function midscreen(objw,objh)
{
  var midscr=new Array();
  if( typeof( window.innerWidth ) == 'number' )
  {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  }
  else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
  {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  }
  else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
  {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  
  midscr['X']=Math.round((myWidth-objw)/2);
  midscr['Y']=Math.round((myHeight-objh)/2);
  
  return midscr;
}

function poperror(TITLE,SENTENCE,WIDTH,HEIGHT)
{
  var posraw=midscreen(WIDTH,HEIGHT);
  
  finalPosX=posraw['X'];
  finalPosY=posraw['Y'];
  
  if (document.all)
  {  
    var html='<div id="poperror" onclick="document.all[\'popmehere\'].innerHTML=\'\';" title="Click to close / Cliquez pour fermer"><div id="poperror_cont" style="width:'+WIDTH+'px;height:'+HEIGHT+'px;"><div id="poperror_title"style="width:'+WIDTH+'px;">'+TITLE+'</div><div id="poperror_sentence" align="justify"style="width:'+(WIDTH-10)+'px;height:'+(HEIGHT-30)+'px;">'+SENTENCE+'</div></div></div>';
    document.all['popmehere'].innerHTML=html;
  
    document.all['poperror_cont'].style.top=finalPosY+'px';
    document.all['poperror_cont'].style.left=finalPosX+'px';
  }
  else if (document.getElementById)
  {
    var html='<div id="poperror" onclick="document.getElementById(\'popmehere\').innerHTML=\'\';" title="Click to close / Cliquez pour fermer"><div id="poperror_cont" style="width:'+WIDTH+'px;height:'+HEIGHT+'px;"><div id="poperror_title"style="width:'+WIDTH+'px;">'+TITLE+'</div><div id="poperror_sentence" align="justify"style="width:'+(WIDTH-10)+'px;height:'+(HEIGHT-30)+'px;">'+SENTENCE+'</div></div></div>';
    document.getElementById('popmehere').innerHTML=html;
    
    document.getElementById('poperror_cont').style.top=finalPosY+'px';
    document.getElementById('poperror_cont').style.left=finalPosX+'px';
  }
}

function helpme(MESS)
{
  if(document.getElementById('adm_help'))
  {
    document.getElementById('adm_help').innerHTML=MESS;
  }
}
function help_reset()
{
  if(document.getElementById('adm_help'))
  {
    document.getElementById('adm_help').innerHTML=MESSDEF;
  }
}

function helpd(MESS)
{
  MESSDEF=MESS;
}

function load_ajax(EID,URL)
{
  var xhr_object = null;
  
  if(window.XMLHttpRequest)
  {
    xhr_object = new XMLHttpRequest();
  }
  else if(window.ActiveXObject)
  {
    xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
  }
  else
  {
    //alert("Can't load AJAX engine!");
    return;
  }
  
  xhr_object.open("GET",URL,true);
  
  
  xhr_object.onreadystatechange = function() {
    if((xhr_object.readyState==4) && (xhr_object.status == 200))
    {
      document.getElementById(EID).innerHTML = xhr_object.responseText;
      
      //debug
      //alert(xhr_object.responseText);
    }
  }
  
  xhr_object.send(null);
}

function my_tools(EID)
{
  if(document.getElementById(EID))
  {
    if(EID=='poptool_vid')
    {
      document.getElementById('poptool_pic').style.display='none';
    }
    else
    {
      document.getElementById('poptool_vid').style.display='none';
    }
    
    if((document.getElementById(EID).style.display=='none') || (document.getElementById(EID).style.display==''))
    {
      document.getElementById(EID).style.display='block';
    }
    else
    {
      document.getElementById(EID).style.display='none';
    }
  }
}
