// If this page is not a secure page, bounce back to the main page.

if (typeof pageSecured!="undefined" && pageSecured && !location.host.match("itl") && !location.host.match("globalbuypower")) {
	location.replace("http://www.opel."+navCountry.toLowerCase()+location.pathname+location.search);
}


//These functions should be considered deprecated, and will be phased out.

function openPromoWin(url) {
	win=window.open(url, "promo", "scrollbars,status,resizable");
}

function openPromoWindow(url,params) {
	win=window.open(url, "promo", params);
}

function openPrivacyWin(url) {
	win=window.open(url, "privacy", "scrollbars,status,resizable,width=360,height=450");
}

function openTandCWin(url) {
	win=window.open(url, "tandc", "scrollbars,status,resizable,width=360,height=450");
}

function openToolWin(url) {
	win=window.open(url, "toolwin", "scrollbars,status,resizable,width=550,height=500");
}

function newWin(url) {
	win=window.open(url, "newwin", "scrollbars,status,resizable");
}

function openDealerLocWin(url) {
	win=window.open(url, "dealerloc", "scrollbars,status,resizable,width=600,height=500");
}

function goAbsolute(url) {
	location.href = url;
}

function goRelative(url) {
	location.href = url;
}

function WM_imageSwap(myImage, mySrc){
	if (typeof(myImage) == 'string') {
		document.images[myImage].src = mySrc;
	} else if ((typeof(myImage) == 'object') && myImage && myImage.src) {
		myImage.src = mySrc;
	}
}
function WM_preloadImages() {
	if (typeof(document.WM) == 'undefined') document.WM = new Object();
	document.WM.loadedImages = new Array();
	var argLength = WM_preloadImages.arguments.length;
	for(arg=0;arg<argLength;arg++) {
		document.WM.loadedImages[arg] = new Image();
		document.WM.loadedImages[arg].src = WM_preloadImages.arguments[arg];
	}
}
function hideElementWithClass(tagType,class_name,class_names_offset,class_names_to_remove)
{
	/* Function to hide element(s) in the body of the page based on the tag type and class name */

	/* Working variables */
	var matching_tags = document.getElementsByTagName(tagType); /* Stores array of tags */
	var matching_tags_counter = 0; /* number of matches against tag type */
	var class_names_counter = 0; /* number of matching class names with tag type */
	var class_names_removed = 0; /* number of tags with matching class name removed */

	//alert("We are in the function");
	/* Loop through all matching tag types */
	while (matching_tags_counter < matching_tags.length)
	{
		/* See if our work is already done */
		if (class_names_removed < class_names_to_remove){
			/* See if class name matches */
			if (matching_tags[matching_tags_counter].className == class_name) {
				/* See if we have got to the correct instance of class name we are interested in */
				if (class_names_counter >= class_names_offset){
					/* Set element to be invisible */
					matching_tags[matching_tags_counter].style.display = "none";
					class_names_removed++;
				}
				class_names_counter++;
				//alert("counter = " +class_names_counter++);
			}
		}
		else{
			/* We are done, so break out of loop */
			break;
		}
		matching_tags_counter++;
	}
}
