// Generic JavaScript template for the Front-End

// used by these components
// cc_FreeTeaser_32, cc_FREE_TSR_Shopping_pic_link, cc_FreeTeaserShopping1_33, cc_LinkDirectory, cc_Links, cc_RelatedLinks, cc_ArticleDetail_Links, cc_Content_32, cc_TeaserLinkContent_32, cc_BottomNavigationBar_32, cc_VideoFreeTeaser_32, pc_headline2_33_BWFT, cc_BW_EinkaufenBox_Links, cc_BW_Links, cc_BW_TeaserLinkContent_1_32, cc_BW_TeaserLinkContent_5_31

// This function opens a video in a new window, and closes an existing window, if it exists

function open_video(whichVideo,width,height) {
	var videoWin;
	if (videoWin) {
		if (!videoWin.closed) {
			videoWin.close();
		}
	}
	
	videoWin = window.open(whichVideo,"diashow","width="+width+",height="+height);
	if (navigator.appName.indexOf("Netscape") != -1)
        postWin.focus();
}
			
// This General function opens a window

function openwinGen(url,type,params) {
    var postWin = window.open(url, type, params);
    if (navigator.appName.indexOf("Netscape") != -1)
        postWin.focus();
}
			
		

// used by these components
// cc_LeftNav_Shopping, cc_LeftSubNavigationBar_31

function funcall(html) {
	parent.location.href=html;
}

// JS for voting components			


var selected =0;
	
function IsSelected1() {
	selected=1;
}
function validate1(url, num)	{
	if(selected==1){
		var pollwindow = window.open("","pollwindow","status=no,resize=no,toolbar=no,scrollbars=yes,width=450,height=375,maximize=null");
		eval('document.voting_form'+num+'.submit()');
	 } else {
		alert("Bitte treffen Sie Ihre Wahl!");
	}
}

		

// JS for Community start

function goToChat()	{
	document.loginForm.submit();
}

function goToForum() {
	top.location.href="http://community.aon.at/";
}

function goToReg() {
	top.location.href="http://community.aon.at/alias.net?to=nav_register";
}


// JS for Community End
		
// JS for sms; used by jim_top, jm_top_component, reminderTopFrame, sms_top_component, top_component, top_component_funbox, top_component_jim, voicememoTopFrame, PortalHomeWorkingExplorer
function send_sms() {
	document.sms_form.target="_top";
	document.sms_form.submit();
}
		
// JS for search functionality, called in search Library

function submit_form(URL) {
	intSelectedIndex = document.search_form.suche.selectedIndex;
	if (intSelectedIndex == 1) {
	Image1= new Image(1,1)
	Image1.src = "http://ivw.jet2web.net/cgi-bin/ivw/CP/Service/search/national"
	intSearchId = eval('document.search_form.suche.options[' + intSelectedIndex + '].value');
	document.search_form.action = URL + intSearchId;
	document.search_form.target="_top"
	top.location.href=document.search_form.action;
	}
	
	if (intSelectedIndex == 2) {
	Image2= new Image(1,1)
	Image2.src = "http://ivw.jet2web.net/cgi-bin/ivw/CP/Service/search/international"
	intSearchId = eval('document.search_form.suche.options[' + intSelectedIndex + '].value');
	document.search_form.action = URL + intSearchId;
	document.search_form.target="_top"
	top.location.href=document.search_form.action;
	}
	
	if (intSelectedIndex == 0) {
	Image3= new Image(1,1)
	Image3.src = "http://ivw.jet2web.net/cgi-bin/ivw/CP/Service/search/inside"
	intSearchId = eval('document.search_form.suche.options[' + intSelectedIndex + '].value');
	document.search_form.action = URL + intSearchId;
	top.location.href=document.search_form.action;
	}
}

function checkForValidty() {
	if (document.loginForm.username.value == "Benutzername" && document.loginForm.password.value == "******") {
		document.loginForm.username.value = "";
		document.loginForm.password.value = "";
	}

	checkUsername();
	
	if (document.loginForm.username.value != "" && document.loginForm.password.value != "") {
		document.loginForm.action = "https://www.aon.at/jet2web/FE/myAon/pzn_authenticate";
		return true
	} else {
		alert("Bitte geben Sie Username und Passwort ein!");
		document.loginForm.username.value = "LoginFehler!";
		document.loginForm.password.value = "";
		document.loginForm.domain.value =1;
		return false
	}
}

function checkUsername() {
	myname = document.loginForm.username.value;
	if (myname == "") {
		return;
	}
	myDomain = myname.substring(myname.indexOf('.'));
	shortenUsername = false;
	if (myDomain.toLowerCase()  == ".aon") {
		document.loginForm.domain.value = 1;
		shortenUsername = true;
	} 
	if (myDomain.toLowerCase()  == ".lion") {
		document.loginForm.domain.value = 2;
		shortenUsername = true;
	} 
	if (myDomain.toLowerCase()  == ".games") {
		document.loginForm.domain.value = 3;
		shortenUsername = true;
	}
	if (shortenUsername) {
		 document.loginForm.username.value = myname.substring(0, myname.indexOf(myDomain));
	}
}
