function addBookMark(url, title){
//Add web page to favorites addBookMark(,)
if(){
(url,title);
}else if (){
(title,url,'');
}else{
alert('Add failed');
}
}
function setHomepage(obj,url) {
// setHome(this, )
try {
= 'url(#default#homepage)';
(url);
} catch (e) {
if () {
try {
("UniversalXPConnect");
} catch (e) {
alert('This operation was rejected by the browser!\nPlease enter "about:config" in the browser address bar and press Enter\n Then set the value of [.codebase_principal_support] to "true", double-click.');
}
var prefs = ['@/preferences-service;1'].getService();
('', vrl);
}
}
}
function boxMove(box){
//Mobile layer
var w = ,h = ;
var iWidth = ;
var iHeight = ;
var moveX = 0,moveY = 0,moveTop = 0,moveLeft = 0,moveable = false;
= function(e){
moveable = true;
e = ?:e;
moveX = ;
moveY = ;
++;
}
= function(e){
if(moveable){
e = ?:e;
var x = - moveX;
var y = - moveY;
if ( x > 0 &&( x + w < iWidth) && y > 0 && (y + h < iHeight)){
= x + "px";
= y + "px";
= "auto";
}
}
}
= function (){moveable = false;};
}
function getHtmlRoot(){
/*Get the root element of the html document*/
if(()=="css1compat"){
htmlRoot = ;
}else{
htmlRoot = ;
}
return htmlRoot;
}
function showWindow(boxId, closeId, showBg){//Popt-up window
htmlRoot = getHtmlRoot();
box = (boxId);
boxId = '#' + boxId;
closeId = '#' + closeId;
showBox = $(boxId);
();
z_index = 20;
moveLeft = (- )/2 + +'px';
moveTop = ( - )/2 + ;+'px';
({position:'absolute', left:moveLeft,zIndex:z_index, top:moveTop});
boxMove(box);
if(showBg){
objMask = ("div");
= "BoxMask";
(objMask);
+= 'position:absolute;top:0; left:0;filter:Alpha(Opacity=50);opacity:0.5;background:#AAA;';
= z_index -1;
= + 'px';
= + + 'px';
}
$(closeId).click(function(){
();
= "none";
});
$('.closeBtn').click = function(){
();
= "none";
};
}
function getFormQuery(formId){
/*Generate query string*/
formObj = (formId);
var i, queryString = "", and = "", itemValue;
for(i = 0; i<; i++ ){
var item = formObj[i];
if ( !='' ){
if( == 'select-one'){
itemValue = [].value;
}else if ( =='checkbox' || =='radio'){
if ( == false ){ continue; }
itemValue = ;
}else if ( == 'button' || == 'submit' || == 'reset' || == 'image'){
continue;
}else{
itemValue = ;
}
// itemValue = escape(itemValue);
queryString += and + + '=' + itemValue;
and="&";
//queryString += and + encodeURIComponent() + '=' +encodeURIComponent( itemValue);
}
}
return queryString;
}
//Define js error handling function
onerror = errHandle;
function errHandle(msg,url,line){
var txt=""
txt = "There is an error in this page!\n\n"
txt += "Error: "+ msg +"\n"
txt += "Address: " + url + "\n"
txt += "Line number: " + line + "\n\n"
alert(txt);
return false;
}
function setAutoWidth(id,width,size){
//Minimum or maximum width
var obj = (id);
if(size=='max'){
= ( > width) ? width + "px" : "auto";
}else{
= ( < width) ? width + "px" : "auto";
}
}
function fontScroll(id){
/*Text scrolling left */
var obj = (id);
var text = ;
var first = (0);
var left = (1, );
= left + first;
//In addition to this writing function setInterval('fontScroll(id)', 500);
}
function bubbleSort(arr){
/*Bubbling sorting method*/
var sign = false // Initialize transposition mark as false
for(var i=0; i < -1; i++){
for(varj=0; j < -1-i; j++){
if(arr[j]> arr[j+1]){
vartemp = arr[j]
arr[j]= arr[j+1]
arr[j+1]= temp
sign= true // If there is any transposition in the current circle comparison, the disposition position is marked as true
}
}
if(sign)// determine whether there has been any transposition in the current circle...
sign= false // If there is a transposition, the resetting of the transposition is marked as false
else
break// If not, terminate
}
return arr;
}
function getCoordinate(evt){
/*Get the coordinates of the cursor*/
var x = ;
var y = ;
('show').innerHTML = x +' &' + y;
}
function checkEmail(email){
/*Detection of multiple semicolon-separated email formats*/
if(email != null){
if((";",0) == -1){ //indexOf(find, start bit) returns the position where a certain string first appears in the source string, and returns -1 if it fails
if(!isEmail(email)){
alert("The format of a single email is incorrect, please re-enter!");
("email").focus();
return false;
}
}else{
var emailArr = (";");//split (separated segment, total array length) string split into string array
var i, iMax = ;
for(i = 0; i < iMax; i++){
if(emailArr[i] != null || emailArr != ""){
if(!isEmail(emailArr[i])){
alert("The mailbox format in multiple mailbox formats is incorrect, please re-check it before entering!");
("email").focus();
return false;
}
}
}
}
}
function isEmail(str){
var reg = /^(\w)+(\.\w+)*@(\w)+((\.\w+)+)$/;
return (str);//test (test) detects whether a string matches a certain pattern.
}
}