window.onload = init;

function init() {
    changeSkin();
}

function setCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days * 24 * 60 * 60 * 1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    
    for (var i = 0; i < ca.length;i++) {
        var c = ca[i];
        
        while (c.charAt(0) == ' ') c = c.substring(1,c.length);
        if(c.indexOf(nameEQ) == 0) {
            return c.substring(nameEQ.length,c.length);
        } 
    } 
    return null;   
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}


function changeSkin(formId) {
    if(readCookie('skinchose') == null) {
    
        document.body.style.cssText = 'color:#000000; background-color:#4581bf; background-repeat: repeat-x;';
        document.getElementById('top_menu').style.backgroundImage = 'url(http://subtitrari.com.ro/skin/imagini/top_menu.gif)';      
        document.getElementById('sigla').style.backgroundImage = 'url(http://subtitrari.com.ro/skin/imagini/sigla.gif)';
        document.getElementById('header').style.backgroundImage = 'url(http://subtitrari.com.ro/skin/imagini/bg_head.gif)';
        document.getElementById('footer').style.backgroundImage = 'url(http://subtitrari.com.ro/skin/imagini/bg_footer.gif)';
        
    } else if(readCookie('skinchose') == 'Verde') {
    
        document.body.style.cssText = 'color: black; background-color: #13392b; background-repeat: repeat-x;';
        document.getElementById('top_menu').style.backgroundImage = 'url(http://subtitrari.com.ro/skin/imagini/top_menu_green.gif)';
        document.getElementById('sigla').style.backgroundImage = 'url(http://subtitrari.com.ro/skin/imagini/sigla_green.gif)';
        document.getElementById('header').style.backgroundImage = 'url(http://subtitrari.com.ro/skin/imagini/bg_head_green.gif)';
        document.getElementById('footer').style.backgroundImage = 'url(http://subtitrari.com.ro/skin/imagini/bg_footer_green.gif)';
        
    } else if(readCookie('skinchose') == 'Albastru') { 
        document.body.style.cssText = 'color:#000000; background-color:#4581bf; background-repeat: repeat-x;';
        document.getElementById('top_menu').style.backgroundImage = 'url(http://subtitrari.com.ro/skin/imagini/top_menu.gif)';
        document.getElementById('sigla').style.backgroundImage = 'url(http://subtitrari.com.ro/skin/imagini/sigla.gif)';
        document.getElementById('header').style.backgroundImage = 'url(http://subtitrari.com.ro/skin/imagini/bg_head.gif)';
        document.getElementById('footer').style.backgroundImage = 'url(http://subtitrari.com.ro/skin/imagini/bg_footer.gif)';
                
    }  else if(readCookie('skinchose') == 'Visiniu') { 
        document.body.style.cssText = 'color:#000000; background-color:#411007; background-repeat: repeat-x;';
        document.getElementById('top_menu').style.backgroundImage = 'url(http://subtitrari.com.ro/skin/imagini/top_menu_visiniu.gif)';
        document.getElementById('sigla').style.backgroundImage = 'url(http://subtitrari.com.ro/skin/imagini/sigla_visiniu.gif)';
        document.getElementById('header').style.backgroundImage = 'url(http://subtitrari.com.ro/skin/imagini/bg_head_visiniu.gif)';
        document.getElementById('footer').style.backgroundImage = 'url(http://subtitrari.com.ro/skin/imagini/bg_footer_visiniu.gif)';              
    } else if(readCookie('skinchose') == 'Dark') {
        document.body.style.cssText = 'color:#000000; background-color:#222222; background-repeat: repeat-x;';
        document.getElementById('top_menu').style.backgroundImage = 'url(http://subtitrari.com.ro/skin/imagini/top_menu_dark.gif)';
        document.getElementById('sigla').style.backgroundImage = 'url(http://subtitrari.com.ro/skin/imagini/sigla_dark.gif)';
        document.getElementById('header').style.backgroundImage = 'url(http://subtitrari.com.ro/skin/imagini/bg_head_dark.gif)';
        document.getElementById('footer').style.backgroundImage = 'url(http://subtitrari.com.ro/skin/imagini/bg_footer_dark.gif)';
    }
    
    var vskin = document.getElementById('skinchose');
    var skin  = vskin.getElementsByTagName('div');
    
    for(var i = 0; i < skin.length;i++) {
        vnameSkin = skin[i].getAttribute('title');
        skin[i].onclick = function() {
            return false;
        }
        
        if(vnameSkin == 'Verde') {
            skin[i].onclick = function() {
                document.body.style.cssText = 'color: black; background-color: #13392b; background-repeat: repeat-x;';
                document.getElementById('top_menu').style.backgroundImage = 'url(http://subtitrari.com.ro/skin/imagini/top_menu_green.gif)';            
                document.getElementById('sigla').style.backgroundImage = 'url(http://subtitrari.com.ro/skin/imagini/sigla_green.gif)';
                document.getElementById('header').style.backgroundImage = 'url(http://subtitrari.com.ro/skin/imagini/bg_head_green.gif)';
                document.getElementById('footer').style.backgroundImage = 'url(http://subtitrari.com.ro/skin/imagini/bg_footer_green.gif)';
                setCookie('skinchose', 'Verde', 30);
            }
        } else if(vnameSkin == 'Albastru') {
            skin[i].onclick = function() {
                document.body.style.cssText = 'color:#000000; background-color:#4581bf; background-repeat: repeat-x;';
                document.getElementById('top_menu').style.backgroundImage = 'url(http://subtitrari.com.ro/skin/imagini/top_menu.gif)';
                document.getElementById('sigla').style.backgroundImage = 'url(http://subtitrari.com.ro/skin/imagini/sigla.gif)';
                document.getElementById('header').style.backgroundImage = 'url(http://subtitrari.com.ro/skin/imagini/bg_head.gif)';
                document.getElementById('footer').style.backgroundImage = 'url(http://subtitrari.com.ro/skin/imagini/bg_footer.gif)';
                setCookie('skinchose', 'Albastru', 30);
            }        
        } else if(vnameSkin == 'Visiniu') {
            skin[i].onclick = function() {
                document.body.style.cssText = 'color:#000000; background-color:#411007; background-repeat: repeat-x;';
                document.getElementById('top_menu').style.backgroundImage = 'url(http://subtitrari.com.ro/skin/imagini/top_menu_visiniu.gif)';
                document.getElementById('sigla').style.backgroundImage = 'url(http://subtitrari.com.ro/skin/imagini/sigla_visiniu.gif)';
                document.getElementById('header').style.backgroundImage = 'url(http://subtitrari.com.ro/skin/imagini/bg_head_visiniu.gif)';
                document.getElementById('footer').style.backgroundImage = 'url(http://subtitrari.com.ro/skin/imagini/bg_footer_visiniu.gif)';
                setCookie('skinchose', 'Visiniu', 30);
            }
        } else if(vnameSkin == 'Dark') {
            skin[i].onclick = function() {
                document.body.style.cssText = 'color:#000000; background-color:#222222; background-repeat: repeat-x;';
                document.getElementById('top_menu').style.backgroundImage = 'url(http://subtitrari.com.ro/skin/imagini/top_menu_dark.gif)';
                document.getElementById('sigla').style.backgroundImage = 'url(http://subtitrari.com.ro/skin/imagini/sigla_dark.gif)';
                document.getElementById('header').style.backgroundImage = 'url(http://subtitrari.com.ro/skin/imagini/bg_head_dark.gif)';
                document.getElementById('footer').style.backgroundImage = 'url(http://subtitrari.com.ro/skin/imagini/bg_footer_dark.gif)'; 
                setCookie('skinchose', 'Dark', 30);
            }      
        }
    }
}
function openNewPopup(url, w, h) {
    var _left = 200;
    var _top = 200;
    var _location = 'no';
    var _directories = 'no';
    var _menubar = 'no';
    var _resizable = 'no';
    var _scrollbars = 'no';
    var _status = 'no';
    var _titlebar = 'no';
    var _toolbar = 'no';
        
    window.popupWindow = window.open(url, '_blank', 'width='+w
        +', height='+h+',left='+_left+', top='+_top+', location='+_location
        +', directories='+_directories+', menubar='+_menubar
        +', resizable='+_resizable+', scrollbars='+_scrollbars
        +', status='+_status+', titlebar='+_titlebar+', toolbar='+_toolbar);
        
    return false;
}
function confirmDelete(delUrl){
        if(confirm("Sunteti sigur ca vreti sa stergeti?")){
                document.location = delUrl;
        }
}
function reincarcaPagina() {
	window.location.reload();	
}