﻿try
{
	if( (window.location.href.toLowerCase().indexOf("http://forms.idc.ac.il/en/ec/youngentrepreneurs/forum") < 0) && (window.location.href.toLowerCase().indexOf("http://forms.idc.ac.il/en/imba/calendar") < 0) && (window.location.href.toLowerCase().indexOf("http://forms.idc.ac.il/he/schools/government/aboutus") < 0) && (window.location.href.toLowerCase().indexOf("http://forms.idc.ac.il/he/executive_education/homepage/") < 0)) 
	{
		if( window.location.href.slice(0,12).toLowerCase() == "http://forms" )
			window.location = window.location.href.toLowerCase().replace("http://forms","http://portal");
	}
}
catch(e){}

// Check if Object is Null
function IsNull(obj)
{
	return typeof(obj) == 'undefined' || obj == null;
}

// Apply Trim on text
function Trim(txt)
{
	return txt.replace(/^\s*|\s*$/g,"");
}	

//  Is Login - if the user is loged in show the EditPage Navigation
function IsLogin()
{
//debugger;
	if( IsNull(document.all.EditPageRow) ) return;

	if (IsLoginRequired())
		//id the "login" link is shown
   		document.all.EditPageRow.style.display="none";
	else
		//the user menu is shown (a span tag)
	   	 document.all.EditPageRow.style.display="block";
}

// On Keypress Event Occour, check if the user type "shift + e"
// If Yes: Show Login Nav
function OnKeypressEvent()
{
	switch (event.keyCode)
	{
		// Shift + E
		case 69:
			if (IsLoginRequired() && !IsNull(document.all.EditPageRow) )
			{
				// The user type Shift + E, Show Login Nav 
	       			document.all.EditPageRow.style.display="block";   
			}
			break;
		default:
			break;
	}	
}

function IsLoginRequired()
{
	var isLoginReq = true;
	
	try
	{
		if (!IsNull(document.all.IDCLoginRow.firstChild))	
			isLoginReq = document.all.IDCLoginRow.firstChild.tagName == "A";
	}
	catch(e){}

	return isLoginReq
}

//Code for ClickTracks
  
/*function ClickTracks_deprecated()
{
    var script1 = document.createElement("script");
    script1.src = 'src="'+document.location.protocol+'//stats1.clicktracks.com/cgi-bin/ctasp-server.cgi?i=nBsYttAnJLEwqP&fp=1&c='+escape(document.cookie)+'">';
    script1.type = 'text/javascript';
    document.body.appendChild(script1);
    
    var noscriptTag = document.createElement("div");
    noscriptTag.id = "noscriptTag";
    noscriptTag.innerHTML = "<noscript><img src='https://stats1.clicktracks.com/cgi-bin/ctasp-server.cgi?i=nBsYttAnJLEwqP&g=1' alt='Web Analytics' border=0 /></noscript>";
    document.body.appendChild(noscriptTag);
}

function ClickTracks()
{
    var script1 = document.createElement("script");
    script1.setAttribute("src",document.location.protocol+'//stats1.clicktracks.com/cgi-bin/ctasp-server.cgi?i=nBsYttAnJLEwqP&fp=1&c='+escape(document.cookie));
    script1.setAttribute("type","text/javascript");
    script1.setAttribute("id","clicktrack");
    document.body.appendChild(script1);
    
    var noscriptTag = document.createElement("div");
    noscriptTag.id = "noscriptTag";
    noscriptTag.innerHTML = "<noscript><img src='https://stats1.clicktracks.com/cgi-bin/ctasp-server.cgi?i=nBsYttAnJLEwqP&g=1' alt='Web Analytics' border=0 /></noscript>";
    document.body.appendChild(noscriptTag);
}*/

