/*
 * name:	visual.js
 * desc:	visual objects implementation
 *
 * version: 1.0.0 IE
 */

 TM_MY_ALERT_CREATED = false;
 
 // Set window pos. to central and show this
 function showWindow ( )
 {
   with (this.style)
   {
	 zIndex = 5000;
	 if (typeof(this.effectOn)!="undefined"&&this.effectOn!=null)
	 {
	   if ((typeof(this.effect)!="undefined"&&this.effect!=null)&&this.effectOn)
	   {
	     this.effect();
	   }
	   else
	   {
	     visibility = "visible";	 
	   }
	 }
	 else
	 {
           visibility = "visible";	 
	 }
   }
 }
 
 function hideWindow ( )
 {
   with (this.style)
   {
	 if (typeof(this.effectOn)!="undefined"&&this.effectOn!=null)
	 {
	   if ((typeof(this.effect)!="undefined"&&this.effect!=null)&&this.effectOn)
	   {
	     this.effect();
	   }
	   else
	   {
	     visibility = "hidden";	 
	   }
	 }
	 else
	 {
           visibility = "hidden";	 
	 }
   }
 }
 
 // set window size to "w"x"h"
 function setWindowSize ( w, h )
 {
   with (this.style)
   {
     pixelWidth = w;
     pixelHeight = h;
   }
   this.width = w;
   this.height = h;
   if ( this.style.visibility == "visible" )
   {
	 showWindow();
   }
 }

 function windowMoveTo ( x, y )
 {
   with (this.style)
   {
     pixelLeft = x;
	 pixelTop  = y;
   }
 }

 function windowPotty ()
 {
   if (typeof(this.effectInitialized)=="undefined"||this.effectInitialized==null)
   {
     this.moveTo(this.style.pixelLeft,-this.style.pixelHeight);
	 this.effectCurrentPhase = 0;
	 this.effectPhase = 15;
	 this.effectInitialized = true;
	 this.style.visibility = "visible";
	 this.setTimeout( "this.effect()", 20 );
   }
   else
   {
     if (this.effectCurrentPhase<this.effectPhase&&(!this.hideStart||typeof(this.hideStart)=="undefined"||this.hideStart==null))
     {
       this.effectCurrentPhase++;
  	   this.moveTo(this.style.pixelLeft,
	             document.body.scrollTop-this.style.pixelHeight+
		  		 Math.round(Math.sin(Math.PI/180*(90/this.effectPhase*this.effectCurrentPhase))*((document.body.clientHeight-this.style.pixelHeight)/2+this.style.pixelHeight)));
	   if (this.effectCurrentPhase<this.effectPhase) this.setTimeout( "this.effect()", 20 );
     }
	 else
	 {
	   this.hideStart = true;
	   this.effectCurrentPhase--;
  	   this.moveTo(this.style.pixelLeft,
	             document.body.scrollTop-this.style.pixelHeight+
		  		 Math.round(Math.sin(Math.PI/180*(90/this.effectPhase*this.effectCurrentPhase))*((document.body.clientHeight-this.style.pixelHeight)/2+this.style.pixelHeight)));
	   if (this.effectCurrentPhase>0) 
	   {
	     this.setTimeout( "this.effect()", 20 );
	   }
	   else
	   {
	     this.style.visibility = "hidden";
	     this.hideStart = false;
	   }
	 }
   }
 }
 
 function windowMoveCentral ()
 {
   with (this.style)
   {
     position = "absolute";
     myWidth = pixelWidth;
	 myHeight = pixelHeight;
	 cWidth = document.body.clientWidth;
	 cHeight = document.body.clientHeight;
	 
     this.moveTo ( Math.round( ( cWidth - myWidth ) / 2 + 0.5 ), document.body.scrollTop+Math.round( ( cHeight - myHeight ) / 2 + 0.5 ) );
   }
 }
 
 function setWindowTitle ( title )
 {
   this.title = title;
 } 
 
 function setWindowText ( text )
 {
   this.text = text;
 }
 
 function drawWindowContent ()
 {
   this.document.write (
       '<link href="css/common.css" type=text/css rel=stylesheet>' +
	   '<table border="0" cellpadding="0" cellspacing="0" width="'+this.width+'"><tr>' +
	   '<td><img src="images/spacer.gif" width="'+(this.width-63)+'" height="1" border="0"></td>' +
	   '<td><img src="images/spacer.gif" width="63" height="1" border="0"></td>' +
	   '<td><img src="images/spacer.gif" width="1" height="1" border="0"></td></tr><tr>' +
	   '<td valign=top height="37" background="images/pan'+this.width+'_header_'+this.color+'_bg.jpg" colspan="2">' +
	   '<table border=0 width="'+this.width+'" cellpadding=2 cellspacing=0><tr><td><font class="'+this.color+'Title">'+this.title+'</font></td></tr></table></td>' +
	   '<td><img src="images/spacer.gif" width="1" height="37" border="0"></td></tr><tr>' +
	   '<td height="'+(this.height-57)+'" valign="middle" align="center" colspan="2" background="images/pan'+this.width+'_body_'+this.color+'_bg.jpg">' +
	   '<table border=0 width="'+this.width+'" cellpadding=5 cellspacing=0><tr><td class="'+this.align+'PanelAlign">' +
	   '<font class="'+this.color+'Body">'+this.text+'</font></td></tr></table></td>' +
	   '<td><img src="images/spacer.gif" width="1" border="0"></td></tr><tr>' +
	   '<td><img name="pan'+this.width+'_navbuttonshift_'+this.color+'_bg" src="images/pan'+this.width+'_navbuttonshift_'+this.color+'_bg.jpg" width="'+(this.width-63)+'" height="19" border="0"></td>' +
	   '<td width=63 align=middle valign="middle" background="images/pan'+this.width+'_navbutton_'+this.color+'_bg.jpg">' +
	   '<img src="images/spacer.gif" border="0" width="5" height="1">' +
	   '<img onmouseup="window.hide();" onmouseout="this.style.cursor=\'default\'" onmouseover="this.style.cursor=\'hand\'" src="images/navbutton_ok_'+this.color+'.gif" border="0" width="16" height="10"></td>' +
	   '<td><img src="images/spacer.gif" width="1" height="19" border="0"></td>' +
	   '</tr></table>'
   );
 }
 
 function getOpLogoString ( logoId, name )
 {
   var id;
   var dir;
   var dispId;
   
   var retval = false;
   if (/^[a-zA-Z]{2}(\d{5})$/.test(logoId))
   {
     id  = RegExp.$1;
	 dir = id.slice(0,2);
	 retval = 
	   '\n<center>\n'+
	   '<b>A kiválasztott operátor logó:</b><p>'+
       '<table align="middel" border="0" cellpadding="0" cellspacing="0" width="86">\n'+
         '<tr>\n'+
           '<td><img src="images/spacer.gif" width="7" height="1" border="0"></td>\n'+
           '<td><img src="images/spacer.gif" width="72" height="1" border="0"></td>\n'+
           '<td><img src="images/spacer.gif" width="7" height="1" border="0"></td>\n'+
           '<td><img src="images/spacer.gif" width="1" height="1" border="0"></td>\n'+
         '</tr>\n'+
         '<tr>\n'+
          '<td colspan="3"><img name="logo_'+TB_MYPOPUP_COLOR+'_up_bg" src="images/logo_'+TB_MYPOPUP_COLOR+'_up_bg.jpg" width="86" height="7" border="0"></td>\n'+
          '<td><img src="images/spacer.gif" width="1" height="7" border="0"></td>\n'+
        '</tr>\n'+
        '<tr>\n'+
          '<td><img name="logo_'+TB_MYPOPUP_COLOR+'_left_bg" src="images/logo_'+TB_MYPOPUP_COLOR+'_left_bg.jpg" width="7" height="14" border="0"></td>\n'+
          '<td><img name="logo" src="oplogo/'+dir+'/'+id+'.gif" width="72" height="14" border="0"></td>\n'+
          '<td><img name="logo_'+TB_MYPOPUP_COLOR+'_right_bg" src="images/logo_'+TB_MYPOPUP_COLOR+'_right_bg.jpg" width="7" height="14" border="0"></td>\n'+
          '<td><img src="images/spacer.gif" width="1" height="14" border="0"></td>\n'+
          '</tr>\n'+
          '<tr>\n'+
            '<td valign="middle" align="middle" background="images/logo_'+TB_MYPOPUP_COLOR+'_foot_bg.jpg" colspan="3">'+logoId+'</td>\n'+
            '<td><img src="images/spacer.gif" width="1" height="20" border="0"></td>\n'+
          '</tr>\n'+
        '</table>\n'+
		'<br><table border=0>' +
		( name ? '<tr><td align="left">Neve:</td><td align="right"><b>'+name+'</b></td></tr>\n':'') +
		'<tr><td align="left">Kódja:</td><td align="right"><b>'+logoId+'</b></td></tr>\n' +
		'<tr><td colspan="2" align="center"><br>A logót megrendelheted, ha sms-ben elküldöd a <b>'+logoId+'</b> szöveget a <br><b>'+TM_SMS_NUMBER+'</b>,</br> számra. Vezetékes telefonról hívd a<br><b>'+TM_TEL_NUMBER+'</b><br> telefonszámot!</td></tr>' +
		'</table>';
   }
   return retval;
 }
 
 function getPicMsgString ( logoId, name )
 {
   var id;
   var dir;
   var dispId;
   
   var retval = false;
   if (/^[a-zA-Z]{2}(\d{6})$/.test(logoId))
   {
     id  = ''+RegExp.$1;
	 dir = id.slice(0,3);
	 retval =
	   '\n<center>\n'+
	   '<b>A kiválasztott képesüzenet:</b><p>'+
       '<table align="middel" border="0" cellpadding="0" cellspacing="0" width="86">\n'+
         '<tr>\n'+
           '<td><img src="images/spacer.gif" width="7" height="1" border="0"></td>\n'+
           '<td><img src="images/spacer.gif" width="72" height="1" border="0"></td>\n'+
           '<td><img src="images/spacer.gif" width="7" height="1" border="0"></td>\n'+
           '<td><img src="images/spacer.gif" width="1" height="1" border="0"></td>\n'+
         '</tr>\n'+
         '<tr>\n'+
          '<td colspan="3"><img name="logo_'+TB_MYPOPUP_COLOR+'_up_bg" src="images/logo_'+TB_MYPOPUP_COLOR+'_up_bg.jpg" width="86" height="7" border="0"></td>\n'+
          '<td><img src="images/spacer.gif" width="1" height="7" border="0"></td>\n'+
        '</tr>\n'+
        '<tr>\n'+
          '<td><img name="logo_'+TB_MYPOPUP_COLOR+'_left_bg" src="images/logo_'+TB_MYPOPUP_COLOR+'_left_bg.jpg" width="7" height="28" border="0"></td>\n'+
          '<td><img name="logo" src="picmsg/'+dir+'/'+id+'.gif" width="72" height="28" border="0"></td>\n'+
          '<td><img name="logo_'+TB_MYPOPUP_COLOR+'_right_bg" src="images/logo_'+TB_MYPOPUP_COLOR+'_right_bg.jpg" width="7" height="28" border="0"></td>\n'+
          '<td><img src="images/spacer.gif" width="1" height="28" border="0"></td>\n'+
          '</tr>\n'+
          '<tr>\n'+
            '<td valign="middle" align="middle" background="images/logo_'+TB_MYPOPUP_COLOR+'_foot_bg.jpg" colspan="3">'+logoId+'</td>\n'+
            '<td><img src="images/spacer.gif" width="1" height="20" border="0"></td>\n'+
          '</tr>\n'+
        '</table>\n'+
		'<br><table border=0>' +
		( name ? '<tr><td align="left">Neve:</td><td align="right"><b>'+name+'</b></td></tr>\n' : '' ) +
		'<tr><td align="left">Kódja:</td><td align="right"><b>'+logoId+'</b></td></tr>\n' +
		'<tr><td colspan="2" align="center"><br>A képesüzenetet megrendelheted, ha sms-ben elküldöd a <b>'+logoId+'</b> szöveget a <br><b>'+TM_SMS_NUMBER+'</b>,</br> számra. Vezetékes telefonról hívd a<br><b>'+TM_TEL_NUMBER+'</b><br> telefonszámot!</td></tr>' +
		'</table>';
   }
   return retval;
 }
