function isInteger(theData) 
{ 
	return (theData.search(/^\d+$/) != -1); 
}

function isDate(theDate) 
{
	var DatePattern = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/;
	var matchArray = theDate.match(DatePattern);
	if (matchArray == null) return false;
	var day = matchArray[1];
	var month = matchArray[3];
	var year = matchArray[4];			
	if ((month < 1) || (month>12)) return false;
	if (day < 1 || day > 31) return false;
	if (year < 1900) return false;
	if ((month == 4 || month == 6 || month==9 || month == 11) && day == 31) return false;
	if (day>=29 && month == 2 && parseInt(year) % 4 !== 0) {return false;}
	if (day>=30 && month == 2 && parseInt(year) % 4 == 0) {return false;}
	return true;
}
function isEmail(theEmail) {
	var emailEXP = /^[a-z_0-9\.]+@[a-z_0-9\.]+\.[a-z]{2,3}$/i
    var IsValid = false;
    if (!theEmail.match(emailEXP)){
		IsValid=false;
	}
	else{
		IsValid = true
	}
	return IsValid
}

function oam(lang)
{ 
	if (lang=='el')	document.forms[0].action="https://services.forthnet.gr/oam/portal/action/Login/template/Login.vm"
	else document.forms[0].action="https://services.forthnet.gr/oam/portal/action/ChangeLanguage/template/Login.vm?key=en"
	formSubmit();
} 

function Webmail() 
{	
	if (document.forms[0].pop3host != null && document.forms[0].pop3host.value == "internet.gr")
	{
		document.forms[0].login_username.value = document.forms[0].username.value;
		document.forms[0].secretkey.value = document.forms[0].password.value;
		document.forms[0].action="http://webmail.internet.gr/src/redirect.php";
	}
	else if (document.forms[0].pop3host != null && document.forms[0].pop3host.value == "forthnet.gr")
	{
		document.forms[0].txtUserName.value = document.forms[0].username.value + '@' + document.forms[0].pop3host.value;
		document.forms[0].txtPassword.value = document.forms[0].password.value;
		document.forms[0].action="https://webmail2.forthnet.gr/default.asp";
	}
	else
	{
		document.forms[0].action="http://webmail.forthnet.gr/defaultinterface/atmail.pl";
	}
	formSubmit(); 
}

function checkWMKey() 
	{
	
	if (event.keyCode == 13)
		{
		Webmail();
		}
	}
function formSubmit() 
{ 
	var Form1 = document.forms[0];   
	Form1.target="_new";  
	Form1.submit();  
	Form1.reset(); 
	Form1.target="_self";  
	Form1.action="";
} 
/////////////////////////////////////////////////////////////////////////////////////
// Pop-Up window
// Type: Generic Script
// Variable : popurl > The location URL (eg. http//www.futureneed.gr)
//            popwindowname > the window name
//            popwidth > the window width
//            popheight > the window height
//            poptoolbar > will the popup have toolbar? (1, 0)
//            poplocation > will the popup have location bar? (1, 0)
//            popresizable > will the popup be resizable? (1, 0)
//            popscrollbar > will the popup have scrollbars? (1, 0)
//            popstatusbar > will the popup have status bar? (1, 0)
//			  menubar	> will the popup have menu bar? (1, 0)	
// Function Call : href="popupwindow('target URL', 'New Window Name', Width, height, toolbar(1/0), locationbar(1/0), resizable(1/0), scrollbar(1/0), statusbar(1/0));"
function popupwindow(popurl,popwindowname,popwidth,popheight,poptoolbar,poplocation,popresizable,popscrollbar,popstatusbar,popmenubar) 
{
	var W = (screen.width/2 - popwidth/2);
	var H = (screen.height/2 - popheight/2);
	newpopup = window.open(popurl,popwindowname,'width='+popwidth+',height='+popheight+',toolbar='+poptoolbar+',location='+poplocation+',resizable='+popresizable+',scrollbars='+popscrollbar+',menubar='+popmenubar+',status='+popstatusbar+',top='+H+',left='+W+'');
	newpopup.focus();
}
function openpopup(popurl,popwindowname,properties) 
{
	newpopup = window.open(popurl,popwindowname,properties);
	newpopup.focus();
}
/////////////////////////////////////////////////////////////////////////////////////