/************************************/
/* for IDCsite.master + rrismaster */
function checkLang()
		{
			urlpath = document.location.href.toString();
			var langExp = new RegExp("/he/");
			var Helang = urlpath.search(langExp);
			if(Helang >0)
				return "He";
			else
				return "En";	
		}
		function GetRRISDate()
		{
			var d=new Date();
			var MyMonth = new Array(12);
			var urlpath = new String();
			
			if(checkLang() == "He")
			{
				MyMonth[0] = "ינואר";
				MyMonth[1] = "פברואר";
				MyMonth[2] = "מרץ";
				MyMonth[3] = "אפריל";
				MyMonth[4] = "מאי";
				MyMonth[5] = "יוני";
				MyMonth[6] = "יולי";
				MyMonth[7] = "אוגוסט";
				MyMonth[8] = "ספטמבר";
				MyMonth[9] = "אוקטובר";
				MyMonth[10] = "נובמבר";
				MyMonth[11] = "דצמבר";
				document.write(d.getDate() + ' ' + MyMonth[d.getMonth()] + ' ,' + d.getYear());
			}
			else
			{
				MyMonth[0] = "January";
				MyMonth[1] = "Febuary";
				MyMonth[2] = "March";
				MyMonth[3] = "April";
				MyMonth[4] = "May";
				MyMonth[5] = "June";
				MyMonth[6] = "July";
				MyMonth[7] = "August";
				MyMonth[8] = "September";
				MyMonth[9] = "October";
				MyMonth[10] = "November";
				MyMonth[11] = "December";
				document.write(MyMonth[d.getMonth()] + ' ' + d.getDate() + ' , ' +d.getYear());				
			}

		}
		function WriteHomePage()
		{
			if(checkLang() == "He")
			{
				document.write("<a href='https://www.idc.ac.il/heb'>עמוד הבית</a>");
			}
			else
			{
				document.write("<a href='https://www.idc.ac.il/eng'>Home Page</a>");
			}
		}
		function WriteContactUs()
		{
			if(checkLang() == "He")
			{
				document.write("<a href='/he/Main/about_idc/campus_tour/Pages/ContactUs.aspx'>צור קשר</a>");
			}
			else
			{
				document.write("<a href='/en/main/about_idc/campus_tour/Pages/ContactUs.aspx'>Contact Us</a>");
			}
		}
		function WriteSiteMap()
		{
			if(checkLang() == "He")
			{
				document.write("<a href='/he/main/about_idc/sitemap/Pages/sitemap.aspx'>מפת האתר | </a>");
			}
			else
			{
				document.write("<a href='/en/main/about_idc/sitemap/Pages/sitemap.aspx'>Site Map | </a>");
			}
		}	
/************************************/


function IDCGalleryNextItem()
{
    ArrayRowIndex++;
    if(ArrayRowIndex >= ItemsGalleryArray.length)
    {
        var item1 = document.getElementById('IDCGalleryImage');
        item1.src=ItemsGalleryArray[0][1];
	item1.alt=ItemsGalleryArray[0][2];
        //item1 = document.getElementById('IDCGalleryTextDesc');
        //item1.innerHTML=ItemsGalleryArray[0][2];
        item1 = document.getElementById('IDCGalleryTextTitle');
        item1.innerHTML='<strong>'+ItemsGalleryArray[0][3] +'</strong>';
        ArrayRowIndex = 0;
    }
    if(ArrayRowIndex < ItemsGalleryArray.length)
    {
        var item = document.getElementById('IDCGalleryImage');
        item.src=ItemsGalleryArray[ArrayRowIndex][1];
	item.alt=ItemsGalleryArray[ArrayRowIndex][2];
        //item = document.getElementById('IDCGalleryTextDesc');
        //item.innerHTML=ItemsGalleryArray[ArrayRowIndex][2];
        item1 = document.getElementById('IDCGalleryTextTitle');
        item1.innerHTML= '<strong>'+ ItemsGalleryArray[ArrayRowIndex][3] + '</strong>' ;
    }
}

function ResetNewsEvents()
{
    var x = document.getElementById('ctl00_ctl15_g_4f69767f_23cc_40d3_aa09_45698887b690_cboMonth');
        x.value='-1';
        x = document.getElementById('ctl00_ctl15_g_4f69767f_23cc_40d3_aa09_45698887b690_cboYear');
        x.value='-1';
        x = document.getElementById('ctl00_ctl15_g_4f69767f_23cc_40d3_aa09_45698887b690_cboOrganizer');
        x.value='-1';
}

