function encode64(input) {
  var keyStr = "ABCDEFGHIJKLMNOP" +
		   "QRSTUVWXYZabcdef" +
		   "ghijklmnopqrstuv" +
		   "wxyz0123456789+/" +
		   "=";


input = escape(input);
var output = "";
var chr1, chr2, chr3 = "";
var enc1, enc2, enc3, enc4 = "";
var i = 0;

do {
  chr1 = input.charCodeAt(i++);
  chr2 = input.charCodeAt(i++);
  chr3 = input.charCodeAt(i++);

  enc1 = chr1 >> 2;
  enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
  enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
  enc4 = chr3 & 63;

  if (isNaN(chr2)) {
     enc3 = enc4 = 64;
  } else if (isNaN(chr3)) {
     enc4 = 64;
  }

  output = output +
     keyStr.charAt(enc1) +
     keyStr.charAt(enc2) +
     keyStr.charAt(enc3) +
     keyStr.charAt(enc4);
  chr1 = chr2 = chr3 = "";
  enc1 = enc2 = enc3 = enc4 = "";
} while (i < input.length);

return output;
}

$(document).ready(function(){
	$('#FooterWrapper').load('ext_FooterTemplate.php');
	$('#change_password').submit(function(){
		change_password();
		return false;
	});
});


$(document).ready(function(){

	// Show Transations? Item with ID="showT"
	$('#showT').click(function(){
		$('#show_transactions').toggle();
	});

	// Login Modul
	$('a[title="Login"]').click(function (){
		$("body :input").attr("disabled", "true");
		$("body").prepend("<div id='BookmarkModul'></div>");
		$('#BookmarkModul').fadeIn("slow");
		$('body').prepend("<div id='BookmarkMenu'></div>");
		$('#BookmarkMenu').css('height','270px').css('background-position','383px 0px');
		$('#BookmarkMenu').show();
		$('#BookmarkMenu').prepend("<form id='BookmarkForm' action='/?page=login' method='post' name='login' ><input name='username' tabindex='1' type='text' id='username' value='Username' style='background:none; border: 1px solid #BBB; padding:5px; font-size:20px; width:280px; position:relative; margin-left:33px; margin-bottom:20px; color:#BBB;'/><input tabindex='2' name='password' type='text' id='passwordfake' value='Password' style='background:none; border: 1px solid #BBB; padding:5px; font-size:20px; width:280px; position:relative; margin-left:33px; margin-bottom:20px; color:#BBB;'/><input type='hidden' name='login' value='1' /><input name='password' type='password' id='password' tabindex='2' value='' style='display:none;background:none; border: 1px solid #BBB; padding:5px; font-size:20px; width:280px; position:relative; margin-left:33px; margin-bottom:20px; color:#BBB;'/><input type='hidden' name='login' value='1' /></form>");
		$('<span></span>').prependTo('#BookmarkMenu');
		$("<input value='Login' title='Login' style='margin-top:-20px;' id='BookmarkMenuInput' type='submit' onclick='javascript:return HitMe(); '/>").appendTo('#BookmarkForm');
		$("<p id='Legacy' style='text-align:center; font-size:11px; margin-top:10px;cursor:pointer;z-index:9000;'>Use Old Login Page</p><p id='Forgot' style='text-align:center; font-size:11px; margin-top:5px;cursor:pointer;z-index:9000;'>Forgot Password?</p>").appendTo('#BookmarkForm');
		$('#username').focus(function(){
			$('#username').css('color', '#333').val('')
		});
		$('#username').blur(function(){
			$('#username').css('color', '#BBB')
		});
		$('#passwordfake').click(function (){
			$(this).remove(); $('#password').show().val('');
		});
		$('#passwordfake').focus(function(){
			$('#passwordfake').css('color', '#333').val('')
		});
		$('#passwordfake').blur(function(){
			$('#passwordfake').css('color', '#BBB')
		});
		/// Exit Login Modul
		///////////////////////////////////////
		$('#BookmarkModul, #BookmarkMenu span').click(function(){
			CloseModulLogin();
		});
		function CloseModulLogin() {
			$("body :input").attr("disabled", false);
			$('#BookmarkModul').remove().fadeOut ("slow");
			$('#BookmarkMenu').remove();
		};
		///////////////////////////////////////
		$('#Legacy').click(function(){
			window.location.href = "?page=login";
		});// Login Legacy Mode
		$('#Forgot').click(function(){
			window.location.href = "?page=resetpw&type=online_username&online=1";
		});// Forget Password
	});

	// Call us POPUP
	$('.callus').click(function(){
		$("body :input").attr("disabled", "true");
		$("body").prepend("<div id='BookmarkModul'></div>");
		$('#BookmarkModul').fadeIn("slow");
		$('body').prepend("<div id='BookmarkMenu'></div>");
		$('#BookmarkMenu').css('height','270px').css('background-position','383px 0px');
		$('#BookmarkMenu').show();
		$('#BookmarkMenu').prepend("<form id='BookmarkForm' action='/?page=login' method='post' name='login' ></form>");
		$('<span></span>').prependTo('#BookmarkMenu');

		/// Exit Call Us Popup
		///////////////////////////////////////
		$('#BookmarkModul, #BookmarkMenu span').click(function(){
			CloseModulLogin();
		});
		function CloseModulLogin() {
			$("body :input").attr("disabled", false);
			$('#BookmarkModul').remove().fadeOut ("slow");
			$('#BookmarkMenu').remove();
		};

	});

	// Bible populate??
	$.get('/ext_PopulateBible.php', function(data){
		var html = '';
	  	//var len = data.length;
	  	var len;
		aData = eval("(" + data + ")");
	  	len = aData.length;
		for (var i = 0; i< len; i++)
		{
		html += '<option value="' + aData[i] +'">Chapter ' +  aData[i] + '</option>';
		length++
		//  alert ('hit');
		}
		$('#bible_chapter').append(html);
	});


});