function openRadio()
{
	var url="/radio";
	mywidth=400;
	myheight=472;
	resize="no";
	window.open(url, "", "width="+mywidth+",height="+myheight+",scrollbars=no,resizable=no");
	
}
function openeuroelections()
{
	//popupwindow("http://web.smart.gr/partner_sites/www.forthnet.gr/euroelections/frameset.asp","euroelections",770,500,0,0,0,0,0,0)
	url="http://web.smart.gr/elections2007/frameset.asp";
	title="euroelections"
	mywidth=1000;
	myheight=650;
	resize="no";
	if (!resize)
		{resize="yes"}
	if (typeof(popupWin) != "object") 
		{
		title = window.open(url, title, "width="+mywidth+",height="+myheight+",top=10,left=5,alwaysRaised=yes,toolbar=0,directories=0,menubar=0,status=0,resizable="+resize+",location=0,scrollbars=no,copyhistory=0");
		}
	else
		{
		if (!popupWin.closed) 
			{
			popupWin.location.href = url;
			}
		else 
			{
			title = window.open(url, title, "width="+mywidth+",height="+myheight+",top=10,left=5,alwaysRaised=yes,toolbar=0,directories=0,menubar=0,status=0,resizable="+resize+",location=0,scrollbars=no,copyhistory=0");
			}
		} 
	title.focus();
}
function npswitch(posting)
{ 
	for (j = 1 ; j < 4; j++) {
		document.getElementById("paper_"+j).style.display = "none";
		document.getElementById("paperDate_"+j).style.display = "none";
		
		document.getElementById('paperTD_'+j).className ='bgverylightblue smallpadding bold searchpaging t2';
		
	}
	document.getElementById("paper_"+posting).style.display="block";
	document.getElementById("paperDate_"+posting).style.display="block";
	document.getElementById('paperTD_'+posting).className ='bglightyellow smallpadding bold searchpaging t2';	
}
function showSport(sportID)
{
	var allDiv = document.getElementsByTagName("div");
	for (i=0 ; i < allDiv.length; i++)
	{
		if (allDiv[i].id.toLowerCase().indexOf('sport') > -1)
		{
			allDiv[i].style.display="none";		
		}
	}
	document.getElementById('sport'+sportID).style.display="block";
}

function sportsProgramValueChanged(obj, channelId, path)
{
	var selectedValue;
	var sUrl = path+"?c=" + channelId;
	var oSlcPhase = document.getElementById("slcPhase");
	if (oSlcPhase != null && typeof oSlcPhase == "object"){
		selectedValue = oSlcPhase.options[oSlcPhase.selectedIndex].value;
		sUrl += "&phaseId=" + selectedValue;
	}
	/* if the control being changed is the one which is associated with phase, reset
		the value of day controls and set it to the first day  */
	if (obj.id != "slcPhase"){ 
		var oSlcDay = document.getElementById("slcDay");
		if (oSlcDay != null && typeof oSlcDay == "object"){
			selectedValue = oSlcDay.options[oSlcDay.selectedIndex].value;
			sUrl += "&dayId=" + selectedValue;
		}
	}
	location.href = sUrl;
}
/*********************** Start SportHomeControl_TabClicked ******************************************/
/*
Date: 13/10/2004
Description: Function SportHomeControl_TabClicked handles the onClick event which is fired by clicking
			 on a Tab in the SportHomeControl control. The implementation code, hides all the presentation 
			 elements (td, tr, table) that are not considered to be visible under the clicked tab and shows
			 the appropriate elemets. That is, when SportHomeControl's tabs respresent the groups of a specific
			 phase of a specific league, then by clicking on a group, control should show only the program
			 and the board of the specific group. On the other hand, when the tabs represent the Program
			 and the Board sections respectively, by making a click on the Program tab, we should see only the program
			 elements.
Parameters: bTabsAreGroupSeparated: Indicates whether the SportHomeControl's tabs represent the groups of a 
								    league phase or, the program and board sections of a league.
			iTabId: In case of groups separation, it holds the GroupId value, whereas in Program-Board case
				    it holds a unique id to separate the tabs(1 for Program, 2 for Board).

*/
function SportHomeControl_TabClicked(bTabsAreGroupSeparated, iTabId)
{
	var oSport = new SportHomeControl("SportHomeControl");
	oSport.TabClicked(bTabsAreGroupSeparated, iTabId);
}

