var LeftImg=document.createElement("img");
LeftImg.src= global_root_path +"webImages/leftC.gif";
var RightImg=document.createElement("img");
RightImg.src= global_root_path + "webImages/rightC.gif";
var LeftHImg=document.createElement("img");
LeftHImg.src= global_root_path +"webImages/leftC_hover.gif";
var RightHImg=document.createElement("img");
RightHImg.src= global_root_path +"webImages/rightC_hover.gif";

var ArchLeftImg = document.createElement("img");
ArchLeftImg.src= global_root_path +"webImages/leftGrey.gif";
var ArchRightImg = document.createElement("img");
ArchRightImg.src= global_root_path +"webImages/rightGrey.gif";
var ArchLeftOvrImg = document.createElement("img");
ArchLeftOvrImg.src= global_root_path +"webImages/leftOrange.gif";
var ArchRightOvrImg = document.createElement("img");
ArchRightOvrImg.src= global_root_path +"webImages/rightOrange.gif";

var LeftBigImg=document.createElement("img");
LeftBigImg.src= global_root_path +"webImages/leftC_new.gif";
var RightBigImg=document.createElement("img");
RightBigImg.src= global_root_path + "webImages/rightC_new.gif";
var LeftHBigImg=document.createElement("img");
LeftHBigImg.src= global_root_path +"webImages/leftC_hover_new.gif";
var RightHBigImg=document.createElement("img");
RightHBigImg.src= global_root_path +"webImages/rightC_hover_new.gif";

var commentImg = document.createElement("img");
commentImg.src= global_root_path +"webImages/commentNor.gif";

var commentImgOver = document.createElement("img");
commentImgOver.src= global_root_path +"webImages/commentOvr.gif";

var greyBg = document.createElement("img");
greyBg.src= global_root_path +"webImages/bgGrey.gif";
var greyBgOvr = document.createElement("img");
greyBgOvr.src= global_root_path +"webImages/bgGrey_Hover.gif";
var newBgR_new = document.createElement("img");
newBgR_new.src= global_root_path +"webImages/newBgR_new.gif";
var newBgRHover_new = document.createElement("img");
newBgRHover_new.src= global_root_path +"webImages/newBgRHover_new.gif";
var newBgRHover_new = document.createElement("img");
newBgRHover_new.src= global_root_path +"webImages/newBgRHover_new.gif";
var shedBg1 = document.createElement("img");
shedBg1.src= global_root_path +"webImages/shedBg1.gif";
var midBgR = document.createElement("img");
midBgR.src= global_root_path +"webImages/midBgR.gif";
var midbgR_new = document.createElement("img");
midbgR_new.src= global_root_path +"webImages/midbgR_new.gif";
var bguftscience = document.createElement("img");
bguftscience.src= global_root_path +"webImages/bguftscience.jpg";
var topNaviBgR = document.createElement("img");
topNaviBgR.src= global_root_path +"webImages/topNaviBgR.gif";
var topBgr = document.createElement("img");
topBgr.src= global_root_path +"webImages/topBgr.gif";
var midtopRpt = document.createElement("img");
midtopRpt.src= global_root_path +"webImages/midtopRpt.png";
var midbottomRpt = document.createElement("img");
midbottomRpt.src= global_root_path +"webImages/midbottomRpt.png";
var midRight = document.createElement("img");
midRight.src= global_root_path +"webImages/midRight.png";
var midLeft = document.createElement("img");
midLeft.src= global_root_path +"webImages/midLeft.png";
var calenderBg = document.createElement("img");
calenderBg.src= global_root_path +"webImages/calenderBg.gif";
var msg_arrow = document.createElement("img");
msg_arrow.src= global_root_path +"webImages/msg_arrow.gif";
var languageHeader = document.createElement("img");
languageHeader.src= global_root_path +"webImages/languageHeader.gif";
var longBg = document.createElement("img");
longBg.src= global_root_path +"webImagesPortal/longBg.gif";
var zomPNormal = document.createElement("img");
zomPNormal.src= global_root_path +"webImages/zomPNormal.gif";
var zomPHover = document.createElement("img");
zomPHover.src= global_root_path +"webImages/zomPHover.gif";

var _gMainPg = '';
var _gMid = 0;


