//------------------------------------------------------------------------------------------------------------------------
function KW_movie(name,width,height)
{
   this.name=name; this.width=width; this.height=height;
}
//------------------------------------------------------------------------------------------------------------------------
var KW_movieList = new Array();
KW_movieList[KW_movieList.length] = new KW_movie('/flash/home_internet.swf','435','299')
KW_movieList[KW_movieList.length] = new KW_movie('/flash/home_phone.swf','435','299')
KW_movieList[KW_movieList.length] = new KW_movie('/flash/home_tv.swf','435','299')

j=parseInt(Math.random()*KW_movieList.length)
j=isNaN(j)?0:j;

var currentdate = 0
var core = 0
//------------------------------------------------------------------------------------------------------------------------
function StringArray (n) 
{
   this.length = n;
   for (var i =1; i <= n; i++)
   {
      this[i] = ' '
   }
}
//------------------------------------------------------------------------------------------------------------------------
image = new StringArray(10)
image[0] = '/flash/no_flash_01.jpg'
image[1] = '/flash/no_flash_02.jpg'
image[2] = '/flash/no_flash_03.jpg'

var ran = 60/image.length
//------------------------------------------------------------------------------------------------------------------------
function ranimage()
{
   currentdate = new Date()
   core = currentdate.getSeconds()
   core = Math.floor(core/ran)
   return(image[core])
}
//------------------------------------------------------------------------------------------------------------------------
// FLASH HOLDER
mac45Flg = 0
if( (navigator.appVersion.indexOf("MSIE 4.5",0)) != -1 )
{
   mac45Flg = 1
}
//------------------------------------------------------------------------------------------------------------------------
function writeswf(movieName, width, height)
{
  // Mac IE4.5
  if(mac45Flg == 0)
  {
      document.write('<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0"');
      document.write(' WIDTH="',width,'"');
      document.write(' HEIGHT="',height,'"');
      document.write(' BORDER="0">');
      document.write('<PARAM NAME=movie VALUE="',movieName,'">');
      document.write('<PARAM NAME=quality VALUE=high>');
      document.write('<PARAM NAME=LOOP VALUE=false>');
      document.write('<PARAM NAME=menu VALUE=false>');
      document.write('<PARAM NAME="BGCOLOR" VALUE="">');
      document.write('<PARAM NAME="BASE" VALUE=".">');
	  document.write('<PARAM NAME="wmode" VALUE="opaque">');
	  document.write('<PARAM NAME="AllowScriptAccess" VALUE="always">');
  }
  document.write('<EMBED SRC="',movieName,'" BASE="." QUALITY=high PLUGINSPAGE="http://www.macromedia.com/jp/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" TYPE="application/x-shockwave-flash" WIDTH="',width,'" HEIGHT="',height,'" BORDER="0" LOOP="false" menu=false BGCOLOR="" wmode="opaque" AllowScriptAccess="always"></EMBED>');  
  if(mac45Flg == 0)
  {
      document.write('</OBJECT>');
  }
}
//------------------------------------------------------------------------------------------------------------------------
// ROLL-OVER
function imgOn(imgName)
{
  if (document.images)
  {
	  if(document[imgName])
	  {
      	document[imgName].src = eval(imgName + "on.src");
	  }
  }
}
//------------------------------------------------------------------------------------------------------------------------
function imgOff(imgName)
{
  if (document.images)
  {
	  if(document[imgName])
	  {
      	document[imgName].src = eval(imgName + "off.src");
	  }
  }
}
//------------------------------------------------------------------------------------------------------------------------
if (document.images)
{
  // TOP MENU MOUSE ON
  img1on = new Image(); img1on.src = '/images/menu_top_home_on.gif';
  img2on = new Image(); img2on.src = '/images/menu_top_tv_on.gif';
  img3on = new Image(); img3on.src = '/images/menu_top_net_on.gif';
  img4on = new Image(); img4on.src = '/images/menu_top_phone_on.gif';
  img5on = new Image(); img5on.src = '/images/menu_top_bs_on.gif';
  img6on = new Image(); img6on.src = '/images/menu_top_cs_on.gif';
  img7on = new Image(); img7on.src = '/images/menu_top_about_on.gif';
  img8on = new Image(); img8on.src = '/images/menu_top_vip_on.gif';
  img9on = new Image(); img9on.src = 'http://mediacomcable.com/images/menu_top_special_on.gif';
  // TOP MENU MOUSE OFF
  img1off = new Image(); img1off.src = '/images/menu_top_home_off.gif';
  img2off = new Image(); img2off.src = '/images/menu_top_tv_off.gif';
  img3off = new Image(); img3off.src = '/images/menu_top_net_off.gif';
  img4off = new Image(); img4off.src = '/images/menu_top_phone_off.gif';
  img5off = new Image(); img5off.src = '/images/menu_top_bs_off.gif';
  img6off = new Image(); img6off.src = '/images/menu_top_cs_off.gif';
  img7off = new Image(); img7off.src = '/images/menu_top_about_off.gif';
  img8off = new Image(); img8off.src = '/images/menu_top_vip_off.gif';
  img9off = new Image(); img9off.src = 'http://mediacomcable.com/images/menu_top_special_off.gif';
  // BOTTOM MENU MOUSE ON
  img11on = new Image(); img11on.src = '/images/menu_bottom_pybo_on.gif';
  img12on = new Image(); img12on.src = '/images/menu_bottom_pc_on.gif';
  img13on = new Image(); img13on.src = '/images/menu_bottom_aoct_on.gif';
  img14on = new Image(); img14on.src = '/images/menu_bottom_cam_on.gif';
  img15on = new Image(); img15on.src = '/images/menu_bottom_hsbs_on.gif';
  // BOTTOM MENU MOUSE OFF
  img11off = new Image(); img11off.src = '/images/menu_bottom_pybo_off.gif';
  img12off = new Image(); img12off.src = '/images/menu_bottom_pc_off.gif';
  img13off = new Image(); img13off.src = '/images/menu_bottom_aoct_off.gif';
  img14off = new Image(); img14off.src = '/images/menu_bottom_cam_off.gif';
  img15off = new Image(); img15off.src = '/images/menu_bottom_hsbs_off.gif';
  // SERVICES MOUSE ON
  img21on = new Image(); img21on.src = '/images_dynamic/srv_family_yes_on.gif';
  img22on = new Image(); img22on.src = '/images_dynamic/srv_starpak_yes_on.gif';
  img23on = new Image(); img23on.src = '/images_dynamic/srv_ondemand_yes_on.gif';
  img24on = new Image(); img24on.src = '/images_dynamic/srv_digital_yes_on.gif';
  img25on = new Image(); img25on.src = '/images_dynamic/srv_hdtv_yes_on.gif';
  img26on = new Image(); img26on.src = '/images_dynamic/srv_dvr_yes_on.gif';
  img27on = new Image(); img27on.src = '/images_dynamic/srv_online_yes_on.gif';
  img28on = new Image(); img28on.src = '/images_dynamic/srv_max_yes_on.gif';
  img29on = new Image(); img29on.src = '/images_dynamic/srv_phone_yes_on.gif';
  //SERVICES MOUSE OFF
  img21off = new Image(); img21off.src = '/images_dynamic/srv_family_yes_off.gif';
  img22off = new Image(); img22off.src = '/images_dynamic/srv_starpak_yes_off.gif';
  img23off = new Image(); img23off.src = '/images_dynamic/srv_ondemand_yes_off.gif';
  img24off = new Image(); img24off.src = '/images_dynamic/srv_digital_yes_off.gif';
  img25off = new Image(); img25off.src = '/images_dynamic/srv_hdtv_yes_off.gif';
  img26off = new Image(); img26off.src = '/images_dynamic/srv_dvr_yes_off.gif';
  img27off = new Image(); img27off.src = '/images_dynamic/srv_online_yes_off.gif';
  img28off = new Image(); img28off.src = '/images_dynamic/srv_max_yes_off.gif';
  img29off = new Image(); img29off.src = '/images_dynamic/srv_phone_yes_off.gif';
}
//------------------------------------------------------------------------------------------------------------------------
//  CLEAR INPUT FIELD
function clearField(field)
{
if ((field.value == field.defaultValue) || (field.value == "Not a valid zip") || (field.value == "Five digit zip"))
{
field.value = "";
}
}
//------------------------------------------------------------------------------------------------------------------------
function checkField(field)
{
if (field.value == "")
{
field.value = field.defaultValue;
}
}
//------------------------------------------------------------------------------------------------------------------------
//  POPUP
function openWindow(url)
{
  newWindow = window.open(url, 'popup', 'toolbar=no,status=no,scrollbars=no,dependant,resizable=no,width=450,height=600,left=yes,top=yes');
  newWindow.focus();
}
function openResizableWindow(url)
{
  newWindow = window.open(url, 'popup', 'toolbar=no,status=no,scrollbars=no,dependant,resizable=yes,width=600,height=600,left=yes,top=yes');
  newWindow.focus();
}
//------------------------------------------------------------------------------------------------------------------------
//  POPUP small
function openWindowSmall(url)
{
  newWindow = window.open(url, 'popupsmall', 'toolbar=no,status=no,scrollbars=no,dependant,resizable=no,width=450,height=400,left=yes,top=yes');
  newWindow.focus();
}
//------------------------------------------------------------------------------------------------------------------------
//  POPUP Investor Relations
function openIRWindow(url)
{
  newWindow = window.open(url, 'popupsmall', 'toolbar=no,status=no,scrollbars=yes,dependant,resizable=no,width=550,height=600,left=yes,top=yes');
  newWindow.focus();
}
//------------------------------------------------------------------------------------------------------------------------