/*********************** End SportHomeControl_TabClicked ******************************************/

function SportHomeControl(sControlName){
//Object Constuctor
	var oTRBoard = document.getElementById("trBoard");	
	var oTRProgram = document.getElementById("trProgram");		
	//Get the left part of control that presents the program
	var oTblProgram = document.getElementById("tblProgram");
	//Get the right part of control that presents the score board 
	var oTblBoard = document.getElementById("tblBoard");
	//Get First Group Tab to know its GroupId
	var oHidFirstGroupTab = document.getElementById("hidFirstGroupTab");
	//Get Last Group Tab to know its GroupId
	var oHidLastGroupTab = document.getElementById("hidLastGroupTab")
	var giTabsNumber;
	this.TabsNumber = giTabsNumber;
	var garTabs = new Array;
	this.Tabs = garTabs;
	CalculateTabs();
	//Tabs Program - Board
	var oProgramImgLeftCorner	= document.getElementById("ProgramImgLeftCorner")
	var oProgramText			= document.getElementById("ProgramText")
	var oProgramImgCenter		= document.getElementById("ProgramImgCenter")
	var oBoardImgRightCorner	= document.getElementById("BoardImgRightCorner")
	var oBoardText				= document.getElementById("BoardText")
	this.TabClicked = TabClicked;
	this.DefaultView = DefaultView;
	function TabClicked(bTabsAreGroupSeparated, iTabId){
		if (bTabsAreGroupSeparated){
		//Control is group separated
			ShowGroup(iTabId);			
		}else{
		//Control is Program/Board separated
			if (iTabId == 1){
				//Show only program contents				
				ShowProgram();
			}else if (iTabId == 2){
				//Show only Board Contents
				ShowBoard();
			}
		}
	}
	function ShowProgram(){
		//Change the colors of tabs
		if (oProgramImgLeftCorner != null && typeof oProgramImgLeftCorner == "object"){
			oProgramImgLeftCorner.src = "/_images/box_left_corner_yellow.gif";
		}
		if (oProgramText != null && typeof oProgramText == "object"){
			oProgramText.className = "tabyellow bgdarkyellow";
		}
		if (oProgramImgCenter != null && typeof oProgramImgCenter == "object"){
			oProgramImgCenter.src = "/_images/box_corner_yb.gif";
		}
		if (oBoardText != null && typeof oBoardText == "object"){
			oBoardText.className = "tab bgdarkblue";
		}
		if (oBoardImgRightCorner != null && typeof oBoardImgRightCorner == "object"){
			oBoardImgRightCorner.src = "/_images/box_right_corner2.gif";
		}
		//Show only Program contents
		if (oTRProgram != null && typeof oTRProgram == "object"){
			oTRProgram.style.display = "";
		}				
		//Hide Board contents
		if (oTRBoard != null && typeof oTRBoard == "object"){
			oTRBoard.style.display = "none";
		}
	}
	function ShowBoard(){
		//Show only Board Contents

		//Change the colors of tabs
		
		if (oProgramImgLeftCorner != null && typeof oProgramImgLeftCorner == "object"){
			oProgramImgLeftCorner.src = "/_images/box_left_corner2.gif";
		}
		if (oProgramText != null && typeof oProgramText == "object"){
			oProgramText.className = "tab bgdarkblue";
		}
		if (oProgramImgCenter != null && typeof oProgramImgCenter == "object"){
			oProgramImgCenter.src = "/_images/box_corner_by.gif";
		}
		if (oBoardText != null && typeof oBoardText == "object"){
			oBoardText.className = "tabyellow bgdarkyellow";
		}
		if (oBoardImgRightCorner != null && typeof oBoardImgRightCorner == "object"){
			oBoardImgRightCorner.src = "/_images/box_right_corner_yellow.gif";
		}
		
		if (oTRBoard != null && typeof oTRBoard == "object"){
			oTRBoard.style.display = "";
		}

		//Hide Program contents
		if (oTRProgram != null && typeof oTRProgram == "object"){
			oTRProgram.style.display = "none";
		}			

	}
	
	function CalculateTabs(){
		var oTRControlTabs = document.getElementById("trControlTabs");
		
		var iFirstGroupId = 0;
		if (oHidLastGroupTab != null && typeof oHidLastGroupTab == "object"){
			iFirstGroupId = oHidLastGroupTab.value;
		}
		
		var iLastGroupId = 0;
		if (oHidLastGroupTab != null && typeof oHidLastGroupTab == "object"){
			iLastGroupId = oHidLastGroupTab.value;
		}

		if (iFirstGroupId > 0 && iLastGroupId == 0){
		
			giTabsNumber = 1;
			garTabs[1] = iFirstGroupId;
			
		}else if (oTRControlTabs != null && typeof oTRControlTabs == "object"){
			var oTdCell;
			var iTabNum = 0;
			var iCellsNumOfTab = 2;
			var iTotalCells = 0;
			var iCellNum = 0;
			var ArCellId = new Array;
			var iCurrTabId;
			var i = 0;
			//find the number of tabs
			for (i=0; i < oTRControlTabs.cells.length; i++){
				oTdCell = oTRControlTabs.cells[i];
				if (oTdCell.firstChild.id != "" || oTdCell.id != ""){
					
					if (oTdCell.firstChild.id != ""){
						iCurrTabId = oTdCell.firstChild.id;
					}else{
						iCurrTabId = oTdCell.id;
					}
					
					iCellNum += 1;
					if (iCellNum == 3){
						iTabNum = 1;
						iTotalCells = iCellNum + iCellsNumOfTab;
						var ArId = iCurrTabId.split("_");
						if (ArId.length == 2){
							ArCellId[iTabNum] = ArId[1];
						}
					}else if (iCellNum == iTotalCells && iTabNum >= 1){
						iTabNum += 1;
						iTotalCells = iCellNum + iCellsNumOfTab;
						var ArId = iCurrTabId.split("_");
						if (ArId.length == 2){
							ArCellId[iTabNum] = ArId[1];
						}
					}
				}
			}
			
			giTabsNumber = iTabNum;
			garTabs = ArCellId;
		}
	}
	
	function ShowGroup(iId){
		var oTrRow = null;
		
		if (oTblProgram != null && typeof oTblProgram == "object"){
			for (var i=0; i<= oTblProgram.rows.length; i++)
			{
				oTrRow = oTblProgram.rows.item(i);
				if (oTrRow != null && typeof oTrRow == "object"){
					var ArIdParts = oTrRow.id.split("_");
					if (ArIdParts.length == 3){
						if ((ArIdParts[0] == "trUnderNextDay" || ArIdParts[0] == "trProg" || ArIdParts[0] == "trNextDay" || ArIdParts[0] == "trUnderProg") && ArIdParts[1]+"" != iId + ""){
							//hide all the rows of which the id attribute consists of the following formula (trProg_GroupId_Position)
							//and GroupId part is not the selected one
							oTrRow.style.display="none";
						}else if ((ArIdParts[0] == "trUnderNextDay" || ArIdParts[0] == "trProg" || ArIdParts[0] == "trNextDay" || ArIdParts[0] == "trUnderProg") && ArIdParts[1]+"" == iId + ""){
							//show all the rows of which the id attribute consists of the following formula (trProg_GroupId_Position)
							//and GroupId part is the selected one
							oTrRow.style.display="";
						}
					}
				}
			}
		}
		
		if (oTblBoard != null && typeof oTblBoard == "object"){
			for (var i=0; i<= oTblBoard.rows.length; i++)
			{
				oTrRow = oTblBoard.rows.item(i);
				if (oTrRow != null && typeof oTrRow == "object"){
					var ArIdParts = oTrRow.id.split("_");
					if (ArIdParts.length == 3){
						if ((ArIdParts[0] == "trBoard" || ArIdParts[0] == "trUnderBoard") && ArIdParts[1]+"" != iId + ""){
							//hide all the rows of which the id attribute consists of the following formula (trProg_GroupId_Position)
							//and GroupId part is not the selected one
							oTrRow.style.display="none";
						}else if ((ArIdParts[0] == "trBoard" || ArIdParts[0] == "trUnderBoard") && ArIdParts[1]+"" == iId + ""){
							//show all the rows of which the id attribute consists of the following formula (trProg_GroupId_Position)
							//and GroupId part is the selected one
							oTrRow.style.display="";
						}
					}
				}
			}
		}
		
		
		//Change the colors of the tabs
		var oTRControlTabs = document.getElementById("trControlTabs");
		var oTdCell = null;
		
		var iFirstGroupId = 0;
		if (oHidLastGroupTab != null && typeof oHidLastGroupTab == "object"){
			iFirstGroupId = oHidLastGroupTab.value;
		}
		
		var iLastGroupId = 0;
		if (oHidLastGroupTab != null && typeof oHidLastGroupTab == "object"){
			iLastGroupId = oHidLastGroupTab.value;
		}

		if (iFirstGroupId > 0 && iLastGroupId == 0){
			//There is only one Group
		}else{
			if (oTRControlTabs != null && typeof oTRControlTabs == "object"){
				
				var iTabNum = 0;
				var iCellsNumOfTab = 2;
				var iTotalCells = 0;
				var iCellNum = 0;
				var ArCellId = new Array;
				var iCurrTabId;
				var i = 0;
				iTabNum = 1;
				var iCellsNumOfFirstTab = 2;
				iTotalCells = iCellsNumOfFirstTab + iCellsNumOfTab;
				iCellNum = 0;
				
				for (i=0; i < oTRControlTabs.cells.length; i++){
				
					oTdCell = oTRControlTabs.cells[i];
					if (oTdCell.firstChild.id != "" || oTdCell.id != ""){
						iCellNum += 1;
						if (iCellNum == iTotalCells && iTabNum >= 1){
							iTabNum += 1;
							iTotalCells = iCellNum + iCellsNumOfTab;
						}
					}
				
					if (oTdCell.firstChild.id != ""){
						//image tag found
						var oImg = oTdCell.firstChild;
						var ArIdParts = oImg.id.split("_");
						if (ArIdParts[1] == iId){
							//is the highlighted tab
							if (ArIdParts[0] == "GroupImgLeftCorner"){
								oImg.src = "/_images/box_left_corner_yellow.gif";							
							}else if (ArIdParts[0] == "GroupImgRightCorner"){
								if (ArIdParts[1] != iLastGroupId){
									//It's a middle tab
									oImg.src = "/_images/box_corner_yb.gif";
								}else{
									//It's the last tab
									oImg.src = "/_images/box_right_corner_yellow.gif";
								}
							}
						}else{
							//is NOT the highlighted tab
							if (ArIdParts[0] == "GroupImgLeftCorner"){
								oImg.src = "/_images/box_left_corner2.gif";
							}else if (ArIdParts[0] == "GroupImgRightCorner"){
								if (ArIdParts[1] != iLastGroupId){
									//It's a middle tab
									if (garTabs[iTabNum + 1] == iId){
										oImg.src = "/_images/box_corner_by.gif";
									}else{
										oImg.src = "/_images/box_corner_bb.gif";
									}
								}else{
									//It's the last tab
									oImg.src = "/_images/box_right_corner2.gif";
								}
							}
						}
					}else if (oTdCell.id != ""){
						//td text found
						var ArIdParts = oTdCell.id.split("_");
						if (ArIdParts[1] == iId){
							oTdCell.className = "tabyellow bgdarkyellow";
						}else{
							oTdCell.className = "tab bgdarkblue";
						}
					}
				}
			}
		}
	}
	
	function DefaultView(){
		
		if (oTRProgram != null && typeof oTRProgram == "object"){
			ShowProgram();
		}else if (oTblProgram != "" && typeof oTblProgram == "object"){
			var iDefaultGroupId = 0;
			if (oHidFirstGroupTab != null && typeof oHidFirstGroupTab == "object"){
				iDefaultGroupId = oHidFirstGroupTab.value;
			}
			ShowGroup(iDefaultGroupId);
		}
	}
}

