/************************************************/
/*		File: Scripts.js						*/
/*		Author: gsuranyi						*/
/*		Histroy:								*/
/*			created 							*/
/*			added function:						*/
/*					setPirula					*/
/*				22/02/2007	- gsuranyi			*/
/*			added function:						*/
/*					zoomIn						*/
/*					setCookie					*/
/*					getCookie					*/
/*				26/02/2007	- gsuranyi			*/
/************************************************/

//------------------------------------------------
// set the coordinates of pirula div
//------------------------------------------------
function setPirula(){
	var pageWidth = 1000;
	var browser=navigator.appName;
	var obj = document.getElementById('pirula');
	var fullWidth;
	if(browser=="Microsoft Internet Explorer"){
		fullWidth = document.body.clientWidth;
	}
	else {
		fullWidth = window.innerWidth;
	}
	if(fullWidth<pageWidth) fullWidth=pageWidth;
	var x = fullWidth - pageWidth;
	var optimal = (x/2)+836;
	obj.style.left = String(optimal)+"px";
	obj.style.visibility = "visible";
}

/*function zoomIn(){
	var obj = document.all.article.;
//document.getElementById('article');
	//obj.style.removeAttribute("fontSize", false);
	//var oldSize = obj.style.getAttribute("fontSize", false);
	window.alert(obj);
 	//obj.style.font.Size = '18pt';
}*/
//------------------------------------------------
// increase fontsize of article div
//------------------------------------------------
var sizes = new Array("10pt","12pt","14pt","16pt");
var titles = new Array("14pt","16pt","18pt","20pt");
var dates = new Array("9pt","11pt","13pt","15pt");
var alltags;
var index;
function zoomIn(){	
	alltags= document.getElementById('article').all; //get all tags in article div
	var oldSize = 0;
	var newSize;
	var skip = 0;
	index = getCookie("index");
	if(index==null || index=="-1" || index==sizes.length - 1){
		index = 0;
	}
	else{
		index = Number(index) + 1;
	}
	setCookie("index","",1);
	setCookie("index",index,1);
	//window.alert(index);
	newSize = sizes[index];
	for(var i=0; i < alltags.length; i++)
			{
				var cn = alltags[i].className;
				var id = alltags[i].id;
				if(id=="report")
				{
					skip = 1;
				}
				if(skip == 1 && id=="temp")
				{
					skip = 0;
				}
				if(skip == 0)
				{
					switch(cn)
					{
						case "article_title":
						case "article_title_green":
						case "titledata":
						{
							alltags[i].style.removeAttribute("fontSize",false);
							alltags[i].style.setAttribute("fontSize",titles[index],false);			
							break;
						}
						case "article_date":
						{
							alltags[i].style.removeAttribute("fontSize",false);
							alltags[i].style.setAttribute("fontSize",dates[index],false);			
							break;
						}
						default:
						{
							alltags[i].style.removeAttribute("fontSize",false);
							alltags[i].style.setAttribute("fontSize",newSize,false);			
						}
					}
				}

			}
 	
}
//------------------------------------------------
// set the last used fontsize of article div 
// from cookie
//------------------------------------------------
function zoomLast(){
	//alert('Zoom last start');
	index = getCookie("index");
	var newSize;
	var skip = 0;
	if(index!="-1")
	{	
		newSize = sizes[index];
		alltags=document.getElementById("article").all; //get all tags in article div		
		if(alltags.length>0)
		{
			for(var i=0; i < alltags.length; i++)
			{
				var cn = alltags[i].className;
				var id = alltags[i].id;
				if(id=="report")
				{
					skip = 1;
				}
				if(skip == 1 && id=="temp")
				{
					skip = 0;
				}
				if(skip == 0)
				{

					switch(cn)
					{
						case "article_title":
						case "article_title_green":
						case "titledata":
						{
							alltags[i].style.removeAttribute("fontSize",false);
							alltags[i].style.setAttribute("fontSize",titles[index],false);			
							break;
						}
						case "article_date":
						{
							alltags[i].style.removeAttribute("fontSize",false);
							alltags[i].style.setAttribute("fontSize",dates[index],false);			
							break;
						}
						default:
						{
							alltags[i].style.removeAttribute("fontSize",false);
							alltags[i].style.setAttribute("fontSize",newSize,false);			
						}
					}
				}

			}
		}
	}
}

//------------------------------------------------
// create a cookie item
//
// c_name:		name of cookie item
// value:		value of cookie item
// expiredays:	expiredays of cookie
//------------------------------------------------
function setCookie(c_name,value,expiredays){
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
//------------------------------------------------
// get value of cookie item
//
// c_name:		name of cookie item
//------------------------------------------------
function getCookie(c_name){
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1; 
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return -1;
}

//------------------------------------------------
// Concat a query string to the url, and redirect
//
// queryString:		queryString key
// value:			queryString value
// openMode:		window.open open mode (new window...)
//------------------------------------------------
function GetUrlWithQuery(queryString,value,openMode)
{
	var retUrl="";
	//alert(querySt(queryString));
	var ret=querySt(queryString);
	var query=document.URL;//full query
	var qArr;
	var fullURLwithoutHashMark;
	var qs;
	var indexOfHM;
	
	if(query.match("#")!=null)
	{
		indexOfHM=query.indexOf("#");
		
		if(query.indexOf("?")==-1)
		{
			fullURLwithoutHashMark=query.slice(0,indexOfHM);
		}
		else
		{
			qArr=query.split("?");
			qs="?"+qArr[1];
			fullURLwithoutHashMark=query.slice(0,indexOfHM)+qs;
		}
		
		//alert(fullURLwithoutHashMark);
	}
	else
	{
		fullURLwithoutHashMark=query
	}
	
	if(ret == 0)
	{	
		retUrl=(fullURLwithoutHashMark+ '?' + queryString + '=' + value); 
		window.open(retUrl,openMode);
	}
	else if(ret==1)
	{
		retUrl=(fullURLwithoutHashMark+ '&' + queryString+'='+value); 
		window.open(retUrl,openMode);
	}
	else
	{
		window.open(document.URLUnencoded,openMode);
	}
}

//------------------------------------------------
// Concat a query string to the url, and redirect
//
// key:		queryString key
//------------------------------------------------
function querySt(key) 
{
	hu = window.location.search.substring(1);
	if(hu=="")
	{
		return 0;
	}
	gy = hu.split("&");
	for (i=0;i<gy.length;i++) 
	{
	    ft = gy[i].split("=");
		if (ft[0] == key) 
		{
			return ft[0];
		}
	}
	return 1;
}

function goToRegistration()
{
  window.open('~/HU/Pages/RegisterUser.aspx','_parent');
}

