var windowWidth = 0, windowHeight = 0;
var pictureIDArray = new Array();
function submitForm(formID,onsucess){
var data = "{";
$.each($(formID).serializeArray(), function() {
alert(this.name);
data += this.name+':"'+this.val()+'"';
});
data += "}";
$.ajax({
type: 'POST',
url: $(formID).href,
data: data,
success: onsuccess,
dataType: dataType
});
}
function ajaxRequest(reqUrl,tab, contentDivID,append){
$("#"+contentDivID+" .more_button").hide();
if (!append){
$("#"+contentDivID).html('
Loading ...
');
}
//$("#"+contentDivID).hide();
$.ajax({
url: reqUrl,
cache: false,
dataType: "html",
divID: contentDivID,
tabName: tab,
success: ((!append)?loadRequestedContent:appendRequestedContent),
complete: fadeInContentHolder
});
}
function fadeInContentHolder(content){
//$("#"+this.divID).fadeIn("slow");
}
function ajaxXMLRequest(reqUrl,contentDivID, loadRequestedContent){
$.ajax({
url: reqUrl,
cache: false,
dataType: "xml",
divID: contentDivID,
success: loadRequestedContent
});
}
function floatingDiv(width,height,content,xPos,yPos){
// can calculate depending on the text lengthi
var html= '';
html +='
';
$('#floatingDiv').html(html);
$('#floatingDiv').show();
}
function closeFloatingDiv(){
$('#floatingDiv').fadeOut();
$('#floatingDiv').html('');
if ($('#shareContent')){
$('#shareContent').fadeOut();
//$('#shareContent').style.display = "none";
}
}
function divAlert(msg){
var height = 70;
var charsPerLine = 40;
if (msg.length > charsPerLine){
height += Math.ceil((msg.length/charsPerLine)*20); //50 chars per row = #rows * 15
}
floatingDiv(320,height,msg);
}
function loadSwfInDiv(divID,swf){
if ($("#"+divID) != undefined){
$("#"+divID).html(swf);
}
}
function setVisible(divID){
if ( $("#"+divID).style.display == "none"){
$("#"+divID).style.display = "block";
return true;
} else {
$("#"+divID).style.display = "none";
return false;
}
}
function setDisplay(divID,value){
if ( $("#"+divID)){
$("#"+divID).style.display = value;
}
}
function setWindowSize() {
var myWidth = 0, myHeight = 0;
if( typeof( window.innerWidth ) == 'number' ) {
//Non-IE
myWidth = window.innerWidth;
myHeight = window.innerHeight;
} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
//IE 6+ in 'standards compliant mode'
myWidth = document.documentElement.clientWidth;
myHeight = document.documentElement.clientHeight;
} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
//IE 4 compatible
myWidth = document.body.clientWidth;
myHeight = document.body.clientHeight;
}
windowWidth = myWidth;
windowHeight = myHeight
}
//////////////
function deleteEntry(entID,entryDivID){
var url = "delete.php?id="+entID+"&rndnum="+Math.random();
var myQuery = new dbQuery();
myQuery.entryDivID = entryDivID;
myQuery.requestData(url,this,"receiveDeleteEntry");
}
function receiveDeleteEntry(query){
var myRecords = query.getRecords();
var recLength = myRecords.length;
for (var i=0;i 0){
$("#"+query.entryDivID).style.borderWidth = 0;
$("#"+query.entryDivID).html('');
//removeChild($("#"+query.entryDivID));
}
removeObject(query);
}
function setTabsVisible(visible){
if (visible){
$('#fullMenu').style.display="block";
$('#shortMenu').style.display="none";
} else {
$('#fullMenu').style.display="none";
$('#shortMenu').style.display="block";
}
}
//------ registration --------//
function validateEmail(emailAddress) {
var emailOK = true;
var atCount = -1;
currentPos = 0;
while (currentPos != -1) {
currentPos = emailAddress.indexOf('@',currentPos+1);
atCount++;
}
if ((atCount > 1)||(atCount == 0)) {
emailOK = false;
}
// are there any characters after the at sign?
if (emailAddress.substr(emailAddress.indexOf("@")+1).length < 1) {
emailOK = false;
}
// are there any '.'s after the at sign?
if (emailAddress.substr(emailAddress.indexOf("@")+1).indexOf('.') == -1) {
emailOK = false;
}
// can't end with dot
if (emailAddress.substr(emailAddress.length - 1,1) == ".") {
emailOK = false;
}
var badChars = new Array("^","!","#","%","$","&","*","+","/","=","?","{","}","|","~");
for (var i=0;i= 2){
//ajaxXMLRequest(url, box.id,receiveAutocomplete);
$.ajax({
type: 'POST',
url: baseUrl+"artist/autocomplete",
data: {artistSearchString:box.value},
success: function (resp){ /*update the count*/
if (resp.success){
var artists = "";
$.each(resp.artists, function(key, value) {
artists += '<' + value["Art_Name"]+' ';
artists += ""+value["Art_Name"]+" ";
});
$('#suggestionDiv').html("
"+artists+"
");
}
},
dataType: "json"
});
}
}
function fillSelected(box_id,value){
$("#"+box_id).val(value);
$('#suggestionDiv').html("");
}
function inArray(elem,array){
for (var i=0; i= 0) {
res = parseInt(width.substring(0, p));
}
else {
//do not know how to calculate other
//values (such as 0.5em or 0.1cm) correctly now
//so just set the width to 1 pixel
res = 1;
}
}
return res;
}
//returns border width for some element
function __getBorderWidth(element) {
var res = new Object();
res.left = 0; res.top = 0; res.right = 0; res.bottom = 0;
if (window.getComputedStyle) {
//for Firefox
var elStyle = window.getComputedStyle(element, null);
res.left = parseInt(elStyle.borderLeftWidth.slice(0, -2));
res.top = parseInt(elStyle.borderTopWidth.slice(0, -2));
res.right = parseInt(elStyle.borderRightWidth.slice(0, -2));
res.bottom = parseInt(elStyle.borderBottomWidth.slice(0, -2));
}
else {
//for other browsers
res.left = __parseBorderWidth(element.style.borderLeftWidth);
res.top = __parseBorderWidth(element.style.borderTopWidth);
res.right = __parseBorderWidth(element.style.borderRightWidth);
res.bottom = __parseBorderWidth(element.style.borderBottomWidth);
}
return res;
}
//returns absolute position of some element within document
function getElementAbsolutePos(element) {
var res = new Object();
res.x = 0; res.y = 0;
if (element !== null) {
res.x = element.offsetLeft;
res.y = element.offsetTop;
var offsetParent = element.offsetParent;
var parentNode = element.parentNode;
var borderWidth = null;
while (offsetParent != null) {
res.x += offsetParent.offsetLeft;
res.y += offsetParent.offsetTop;
var parentTagName = offsetParent.tagName.toLowerCase();
if ((__isIE && parentTagName != "table") ||
(__isFireFoxNew && parentTagName == "td")) {
borderWidth = __getBorderWidth(offsetParent);
res.x += borderWidth.left;
res.y += borderWidth.top;
}
if (offsetParent != document.body &&
offsetParent != document.documentElement) {
res.x -= offsetParent.scrollLeft;
res.y -= offsetParent.scrollTop;
}
//next lines are necessary to support FireFox problem with offsetParent
if (!__isIE) {
while (offsetParent != parentNode && parentNode !== null) {
res.x -= parentNode.scrollLeft;
res.y -= parentNode.scrollTop;
if (__isFireFoxOld) {
borderWidth = __getBorderWidth(parentNode);
res.x += borderWidth.left;
res.y += borderWidth.top;
}
parentNode = parentNode.parentNode;
}
}
parentNode = offsetParent.parentNode;
offsetParent = offsetParent.offsetParent;
}
}
return res;
}
function requestHTMLContent(url,targetDIV,executeWhenLoaded){
if ($("#"+targetDIV) != null){
$("#"+targetDIV).html( "
");
}
var myQuery = new dbQuery();
myQuery.targetDIV = targetDIV;
myQuery.onLoadFunction = executeWhenLoaded;
myQuery.requestData(url+"&rndnum="+Math.random(),this,"receiveHTMLContent");
}
function receiveHTMLContent(query){
var myRecords = query.getRecords();
var recLength = myRecords.length;
// var html = unescape(myRecords[1].getPropertyValue("content"));
var html = (myRecords[1].getPropertyValue("content"));
if ($("#"+query.targetDIV) != null){
$("#"+query.targetDIV).html( base64Decode(html));
}
if (query.onLoadFunction){
query.onLoadFunction();
}
// removeObject(query);
}
function updateStatus(box){
$.ajax({
type: 'POST',
url: baseUrl+"/site/updateStatus/st",
data: {status:$("#web_status").val()},
success: function (resp){ /*update the count*/
if (resp.success){
// $("#like_count_"+id).text(parseInt($("#like_count_"+id).text())+1);
} else {
divAlert(resp.msg);
}
},
dataType: "json"
});
}
function addResponseComment(form){
if (userID == ""){
divAlert("You have to be logged in to add comments.