function PollVote(sURLToVote, iPollId){
	var rdoAnswers = document.getElementsByName("rdoAns");
	var iId = 0;
	if (rdoAnswers != null && typeof rdoAnswers == "object"){
		for (var i=0; i<rdoAnswers.length; i++){
			if (rdoAnswers[i].checked){
				iId = rdoAnswers[i].value;
				break;
			}
		}
	}

	if (iId > 0){
		location.href = sURLToVote + "&ansid=" + iId;

		openpopup('PollResults.aspx?iPollId=' + iPollId,'','scrollbars=yes,width=535,height=395');
	}else{
		alert('Παρακαλώ επιλέξτε μια απάντηση');
	}
	
}

function CheckAvailability(){
	var	txtDomainName = document.getElementById("txtDomainName");
	if (txtDomainName != null && typeof txtDomainName == "object"){
		var sDomainName = txtDomainName.value + ".gr";
		var form = document.forms[0];
		form.action = 'sc.aspx?c=10007058&domainname=' + sDomainName;
		
		form.submit();
		location.href = 'sc.aspx?c=10007058&domainname=' + sDomainName;
		return;
	}
}

function getAdslWizard(){
	var	phone1 = document.getElementById("phone1");
	if (phone1 != null && typeof phone1 == "object")
	{
		if (phone1.value != '')
		{
			//alert('http://adslwizard.forthnet.gr/index.asp?phone=' + phone1.value)
			//openpopup('http://adslwizard.forthnet.gr/index.asp?phone=' + phone1.value,'','scrollbars=no,resizable=no,width=550,height=450');
			popup('http://adslwizard.forthnet.gr/index.asp?phone=' + phone1.value);
			//return;
		}
		else
		{
			alert("Παρακαλούμε συμπληρώστε τον Αρ. Τηλεφώνου σας.");
		}

	}
}

