var ns4 = (document.layers) ? true : false;
var ns6 = ((document.getElementById)&&(!document.all)) ? true : false;
var ie4 = (document.all) ? true : false;

// detect platform
//var agent = navigator.userAgent.toLowerCase();

//var win = ((agent.indexOf("win") != -1) || (agent.indexOf("16bit") != -1)) ? true : false;
//var mac = (agent.indexOf("mac") != -1) ? true : false;
//var linux = (agent.indexOf("linux") != -1) ? true : false;

var toggle = 1;
var toggleh = 1;
var toggle_z = new Array();
function properties(obj) {
    var result = ""
    for (var i in obj) {
	result += obj.id + "." +
	i + " = " + obj[i] + "<BR>"
    }
    result += "<HR>"
    return result
}
function rollOn(num,serial)
{
    if( serial == 'h' )
	togglec = toggleh;
   else
   {
	if(toggle_z[serial])
		togglec = toggle_z[serial];
	else    
		togglec = toggle;	
    }
    if(ie4)
    {
	theObj = eval("document.all[\'li" + togglec + "_" + serial + "\']");
//	theObj1 = eval("document.all[\'li" + toggle + "d\']");
    }	
    if(ns6)
    {
	theObj = eval("document.getElementById(\'li" + togglec + "_" + serial + "\')");
//	theObj1 = eval("document.getElementById(\'li" + toggle + "d\')");
    }		
    theObj.className = '';
//    theObj1.className = '';
    if(ie4)
    {
	theObj = eval("document.all[\'li" + num + "_" + serial + "\']");
//	theObj1 = eval("document.all[\'li" + num + "d\']");
    }	
    if(ns6)
    {
	theObj = eval("document.getElementById(\'li" + num + "_" + serial + "\')");
//	theObj1 = eval("document.getElementById(\'li" + num + "d\')");
    }		
    theObj.className = 'current';
//    theObj1.className = 'current';
//    toggle = num;
    if( serial == 'h')
	toggleh = num;
    else
    {
	toggle = num;    	
	toggle_z[serial] = num;
    }
}

function rollOff(num)
{
//    if(document.images)
//		eval('document.images["imgTab'+num+'"].src='+'\'tab_off.gif\'');
}