function IDCHeaderSchoolName()
		{
			var other = true;
			var cUrl = document.location.href.toLowerCase();
			if(cUrl.indexOf('/he/schools/government/') > 0)
			{
				document.write('<tr><td class="school_newTitle" colspan="2"><center><b>בית ספר לאודר לממשל, דיפלומטיה ואסטרטגיה<h1 align="center"></H1></td></tr>');
				other = false;
			}
			if(cUrl.indexOf('/he/schools/communications/') > 0)
			{
				document.write('<tr><td class="school_newTitle" colspan="2"><center><b>בית ספר סמי עופר לתקשורת</b></center></td></tr>');
				other = false;
			}
			if(cUrl.indexOf('/he/schools/law/') > 0)
			{
				document.write('<tr><td class="school_newTitle" colspan="2"><center><b>בית ספר רדזינר למשפטים</b></center></td></tr>');
				other = false;
			}
			if(cUrl.indexOf('/he/schools/business/') > 0)
			{
				document.write('<tr><td class="school_newTitle" colspan="2"><center><b>בית ספר אריסון למנהל עסקים</b></center></td></tr>');
				other = false;
			}
			if(cUrl.indexOf('/he/schools/psychology/') > 0)
			{
				document.write('<tr><td class="school_newTitle" colspan="2"><center><b>בית הספר החדש לפסיכולוגיה</b></center></td></tr>');
				other = false;				
			}
			if(cUrl.indexOf('/he/schools/cs/') > 0)
			{
				document.write('<tr><td class="school_newTitle" colspan="2"><center><b>בית ספר אפי ארזי למדעי המחשב</b></center></td></tr>');
				other = false;
			}
			if(cUrl.indexOf('/he/schools/rris/') > 0)
			{
				document.write('<tr><td class="school_newTitle" colspan="2"><center><b>בית ספר רפאל רקנאטי הבינ"ל</b></center></td></tr>');
				other = false;
			}		
			if(other)
			{
				var imgLogo = document.getElementById('idcTopLogo');
				imgLogo.src = "/PublishingImages/NewSiteStyle/logo.gif";
			}
		}
function newsOpenWindow(address) 
{
window.open( address, "myWindow", 
"status = 1, height = 200, width = 250, resizable = 0" )
}

var time = null
function move(adress) {
window.location = adress
}




function autoenableflash() 
{
	objects = document.getElementsByTagName("object");
	for (var i = 0; i < objects.length; i++)
		{
		objects[i].outerHTML = objects[i].outerHTML;
		}
} 

function ChangeCredits(ddl_StatusId, txt_CreditsId, ClientId_Prefix) {
    //debugger;
    var txt_CreditsClientId = txt_CreditsId;
    var ddl_StatusClientId = ClientId_Prefix + "$" + ddl_StatusId;
    txt_Credits = document.getElementById(txt_CreditsClientId);
    ddl_Status = document.getElementById(ddl_StatusClientId);
    if (ddl_Status.value == "לא הגיע - חייב בעונש" && (parseInt(txt_Credits.value) > 0)) {
        txt_Credits.value = parseInt(txt_Credits.value) - 2 * parseInt(txt_Credits.value);
    }
    if ((ddl_Status.value == "הגיע" || ddl_Status.value == "לא הגיע - ללא עונש") && (parseInt(txt_Credits.value) < 0)) {
        txt_Credits.value = Math.abs(parseInt(txt_Credits.value));
    }
}
function CheckSaveRegistrationPsychoStatus() {
    //debugger;
    if (postback == true && !confirmed) {
        return "שינויים שביצעת לא נשמרו במערכת! האם אתה בטוח שהינך מעוניין לצאת מהדף  ? כדי לשמור יש ללחוץ  cancel ואז שמור שינויים";
        }
    }
    function ConfirmWindow(obj) {
        //debugger;
        var res = true;    
        if (postback == true) {
            var res = confirm("שינויים שביצעת לא נשמרו במערכת! האם אתה בטוח שהינך מעוניין לצאת מהדף  ? כדי לשמור יש ללחוץ בטל ואז שמור שינויים");
            if (res)
                confirmed = true;
            else {
                confirmed = false;
                savedStatus = document.getElementById(saveDdlStatusId);
                savedTestName = document.getElementById(saveDdlTestNamesId);
                savedStatus.value = OrigStatesValue;
                savedTestName.value = OrigTestNameValue;
            }
        }
        return res;
    }
    function OnDataChange() {
       postback = true;
    }

function ConfirmBeforeDelete(source) {
    var msg = '';
    if (source == 'DeleteTestOccasion') {
        msg = 'אתה עומד למחוק את המועד, האם אתה בטוח?';
    }
    if (source == 'DeleteTestOccasionRegistration') {
        msg = 'אתה עומד למחוק הרשמה של משתתף בניסוי , האם אתה בטוח?';
    }
    var res = confirm(msg);
    if (res)
        confirmed = true;
    else
        confirmed = false;

    return confirmed;

}
var OrigStatesValue, OrigTestNameValue;

function SaveStates() {
    var ddlStatus = document.getElementById(saveDdlStatusId);
    var ddlTestNames = document.getElementById(saveDdlTestNamesId);
    OrigStatesValue = ddlStatus.value;
    OrigTestNameValue = ddlTestNames.value;
}


