
// go to the register tab after logging out all accounts
function register_link(anchor){
	append_js();
	append_iframe();
	document.write('<a href="http://learn.digitalchalk.com/dc/course/registerCourses.dc" target="_blank">');
	document.write(anchor);
	document.write('</a>');
}

// url = where users should be redirected to
function login_link(id,anchor,origin,userEmail,userPass){
	append_js();
	append_iframe('demo');
	append_form(id,origin,userEmail,userPass,'demo');
	append_link(id,anchor);
	append_jqueryLink(id,'demo');
}

// url = where users should be redirected to
function login_dcdemo(id,anchor,origin,userEmail,userPass){
	document.write(aa);
	//append_js();
	//append_iframe('dcdemo');
	//append_form(id,origin,userEmail,userPass,'dcdemo');
	//append_link(id,anchor);
	//append_jqueryLink(id,'dcdemo');
}

// url = where users should be redirected to
function login_learn(id,anchor,origin,userEmail,userPass){
	append_js();
	append_iframe('learn');
	append_form(id,origin,userEmail,userPass,'learn');
	append_link(id,anchor);
	append_jqueryLink(id,'learn');
}

// APPEND JQUERY LINKS TO MAKE THE ANCHORS EXECUTE THE FORMS
function append_jqueryLink(id,dcsite){
	document.write('<script type="text/javascript">');
	document.write('$("#DC_LINK_' + id + '").click(function() { ');
	document.write('$("#DC_LOGOUT").attr("src","http://' + dcsite + '.digitalchalk.com/dc/customer/logout.dc");');
	document.write('$("#DC_FORM_' + id + '").submit(); return false; });');
	document.write('</script>');
}

// APPEND FORM FOR LOGIN
function append_form(id,origin,userEmail,userPass,dcsite){
	document.write('<form action="http://' + dcsite + '.digitalchalk.com/dc/customer/login.dc" method="POST" id="DC_FORM_' + id + '" target="_blank" style="display:none">');
	document.write('<input type="hidden" name="origin" value="' + origin + '" />');
	document.write('<input type="hidden" name="emailAddress" value="' + userEmail + '" />');
	document.write('<input type="hidden" name="password" value="' + userPass + '" />');
	document.write('</form>');
}

// APPEND LINK USING THE PROVIDED ELEMENT
function append_link(id,anchor){
	document.write('<a href="#" id="DC_LINK_' + id + '">');
	document.write(anchor);
	document.write('</a>');
}

// APPEND IFRAME FOR LOGOUT, WILL CHECK IF ALREADY EXISTS
function append_iframe(dcsite){
	var iframeExists = document.getElementById('DC_LOGOUT');
	if (iframeExists == undefined){
		document.write('<iframe src="http://' + dcsite + '.digitalchalk.com/dc/customer/logout.dc" id="DC_LOGOUT" frameborder="0" height="0" width="0"></iframe>');
	}
}

// APPEND JQUERY TO CLIENT SITE <HEAD>
function append_js(){
    var head = document.getElementsByTagName('head')[0];
	var script = document.createElement('script');
	script.type = 'text/javascript';
	script.src = 'http://digitalchalk.com/dc.library/jquery.js';
	head.appendChild(script);
}