function RepLR(mid,flag){
	//alert(mid);
	if(flag==1){
		document.getElementById('L'+mid).src=LeftHImg.src;
		document.getElementById('M'+mid).className='tectBg2Select left';
		document.getElementById('R'+mid).src=RightHImg.src;
	}else{
		document.getElementById('L'+mid).src=LeftImg.src;
		document.getElementById('M'+mid).className='tectBg2 left';
		document.getElementById('R'+mid).src=RightImg.src;		
	}
	
	setDefaultMenu(_gMainPg,_gMid);
}

function RepLRBig(mid,flag){
	if(flag==1){
		document.getElementById('L'+mid).src=LeftHBigImg.src;
		document.getElementById('M'+mid).className='tectBg2BigSelect left';
		document.getElementById('R'+mid).src=RightHBigImg.src;
	}else{
		document.getElementById('L'+mid).src=LeftBigImg.src;
		document.getElementById('M'+mid).className='tectBg2Big left';
		document.getElementById('R'+mid).src=RightBigImg.src;		
	}
}

function RepLRBigRev(mid,flag){
	if(flag==1){
		document.getElementById('L'+mid).src=LeftBigImg.src;
		document.getElementById('M'+mid).className='tectBg2BigRevSelect left';
		document.getElementById('R'+mid).src=RightBigImg.src;				
	}else{
		document.getElementById('L'+mid).src=LeftHBigImg.src;
		document.getElementById('M'+mid).className='tectBg2BigRev left';
		document.getElementById('R'+mid).src=RightHBigImg.src;
	}
}


function showOrg(mid,flag){
	if(flag==1){
		document.getElementById('L'+mid).src=ArchLeftOvrImg.src;
		document.getElementById('M'+mid).className='tectBgYellowSelect';
		document.getElementById('R'+mid).src=ArchRightOvrImg.src;
	}else{
		document.getElementById('L'+mid).src=ArchLeftImg.src;
		document.getElementById('M'+mid).className='tectBgYellow';
		document.getElementById('R'+mid).src=ArchRightImg.src;		
	}
}



function setDefaultMenu(menuName,mid){
	
	if(_gMainPg == '') {
		_gMainPg = menuName;
		_gMid = mid;
	}
	
	switch(menuName){
		case 'home':
			document.getElementById('L'+mid).src=LeftHImg.src;
			document.getElementById('M'+mid).className='tectBg2Select left';
			document.getElementById('R'+mid).src=RightHImg.src;
		break;
		case 'form':
			document.getElementById('L'+mid).src=LeftHImg.src;
			document.getElementById('M'+mid).className='tectBg2Select left';
			document.getElementById('R'+mid).src=RightHImg.src;
		break;		
	}
}




var TopImg=document.createElement("img");
TopImg.src= global_root_path +"webImages/leftTop.gif";
var BottomImg=document.createElement("img");
BottomImg.src= global_root_path +"webImages/leftBottom.gif";
var TopHImg=document.createElement("img");
TopHImg.src= global_root_path +"webImages/leftTopHover.gif";
var BottomHImg=document.createElement("img");
BottomHImg.src= global_root_path +"webImages/leftBottomHover.gif";

var _gMainPg = '';
var _gMid = 0;


function TepLR(mid,flag){
	if(flag==1){
		document.getElementById('T'+mid).src=TopHImg.src;
		document.getElementById('leftBG'+mid).className='leftNaviSelect';
		document.getElementById('B'+mid).src=BottomHImg.src;
	}else{
		document.getElementById('T'+mid).src=TopImg.src;
		document.getElementById('leftBG'+mid).className='leftNavi';
		document.getElementById('B'+mid).src=BottomImg.src;		
	}
	
	setDefaultMenu(_gMainPg,_gMid);
}

function TepPdf(mid,flag){
	if(flag==1){
		document.getElementById('T'+mid).src=TopHImg.src;
		document.getElementById('leftBG'+mid).className='leftNaviPdfSelect';
		document.getElementById('B'+mid).src=BottomHImg.src;
	}else{
		document.getElementById('T'+mid).src=TopImg.src;
		document.getElementById('leftBG'+mid).className='leftNaviPdf';
		document.getElementById('B'+mid).src=BottomImg.src;		
	}
}

function setDefaultMenu(menuName,mid){
	
	if(_gMainPg == '') {
		_gMainPg = menuName;
		_gMid = mid;
	}
	
	switch(menuName){
		case 'home':
			document.getElementById('T'+mid).src=TopHImg.src;
			document.getElementById('leftBG'+mid).className='leftNavi';
			document.getElementById('B'+mid).src=BottomHImg.src;
		break;
		case 'form':
			document.getElementById('T'+mid).src=TopHImg.src;
			document.getElementById('leftBG'+mid).className='leftNavi';
			document.getElementById('B'+mid).src=BottomHImg.src;
		break;		
	}
}







