/**
 * Functions to enhance appearance and functionality of Knology.com
 **/
window.onload = onLoader;

function onLoader(){
   setSK();
   setSSK();
   corners('navigation-and-search','bottom')
   var addCorners = ['bottom','availability-and-offers','offers','new-at-knology','more-promos','alternative-service-provider','quick-view','plexus-demos','support-guides','solutions-banner','offers-and-hookups','product-promos','biz-small','biz-medium','biz-carrier','biz-offers-and-hookups'];
   for(i=0;i<addCorners.length;i++){
       corners(addCorners[i],'all');
   }
   
   var addPipes = ['navigation-and-search','support-quick-links'];
   
   for(i=0;i<addPipes.length;i++){
       addPipesBetweenLinks(addPipes[i]);
   }
/***
   document.getElementById("search_site").checked = true;
***/
 if (document.getElementById("search_site")) {
     document.getElementById("search_site").checked = true;}

}

function setSK(){
    if(!document.getElementById('sk')){return;}
	var sk = document.getElementById('sk');
	sk.onfocus = clearSearchBox;
	sk.onblur = setSearchBox;
}

function setSSK(){
    if(!document.getElementById('ssk')){return;}
	var ssk = document.getElementById('ssk');
	ssk.onfocus = clearSearchBox;
	ssk.onblur = setSearchBox;
}

function setSearchBox(){
	if(this.value == ''){	this.value = 'search';}
	else{	this.value = this.value;}
}
function clearSearchBox(){this.value = '';}

/* rollover functions */
function imageSwapIn(imgID,newSrc){
	var image = document.getElementById(imgID);
	var oldSrc = image.setAttribute('title',image.src);
	image.src = newSrc;
}
function imageSwapOut(imgID){
	var image = document.getElementById(imgID);
	var oldSrc = image.getAttribute('title');
	image.src = oldSrc;
	image.removeAttribute('title');
}

/*** ADDING CORNERS TO A CONTAINING ELEMENT ***
--- How it works ---
	corners() uses DOM scripting to add four <i> tags as child elements
	of the containing element you specify. Each tag has a class name based 
	on its position: i.topRightCorner, i.topLeftCorner, i.bottomRightCorner,
	i.bottomLeftCorner.
	
	Use CSS to position each corner.	
	
--- If you want top corners OR bottom corners ---
	Use: 
	corners('idNameOfElement','topOrBottom')
	
	Where 'idNameOfElement' is the id value of the containing element and 'topOrBottom'
	is either 'top' or 'bottom' depending on the position of your desired corners.
	
--- If you want all four corners ---
	You can use the above example, OR add the id value of the containing
	element to the addCorners array below.

--- If you want three corners ---
	Follow the instructions for four corners, but only apply styles to three of the 
	four created elements.
	
--- Applying styles ---
	In order to position the corners:
		* Set the containing element position to relative (position: relative)
		* Set the child i elements' position to absolute (position: absolute)
		* Set top, left, bottom, and right positioning (using 'idNameOfElement i.topLeftCorner,' etc.) in the following files:
				* style/overrides.css
				* style/ie6.css (for IE6-specific positioning)
				* style/ie7.css (if IE7-specific positioning if necessary)
*/	

function corners(parentElementId,topBottomOrAll){
     /* 
     if you want three corners define only three of the four classes in your CSS. 
     */
     if(!document.getElementById){ return; }
     if(!document.getElementById(parentElementId)){ return; }
     if(topBottomOrAll == 'top'){
       var bClassNames = ["topLeftCorner","topRightCorner"];
     } else if(topBottomOrAll == 'bottom') { 
       var bClassNames = ["bottomLeftCorner","bottomRightCorner"];
     } else if(topBottomOrAll == 'all'){
        var bClassNames = ["topLeftCorner","topRightCorner","bottomLeftCorner","bottomRightCorner"];
     } else {
 	    return;
     }
     var parentEl = document.getElementById(parentElementId);
     var containers = new Array();
     for(var i=0; i < bClassNames.length; i++){
         containers[i] = document.createElement('i');
         containers[i].className = bClassNames[i];
         parentEl.appendChild(containers[i]);
     }
}
   
/* adds borders to top links */
function addPipesBetweenLinks(parentElementId){
	if(!document.getElementById(parentElementId)){return};
		var parentOfLinks = document.getElementById(parentElementId);
		var menuItems = parentOfLinks.getElementsByTagName('LI');
		for(var i=0; i < menuItems.length-1; i++){
			menuItems[i].className = 'linkPipe';
		}
}
 
var newwin; // global variable
function openPopup(){
    newwin = window.open("popup-page-name.html",
    "popUpWindowName",
    "width=583,height=600,resizable=yes,scrollbars=yes,status=no");
}

