function fixPNG(element)
{
    if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent))
    {
        var src;
        
        if (element.tagName=='IMG')
        {
            if (/\.png$/.test(element.src))
            {
                src = element.src;
                element.src = "/images/login/blank.gif";
            }
        }
        else
        {
            src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i)
            if (src)
            {
                src = src[1];
                element.runtimeStyle.backgroundImage="none";
            }
        }
        
        if (src) element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
    }
}

function visible_forgotpassword() {
document.getElementById("forgotpassword").style.display = 'block';
}

function invisible_forgotpassword() {
document.getElementById("forgotpassword").style.display = 'none';

}

$(document).ready(function(){
						   
var marg = 0;
var privList = new Array();
var srcList = new Array();
var srcActiveList = new Array();
var srcFonList = new Array();
itemCont = $(".picCont");
itemImg = $(".picCont img");

var prRotCount = itemCont.size();; 
//alert(prRotCount);

$(".picCont img").each(function(i){
	//currentTitle = $(this).attr('alt');
	//currentSrc = $(this).attr('name');
	
	privList[i + 1] = $(this).attr('alt');	
	srcList[i + 1] = '/images/login/pic_' + $(this).attr('name') + '.gif';
	srcActiveList[i + 1] = '/images/login/act_pic_' + $(this).attr('name') + '.png';
	srcFonList[i + 1] = '/images/login/fon_' + $(this).attr('name') + '.jpg';
	
	$(this).attr('name', i);
	//
});


var prRan = Math.random();
prRan = Math.round(prRan * 10);
if(prRan == 0){prRan = 1};


//alert(prRan);
for(i = 0; i < (prRan - 7); i++){
	itemCont[i].style.display = 'none';
///alert(prRan);
marg++;
}

for(i = 0; i < prRotCount; i++){
		itemImg[i].src = srcList[i + 1];
        itemImg[i].style.filter = 'expression(fixPNG(this))';
        
		itemCont[i].style.background =  '#E1E1E1';
}

$("#pl_tit").html(privList[prRan]);

	itemImg[prRan].style.filter = 'expression(fixPNG(this))';
    itemCont[prRan - 1].style.background =  'none';
    itemImg[prRan - 1].src =  srcActiveList[prRan]; 
    document.getElementById('mainFon').style.background =  'url('+ srcFonList[prRan] + ') left top no-repeat';

//alert(prRotCount);
$("#right").click(function(i){
    last = marg + 7;
	if(last < prRotCount){
	itemCont[marg].style.display = 'none';
    marg++;
    }
});
$("#left").click(function(i){
	curr = marg - 1;
	if(curr >= 0){
	itemCont[curr].style.display = '';
	marg--;
	}
});

$(itemImg).click(function(i){
	thisNumber = $(this).attr('name')*1;
	
	for(i = 0; i < prRotCount; i++){
        itemImg[i].src = srcList[i + 1];
        itemImg[i].style.filter = 'expression(fixPNG(this))';
        
        itemCont[i].style.background =  '#E1E1E1';
    }
	
    $("#pl_tit").html(privList[thisNumber + 1]);
	
    itemImg[thisNumber].style.filter = 'expression(fixPNG(this))';
    itemCont[thisNumber].style.background =  'none';
    itemImg[thisNumber].src = srcActiveList[thisNumber + 1];
    document.getElementById('mainFon').style.background =  'url(' + srcFonList[thisNumber + 1] + ') left top no-repeat';
	
	
});




}); 