// Featured Media FadeIn
///////////////////////////////////////////////////
$(document).ready(function() {
  $('#XSLWRAPPER').append( $('#PHPTOXSL') );

	$('.FeaturedMedia').fadeIn("slow");


});
///////////////////////////////////////////////////


$(document).ready(function() {


$('#gotostep2').click(function()
{

//$('#step1').hide();
$('#step2').show();

});


});

	$(document).ready(function() {
		$.ajaxSettings.cache = false;
		$('#MainContentBookmark').load("BookmarkFunction/index.php", function(response, status, xhr) {
		if (status == "error") {
			var msg = "Sorry but there was an error: ";
			$("#error").html(msg + xhr.status + " " + xhr.statusText);
		}
		return false;
	});
});


$(document).ready(function() {
	$(function() {
	    $("#BibleButton")
		  .mouseover(function() {
			var src = $(this).attr("img").match(/[^\.]+/) + "bible.png";
			$(this).attr("img", src);
		  })
		  .mouseout(function() {
			var src = $(this).attr("img").replace("bible", "bible-rollover");
			$(this).attr("img", src);
		  });
	});
});

$(document).ready(function() {
	$('#username').live('keydown', function(e) {
	  var keyCode = e.keyCode ;
	  if (keyCode == 9) {
		$('#passwordfake').remove();
		$('#password').show();
		$('#password').blur();

	    };
	});

	$('#passwordfake').click(function(){
		$(this).remove();
		$('#password').show().focus();
	});

	$('#passwordfake2').click(function(){
		$(this).remove();
		$('#password2').show().focus();
	});
});

