// -------------------------------------------------------------------------------------------------------- //
// ---------------------------------- Common JS Functions for Lyoness.ag ---------------------------------- //
// -------------------------------------------------------------------------------------------------------- //

// RollOver										//
function RollOver(img_name, img_src) {
   document[img_name].src = img_src;
}
   
// Open a new window and zoom pic
function ZoomPic(strSrc, width, height) {
	if (width.length>0) { myWidth = parseInt(width); } else { myWidth = 620; }
	if (height.length>0) { myHeight = parseInt(height); } else { myHeight = 520; }
	MyWin = window.open(strSrc, "ZoomWin", "width=" + myWidth + ",height=" + myHeight + ",scrollbars=no,screenX=0,screenY=0,left=" + (screen.availWidth/2-(myWidth/2)) + ",top=" + (screen.availHeight/2-(myHeight/2)) + ",resizable=no, status=yes, toolbar=no");
}


// Show Right Cursor //
function ShowCursor(ThisItem, CurType) {
	if (CurType==1) {
		ThisItem.style.cursor='pointer';
	} else {
		ThisItem.style.cursor='help';
	}
	return false;
}

// Open ToolTip Win
function OpenToolTipWin(src, param, type) {
	var sw, sh, w, h;
	w = 450;
	h = 160;
	if (w==0) { w = 480; sw = 240; } else { sw = w/2; }
	if (h==0) { h = 300; sh = 280; } else { sh = (h/2) + 100; }
	if (type=='1') {
		window.open(src + '?prop=' + param,'win'+w+h,'left=' + ((screen.availWidth/2)-sw) + ',top=' + ((screen.availHeight/2)-sh) + ',toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,resizable=yes,copyhistory=no,width=' + (w + 60) +',height=' + (h + 120));
	} else {
		window.open(src + '?data=' + param,'win'+w+h,'left=' + ((screen.availWidth/2)-sw) + ',top=' + ((screen.availHeight/2)-sh) + ',toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,resizable=yes,copyhistory=no,width=' + (w + 60) +',height=' + (h + 120));
	}
}

// Open ToolTip Win
function OpenBrWin(src, w, h) {
	var sw, sh, w, hm, win;
	if (w.length==0) { w = 1000; sw = 500; } else { sw = w/2; }
	if (h.length==0) { h = 800; sh = 300; } else { sh = (h/2) + 100; }
	win = window.open(src,'win'+w+h,'left=' + ((screen.availWidth/2)-sw) + ',top=' + ((screen.availHeight/2)-sh) + ',toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,resizable=yes,copyhistory=no,width=' + (w + 60) +',height=' + (h+40));
}

// Open Window in Fullscreen Mode
function OpenFullScreen(URL) {
	window.open(URL, '_blank', 'fullscreen=yes,scrollbars=auto,toolbar=no,location=no,directories=no,menubar=no');
}

// Go to page 																//
//	Change Request at: 12. Feber 09											//
//	Nach Umschaltung des Landes soll auf die gleiche Seite geleitet werden	//
//	wenn diese existiert. Gecheckt wird das in der redirect_page.asp		//
//	Händlersuche auf das File 'DisplayDealerSearchAdvancedStartFirst' um-		//
//	leiten.																	//
function GoToUrl(Url)
{
	var ReLink=Url;
	var Page;
	if (Url!='') {
		if (location.href.indexOf("/internal") != -1) {
			if (location.href.indexOf("/DisplayCustomerRegistrationOpenArea") != -1) { 
				ReLink = location.href.substring(0, location.href.lastIndexOf("/")) + '/DisplayCustomerRegistrationOpenArea' + '?CountryCode=' + Url.substring(Url.lastIndexOf("/")+1) + "&RegistrationTheme=cff";
				location.href=ReLink;
			}

		} else {
			Page = location.href.substring(location.href.lastIndexOf("/")+1);
			location.href="/tools/redirect_page.asp?URL=" + ReLink + "&Page=" + Page;
		}
	}
}


// Submit a form on enter key
function submitenter(myfield,e) {
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;

	if (keycode == 13) {
   		myfield.form.submit();
		
   	return false;
   }
else
   return true;
}
// Submit a form on enter key _ login frm with Coremetrix Links
function submitenter_l1(myfield,e) {
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;

	if (keycode == 13) {
		if(coremetricsOnFlag) cmCreateConversionEventTag('Login Initiation: [PLACEHOLDER_COUNTRY_ISO] (Customer)','1','Login Customer','10');
   		myfield.form.submit();
		
   	return false;
   }
else
   return true;
}
// Submit a form on enter key _ login frm with Coremetrix Links
function submitenter_l2(myfield,e) {
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;

	if (keycode == 13) {
		if(coremetricsOnFlag) cmCreateConversionEventTag('Login Initiation: [PLACEHOLDER_COUNTRY_ISO] (Dealer)','1','Login Dealer','10');
   		myfield.form.submit();
		
   	return false;
   }
else
   return true;
}

// Extract the country path from url //
function GetPathFromUrl() {
	var aItems;
	var url = location.href;
	aItems = url.split("/");
	return (aItems[aItems.length-2]);
}

function pageDown () {
  if (window.scrollBy)
    window.scrollBy(0, window.innerHeight ? window.innerHeight : document.body.clientHeight);
}
function pageUp () {
  if (window.scrollBy)
    window.scrollBy(0, window.innerHeight ? window.innerHeight : document.body.clientHeight);
}

// Call function for rollband banners												//
function OpenDealerDetail(vCountryCode, vDealerId) {
    document.location.href = "../internal/DealerCenter/DealerSearchAdvanced/DisplayDealerSearchAdvancedDetailFirst?CountryCode=" + vCountryCode + "&dealerid=" + vDealerId;
    return true;
}

// Call function for rollband banners												//
function OpenDealerDetailUrl(url) {
    document.location.href = url;
    return true;
}

// Randomizer of images			//
//	Gewichtung 1:3				//
function Randomizer(count) {
	var index, Realindex;
	index = Math.floor(Math.random() * count);
	Realindex = 0;
	if (index==0 || index==1) Realindex = 1;
	if (index==2 || index==3) Realindex = 2;
	return Realindex;
}

// Show | Hide NewsItems
function changeDisplay(item) {
	
	//Close all elements __________________________
	/*
	for (var i=1; i<=document.frmNews.c_news.value;i++) {
		if (i != item) {
			document.getElementById("item_" + i).style.display = 'none';
			document.getElementById("item_" + i).style.visibility = 'hidden';
			if (document.getElementById("row_" + i)) {
				document.getElementById("row_" + i).innerHTML = '<div align="right"><a href="javascript:changeDisplay(' + i + ')">...lesen Sie mehr</a></div>';
			}
		}
	}
	*/
	
	//Open | Close ITEM ____________________________
	var x = document.getElementById("box_" + item);
	
	if(x!=null){
		if(x.style.display=='none'){
			x.style.display = '';
		}else{
			x.style.display = 'none';
		}
	}
	x=null;
}

function SetPath() {
	if (location.href.indexOf("prev.asp") != -1) { 
		return "/webfiles_cff/";
	} else {
		return "/";
	}
}
