//Tips functions
var oldText;
var tipObj;
var tipFlag=false;



function tipOff(){
   if(this.tipFlag){
      this.tipObj.style.position="static";
      this.tipObj.innerHTML=this.oldText;
      this.tipFlag=false;
   }
   //return false;
}

function tipOn(obj,tipText){   
   if(!this.tipFlag){
      tipText=tipText.replace("-b-","<b>");
      tipText=tipText.replace("-/b-","</b>");
      tipText=tipText.replace("-br-","<br />");
      this.tipObj=obj;
      this.oldText = obj.innerHTML;   
      obj.style.position="relative";
      obj.innerHTML+= "<div class=\"tip\" id=\"tipId\">"+tipText+"</div>";	      
      this.tipFlag=true;
   }    
}

function popup(href,width,height,target){
      window.open(href, target, config='width='+width+',height='+height+',toolbar=0,resizable=1,menubar=0,status=0');
   }

function goThere(){
	var list = document.forms[0].urlList;
	location = list.options[list.selectedIndex].value;
}

//banners block start
//var current = Math.floor(Math.random()*3+1);
var current = 3;
//var current = 1;
var previous;
var last;
current == 1 ? previous = 3 : previous = current-1;
var idTimer;
var id;



function again(){
   idTimer=setTimeout('rotate()',1000);
}

function rotate(){
   current++; 
   if(current>3) current=1;
   document.getElementById('banner'+previous).style.display='none';
   document.getElementById('banner'+current).style.display='block';   
   previous=current; 
   idTimer = setTimeout('rotate()',5000);      
}

function freeze(id){    
   clearTimeout(idTimer);      
   //debug("freeze:"+id+"; hide: "+current+"; none: "+previous);   
   document.getElementById('banner'+current).style.display='none';
   //document.getElementById('banner'+current).style.zIndex=2;
   current=id;
   //alpha('banner'+id,0);
   document.getElementById('banner'+id).style.display='block';      
   //document.getElementById('banner'+id).style.zIndex=3;
   //fadeIn('banner'+id,0);   
   previous = id;   
}

function alpha(id, value) {
   document.getElementById(id).style.opacity = value/100; //Opera & FF
   document.getElementById(id).style.filter = 'alpha(opacity=' + value*1 + ')'; // IE
}

function fadeIn(id,aIn){
   if(aIn<=100){
      aIn+=10;
      alpha(id, aIn);
	  setTimeout('fadeIn(\''+id+'\','+aIn+')',10);
   }
}

function fadeOut(id){
   this.id = id;
   if(a>=50){
      alpha(this.id, a);
	  a-=1+100;
	  setTimeout('fadeIn(id)',10);
   }
}

function debug(msg){   
   document.getElementById('debug').innerHTML="Debug("+new Date().getSeconds()+"): "+msg+" ";
}
//banners block end



//colored table rows
function alternationRows(table){
   //alert("êðàñèì!");
   var table;
   var dom;
   if(document.getElementById(table).childNodes[0].nodeType!=3){
      table = document.getElementById(table).childNodes[0].childNodes;
	  dom = false;
   }else{
      table = document.getElementById(table).childNodes[1].childNodes;
	  dom = true;
   }
   //alert(table[0].nodeType);
   if(!dom){
      for(var i=0;i<table.length;i++){
		 if(i%2==0){
  	        table[i].className="dark";
		 }else{
		    table[i].className="light";
		 }
      }
   }else{
      var prev = "light";
      for(var i=0;i<table.length;i++){
	     if(table[i].nodeType!=3){
		 if(prev=="light"){
            table[i].className="dark";
			prev="dark";
		 }else{
		    table[i].className="light";
			prev="light";
		 }	     
		 }
      }
   }
}


// Google Analitics Electronic commerce function

function commerce(shop, price, name, category){
	/*
	if(shop == "SoftKey") price = Math.round(price / 26);
	if(shop == "Softkey") price = Math.round(price / 26);
	if(shop == "Allsoft") price = Math.round(price / 26);
	if(shop == "AllSoft") price = Math.round(price / 26);
	if(shop == "Mobile2Day") price = Math.round(price * 1.3);
	if(shop == "Mobile2day") price = Math.round(price * 1.3);http://cms.paragon-software.com/system/workplace/editors/editor_main.jsp?resource=%2Finc%2Ffunctions.js#
	*/
	var trans  = "UTM:T|000|" + shop + "|" + price + "|0.00|00.00|New York|CA|USA\n";
		trans += "UTM:I|000|XXX000|" + name + "|" + category + "|" + price + "|1";
	
	document.getElementById("utmtrans").value = trans;
	
	__utmSetTrans();
	
	}
//
// подсветка для фич и фака
//
var currentItem;
function hightlightItem(id){
   obj = document.getElementById(id);
   obj.className="featuresHightlight";
   currentItem=obj;   
   setTimeout('unlight()',5000);
}
function unlight(){
   if(obj){
      obj.className="";
      currentItem=null;
   }
}


// Google Analitics transactions
function funcGoogle(shortName,productName,category,price){

time=new Date();
var dates = time.getDate();
if (dates<10) {dates="0"+dates;}
var month = time.getMonth()+1;
if (month<10) {month="0"+month;}
var seconds = time.getSeconds();
if (seconds<10) {seconds="0"+seconds;}
var minutes = time.getMinutes();
if (minutes<10) {minutes="0"+minutes;}
var hours = time.getHours();
if (hours<10) {hours="0"+hours;}
var OrderId = dates +""+ month +"0"+ (time.getYear()-100) +""+ hours +""+ minutes +""+ seconds;

pageTracker._addTrans(
   OrderId,                           
   "",                       
   price,                       
   "0.0",                              
   "0",                      
   "",              
   "",          
   ""                                 
 );

 pageTracker._addItem(
   OrderId,                                  
   shortName,                                   
   productName,                         
   category,                         
   price,                                    
   "1"                                      
 );

 pageTracker._trackTrans(); 
}


//screenshots functions
function showScreen(obj){
        c = document.getElementById("screens_container");
        c.style.display='block';
        
        img = document.getElementById("big_screen");
        img.src = obj.href;
        
        b = document.getElementById("screens_body");
        b.style.width=img.width+ 64;
        b.style.height=img.height + 38;
        //alert(img.width + " x "+ img.height);
    
    }
    

    function scr_close(){
        c = document.getElementById("screens_container");
        c.style.display='none';
    }