//  POPUP small
function openInternationalRatesWindow(url)
{
   newWindow = window.open(url, 'popupsmall', 'toolbar=no,status=no,scrollbars=no,dependant,resizable=no,width=475,height=375,left=yes,top=yes');
   newWindow.focus();
}
/***********************************************
* Switch Content script- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use. Last updated April 2nd, 2005.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
var enablepersist="on" //Enable saving state of content structure using session cookies? (on/off)
var collapseprevious="no" //Collapse previously open content when opening present? (yes/no)
var contractsymbol='- ' //HTML for contract symbol. For image, use: <img src="../javascript/whatever.gif">
var expandsymbol='+ ' //HTML for expand symbol.
//------------------------------------------------------------------------------------------------------------------------
if (document.getElementById)
{
  //alert("creating switchcontent style class");
  document.write('<style type="text/css">')
  document.write('.switchcontent{display:none;}')
  document.write('</style>')
}
//------------------------------------------------------------------------------------------------------------------------
function getElementbyClass(rootobj, classname)
{
   //this does not work
   var temparray=new Array()
   var inc=0
   var rootlength=rootobj.length
   for (i=0; i<rootlength; i++)
   {
      //alert("rootobj["+i+"].className="+rootobj[i].className);
      if (rootobj[i].className==classname)
      temparray[inc++]=rootobj[i]
   }
   return temparray
}
//------------------------------------------------------------------------------------------------------------------------
function sweeptoggle(ec){
var thestate=(ec=="expand")? "block" : "none"
var inc=0
while (ccollect[inc]){
ccollect[inc].style.display=thestate
inc++
}
revivestatus()
}
//------------------------------------------------------------------------------------------------------------------------
function contractcontent(omit){
var inc=0
  /*
  while (ccollect[inc])
  {
  if (ccollect[inc].id!=omit)
  ccollect[inc].style.display="none"
  inc++
  }
  */
}
//------------------------------------------------------------------------------------------------------------------------
function expandcontent(curobj, cid){
var spantags=curobj.getElementsByTagName("SPAN")
var showstateobj=getElementbyClass(spantags, "showstate")
if (ccollect.length>0){
if (collapseprevious=="yes")
contractcontent(cid)
document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="block")? "block" : "none"
if (showstateobj.length>0){ //if "showstate" span exists in header
if (collapseprevious=="no")
showstateobj[0].innerHTML=(document.getElementById(cid).style.display=="block")? contractsymbol : expandsymbol
else
revivestatus()
}
}
}
//------------------------------------------------------------------------------------------------------------------------
function revivecontent()
{
    contractcontent("omitnothing")
    selectedItem=getselectedItem()
    selectedComponents=selectedItem.split("|")
    for (i=0; i<selectedComponents.length-1; i++)
    document.getElementById(selectedComponents[i]).style.display="block"
}
//------------------------------------------------------------------------------------------------------------------------
function revivestatus()
{
      var inc=0
      while (statecollect[inc])
      {
        if (ccollect[inc].style.display=="block")
        statecollect[inc].innerHTML=contractsymbol
        else
        statecollect[inc].innerHTML=expandsymbol
        inc++
      }
}
//------------------------------------------------------------------------------------------------------------------------
function get_cookie(Name) 
{
  var search = Name + "="
  var returnvalue = "";
  if (document.cookie.length > 0) 
  {
     offset = document.cookie.indexOf(search)
     if (offset != -1)
     {
        offset += search.length
        end = document.cookie.indexOf(";", offset);
        if (end == -1) end = document.cookie.length;
        returnvalue=unescape(document.cookie.substring(offset, end))
     }
  }
  return returnvalue;
}
//------------------------------------------------------------------------------------------------------------------------
function getselectedItem()
{
  if (get_cookie(window.location.pathname) != "")
  {
     selectedItem=get_cookie(window.location.pathname)
     return selectedItem
  }
  else
  {
     return ""
  }
}
//------------------------------------------------------------------------------------------------------------------------
function saveswitchstate()
{
   var inc=0, selectedItem=""
   /*
   while (ccollect[inc])
   {
      if (ccollect[inc].style.display=="block")
      selectedItem+=ccollect[inc].id+"|"
      inc++
   }
   document.cookie=window.location.pathname+"="+selectedItem
   */
}