function showHideLayer(i,serial)
{
	var i, serial, args, theObj, theObj1, theObj2, theObj3, vHeight, twice;
    args = showHideLayer.arguments;
	
    if( serial == 'h' )
    {
	togglec = toggleh;
	if (ie4 || ns6)
	{
    	    if(ie4)
	    {
        	theObj = eval("document.all[\'tab" + toggle + "_" + toggleh + "\']");
	    }    
    	    if(ns6)
	    {
        	theObj = eval("document.getElementById(\'tab" + toggle + "_" + toggleh + "\')");
	    }
    	    theObj.style.visibility = 'hidden';
    	    if(document.images)
        	rollOff(toggle);
    	    if(ie4)
        	theObj = eval("document.all[\'tab1_" + i + "\']");
    	    if(ns6)
        	theObj = eval("document.getElementById(\'tab1_" + i + "\')");
    	    if(theObj)
    	    {
            theObj.style.zindex = 10;
        	theObj.style.visibility = 'visible';
        	if(document.images)
            	    rollOn(1,i);
    	    }
	}
    // ns4 tab controls
	if(ns4)
	{
    	    theObj = eval("document.layers[\'tab" + toggle + "_" + toggleh + "\']");
    	    theObj.visibility="hide";
    	    rollOff(toggle);
    	    theObj = eval("document.layers[\'tab1_" + i + "\']");
    	    theObj.top = scrollTopbound;
    	    theObj.clip.top = 0;
    	    theObj.clip.bottom = 231;
    	    if(theObj)
    	    {
        	theObj.zindex = 10;
        	theObj.visibility="show";
        	if (theObj.document.height < 250)
            	    showSlider = 0;
        	else
            	    showSlider = 1;
        	if(document.images)
            	    rollOn(1,i);
    	    }
    	    objSlider.top = sliderTopbound;
	}
    }	
    else
    {    
	if(toggle_z[serial])
		togglec = toggle_z[serial];
	else
		togglec = toggle;
    }
    // ie4 & ns6 tab controls
	if (ie4 || ns6)
	{
    	    if(ie4)
	    {
        	theObj = eval("document.all[\'tab" + togglec + "_" + serial + "\']");
	    }    
    	    if(ns6)
	    {
        	theObj = eval("document.getElementById(\'tab" + togglec + "_" + serial + "\')");
	    }
    	    theObj.style.visibility = 'hidden';

    	    if(document.images)
        	rollOff(togglec);
    	    if(ie4)
	    {
        	theObj = eval("document.all[\'tab" + i + "_" + serial + "\']");
        	theObj1 = eval("document.all[\'tab" + 1 + "_" + serial + "\']");
        	theObj2 = eval("document.all[\'tab" + 2 + "_" + serial + "\']");
        	theObj3 = eval("document.all[\'tab" + 3 + "_" + serial + "\']");
        	theObj4 = eval("document.all[\'tab" + 4 + "_" + serial + "\']");
	    }
    	    if(ns6)
	    {
        	theObj = eval("document.getElementById(\'tab" + i + "_" + serial + "\')");
        	theObj1 = eval("document.getElementById(\'tab" + 1 + "_" + serial + "\')");
        	theObj2 = eval("document.getElementById(\'tab" + 2 + "_" + serial + "\')");
        	theObj3 = eval("document.getElementById(\'tab" + 3 + "_" + serial + "\')");
        	theObj4 = eval("document.getElementById(\'tab" + 4 + "_" + serial + "\')");
	    }
    	    if(theObj)
    	    {
            theObj.style.zindex = 10;
//        	theObj1.style.visibility = 'hidden';
//        	theObj2.style.visibility = 'hidden';
//        	theObj3.style.visibility = 'hidden';
//        	theObj4.style.visibility = 'hidden';
        	theObj.style.visibility = 'visible';
        	if(document.images)
            	    rollOn(i,serial);
    	    }
	}
    // ns4 tab controls
	if(ns4)
	{
    	    theObj = eval("document.layers[\'tab" + toggle + "_" + serial + "\']");
    	    theObj.visibility="hide";
    	    rollOff(toggle);
    	    theObj = eval("document.layers[\'tab" + i + "_" + serial + "\']");
    	    theObj.top = scrollTopbound;
    	    theObj.clip.top = 0;
    	    theObj.clip.bottom = 231;
    	    if(theObj)
    	    {
        	theObj.zindex = 10;
        	theObj.visibility="show";
        	if (theObj.document.height < 250)
            	    showSlider = 0;
        	else
            	    showSlider = 1;
        	if(document.images)
            	    rollOn(i,serial);
    	    }
    	    objSlider.top = sliderTopbound;
	}
}


function displayNoneLayer(i)
{
	var i, args, theObj, vHeight, twice;
    args = displayNoneLayer.arguments;
    // ie4 & ns6 tab controls
	if (ie4 || ns6)
	{
    	    if(ie4)
	    {
        	theObj = eval("document.all[\'tab" + toggleh + "_h\']");
	    }    
    	    if(ns6)
	    {
        	theObj = eval("document.getElementById(\'tab" + toggleh + "_h\')");
	    }
    	    theObj.style.display = 'none';
    	    if(document.images)
        	rollOff(toggleh);
    	    if(ie4)
        	theObj = eval("document.all[\'tab" + i + "_h\']");
    	    if(ns6)
        	theObj = eval("document.getElementById(\'tab" + i + "_h\')");
    	    if(theObj)
    	    {
            theObj.style.zindex = 10;
        	theObj.style.display = 'inline';
        	if(document.images)
            	    rollOn(i,'h');
    	    }
	    for(j=1;j<=3;j++)
	    {
		if(ie4)
		{
        	    theObj = eval("document.all[\'tab" + j + "_" + i+ "\']");
		}    
    		if(ns6)
		{
        	    theObj = eval("document.getElementById(\'tab" + j + "_" + i + "\')");
		}	
		if(theObj.style.visibility == 'visible')
		    toggle = j;
	    }
	}
    // ns4 tab controls
	if(ns4)
	{
    	    theObj = eval("document.layers[\'tab" + toggle + "_h\']");
    	    theObj.visibility="hide";
    	    rollOff(toggle);
    	    theObj = eval("document.layers[\'tab" + i + "_h\']");
    	    theObj.top = scrollTopbound;
    	    theObj.clip.top = 0;
    	    theObj.clip.bottom = 231;
    	    if(theObj)
    	    {
        	theObj.zindex = 10;
        	theObj.visibility="show";
        	if (theObj.document.height < 250)
            	    showSlider = 0;
        	else
            	    showSlider = 1;
        	if(document.images)
            	    rollOn(i,serial);
    	    }
    	    objSlider.top = sliderTopbound;
	}
}