// Product Hovers
///////////////////////////////////////////////////
function FeaturedOptions () {



$(document).ready(function() {

	var ProductHover;



	$(".POBox",this).hover(function(){


		//PRODUCT ID
		var ProductId = '' + $(this).attr('id') + '';

		//PRODUCT TYPE
		var ProductType = $(this).attr('title');

		var Language =  $(this).attr('language');



		ProductHover = $(this).find('.ProductOverlay').hide();
		$('body').append(ProductHover);

		ProductHover.show(); //Show tooltip


		var ImageDir;

		if(Language  == 'pt')
			ImageDir = "images_pt";
		else
			ImageDir = "images";

		if (ProductType == 'Still') { $('<img class="ProductPreviewStyle" src="' + ImageDir + '/composite/'+ ProductId +'_thumb_90.jpg" /></img>').appendTo('.ProductOverlay');  }},




	function() {

		var ProductType = $(this).attr('title');
        if (ProductType == 'Still') { $('.ProductPreviewStyle').remove(); };



        var ProductId;
		ProductId = '';
		ProductHover.hide(); //Hide and remove tooltip appended to the body

		$(this).append(ProductHover);  //Return the tooltip to its original position


	}).mousemove(function(e) {
	//console.log(e.pageX)
		  var mousex = e.pageX + 20; //Get X coodrinates
		  var mousey = e.pageY + 20; //Get Y coordinates
		  var ProductHoverWidth = ProductHover.width(); //Find width of tooltip
		  var ProductHoverHeight = ProductHover.height(); //Find height of tooltip

		 //Distance of element from the right edge of viewport
		  var ProductHoverVisX = $(window).width() - (mousex + ProductHoverWidth);
		  var ProductHoverVisY = $(window).height() - (mousey + ProductHoverHeight);

		if ( ProductHoverVisX < 20 ) { //If tooltip exceeds the X coordinate of viewport
			mousex = e.pageX - ProductHoverWidth - 20;

		$(this).find('.ProductOverlay').css({  top: mousey, left: mousex });

		} if ( ProductHoverVisY < 20 ) { //If tooltip exceeds the Y coordinate of viewport
			mousey = e.pageY - ProductHoverHeight - 20;
			ProductHover.css({  top: mousey, left: mousex });
		} else {
			ProductHover.css({  top: mousey, left: mousex });
		}

	});




 });

}
////////////////////////////////////////////////////





// Image Preview
///////////////////////////////////////////////////
$(document).ready(function() {

//  $("#ProductExpand" ,this).fancybox({
//	  'autoScale'			:  true,
//	  'transitionIn'		: 'none',
//	  'transitionOut'		: 'none',
//	  'type'				: 'iframe'
//  });

$('.DownloadDropDownForm').change(function() {
    $('.DownloadBtn',this).css('background-position', '0px -1px')
});

$('.DownloadBtn').click(function() {
    $('.DownloadBtn',this).css('background-position', '0px -16px')
});


$('.input').change(function() {
  $('.DownloadBtn_details').css('background-position', '0px 1px')


});






 });
////////////////////////////////////////////////////











// Advanced Search
///////////////////////////////////////////////////

function AdvancedSearchToggle () {

	$("#browse_bybook").click(function() {
		$.get('/aj/show_bible_div.php', function(data){
			$("#bible_chapter_div").html(data);
			$("#advancedsearchlayer").fadeIn("fast");
		});

		$("#advancedsearchlayer").mouseleave(function(){
			$("#advancedsearchlayer").fadeOut("fast");
		})
	});

	$("#browse_bykeyword").click(function() {
		$.get('/aj/show_keywords_div.php', function(data){
			$("#SearchCaseV2").html(data);
			$("#advancedsearchlayerB").fadeIn("fast");
		});

		$(".SearchCaseV2").mouseleave(function(){
			$("#advancedsearchlayerB").fadeOut("fast");
		})
	});
}


function ModulTextAnimate () {
$(document).ready(function() {
$(".JonsSexyModalText").fadeIn('slow');
$(".JonsSexyModalHeader").fadeIn('slow');
 });


}

function  MotionDownloadHelp () {

	  $(document).ready(function() {
      $("#various1").fancybox({
		  'titlePosition'		: 'inside',
		  'transitionIn'		: 'none',
		  'transitionOut'		: 'none'
	  });
	});
}






function InternalModuls () {

	$(document).ready(function() {
		$("#Watermark1").fancybox({
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
		});

		$("#Watermark2").fancybox({
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
		});

		$("#Watermark3").fancybox({
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
		});

		$("#Watermark4").fancybox({
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
		});

		$("#Watermark5").fancybox({
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
		});

		$("#Watermark6").fancybox({
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
		});

		$("#Watermark7").fancybox({
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
		});

		$("#Watermark8").fancybox({
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
		});

		$("#Watermark9").fancybox({
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
		});


		$("#various1").fancybox({
		'titlePosition'		: 'inside',
		'transitionIn'		: 'none',
		'transitionOut'		: 'none'
		});

		$("#various2").fancybox({
		'titlePosition'		: 'inside',
		'transitionIn'		: 'none',
		'transitionOut'		: 'none'
		});

		$("#various4").fancybox({
		'titlePosition'		: 'inside',
		'transitionIn'		: 'none',
		'transitionOut'		: 'none'
		});


		$("#various5").fancybox({
		'titlePosition'		: 'inside',
		'transitionIn'		: 'none',
		'transitionOut'		: 'none'
		});

	});

}