if (enablepersist=="on" && document.getElementById)
{
    window.onunload=saveswitchstate
}
//------------------------------------------------------------------------------------------------------------------------
//functions added after pknetworks

function click_submit(in_value)
{
	document.main.button_click.value = in_value;
	document.main.submit();
}
//------------------------------------------------------------------------------------------------------------------------
function click_submit_signup(in_value)
{
	var agree = confirm("I authorize Mediacom to send me service updates in my area by email.");
	if (agree){
		document.main.button_click.value = in_value;
		document.main.submit();		
		return true ;
	}
	else
	{
		return false ;
	}
}
//------------------------------------------------------------------------------------------------------------------------
function checkAll(inObj)
{

	//called when the "all" checkbox is clicked
	if(inObj.checked)
	{
		set_value=true;
	} 
   else
   {
      set_value=false;
   }
	//set all checkboxes as determined above
	for(i=2;i<document.main.elements.length;i++)
	{
		if(document.main.elements[i].type == "checkbox" && document.main.elements[i] != inObj)
			document.main.elements[i].checked=set_value;
	}
}
//------------------------------------------------------------------------------------------------------------------------
//called by checkboxes when clicked
function notAll(in_obj)
{
	if(!in_obj.checked)
	{
		for(i=2;i<document.main.elements.length;i++)
		{
			if(document.main.elements[i].type == "checkbox" && document.main.elements[i].value == "-1")
				document.main.elements[i].checked=false;
		}
	}
}
 //------------------------------------------------------------------------------------------------------------------------