function popup(url) 
{
	var width  = 550
	var height = 450
	var left   = (screen.width  - width)/2;
	var top    = (screen.height - height)/2;
	var params = 'width='+width+', height='+height;
	params += ', top='+top+', left='+left;
	params += ', directories=no';
	params += ', location=no';
	params += ', menubar=no';
	params += ', resizable=no';
	params += ', scrollbars=no';
	params += ', status=no';
	params += ', toolbar=no';
	newwin=window.open(url,'windowname5', params);
	if (window.focus) {newwin.focus()}
	return false;
}

function getAdslActivation(){
	var	phone2 = document.getElementById("phone2");

	if (phone2 != null && typeof phone2 == "object")
	{
		if (phone2.value != '')
		{
			var form = document.forms[0];

//			document.forms['Form1'].action = 'adslstatus.aspx?c=10007803&txtPhoneNum=' + phone2.value;
//			document.forms['Form1'].submit();
			location.href = 'adslstatus.aspx?c=10007803&txtPhoneNum=' + phone2.value;
			
			return;
		}
		else
		{
			alert("Παρακαλούμε συμπληρώστε τον Αρ. Τηλεφώνου σας.");
		}
	}
}

function UserName_Password_OnKeyPress(){
	if (event.keyCode == 13){
		CheckAvailability();
	}
}