function appendOptionLast($val, $text, $obj) {
	var elOptNew = document.createElement('option');
	elOptNew.text = $text;
	elOptNew.value = $val;
	var elSel = document.getElementById($obj);
	var elOptOld = elSel.options[elSel.selectedIndex];
	try {
		elSel.add(elOptNew, elOptOld); // standards compliant; doesn't work in IE
	}
	catch(ex) {
		elSel.add(elOptNew,elSel.selectedIndex); // IE only
	}
	elSel.selectedIndex = 0;
}



// call an ajax php script.
// we need the php script
// we need the args
// we need the div to update
function ajax_loader($call_function,$call_args,$div_name) {
	////alert($call_args);

	var MainContent = document.getElementById($div_name);

	var FormName = document.getElementById($div_name + 'form');

	/*"function":"Charge!",*/


	if($call_args == 'SUBMIT') {

		if(FormName.form_amount.value < 0.01) {
			alert("Invalid amount....");
			return false;
		}

		if($('#pbc_checkbox').attr('checked')) {
			$rc = confirm("Are you Sure... A check transaction will be added for: \$" + FormName.form_amount.value + " dollars.");
		} else {
			$rc = confirm("Are you Sure... card will be charged: \$" + FormName.form_amount.value + " dollars.");
		}
		if(!$rc) return false;

		if(FormName.form_amount.value > 500) {
			$rc = confirm("Are you really sure... this is over $500.00 dollars.");
			if(!$rc) return false;
		}
	}

       if(FormName) {
                $new_args = '{';
                if($call_args == 'SUBMIT')
                        $new_args += '"function":"Charge!",';

                $(':input', '#virtualterminalform').each(function() {
                        $new_args += this.id + ': ' + this.value + '",';
                });

                $new_args += '"user_id":"' + $('#form_user_id').val() + '",';
                $new_args += '"cc_update":"' +$('#update_ccard_checkbox').attr('checked') + '",';
		$new_args += '"pbc_update":"' +$('#pbc_checkbox').attr('checked') + '",';
                $new_args += '"details":"' + $('#form_details').val().replace(/\n/g, "<br />") + '"';

                $new_args += '}';
                $call_args = "DATA="+$new_args;
        }

	if($call_args == 'UserSearch') {
		FormName = document.getElementById('searchformid');

		var $fieldName;
		var $fieldValue;
		$new_args = "";
		for(i=0; i<FormName.elements.length; i++) {
			$fieldName = FormName.elements[i].name;
			$fieldValue = FormName.elements[i].value;
			$new_args += ',"' + $fieldName + '":"' + $fieldValue + '"';
		}
		$new_args = '{"dummy":"dummy"' + $new_args + '}';
		$call_args = $new_args;
	}


	//MainContent.innerHTML = "Processing... Please wait..... !";
	//$(MainContent).html("Processing... Please wait..... !");
	$.ajax({
		    type: "get",
		    async: false,
		    url: $call_function,
		    data: $call_args,
		    success: function(data){
				if(data.substr(0,1) == "<") {
					$(MainContent).html(data);
					MainContent.style.display='block';
				} else {
					var aMsg = eval("(" + data + ")");
					var szOut = "";
					var x;
					var isError = 0;
					for(x in aMsg['error']) {
						if(aMsg['error'][x] == '') {
						} else {
							szOut = "Error: " + szOut + aMsg['error'][x] + "\n";
							isError ++;
						}
					}
					for(x in aMsg['info']) {
						szOut = szOut + aMsg['info'][x] + "\n";
					}

					for(x in aMsg['none']) {
						szOut = szOut + aMsg['none'][x] + "\n";
					}

					//MainContent.innerHTML = szOut;
					if(isError == 0) {
						data = "<a href='' onclick='return ajax_closer(\"virtualterminal\");'><img border='0' src='/gfx/close-bible-button.png'/></a>";
						data += "<a href='' onclick='return hide_popout('');'><img border='0' src='/global/images/close-button.png'/></a>";
						data += szOut;
						$(MainContent).html(data);
						MainContent.style.display='block';
					} else {
						alert(szOut);
					}
				}

		  }
	});
	return false;
}