//  Job POPUP
function openJobDetails(url)
{
  newWindow = window.open(url, 'popup', 'toolbar=no,status=no,scrollbars,dependant,resizable=no,width=520,height=450,left=yes,top=yes');
  newWindow.focus();
}
//------------------------------------------------------------------------------------------------------------------------
//Javascript for displaying EZ Armor divs
var scrollX  = 0;
var scrollY  = 0;
var mywidth  = 0;
var myheight = 0;

function calcSCROLL(){
	if(typeof(window.pageYOffset)=='number') {
		scrollY = window.pageYOffset;
		scrollX = window.pageXOffset;
	}
	else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		scrollY = document.body.scrollTop;
		scrollX = document.body.scrollLeft;
	} 
	else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		scrollY = document.documentElement.scrollTop;
		scrollX = document.documentElement.scrollLeft;
	}
}

function getDims(){
	if( typeof( window.innerWidth ) == 'number' ) {
		mywidth = window.innerWidth - 30;
		myheight = window.innerHeight;
	} 
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		mywidth = document.documentElement.clientWidth;
		myheight = document.documentElement.clientHeight;
	} 
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		mywidth = document.body.clientWidth;
		myheight = document.body.clientHeight;
	}
}

function showDIV(idIN) {
	calcSCROLL();
	var tempA = document.getElementById("antivirusDIV").style;
	var tempB = document.getElementById("fwDIV").style;
	var tempC = document.getElementById("spywareDIV").style;
	var temp  = document.getElementById(idIN).style;
	var leftSpace = (mywidth)-(mywidth/2)-((mywidth*0.7)/2);
	
	if(leftSpace >=0){
		temp.left = leftSpace;
	}
	else{
		temp.left = 0;
	}
	temp.top  = (myheight*0.10)+(scrollY);
	tempA.visibility = "hidden";
	tempB.visibility = "hidden";
	tempC.visibility = "hidden";
	temp.visibility = "visible";
}