var tim;
//MAC NETSCAPE move the pixels game
if (ns4) {
    if (mac) {
        var MacLeft = 0;
        var MacTop = -15;
    } else {
        var MacLeft = 0;
        var MacTop = 0;
    }
}
// netscape layer properties.
var scrollTopbound = 370 + MacTop;
var scrollBotbound = 180;
var nLayerHeight = 180;
var nLayerWidth = 440;
var nLayerLeft = 165 + MacLeft;
var scrollSpeed = 2;
var sliderTopbound = 343;
var sliderBotbound = 522;
var sliderHbound = 187;
//*

function AdjustHeight()
{
	// get objects
	var tabOne;
	tabOne = document.getElementById('tab1');
	var tabTwo;
	tabTwo = document.getElementById('tab2');
	var tabThree 
	tabThree = document.getElementById('tab3');
	var tabFour;
	tabFour = document.getElementById('tab4');
	var tabFive;
	tabFive = document.getElementById('tab5');
	var tabSix;
	tabSix = document.getElementById('tab6');
	// set to 0
	var maxHeight = 0;
	// find the tallest box
	if ((tabOne.offsetHeight >= tabTwo.offsetHeight) && (tabOne.offsetHeight >= tabThree.offsetHeight) && (tabOne.offsetHeight >= tabFour.offsetHeight) && (tabOne.offsetHeight >= tabFive.offsetHeight) && (tabOne.offsetHeight >= tabSix.offsetHeight))
		maxHeight = tabOne.offsetHeight;
	else if ((tabTwo.offsetHeight >= tabThree.offsetHeight) && (tabTwo.offsetHeight >= tabFour.offsetHeight) && (tabTwo.offsetHeight >= tabFive.offsetHeight) && (tabTwo.offsetHeight >= tabSix.offsetHeight))
		maxHeight = tabTwo.offsetHeight;
	else if ((tabThree.offsetHeight >= tabFour.offsetHeight) && (tabThree.offsetHeight >= tabFive.offsetHeight) && (tabThree.offsetHeight >= tabSix.offsetHeight))
		maxHeight = tabThree.offsetHeight;
	else if ((tabFour.offsetHeight >= tabFive.offsetHeight) && (tabFour.offsetHeight >= tabSix.offsetHeight))
		maxHeight = tabFour.offsetHeight;
	else if ((tabFive.offsetHeight >= tabSix.offsetHeight))
		maxHeight = tabFive.offsetHeight;
	else
		maxHeight = tabSix.offsetHeight;
	// add 30
	maxHeight += 30;	
	// set the height
	document.getElementById('TableBox').style.height = maxHeight + 'px';
}
function switch_text(num)
{
    if(document.getElementById)
    {
	theObj = eval("document.getElementById(\'heart_text_on" + num + "\')");
	theObj1 = eval("document.getElementById(\'heart_text_off" + num + "\')");
	if(theObj.style.visibility=='visible')
	{
	    theObj.style.visibility='hidden';
	    theObj1.style.visibility='visible';
	}
	else
	{
	    theObj.style.visibility='visible';
	    theObj1.style.visibility='hidden';
	}
    }		
    else if(document.all)	
    {
	theObj = eval("document.all(\'heart_text_on" + num + "\')");
	theObj1 = eval("document.all(\'heart_text_off" + num + "\')");
	if(theObj.style.visibility=='visible')
	{
	    theObj.style.visibility='hidden';
	    theObj1.style.visibility='visible';
	}
	else
	{
	    theObj.style.visibility='hidden';
	    thObj1.style.visibility='visible';
	}	
    }
}
function hidden_visible(layer,fl)
{
    if(document.getElementById)
    {
	if((document.getElementById(layer).style.display == 'inline' )&&(!fl))
	{
	    document.getElementById(layer).style.display = 'none';
	}
	else
	{
	    document.getElementById(layer).style.display = 'inline';
	}
    }
    else if(document.all)
    {
	if((document.all[layer].style.display == 'inline')&&(!fl))
	{
	    document.all[layer].style.display = 'none';
	}
	else
	{
	    document.all[layer].style.display = 'inline';
	}
    }
}
function hidden_visible1(layer,fl)
{
    if(document.getElementById)
    {
	if((document.getElementById(layer).style.display == 'inline' )&&(!fl))
	{
	    document.getElementById(layer).style.display = 'none';
	}
	else if(fl)
	{
	    document.getElementById(layer).style.display = 'inline';
	}
    }
    else if(document.all)
    {
    
	if((document.all[layer].style.display == 'inline')&&(!fl))
	{
	    document.all[layer].style.display = 'none';
	}
	else if(fl)
	{
	    document.all[layer].style.display = 'inline';
	}
    }
}
function change_className(name,id,user_id)
{
    for(i=0;i<17;i++)
    {
	if( i == id )
	{
	    eval("document.getElementById('"+name+i+"_"+user_id+"').className='post_card'");
	}    
	else
	{
	    eval("document.getElementById('"+name+i+"_"+user_id+"').className=''");    
	}    
    }
}
function ShowWin(image,L_Close)
{
    IMGW = window.open("",'_blank','HEIGHT=400,WIDTH=500');
    IMGW.document.write('<html><head>');
    IMGW.document.write('<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">');
    IMGW.document.write('</head>');    
    IMGW.document.write('<body>');    
    IMGW.document.write('<table width="100%">');
    IMGW.document.write('<tr>');    
    IMGW.document.write('<td>');        
    IMGW.document.write('<img src="'+image+'" >');
    IMGW.document.write('</td>');        
    IMGW.document.write('</tr>');        
    IMGW.document.write('<tr>');        
    IMGW.document.write('<td align="center">');        
    IMGW.document.write('<a href="javascript:window.close();">'+L_Close+'</a>');
    IMGW.document.write('</td>');        
    IMGW.document.write('</tr>');        
    IMGW.document.write('</table>');  
    IMGW.document.write('</body>');              
    IMGW.document.write('</html>');    
}