// close a div given it's name.
function ajax_closer($div_name) {
	var MainContent = document.getElementById($div_name);
	MainContent.style.display='none';
	return false;
}

function ajax_closer_2($close_name,$open_name) {
	$('#' + $close_name).hide();
	if($open_name == '') {
	}  else {
		$('#' + $open_name).show();
	}
	return false;
}

function update_pbc() {
	alert("PBC V2");
	$("#form_ccards").toggle();
	$("#update_ccard_span").toggle();
	/*
	$("#form_cc_number").toggle();
	$("#form_cc_expires").toggle();
	$("#form_cc_type").toggle();
	*/

}

function update_submit_button() {
	var MainContent 	= document.getElementById('form_button');
	var FormName 	= document.getElementById('virtualterminalform');
	var selObj 		= document.getElementById('form_description');
	var cbObj		= document.getElementById('form_confirm');


	selIndex = selObj.selectedIndex;
	if(selIndex == 0) {
		alert("Please make a selection...");
		cbObj.checked = false;
		return false;
	}

	if(FormName.form_amount.value < 0.01) {
		alert("Invalid amount....");
		cbObj.checked = false;
		return false;
	}

	if(MainContent.disabled == true) {
		MainContent.disabled=false;
		MainContent.value="Charge!";
	} else {
		MainContent.disabled=true;
		MainContent.value="Please confirm";
	}

	return false;
}


function formatCurrency(num) {
    num = isNaN(num) || num === '' || num === null ? 0.00 : num;
    return parseFloat(num).toFixed(2);
}

function update_form_price(id,id2update) {
	var selObj = document.getElementById(id);
	var MainContent 	= document.getElementById('form_button');

	// if we have form_description, this is a select box that we do stuff with.
	// ... we take ($price) and updated the amount with $price.
	// if we have form_qty, we take the amount and multiply by the quantity.
		if(id == "form_description") {
			selIndex = selObj.selectedIndex;
			selText  = selObj.options[selIndex].text;
			selText = selText.replace("("," ");
			selText = selText.replace(")"," ");
			$aList = selText.split('$');
			$newValue = $aList[1];
			document.getElementById('form_button').disabled=false;
		}
		else
		if(id == "form_qty") {
			$newValue = selObj.value * document.getElementById(id2update).value;
		}


		if($newValue) {
			document.getElementById(id2update).value = formatCurrency($newValue);
		}

		// make button re-disabled.
			MainContent.disabled=true;
			MainContent.value="Please confirm";
	return false;
}

function js_array_to_php_array (a)
// This converts a javascript array to a string in PHP serialized format.
// This is useful for passing arrays to PHP. On the PHP side you can
// unserialize this string from a cookie or request variable. For example,
// assuming you used javascript to set a cookie called "php_array"
// to the value of a javascript array then you can restore the cookie
// from PHP like this:
//    <?php
//    session_start();
//    $my_array = unserialize(urldecode(stripslashes($_COOKIE['php_array'])));
//    print_r ($my_array);
//    ?>
// This automatically converts both keys and values to strings.
// The return string is not URL escaped, so you must call the
// Javascript "escape()" function before you pass this string to PHP.
{
    var a_php = "";
    var total = 0;
    for (var key in a)
    {
        ++ total;
        a_php = a_php + "s:" +
                String(key).length + ":\"" + String(key) + "\";s:" +
                String(a[key]).length + ":\"" + String(a[key]) + "\";";
    }
    a_php = "a:" + total + ":{" + a_php + "}";
    return a_php;
}