function hideDIV(idIN) {
	var temp  = document.getElementById(idIN).style;
	temp.visibility = "hidden";
}

//-------------------------------------------------------------------------------------------------------------
//To show Payment center divs
function openCenteredDiv(divName){
	getDims();
	var temp  = document.getElementById(divName).style;
	var tempWidth = parseInt(temp.width);
	var leftSpace = (mywidth/2)-(tempWidth/2);
	
	if(leftSpace >=10){
		temp.left = leftSpace;
	}
	else{
		temp.left = 10;
	}
	temp.visibility = "visible";
}

function moveXbySlicePos (x, img) { 
	if (!document.layers) {
		var onWindows = navigator.platform ? navigator.platform == "Win32" : false;
		var macIE45 = document.all && !onWindows && getExplorerVersion() == 4.5;
		var par = img;
		var lastOffset = 0;
		while(par){
			if( par.leftMargin && ! onWindows ) x += parseInt(par.leftMargin);
			if( (par.offsetLeft != lastOffset) && par.offsetLeft ) x += parseInt(par.offsetLeft);
			if( par.offsetLeft != 0 ) lastOffset = par.offsetLeft;
			par = macIE45 ? par.parentElement : par.offsetParent;
		}
	} else if (img.x) x += img.x;
	return x;
}

function moveYbySlicePos (y, img) {
	if(!document.layers) {
		var onWindows = navigator.platform ? navigator.platform == "Win32" : false;
		var macIE45 = document.all && !onWindows && getExplorerVersion() == 4.5;
		var par = img;
		var lastOffset = 0;
		while(par){
			if( par.topMargin && !onWindows ) y += parseInt(par.topMargin);
			if( (par.offsetTop != lastOffset) && par.offsetTop ) y += parseInt(par.offsetTop);
			if( par.offsetTop != 0 ) lastOffset = par.offsetTop;
			par = macIE45 ? par.parentElement : par.offsetParent;
		}		
	} else if (img.y >= 0) y += img.y;
	return y;
}

function FIND(item) {
	if( window.mmIsOpera ) return(document.getElementById(item));
	if (document.all) return(document.all[item]);
	if (document.getElementById) return(document.getElementById(item));
	return(false);
}

//----------------------------------------------------------------------------------------------------------------
//To show/hide generic popup divs
function showPopupDiv(divName, linkName, x, y){
	var obj = FIND(linkName) || document.images[linkName] || document.links[linkName] || document.anchors[linkName];
	var temp = document.getElementById(divName).style;
	
	x = moveXbySlicePos (x, obj);
	y = moveYbySlicePos (y, obj);
	
	temp.left = x;
	temp.top = y;
	temp.visibility = "visible";
}

function hidePopupDiv(divName){
	var temp = document.getElementById(divName).style;
	temp.visibility = "hidden";
	temp.left = -2000;
	temp.top = -2000;
}

//Auto tab function for phone entry
function autoTab(element, nextElement) {
    if (element.value.length == element.maxLength && nextElement != null) {
        element.form.elements[nextElement].focus();
    }
}

//Checks for valid email address
function validateEmail(str) 
{
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	
	if (str.indexOf(at)==-1)
	{
		return false
	}
	
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
	{
		return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
	{
		return false
	}

	if (str.indexOf(at,(lat+1))!=-1)
	{
		return false
	}

	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
	{
		return false
	}

	if (str.indexOf(dot,(lat+2))==-1)
	{
		return false
	}
		
	if (str.indexOf(" ")!=-1)
	{
		return false
	}

	return true					
}