function AddFavorite(){
		if (document.all) {
				window.external.addFavorite(document.location.href, document.title);
		} else {
		    window.sidebar.addPanel(document.title, document.location.href, "");
		}
}

function IsEmail(email){
    return email.search(/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/i) != -1;
}

function IsPhone(phone){
    return phone.search(/^[0-9]+([ \-]+[0-9]+[ \-]*)*[0-9]+$/i) != -1;
}

function GetPathLevel(){
		var str_url = document.URL.substr(document.URL.indexOf(document.domain)).replace(document.domain, '');
		str_url = str_url.substr(0, 1) == '/' ? str_url.substr(1) : str_url;
		var arr_url = str_url.split('/');
		if(arr_url[0].indexOf('.') > -1) arr_url.shift();
		return arr_url.length;
}

function GetPathPrefix(){
		var int_level = GetPathLevel();
		var str_prefix = '';
		for(var i=1; i<int_level; i++) str_prefix += '../';
		return str_prefix;
}

function Hand(elt){
    elt.style.cursor = 'pointer';
}
function FlushSafeCode (safe_code_id) {
    var obj_sc = document.getElementById(safe_code_id);
		var url = obj_sc.getAttribute('src');
		url = url.split('?')[0];
		url += '?r='+Math.random();
		obj_sc.setAttribute('src', url);
		return false;
}

/*function ChangeCUY(val){
		var str_anchor = '';
		var str_url = document.URL;
		if(document.URL.indexOf('#') > -1){
		    str_anchor = document.URL.substr(document.URL.indexOf('#'));
				str_url = document.URL.replace(document.URL.substr(document.URL.indexOf('#')), '');
		}
		var arr_url = str_url.split('?');
		str_url = arr_url[0] || str_url;
		var arr_para = arr_query_string = new Array(), flag = false, c = 0, temp_para_string = '';
		if(arr_url[1]){
		    arr_para = arr_url[1].split('&');
				for(var i=0; i<arr_para.length; i++){
				    var arr_temp = arr_para[i].split('=');
						if(arr_temp[0] == 'cuy') {
						    arr_temp[1] = val;
						    flag = true;
						}
						arr_query_string[c++] = arr_temp[0] + '=' + arr_temp[1];
				}
		}
		temp_para_string = arr_query_string.join('&');
		if(flag){
				str_url = str_url+'?'+temp_para_string;
				if(str_anchor) str_url = str_url+'?'+temp_para_string + str_anchor;
		}else{
		    if(temp_para_string){
						str_url = str_url+'?cuy='+val+'&'+temp_para_string;
						if(str_anchor) str_url = str_url+'?cuy='+val+'&'+temp_para_string + str_anchor;
				}else{ 
						str_url = str_url+'?cuy='+val;
						if(str_anchor) str_url = str_url+'?cuy='+val + str_anchor;
				}
		}
		window.location.href = str_url;
}*/

function ChangeCUY(form_id){
    var elem_form = document.getElementById(form_id);
		elem_form.setAttribute('action', '');
		elem_form.submit();
}