function verify_userid(username,password) {
	var szdata;
	var aMsg;
	var reqUrl = my_server_url + "/aj/";
	var RC;

	// we used to send the userid/pass stuff in clear text which was bad... it was logged in the url and could be
	// sniffed via a packet sniffer.
	// now we encode the data at least.... we should encrypt it too....
		var encodedData = new Array();
		encodedData['user_name'] = username;
		encodedData['user_pass'] = password;
		var szEncodeData = js_array_to_php_array(encodedData);
		szdata = "dummy=dummy/function:get_user_auth/encodedData:" +  encode64(szEncodeData);
	RC = 0; // assume no

	var full_url = reqUrl + "?" + szdata;
	$.getJSON(full_url, function(data){
		var items = [];
		$.each(data, function(key, val) {
			if(key == 'RC') {
				if(val == 1) {
					$('#BookmarkForm').submit();
					return true;
				} else  {
					$("<div class='SuccessAlert' style='margin:auto; width:896px;height:104px;background-image:url(/gfx/Alert.png);font-size:20px;color:#fff; line-height:80px;padding-left:100px;text-shadow:1px 1px 0px #888;'>Oops! There was a problem with the username or password. Please try again.</div>").prependTo('#BookmarkModul');
					$('.SuccessAlert').slideDown('slow').delay(6000).slideUp('slow',function() {
						$(this).remove();
						});
					return false;
				}
			}
		});
	});
	return false;
}

function HitMe () {
	var username = $('#username').val();
	var password = $('#password').val();
	var RC;
	RC = verify_userid(username,password);
	/*
	if(RC == 1) {
		$('#BookmarkForm').submit();
		return true;
	} else  {
		$("<div class='SuccessAlert' style='margin:auto; width:896px;height:104px;background-image:url(/gfx/Alert.png);font-size:20px;color:#fff; line-height:80px;padding-left:100px;text-shadow:1px 1px 0px #888;'>Oops! There was a problem with the username or password. Please try again.</div>").prependTo('#BookmarkModul');
		$('.SuccessAlert').slideDown('slow').delay(6000).slideUp('slow',function() {
			$(this).remove();
			});
	}
	*/
	return false;
};


function JustClose () {

	 $('#SureThing').slideUp('fast'); $('#SureThing').remove();

	return false;
	};



function DeleteEmailSub () {




var user_id = $('#USERID').val();
var ThisValue = $('#EmailType').val();

 $.getJSON("/AdminEmailFunction/PHP/EmailAPI.php?&DeleteEmails=1",
  			{user_id: user_id, EmailType: ThisValue  }, function(data){});


	Alert (

	 Placement = 'body',
	 Content   = "You have successfully been removed from the list",
	 Confirm   = 'null',
	 YesText   = 'Im Excited!'

	);

$('#EmailType').remove();
 $('#SureThing').remove();
 };


function Ask (Placement,Confirm,Decline,Content,YesText,NoText) {
$('<div id="SureThing" style=" display:none; width:641px; height:194px; background-image:url(AdminEmailFunction/images/SureBox.png); margin-left:50%; left:-352px; position:absolute;  z-index:9000;"><div id="SureContent" style="width:570px; padding:20px; height:99px;  margin:auto;" ><p style="font-size:15px; color:#555;line-height:24px; text-indent:15px; text-shadow:1px 1px 0px #FFF;">'+ Content +'</p></div><div id="SureOptions" style="width:150px;height:42px;left:-6px;margin:auto; position:relative;"><a class="SureYes" style="line-height:42px; font-size:14px; text-shadow:1px 1px 0px #333; color:#FFF; margin:auto; text-align:center; position:relative; display:inline-block; cursor:pointer;float:left;left:25px;">'+YesText+'</a><a class="SureNo" style="line-height:42px; font-size:14px;text-shadow:1px 1px 0px #333; color:#FFF; margin:auto; text-align:center; position:relative; display:inline-block; cursor:pointer;float:right;right:30px;">'+ NoText +'</a></div></div>').prependTo(Placement);
$('#SureThing').slideDown('fast');
$('.SureYes').click (function () { eval( Confirm + '();' );   $('#SureThing').slideUp('fast'); $('#SureThing').remove();});
$('.SureNo').click (function ()  { eval( Decline + '();' );   $('#SureThing').slideUp('fast'); $('#SureThing').remove(); });
}

