﻿///////////////////////////////////
// DO NOT add Page/Document Load event handlers in this file
///////////////////////////////////

// Solve Flickering CSS Background Images in IE6
try {
document.execCommand("BackgroundImageCache", false, true);
} 
catch(err) {}


/*** Nestle namespace declaration */
var Nestle = function() {
    return {
        Blog: function() { },
        FileBrowser: function() { },
        Common: function() { },
        Admin:function(){},
        Event:function(){},
        Forum: function() { },
        Milestone: function() { },
        BloggerY3: function() { }
    };
} ();


function sendAjaxPostRequest(setting) {
    $.ajax({
        data: setting.data,
        url: setting.url,
        dataType: setting.dataType,
        type: 'POST',
        timeout: 30000,
        success: setting.success,
        complete: setting.complete,
        beforeSend: setting.beforeSend,
        error: setting.error
    });
}


// JavaScript Document

function showMoviePopup(src) {

	var hostUrl = window.location.protocol + '//' + window.location.host;
    var flvUrl = src.toString().indexOf('/', 0) == 0 ? hostUrl + src : hostUrl + '/' + src;
    var imageUrl = src.toString().indexOf('/', 0) == 0 ? hostUrl + src.replace(".flv", ".jpg") : hostUrl + '/' + src.replace(".flv", ".jpg");
    
    var html = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' width='350' height='350' id='player1' name='player1'> "
                    + "<param name='movie' value='/Scripts/jwplayer/player.swf'> "
                    + "<param name='allowfullscreen' value='true'> "
                    + "<param name='allowscriptaccess' value='always'> "
                    + "<param name='flashvars' value='file=" + flvUrl + "&image=" + imageUrl + "'> "
                    + "<embed id='player2' "
                        + "name='player2' "
                        + "src='/Scripts/jwplayer/player.swf' "
                        + "width='350' "
                        + "height='350' "
                        + "allowscriptaccess='always' "
                        + "allowfullscreen='true' "
                        + "flashvars='file=" + flvUrl + "&image=" + imageUrl + "' "
                        + "/>"
                    + "</object>";
                
    var popup_html =  "<div id='boxes' style='display:block;'>"
						  + "<div id='dialog_Video' class='window' style='display:block;'>"
						    
						   + "<div id='ModalPopupVideo'>"
							+ "<div class='modalpopup_rounded_top'><a class='layer_close' href='javascript:void(0);' onclick='stopVideo();'>Close</a></div>"
						    + "<div class='modalpopup_rounded_content'>"+html+"</div>"
						    + "<div class='modalpopup_rounded_bottom'></div>"
						    + "</div>"
							+ "</div>"
						  + "<div id='mask'></div>"
						+ "</div>";

	
    $.fn.jmodal({
        title: 'Movie',
        content: popup_html,
        width: 395,
        height: 395,
		buttonText: { ok: 'Send', cancel: 'Close' },
        closeCss: { 'display': 'none' }
     });
}


function stopVideo(){
	document.getElementById('ModalPopupVideo').innerHTML = '';
}



function rollover(obj){
	
}

function rollout(obj){
	
}


function ismaxlength(obj, mlength){
	if (obj.value.length>mlength);
		obj.value=obj.value.substring(0,mlength);
}

function OpenPopupWindow(url, width, height){
	window.open(url, "popupWin", "width="+width+",height="+height);
}


function getSiteUrl(useSSL){
	var url ='';
	if (useSSL)
		url = 'https://';
	else
		url = 'http://';
		
	if (window.location.port == '80' || window.location.port == '')
		url = url + window.location.hostname + '/';
	else
		url = url + window.location.hostname + ':' + window.location.port + '/';
		
	return url;
}


function getFullUrl(orgUrl, useSSL){
	var url ='';
	if (useSSL)
		url = 'https://';
	else
		url = 'http://';
		
	if (window.location.port == '80' || window.location.port == '')
		url = url + window.location.hostname + orgUrl;
	else
		url = url + window.location.hostname + ':' + window.location.port + orgUrl;
		
	return url;
}

function addGooglePageTrack(url){
	//if (document.getElementById('hidGoogleAnalyticID')){
	//	var pageTracker = _gat._getTracker(document.getElementById('hidGoogleAnalyticID').value);
	if (pageTracker)
		pageTracker._trackPageview(url);
	//}
}

function checkRememberMe(username, password, rememberMe){
	// set cookies to expire in 30 days
	var expireInDay=30;

	if (rememberMe){
		$.cookie('username', username, { expires: expireInDay, path: '/' });
		$.cookie('password', password, { expires: expireInDay, path: '/' });
		$.cookie('remember', true, { expires: expireInDay, path: '/' });
	} else {
		// reset cookies
		$.cookie('username', null, {path: '/'});
		$.cookie('password', null, {path: '/'});
		$.cookie('remember', null, {path: '/'});
	}
}

function loadRememberMe(usernameObj, passwordObj, rememberMeObj){

	var remember = $.cookie('remember');

	if ( remember == 'true' ) {
		var username = $.cookie('username');
		var password = $.cookie('password');

		// autofill the fields
		$(usernameObj).attr("value", username);
		$(passwordObj).attr("value", password);
		$(rememberMeObj).attr('checked','checked');
		
	}
}