/* Portal Home Page: WebEmail Control*/
function UserName_OnFocus(obj){	
	if (obj != null && typeof obj == "object"){
		if (obj.value == "e-mail"){
			obj.value = "";
		}
	}
}
function UserName_OnBlur(obj){	
	if (obj != null && typeof obj == "object"){
		if (obj.value == ""){
			obj.value = "e-mail";
		}
	}
}

/* Portal Home Page: WebEmail Control*/


function ShowPopUpPostingBanner(sPostingUrl){	
	var sPage = "/templates/postingPopUpBanner.aspx";
	var sPostingId;
	var sPostingUrl_Ar = sPostingUrl.split('=');
	var sPostingOrChannnel;
	if (sPostingUrl_Ar.length > 1){
		
		sPostingId = sPostingUrl_Ar[1];
		sPostingOrChannnel = sPostingUrl_Ar[0].substr(sPostingUrl_Ar[0].length -1, 1); 
	}
//	alert(sPostingOrChannnel + " = " + sPostingId );

var sFeatures="width=500,height=370,directories=no,location=no,menubar=no,scrollbars=yes, status=no, toolbar=no,resizable=no,titlebar=yes";
window.open(sPage + "?" + sPostingOrChannnel + "=" + sPostingId, "_blank", sFeatures)
	
}
function getRadioCheckedValue(radioObj) 
{
	if(!radioObj)	return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked) return radioObj.value;
		else return "";
	for(var i = 0; i < radioLength; i++) 
	{
		if(radioObj[i].checked) return radioObj[i].value;
	}
	return "";
}