var TopLeftImg=document.createElement("img");
TopLeftImg.src= global_root_path +"webImages/topNLc.gif";
var TopBlank= document.createElement("img");
TopBlank.src= global_root_path +"webImages/topSpc.gif";
var TopRightImg=document.createElement("img");
TopRightImg.src= global_root_path +"webImages/topNLc.gif";
var TopLeftHImg=document.createElement("img");
TopLeftHImg.src= global_root_path +"webImages/topLc.gif";
var TopRightHImg=document.createElement("img");
TopRightHImg.src= global_root_path +"webImages/topRc.gif";

var _gMainPg = '';
var _gMid = 0;

function findPosX(obj) {
	var curleft = 0;
	if(obj) {
	if (obj.offsetParent) 	{
		while (obj.offsetParent) {
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x) {
		curleft += obj.x;
	}
	return curleft;
	}
}

function findPosY(obj) {
	var curtop = 0;
	if(obj) {
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.x) {
		curtop += obj.x;
	}
	return curtop;
	}
}

function TopMenu(mid,flag,cnt,lst){
	var midLess = (mid - 1);
	if(flag==1){
		document.getElementById('TR'+midLess).src=TopLeftHImg.src;
		document.getElementById('topNavi'+mid).className='topNaviSelect';
		document.getElementById('TR'+mid).src=TopRightHImg.src;
		if(document.getElementById('mainnavi_'+ mid) && document.getElementById('subnavi_'+mid)){
			var divLeft = findPosX(document.getElementById('mainnavi_'+ mid));
			var divTop = findPosY(document.getElementById('mainnavi_'+ mid));
			
			var divWidth = document.getElementById('mainnavi_'+ mid).offsetWidth;
			document.getElementById('midData_'+mid).style.width = (divWidth + 10) + 'px';
			if(cnt == 1){
				var leftSide = (divLeft - 200);
			}else{
				var extraWidth = document.getElementById('TR'+midLess).offsetWidth;
				var leftSide = divLeft - extraWidth;
			}
			
			document.getElementById('subnavi_'+mid).style.left = leftSide + 'px';
			document.getElementById('subnavi_'+mid).style.top = (divTop + 24) + 'px';
			document.getElementById('subnavi_'+mid).style.visibility = 'visible';
			document.getElementById('subnavi_'+mid).style.display = 'block';	
		}	
	}else{
		var imgName = (cnt == 1) ? TopBlank.src : TopLeftImg.src;
		var imgName1 = (lst == 1) ? TopBlank.src : TopRightImg.src;
		document.getElementById('TR'+midLess).src= imgName;
		document.getElementById('topNavi'+mid).className='topNavi';
		document.getElementById('TR'+mid).src= imgName1;
		if(document.getElementById('subnavi_'+mid)){
			document.getElementById('subnavi_'+mid).style.visibility = 'hidden';
			document.getElementById('subnavi_'+mid).style.display = 'none';
		}
	}
	
	//setDefaultMenu(_gMainPg,_gMid);
}

function setDefaultMenu(menuName,mid){
	
	if(_gMainPg == '') {
		_gMainPg = menuName;
		_gMid = mid;
	}
	
	switch(menuName){
		case 'home':
			document.getElementById('TL'+mid).src=TopLeftHImg.src;
			document.getElementById('topNavi'+mid).className='topNavi';
			document.getElementById('TR'+mid).src=TopRightHImg.src;
		break;
		case 'form':
			document.getElementById('TL'+mid).src=TopLeftHImg.src;
			document.getElementById('topNavi'+mid).className='topNavi';
			document.getElementById('TR'+mid).src=TopRightHImg.src;
		break;		
	}
}

function showPollResult(pollId, langId){
	var ajaxVar = new ajaxVars();
	ajaxVar.vars['action'] = "runFunction";
	ajaxVar.vars['func'] = "submitVote";
	ajaxVar.vars['pollId'] = pollId;
	ajaxVar.vars['langId'] = langId;
	ajaxVar.vars['isNewSession'] = 0;
	ajaxVar.vars['ShowExtraLink'] = 1;
	ajaxVar.gotoFunction = 'pollGraph';
	ajaxVar.AjaxPostSQL();
}

