
var news = new Array();
function createCookie(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 ShowTopNews() {
        if(news[index] == null)
            _Default.LoadNews(newsid[index],ShowTopNews_CallBack)
        else 
            TopNewsLayer.innerHTML = news[index]
    }
    function ShowTopNews_CallBack(res) {
        TopNewsLayer.innerHTML = res.value;
        news[index] = res.value;
        
    }
    function NextNews() {
        
        index++;
        if(index >= newsid.length)
            index = 0;
       
       
        ShowTopNews();
    }
    function PrvNews() {
        index--;
        if(index < 0)
            index = newsid.length-1
        ShowTopNews();
    }
    
    function StartNewsRotator() {
        interval = setInterval('NextNews()',5000);
    }

    function  StopNewsRotator() {
     
        clearInterval(interval);
    }

    function NextPhotoGallery() {
        gallerypage++;
        _Default.GetPhotos(gallerypage,lang,ShowPhotoGallery_CallBack) ;
    }
    function PrvPhotoGallery() {
        gallerypage--;
        _Default.GetPhotos(gallerypage,lang,ShowPhotoGallery_CallBack) ;
    }
    
    function ShowPhotoGallery() {
        _Default.GetPhotos(gallerypage,lang,ShowPhotoGallery_CallBack) ;
    }
    
    function ShowPhotoGallery_CallBack(resp) {
        
        if (resp.value.indexOf('~') > -1) {
        	gallerypage = resp.value.substring(0,resp.value.indexOf('~')) ;
		    PhotoGallery.innerHTML = resp.value.substring(resp.value.indexOf('~') + 1);
    	}
	    else {
    		PhotoGallery.innerHTML = resp.value;
	    }
    }
function eraseCookie(name) {
	createCookie(name,"",-1);
}
 function ChangeTheme(name){
        document.styleSheets[0].href = "App_Themes/" + name + "_"+lang+"/Default.css";
        createCookie("NofaTheme",name,100000);
        
    }
    function Goto(url) {
        location.target="_blank";
        location.href = url;
    }
    
