﻿
$(document).ready(function(){
    
});

//PEOPLE TAB FUNCTIONS - START
function RenderPeoples()
{
}

function LoadCastUpVod(id,title)
{ 
    $("#VodClipTitle").html(title);
    $("#VODFrame").html("<IFRAME SRC='"+CastUpVODUrl+id+"&ak=null' ALLOWTRANSPARENCY='true' WIDTH='336' HEIGHT='300' FRAMEBORDER='0'></IFRAME>");
   
}


var timeoutFadeIn = null;
var timeoutFadeOut = null;
var index = 1;

function delay(id)
{
    if (timeoutFadeIn)
        clearTimeout(timeoutFadeIn);
        
    timeoutFadeIn = setTimeout(
    function()
    {
        showBigDexUser(id);
    } );   
}
function showBigDexUser(smallDexUserId)
{
    var startTop = -37;     
    var startRight = -32;
   
    var column = smallDexUserId % 11; if (column == 0) { column = 11 };
    var row = Math.ceil(smallDexUserId / 11);
   
    var top = startTop + (row-1) * 67;
    var right = startRight + (column-1) * 63;

    var userHoverHtml = $('#DexUserHover' + smallDexUserId + 'Content').html();
    
    $('#DexUserHover').html(userHoverHtml).css({top:top + 'px', right:right + 'px' }).fadeIn(100
            ,function()
            {
                if (timeoutFadeOut)
                    clearTimeout(timeoutFadeOut);
                    
                timeoutFadeOut = setTimeout( function() { $("#DexUserHover:visible").fadeOut('slow'); }, 3000);
               
            }    );
      
}
//PEOPLE TAB FUNCTIONS - END

$(function() {
    $("#txtFaculty")
        .change(function() { $('#txtFaculty').val(''); })
        .autocomplete(
            "Handlers/GetFacultyList.ashx",
            {
	            delay:4,
	            minChars:2,
	            matchSubset:1,
	            matchContains:1,
	            cacheLength:10,
	            autoFill:false
            });
    //showReleventFields(2);
});

// GADGET TAB EMAIL
function postToNewWindow(url, fields)
{
    var form = document.createElement('form');
    form.action = url;
    form.method = 'post';
    form.target= '_blank';
    form.enctype = 'multipart/form-data';
    for(var field in fields)
    {
        form.innerHTML += "<input type='hidden' name='" + field + "' value='" + eval('fields["' + field + '"]') + "' />";
    }
        
    document.body.appendChild(form);
    form.submit();
    document.body.removeChild(form);
}

function logInToUserMailAccount()
{
    var mailAccount = $("#EmailTabContent input[@type=radio][@checked]").val();
    var engineUrl, parameters;
    switch (mailAccount) {
		case "Hotmail.co.il":
		    engineUrl = 'https://hotmail.msn.co.il/authenticate.asp';
			parameters = {
                    loginname : $("#txtUserName").val(),
                    loginpassword : $("#txtUserEmailPassword").val()
                };
            break;
		case "Yahoo":
		    engineUrl = 'http://login.yahoo.com/config/login';
			parameters = {
                    login : $("#txtUserName").val(),
                    passwd : $("#txtUserEmailPassword").val(),
                    '.tries' : '',
                    '.src' : 'ym',
                    '.last' : '',
                    promo : '',
                    lg : 'us',
                    '.intl' : '',
                    '.bypass' : ''
                };
            break;
		case "Hotmail.com":
		    engineUrl = 'https://login.passport.com/ppsecure/post.srf?id=2&amp;vv=30&amp;lc=1033&amp;bk=1116923309';
			parameters = {
                    login : $("#txtUserName").val(),
                    passwd : $("#txtUserEmailPassword").val(),
                    PPSX : 'Pa', 
                    PwdPad : '',
                    passwdautocomplete : ''
			    };
            break;
		case "CoolMail":
		    engineUrl = 'http://webmail.nana10.co.il/';
			parameters = {
                    username : $("#txtUserName").val(),
                    password : $("#txtUserEmailPassword").val(),
                    language : 'iw',
                    country : 'IL'			
		    	};
            break;
		case "InterMail":
		    engineUrl = 'http://www.intermail.co.il/LoginMembers.asp';
			parameters = {
			        User : $("#txtUserName").val(),
			        Password : $("#txtUserEmailPassword").val(),
			        logme : '1'
		    	};
            break;
		case "Walla Mail":
		    engineUrl = 'http://friends.walla.co.il/';
			parameters = {
			        "w" : "/@login.commit",
			        "ReturnURL" : 'http://mail.walla.co.il/index.cgi',
			        "theme" : '',
			        "username" : $("#txtUserName").val(),
			        "password" : $("#txtUserEmailPassword").val()
			    };
            break;
		case "Gmail":
		    engineUrl = 'https://www.google.com/accounts/ServiceLoginAuth';
			parameters = {
                    service : 'mail',
                    "continue" : "http://gmail.google.com/gmail",
                    Email : $("#txtUserName").val(),
                    Passwd : $("#txtUserEmailPassword").val()
			    };
			break;
	}        
    postToNewWindow(engineUrl, parameters);
}