function pollGraph(data, fnVars){
	pollDivObj = document.getElementById('poll');
	pollDivObj.style.visibility = 'hidden';
	pollDivObj.style.display = 'none';
	pollResObj = document.getElementById('pollresult');
	pollResObj.style.visibility = 'visible';
	pollResObj.style.display = 'block';
	pollResObj.innerHTML = data;
}

function showVotingOptions(pollId, langId){
	pollResObj = document.getElementById('pollresult');
	pollResObj.style.visibility = 'visible';
	pollResObj.style.display = 'block';
	var linkText = (langId == 'de') ? 'Ergebnisse zeigen' : 'Show results';
	pollResObj.innerHTML = '<div align="center"><a href="javascript:void(0);" onclick="showPollResult(' + pollId +',\''+ langId +'\');" style="text-decoration:underline;">'+ linkText +'</a></div>';
	pollDivObj = document.getElementById('poll');
	pollDivObj.style.visibility = 'visible';
	pollDivObj.style.display = 'block';
}


function submitVote(formObj, pollId, isNewSession, langId){
	var errorDivObj = document.getElementById('errorDiv');
	errorDivObj.innerHTML = "";
	errorDivObj.style.display = "block";
	errorDivObj.style.visibility = "hidden";
	
	var id = 0;
	var pollSelected = false;
		
	if(isNewSession == 1){
		var optionsLength = formObj.pollOption.length;
		
		for(var i=0;i<optionsLength;i++){
			if(formObj.pollOption[i].checked) {
				id =  formObj.pollOption[i].value;
				pollSelected = true;
			}
		}
	}else{
		pollSelected = true;
	}
	
	if(pollSelected){
		var ajaxVar = new ajaxVars();
		ajaxVar.vars['action'] = "runFunction";
		ajaxVar.vars['func'] = "submitVote";
		ajaxVar.vars['pollId'] = pollId;
		ajaxVar.fnVars['pollId'] = pollId;
		ajaxVar.vars['langId'] = langId;
		ajaxVar.vars['id'] = id;
		ajaxVar.vars['isNewSession'] = isNewSession;
		ajaxVar.vars['ShowExtraLink'] = 0;
		ajaxVar.gotoFunction = 'submitVoteDone';
		ajaxVar.AjaxPostSQL();
	}else{
		errorDivObj.style.display = "block";
		errorDivObj.style.visibility = "visible";
		errorDivObj.innerHTML = (langId == 'de') ? "Wählen Sie eine Antwort" : "Choose an answer";
	}
}
function submitVoteDone(data, fnVars){
	pollDivObj = document.getElementById('poll');
	pollDivObj.style.visibility = 'visible';
	pollDivObj.innerHTML = data;
	pollResObj = document.getElementById('pollresult');
	pollResObj.style.visibility = 'hidden';
	pollResObj.style.display = 'none';
	var selPollId = fnVars['pollId'];
	var frm = document.getElementById("pollingFrame");
	frm.src = global_root_path + "setPortalCookie.php?pollingId="+ selPollId;
}

function validate(email) {
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	if(reg.test(email) == false) {
		return false;
	}else{
		return true;   
	}
}

var logBtnImg = document.createElement("img");
logBtnImg.src= global_root_path +"webImages/loginButton.gif";
var logBtnImgOvr = document.createElement("img");
logBtnImgOvr.src= global_root_path +"webImages/loginButtonOver.gif";

var sendenBtnImg = document.createElement("img");
sendenBtnImg.src= global_root_path +"webImages/senden.gif";
var sendenBtnImgOvr = document.createElement("img");
sendenBtnImgOvr.src= global_root_path +"webImages/sendenOver.gif";

function ChangeSubButton(obj,btnImgName){
	obj.src = global_root_path +"webImages/"+ btnImgName;
}

function changeButtonImage(idVal,typVal){
	var divObjtp = document.getElementById('topimg_' + idVal);
	var divObjmid = document.getElementById('midimg_' + idVal);
	var divObjbtm = document.getElementById('btmimg_' + idVal);
	if(typVal == 1){
		divObjtp.className = 'tgryBGOver';
		divObjmid.className = 'mgryBGOver';
		divObjbtm.className = 'bgryBGOver';
	}else{
		divObjtp.className = 'tgryBG';
		divObjmid.className = 'mgryBG';
		divObjbtm.className = 'bgryBG';
	}
}
