// JavaScript Document
var siteRoot = "";

function popWindow( url, width, height, windowName ) {
    //get center coords
    var left = (screen.width - width) / 2;
    var top = (screen.height - height) / 2;
	newwindow = window.open(url, windowName, 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=' + width + ',height=' + height + ',left=' + left + ',top=' + top);
}

function popSignup(){
	popWindow("etqw_signup.htm", 540, 570, "signup");
}
function popIM(lang){
	popWindow("im/etqw_im.html?language="+lang, 540, 570, "aim");
}
function popPreorder(){
	popWindow("preorder/popup_preorder.html", 453, 580, "preorder");
}

function popWall(imgpath, w, h, lang){
	//popWindow(_root + "wallpaper.html?image="&imgpath, 800, 600, "wallpaper");
	var url = siteRoot + "wallpaper.html?image=" + imgpath + "&language="+lang;
	var windowName = "wallpaper"
	var width = w;
	var height = h;
	var left = (screen.width - width) / 2;
	var top = (screen.height - height) / 2;
	newwindow = window.open(url, windowName, 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=' + width + ',height=' + height + ',left=' + left + ',top=' + top);
}

function popSS(imgpath, desc){
	//popWindow(imgpath, 1024, 768, "ss");
	popWindow("popup_ss.html?image=" + imgpath + "&desc=" + desc, 1024, 768, "ss");
}

function newWindow(url){
	newwindow = window.open(url);
}

function saveFile(file){
	file = "_swf/_videos/" + file;
	newwindow = window.open(file, 'file');
	window.close('file');
}

function popVideo(file, w, h, ftype){
	var cid = "";
	file = "_swf/_videos/" + file;
	var url= siteRoot + "/video.html?msizeW="+w+"&msizeH="+h+"&country="+cid+"&type="+ftype+"&movie="+file;
	popWindow(url, 490,  400, 'video');
}



function popQT(file, w, h, ftype){
	popVideo(file, w, h, ftype);
}

function popAVI(file, w, h, ftype){
	popVideo(file, w, h, ftype);
}

function popIPOD(file, w, h, ftype){
	popVideo(file, w, h, ftype);
}

function popPSP(file, w, h, ftype){
	popVideo(file, w, h, ftype);
}


//**********************************************************************
// COOKIE STUFF
//**********************************************************************

// return expiration date
function getExpDate(days, hours, minutes) {
    var expDate = new Date();
    if (typeof days == "number" && typeof hours == "number" && typeof hours == "number") {
        expDate.setDate(expDate.getDate() + parseInt(days));
        expDate.setHours(expDate.getHours() + parseInt(hours));
        expDate.setMinutes(expDate.getMinutes() + parseInt(minutes));
        return expDate.toGMTString();
    }
}
// get cookie
function getCookie( name )
{
  var start = document.cookie.indexOf( name + "=" );
  var len = start + name.length + 1;
  if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
    return null;
  }
  if ( start == -1 ) return null;
  var end = document.cookie.indexOf( ";", len );
  if ( end == -1 ) end = document.cookie.length;
  return unescape( document.cookie.substring( len, end ) );
}

// set cookie
function setCookie( name, value, expires, path, domain, secure )
{
  var today = new Date();
  today.setTime( today.getTime() );
  if ( expires ) {
    expires = expires * 1000 * 60 * 60 * 24;
  }
  var expires_date = new Date( today.getTime() + (expires) );
  document.cookie = name+"="+escape( value ) +
    ( ( expires ) ? ";expires="+expires_date.toGMTString() : "" ) + //expires.toGMTString()
    ( ( path ) ? ";path=" + path : "" ) +
    ( ( domain ) ? ";domain=" + domain : "" ) +
    ( ( secure ) ? ";secure" : "" );
}

// delete cookie
function deleteCookie( name, path, domain ) 
{
  if ( getCookie( name ) ) document.cookie = name + "=" +
    ( ( path ) ? ";path=" + path : "") +
    ( ( domain ) ? ";domain=" + domain : "" ) +
    ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}


