/*
-- Program: CakeMail Interface
-- Author: The Code Kitchen Inc.
-- Email: info@cakemail.com
-- Date: 10/31/2007
@ [2007] - The Code Kitchen.

This software is subjected to the terms and conditions of the CakeMail Interface
License Agreement, version 1.0. You cannot use this software, except by 
complying to the terms of this license.  In short, the CakeMail interface is 
available for you to download, use, copy, modify, integrate in your own software
and propagate, as long as you agree to use it exclusively with the CakeMail 
hosted application service and application programming interface (API). You can
download a copy of the license at the following URL:
http://www.cakemail.com/license_1.0

This software is propagated "as is", without any warranty of any kind, express
or tacit.  Read the license to learn the exact conditions pertaining to your 
rights and obligations in relation with this work.
*/

function addslashes_all(str) {
    str = str.replace(/\'/g,'\\\'');
    str = str.replace(/\"/g,'\\"');
    str = str.replace(/\\/g,'\\\\');
    return str;
}


function addslashes(str) {
    str = str.replace(/\"/g,'\\"');
}


function stripslashes_all(str) {
    str = str.replace(/\\'/g,'\'');
    str = str.replace(/\\"/g,'"');
    str = str.replace(/\\\\/g,'\\');
    return str;
}


function strip_tags(element) {
    //element.value = element.value.stripTags();
}


function strip_tags_form(form) {
    for (var i = 0; i < form.elements.length; i++) {
        if (form.elements[i].type == "text" || form.elements[i].type == "password") {
            //form.elements[i].value = form.elements[i].value.stripTags();
        }
    }
}

function change_div_display(divObj, isVisible, visibleStyle) {
	try {
		divObj.style.setAttribute("display", isVisible ? visibleStyle : "none");
	} catch(e) {
		divObj.style.display = isVisible ? visibleStyle : "none";
	}
}

function show_client_dd() {
	change_div_display(document.getElementById("header_top_menu"), false);
	change_div_display(document.getElementById("switch_client"), true, "inline");
	return false;
}

function hide_client_dd() {
	change_div_display(document.getElementById("switch_client"), false);
	change_div_display(document.getElementById("header_top_menu"), true, "inline");
	return false;
}

function switch_to_client() {
	var client_id = document.getElementById("client_id_to_switch").value;
	if (client_id) {
		window.location.href = "admin/clients.php?action=login&client_id=" + client_id;
	}
	return false;
}

