// Imulus Global Javscript Code

// Create an external link icon using an image
$(document).ready(function() {
//	$('a:not(:has(img)|.button|.video|.website)').filter(function() {
//		return this.hostname && this.hostname !== location.hostname;
//	}).after(' <img class="external" src="/images/icons/external.gif" alt="external link"/>');
});




$(document).ready(function() {

	//$("a[href^='http:']").not("[href*='get10.com']").attr('target','_blank');

	$("a.video").each(function () {
		var youtube = $(this).attr("href");
		
		videoID = youtube.split("=");
		if (videoID) {
			youtube = videoID[1];
		}

		//var newLink = "javascript:playVideo('youtube','" + youtube + "')";

		//$(this).attr({href: newLink});
		
		$(this).click(function() { playVideo('youtube',youtube); return false; });
		
	});
});

function GoNonHTTPS() {
    var CurrentURL = window.location.hostname + window.location.pathname;
    CurrentURL = CurrentURL.toLowerCase();
    //alert(CurrentURL);
    var newURL = "";
    if (CurrentURL.indexOf("ocalhost") == -1) { // if we are not on the dev server...
        if (window.location.href.indexOf("ttps://") == -1) { // if we are not on https...
            // make the following pages secure
            // join-get10/payment-info.aspx
            // get-featured (the main sign up form)
            // the fundraising form.
//            if (CurrentURL.indexOf("payment-info.aspx") > 0 || CurrentURL == "www.get10.com/get-featured" || CurrentURL.indexOf("undraising") > 0) {
//                newURL = "https://" + CurrentURL;
//                window.location.href = newURL;
//                return true;
//            }
        } else { // we are on https


            if (CurrentURL.indexOf("retailer-info") == -1 && CurrentURL.indexOf("login") == -1 && CurrentURL.indexOf("payment-info.aspx") == -1 && CurrentURL != "www.get10.com/get-featured" && CurrentURL.indexOf("undraising") == -1 && CurrentURL.indexOf("account-edit.aspx") == -1 && CurrentURL.indexOf("payment-method.aspx") == -1) {
            //alert('ok');
            newURL = "http://" + CurrentURL;
            window.location.href = newURL;
            
            return true;
            }

            
        }
    }
}

function playVideo(targetDiv, videoID) {
	var html = '';

	html += '<object width="560" height="340">';
	html += '<param name="movie" value="http://www.youtube.com/v/' + videoID + '&hl=en&fs=1&autoplay=1"></param>';
	html += '<param name="allowFullScreen" value="true"></param>';
	html += '<param name="allowscriptaccess" value="always"></param>';
	html += '<param name="wmode" value="transparent"></param>';
	html += '<embed src="http://www.youtube.com/v/' + videoID + '&hl=en&fs=1&autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340" wmode="transparent"></embed>';
	html += '</object>';
	
	$('#' + targetDiv + '').html(html);
	
	return false;
}
	
	
	
	

