


/******************************* common ***************************************/
function slide(e)
{
	$(e).slideToggle(400);
}
function redirect(url){
    setTimeout(function(){window.location = url;},0);
}

function getPageScroll() {
    var xScroll, yScroll;
    if (self.pageYOffset) {
      yScroll = self.pageYOffset;
      xScroll = self.pageXOffset;
    } else if (document.documentElement && document.documentElement.scrollTop) {
      yScroll = document.documentElement.scrollTop;
      xScroll = document.documentElement.scrollLeft;
    } else if (document.body) {// all other Explorers
      yScroll = document.body.scrollTop;
      xScroll = document.body.scrollLeft;
    }
    return new Array(xScroll,yScroll)
}

function getPageHeight()
	{
		var windowHeight
		if (self.innerHeight) { // all except Explorer
		  windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) {
		  windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
		  windowHeight = document.body.clientHeight;
		}
		return windowHeight
	}
function getPageWidth()
	{
		var windowWidth
		if (self.innerWidth) { // all except Explorer
		  windowWidth = self.innerWidth;
		} else if (document.documentElement && document.documentElement.clientWidth) {
		  windowWidth = document.documentElement.clientWidth;
		} else if (document.body) { // other Explorers
		  windowWidth = document.body.clientWidth;
		}
		return windowWidth
	}
function isArray(obj) {
    if(obj.constructor.toString().indexOf("Array") == -1)return false;
    else return true;
}

function str_replace(search, replace, subject){
    if(isArray(subject)){
        return subject[0].replace(new RegExp(search,"gi"), replace);
    }else{
        return subject.replace(new RegExp(search,"g"), replace);
    }
}

function count(search, subject) {
    var i = 0;
    var pos = subject.indexOf(search);
    var result = subject.substring(0);
    do {
        if (pos == -1) {
            return i;
        }
        result = result.substring(pos + search.length);
        pos = result.indexOf(search);
        i++;
    } while (i > 0);
    return false;
}

function randString() {
	var chars = "ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
	var string_length = 10;
	var randomstring = '';
	for (var i=0; i<string_length; i++) {
		var rnum = Math.floor(Math.random() * chars.length);
		randomstring += chars.substring(rnum,rnum+1);
	}
	return randomstring;
}