var postcards=Array(
'val1.jpg',
'val2.jpg',
'val3.jpg',
'val4.jpg',
'val5.jpg',
'val6.jpg',
'val7.jpg',
'val8.jpg',
'val9.jpg',
'val10.jpg',
'card1.jpg',
'card2.jpg',
'card3.jpg',
'card4.jpg',
'card5.jpg',
'card6.jpg',
'card7.jpg',
'card8.jpg',
'card9.jpg',
'card10.jpg',
'1089736598564230.jpg',
'148.gif',
'he18.jpg',
'he19.jpg',
'he5.jpg',
'Iloveyou.jpg',
'Imissyou.jpg',
'Ithinkaboutyou.jpg',
'kiss1.gif',
'lips.jpg',
'missyou20.jpg',
'rozaserdce.jpg',
'smile_card6.jpg',
'vps3.gif',
'womans_kiss.jpg',
'zverushki7.jpg',
'zzz08.jpg');

function print_postcards(id,L_Show,L_Close,num)
{
    var postcard,postcard_small;
    var i=0,j=0;
    len = postcards.length;
    for( i=0 ; i<len ; i++){
	postcard='/images/postcards/'+postcards[i];
	postcard_small='/images/postcards-small/'+postcards[i];
	document.write('<td><img id="card'+i+'_'+id+'" src="'+postcard_small+'" onClick="change_className(\'card\','+i+',\''+id+'\');document.forms[\'send_card'+id+'\'].message.value=\'<img src='+postcard+'>\';" height="70px"><br><a href="javascript:void(0);" onClick="ShowWin(\''+postcard+'\',\''+L_Close+'\');" class="gen">'+L_Show+'</a></td>');
	j++;
	if(!(j%num))document.write('</tr><tr>');
    }
}