function Alert (Placement,Content,Confirm,YesText) {
$('<div id="SureThing" style=" display:none; width:641px; height:194px; background-image:url(AdminEmailFunction/images/SureBoxSingle.png); margin-left:54%; left:-352px; position:absolute;  z-index:9000;"><div id="SureContent" style="width:570px; padding:20px; height:99px;  margin:auto;" ><p style="font-size:15px; color:#555;line-height:24px; text-shadow:1px 1px 0px #FFF;text-align:center;">'+ Content +'</p></div><div id="SureOptions" style="width:150px;height:42px;left:-6px;margin:auto; position:relative;"><a class="SureYes" style="line-height:42px; font-size:14px; text-shadow:1px 1px 0px #333; color:#FFF; margin:auto; text-align:center; position:relative; cursor:pointer; display:block;padding:5px;top:-5px;">'+YesText+'</a></div></div>').prependTo(Placement);
$('#SureThing').slideDown('fast');
$('.SureYes').click (function ()  {    eval( Confirm + '();' );   $('#SureThing').slideUp('fast');  $('#SureThing').remove(); });

}


function ChangeTitle () {

var PromoTitleVal
PromoTitleVal = $('#TemplateName').val();
$('#PromotionalTitle').val(PromoTitleVal);


};
function DontChangeTitle () { };



function ClearUrl () {    $('#AdBlockLink').val('').focus();        };
function RestoreUrl () {  $('#AdBlockLink').val('http://www.gracewaymedia.com/').focus();     };

function DoPreview () {


var TemplateIDUpdate
var TemplateName;
var PromotionalTitle;
var TemplateLink;

TemplateIDUpdate = $('#NewEmailId').val();
TemplateName     = $('#TemplateName').val();
PromotionalTitle = $('#PromotionalTitle').val();
TemplateLink     = $('#AdBlockLink').val();
window.location.href = "/AdminEmailFunction/PHP/PreviewTemplate.php?&CustomTemplate=1&TemplateId=" + TemplateIDUpdate + "&Template_Title="+ PromotionalTitle + "&Template_Link=" + TemplateLink;
	 }

function phone_hangup(number,user_id) {
	var url="/aj/";
	var args="dummy=dummy/function:hangup/number:" + number + "/user_id:" + user_id;
	$.ajax({
		  type: "get",
		  async: true,
		  url: url,
		  data: args,
		  success: function(data){}
		});
	return false;
}

$(document).ready(function() {
    $('a[rel="phone1"]').click( function() {
	wWidth = 500;
	wHeight = 200;

	url = $(this).attr('href');
	params = '';
	modal_params = 'Width=' + wWidth + 'px,Height=' + wHeight + 'px,resizable=0,help=0,unadorned=1,toolbar=0,location=0,status=0,scrollbars=0,modal=1';
	myWindow = window.open(url, params, modal_params);
	myWindow.moveTo(screen.width/2-wWidth,screen.height/2-wHeight);

	return false;
    });

    $('a[rel="phone2"]').click( function() {
	wWidth = 500;
	wHeight = 200;

	url = $(this).attr('href');
	params = '';
	modal_params = 'Width=' + wWidth + 'px,Height=' + wHeight + 'px,resizable=0,help=0,unadorned=1,toolbar=0,location=0,status=0,scrollbars=0,modal=1';
	myWindow = window.open(url, params, modal_params);
	myWindow.moveTo(screen.width/2-wWidth,screen.height/2-wHeight);

	return false;
    });

    $('a[rel="hangup"]').click( function() {
	wWidth = 0;
	wHeight = 0;

	url = $(this).attr('href');
	params = '';
	modal_params = 'Width=' + wWidth + 'px,Height=' + wHeight + 'px,resizable=0,help=0,unadorned=1,toolbar=0,location=0,status=0,scrollbars=0,modal=1';
	myWindow = window.open(url, params, modal_params);
	return false;
    });

});


function ajax_user_info(user_id,admin_id) {
	var reqURL = "/aj/user_info.php";

	var szdata = "user_id=" + user_id + "&admin_id=" + admin_id;

	$.ajax({
	    type: "get",
	    async: true,
	    url: reqURL,
	    data: szdata,
	    success: function(data){
		$('#submain').html(data);
		$('#main').hide();
		$('#submain').show();
		}
	});
	return false;
}

