// TRIM FUNCTION
function leftTrim(sString)
{
while (sString.substring(0,1) == ' ')
{
sString = sString.substring(1, sString.length);
}
return sString;
}

function rightTrim(sString)
{
while (sString.substring(sString.length-1, sString.length) == ' ')
{
sString = sString.substring(0,sString.length-1);
}
return sString;
}


function trimAll(sString)
{
while (sString.substring(0,1) == ' ')
{
sString = sString.substring(1, sString.length);
}
while (sString.substring(sString.length-1, sString.length) == ' ')
{
sString = sString.substring(0,sString.length-1);
}
return sString;
}

function TAreaLength(areaName,counter,limit)
{
if (areaName.value.length>limit)
areaName.value=areaName.value.substring(0,limit);
else
counter.value = limit - areaName.value.length;
}

function SecureWords(theValue) {

var myArray = new Array('select','insert','update','delete','*','=','"');

	for (var i=0;i<=myArray.length;i++) {
		theValue = theValue.toLowerCase().replace(myArray[i],'');				
	}	
	
return theValue; 	
}

function getObj(name)
{
	if (document.getElementById)
	{
		this.obj = document.getElementById(name);
	}
	else if (document.all)
	{
		this.obj = document.all[name];
	}
	else if (document.layers)
	{
		this.obj = document.layers[name];
	}

return this.obj;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/* PRELOADER */
//BGRs
MM_preloadImages('http://www.shape.gr/bg.gif','http://www.shape.gr/bggreen.gif','http://www.shape.gr/bgorange.gif','http://www.shape.gr/myimages/loginareabackfinal.jpg','http://www.shape.gr/myimages/shapetoolsbackground.jpg','http://www.shape.gr/myimages/newsletterbacknew.jpg');
//INDEX
MM_preloadImages('http://www.shape.gr/myimages/newsloader.gif','http://www.shape.gr/myimages/ajax-loader2.gif','http://www.shape.gr/myimages/ajax-loaderform.gif');
//BARS
MM_preloadImages('http://www.shape.gr/myimages/ajax-loadercat0.gif','http://www.shape.gr/myimages/ajax-loadercat1.gif','http://www.shape.gr/myimages/ajax-loadercat2.gif','http://www.shape.gr/myimages/ajax-loadercat3.gif','http://www.shape.gr/myimages/ajax-loadercat4.gif','http://www.shape.gr/myimages/ajax-loadercat5.gif','http://www.shape.gr/myimages/ajax-loadercat6.gif');
//ROLOVERS
MM_preloadImages('http://www.shape.gr/myimages/email_on.jpg','http://www.shape.gr/myimages/print_on.jpg','http://www.shape.gr/myimages/bookmark_on.jpg');
/* PRELOADER */


function ajaxObject(url, callbackFunction) {
  var that=this;      
  this.updating = false;
  this.abort = function() {
    if (that.updating) {
      that.updating=false;
      that.AJAX.abort();
      that.AJAX=null;
    }
  }
  this.update = function(passData,postMethod) { 
    if (that.updating) { return false; }
    that.AJAX = null;                          
    if (window.XMLHttpRequest) {              
      that.AJAX=new XMLHttpRequest();              
    } else {                                  
      that.AJAX=new ActiveXObject("Microsoft.XMLHTTP");
    }                                             
    if (that.AJAX==null) {                             
      return false;                               
    } else {
      that.AJAX.onreadystatechange = function() {  
        if (that.AJAX.readyState==4) {             
          that.updating=false;                
          that.callback(that.AJAX.responseText,that.AJAX.status,that.AJAX.responseXML);        
          that.AJAX=null;                                         
        }                                                      
      }                                                        
      that.updating = new Date();                              
      if (/post/i.test(postMethod)) {
        var uri=urlCall+'?'+that.updating.getTime();
        that.AJAX.open("POST", uri, true);
        that.AJAX.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        that.AJAX.send(passData);
      } else {
        var uri=urlCall+'?'+passData+'&timestamp='+(that.updating.getTime()); 
        that.AJAX.open("GET", uri, true);                             
        that.AJAX.send(null);                                         
      }              
      return true;                                             
    }                                                                           
  }
  var urlCall = url;        
  this.callback = callbackFunction || function () { };
}


function Delay(Div){	
	getObj(Div).innerHTML = "<span class='textB'>Loading...</span><br /><img src='http://www.shape.gr/loading_transp.gif' width='87' height='24' />";
}


function FillTools(ID) {
	Delay('tools');
	var httpReq = new ajaxObject('myincludes/calcs_model.php', function Calc(responseTxt,responseStat) {
	getObj('tools').innerHTML = responseTxt; 
}
);
	var data = "";
	data += "id=" + ID;
	data += "&Action=Show";
	httpReq.update(data,'POST');	
}


function BgImage(IMG){
	document.body.style.background = 'url(http://www.shape.gr/' + IMG + ')';
	createCookie('shapebgimage',IMG,365);
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

/*
if (readCookie('shapebgimage') == 'bg.gif' || readCookie('shapebgimage') == 'bggreen.gif' || readCookie('shapebgimage') == 'bgorange.gif') {
	BgImage(readCookie('shapebgimage'));
	document.body.style.backgroundImage = 'url(http://www.shape.gr/' + readCookie('shapebgimage') + ')';	
}
else {
	BgImage('bg.gif');
	document.body.style.backgroundImage = 'url(http://www.shape.gr/bg.gif)';	
}*/

function ClearSearch() {
var sform = document.search;
var str = sform.search_key.value;
if (trimAll(str) == 'Αναζήτηση..') {
	sform.search_key.value = '';
}
}

function Search() {
var sform = document.search;
var str = sform.search_key.value;
if (trimAll(str) == 'Αναζήτηση..' || trimAll(str) == '' || str.length < 4) {
	alert('Ελάχιστοι χαρακτήρες για αναζήτηση: 4 !');
}
else {
	sform.submit();	
}
}

// MAIN CATS
function LatestPosts(CID,TYPE,DIV) {	
	//getObj(DIV).innerHTML = "<img src='http://www.shape.gr/myimages/ajax-loadercat" + TYPE + ".gif' width='128' height='15' style='padding-top:80px; padding-left:350px;'>"; 
	var httpReq = new ajaxObject('http://www.shape.gr/myincludes/forum_model.php', function fin(responseTxt,responseStat) {
	getObj(DIV).innerHTML = responseTxt; 
}
);
	var data = "";
	data += "cid=" + CID;
	data += "&type=" + TYPE;
	data += "&Action=LatestPosts";
	httpReq.update(data,'POST');	
}

function FeaturedArticle(CID,DIV,TYPE) {	
	getObj(DIV).innerHTML = "<img src='http://www.shape.gr/myimages/ajax-loadercat" + TYPE + ".gif' width='128' height='15' style='padding-top:60px; padding-left:350px;'>"; 
	var httpReq = new ajaxObject('http://www.shape.gr/myincludes/category_model.php', function fin(responseTxt,responseStat) {
	getObj(DIV).innerHTML = responseTxt; 
}
);
	var data = "";
	data += "cid=" + CID;
	data += "&type=" + TYPE;
	data += "&Action=FeaturedArticle";
	httpReq.update(data,'POST');	
}

function listArticles(CID,DIV,TYPE,PG) {
	getObj(DIV).innerHTML = "<img src='http://www.shape.gr/myimages/ajax-loadercat" + TYPE + ".gif' width='128' height='15' style='padding-top:210px; padding-left:350px;'>"; 
	var httpReq = new ajaxObject('http://www.shape.gr/myincludes/category_model.php', function fin(responseTxt,responseStat) {
	getObj(DIV).innerHTML = responseTxt; 
}
);
	var data = "";
	data += "cid=" + CID;
	data += "&type=" + TYPE;
	data += "&page=" + PG;
	data += "&Action=listArticles";
	httpReq.update(data,'POST');	
}

function LoadCover(DIV) {
	getObj(DIV).innerHTML = "<img src='http://www.shape.gr/myimages/ajax-loader2.gif' width='32' height='32' style='padding-top:90px; padding-left:70px;'>"; 
	var httpReq = new ajaxObject('http://www.shape.gr/myincludes/cover_model.php', function fin(responseTxt,responseStat) {
	getObj(DIV).innerHTML = responseTxt;	
}
);
	var data = "";
	data += "Action=LoadCover";
	httpReq.update(data,'POST');
	CoverArticles('CoverArticles');
}

function LoadCover2(DIV) {
	getObj(DIV).innerHTML = "<img src='http://www.shape.gr/myimages/ajax-loader2.gif' width='32' height='32' style='padding-top:90px; padding-left:80px;'>"; 
	var httpReq = new ajaxObject('http://www.shape.gr/myincludes/cover_model.php', function fin(responseTxt,responseStat) {
	getObj(DIV).innerHTML = responseTxt;	
}
);
	var data = "";
	data += "Action=LoadCover2";
	httpReq.update(data,'POST');
	CoverArticles('CoverArticles');		
}

function LoadCoverNew(DIV) {
	getObj(DIV).innerHTML = "<img src='http://www.shape.gr/myimages/ajax-loader2.gif' width='32' height='32' style='padding-top:90px; padding-left:80px;'>"; 
	var httpReq = new ajaxObject('http://www.shape.gr/myincludes/cover_model.php', function fin(responseTxt,responseStat) {
	getObj(DIV).innerHTML = responseTxt;	
}
);
	var data = "";
	data += "Action=LoadCoverNew";
	httpReq.update(data,'GET');	
}

function CoverArticles(DIV) {
	var httpReq = new ajaxObject('http://www.shape.gr/myincludes/cover_model.php', function fin(responseTxt,responseStat) {
	getObj(DIV).innerHTML = responseTxt;	
}
);
	var data = "";
	data += "Action=CoverArticles";
	httpReq.update(data,'POST');	
}

function Article(CID,AID,DIV,TYPE) {	
	getObj(DIV).innerHTML = "<img src='http://www.shape.gr/myimages/ajax-loadercat" + TYPE + ".gif' width='128' height='15' style='padding-top:100px; padding-bottom:100px; padding-left:350px;'>"; 
	var httpReq = new ajaxObject('http://www.shape.gr/myincludes/article_model.php', function fin(responseTxt,responseStat) {
	getObj(DIV).innerHTML = responseTxt; 
}
);
	var data = "";
	data += "cid=" + CID;
	data += "&aid=" + AID;	
	data += "&Action=Article";
	httpReq.update(data,'POST');	
}

function ArticlePager(AID,CID,DIV,TYPE,PG,TOTAL) {	
	getObj(DIV).innerHTML = "<img src='http://www.shape.gr/myimages/ajax-loadercat" + TYPE + ".gif' width='128' height='15' style='padding-top:100px; padding-bottom:100px; padding-left:350px;'>"; 
	var httpReq = new ajaxObject('http://www.shape.gr/myincludes/article_model.php', function fin(responseTxt,responseStat) {
	getObj(DIV).innerHTML = responseTxt; 
	PagesStr = '';
	PagesClass = '';
	for (i=1;i<=TOTAL;i++) {
		if (i == PG) {
			PagesClass = "class='page1'";		
		}
		else {
			PagesClass = "class='page2'";
		}		
		
		if (PagesStr == '') {
		if (i==1) {	
			PagesStr += "<a href=\"javascript:Article("+CID+","+AID+",'Article',"+TYPE+")\" " + PagesClass + ">"+i+"</a>";	
		}
		else {
			PagesStr += "<a href=\"javascript:ArticlePager("+AID+","+CID+",'content',"+TYPE+","+i+","+TOTAL+")\" " + PagesClass + ">" + i + "</a>";
		}
		}
		else {
			PagesStr += "&nbsp;|&nbsp;<a href=\"javascript:ArticlePager("+AID+","+CID+",'content',"+TYPE+","+i+","+TOTAL+")\" " + PagesClass + ">" + i + "</a>";	
		}
		
	}
	getObj('Pages').innerHTML = PagesStr; 
}
);
	var data = "";
	data += "aid=" + AID;
	data += "&page=" + PG;	
	data += "&Action=ArticlePager";
	httpReq.update(data,'POST');	
}

function relArticles(CID,AID,DIV,TYPE,PG) {	
	getObj(DIV).innerHTML = "<img src='http://www.shape.gr/myimages/ajax-loadercat" + TYPE + ".gif' width='128' height='15' style='padding-top:100px; padding-bottom:100px; padding-left:350px;'>"; 
	var httpReq = new ajaxObject('http://www.shape.gr/myincludes/article_model.php', function fin(responseTxt,responseStat) {
	getObj(DIV).innerHTML = responseTxt; 
}
);
	var data = "";
	data += "cid=" + CID;
	data += "&aid=" + AID;
	data += "&page=" + PG;	
	data += "&Action=relArticles";
	httpReq.update(data,'POST');	
}

function PrintMe(Div){
  var content=getObj(Div).innerHTML;
  content += '<p class="mytext2"><b>copyright 2008 - shape.gr</b></p>';
  var pwin=window.open('','print_content','width=600,height=600,scrollbars=1');
  pwin.document.open();
  pwin.document.write('<html><head>');
  pwin.document.write('<link href="http://www.shape.gr/shapestyles.css" rel="stylesheet" type="text/css" />');
  pwin.document.write('<link href="http://www.shape.gr/shape1.css" rel="stylesheet" type="text/css" /></head>');  
  pwin.document.write('<body onload="window.print()">'+content+'</body></html>');   
  pwin.document.close(); 
}

function Bookmark(url,title){
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
  window.external.AddFavorite(url,title);
  } else if (navigator.appName == "Netscape") {
    window.sidebar.addPanel(title,url,"");
  } else {
    alert("Πατήστε CTRL-D (Firefox) or CTRL-T (Opera) για προσθήκη στα Bookmarks/Favorites!");
  }
}

function getBrowserHeight() {
	var intH = 0;
    var intW = 0;

    if(typeof window.innerWidth  == 'number') {
    	intH = window.innerHeight;
        intW = window.innerWidth;
	} 
    else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        intH = document.documentElement.clientHeight;
        intW = document.documentElement.clientWidth;
    }
    else if(document.body && (document.body.clientWidth || document.body.clientHeight)) {
        intH = document.body.clientHeight;
        intW = document.body.clientWidth;
    }
          return {width: parseInt(intW), height: parseInt(intH)};
}

function ShowHideComment(Div){
	if (getObj(Div).style.display == 'block') {
		getObj(Div).style.display = 'none';	
	}
	else {
		getObj(Div).style.display = 'block';			
	}
}

function ShowHideEmail(Div){
	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;
  }	

	getObj(Div).style.left = (myWidth - 400) / 2 + 'px';
	getObj(Div).style.top = (myHeight - 300) / 2 + 'px';	
	
	if (getObj(Div).style.display == 'block') {
		getObj(Div).style.display = 'none';	
	}
	else {
		getObj(Div).style.display = 'block';			
	}
}

function ShowFiles(Div,Aid){
	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;
  }	

	getObj(Div).style.left = (myWidth - 550) / 2 + 'px';
	getObj(Div).style.top = 250 + 'px';	
	
	if (getObj(Div).style.display == 'block') {
		getObj(Div).style.display = 'none';	
		getObj('FilesContent').innerHTML = '';
	}
	else {
		ShowFilesPages('FilesContent',Aid,0);
		getObj('FilesDiv').style.display = 'block';			
	}
}

function ShowFilesPages(Div,Aid,Page){
	//getObj(Div).innerHTML = "<img src='http://www.shape.gr/myimages/ajax-loaderemail.gif' width='16' height='16'>"; 
	var httpReq = new ajaxObject('http://www.shape.gr/myincludes/files_model.php', function fin(responseTxt,responseStat) {
	getObj(Div).innerHTML = responseTxt; 
}
);
	var data = "";
	data += "aid=" + Aid;
	data += "&page=" + Page;	
	data += "&Action=ShowFilesPages";
	httpReq.update(data,'POST');

}

function EmailFriend(URL) {	
	getObj('EmailRes').innerHTML = "<img src='http://www.shape.gr/myimages/ajax-loaderemail.gif' width='16' height='16'>"; 
	var httpReq = new ajaxObject('http://www.shape.gr/myincludes/article_model.php', function fin(responseTxt,responseStat) {
	getObj('EmailRes').innerHTML = responseTxt;	
}
);
	var data = "";
	data += "fromname=" + getObj('fromname').value;
	data += "&fromemail=" + getObj('fromemail').value;
	data += "&toemail=" + getObj('toemail').value;
	data += "&url=" + URL;	
	data += "&Action=EmailFriendNew";
	httpReq.update(data,'POST');	
}

/* FAVOURITES */
function AddFavourite(MID,AID,CID,ADATE,URI) {
	var conf = 'Για την προσθήκη άρθρου στα αγαπημένα σου, πρέπει να είσαι συνδεδεμένο μέλος..\nΘέλεις να συνδεθείς/εγγραφείς τώρα;';
	if (trimAll(MID) == '') {
		if (confirm(conf)) {
			location.href='http://www.shape.gr/news/175?uri='+URI;	
		}
	}
	else {
	var httpReq = new ajaxObject('http://www.shape.gr/myincludes/fav_model.php', function fin(responseTxt,responseStat) {
	alert(responseTxt); 		
}
);
	var data = "";
	data += "mid=" + MID;
	data += "&aid=" + AID;
	data += "&cid=" + CID;
	data += "&adate=" + ADATE;
	data += "&Action=AddFavourite";
	httpReq.update(data,'POST');	
}
}

function DeleteFavourite(MID,FID) {
	var httpReq = new ajaxObject('http://www.shape.gr/myincludes/fav_model.php', function fin(responseTxt,responseStat) {
	if (responseTxt == '[NOTOK]') {
		alert('Παρουσιάστηκε σφάλμα..'); 		
	}
	else {
		location.href='http://www.shape.gr/favourites';		
	}
}
);
	var data = "";
	data += "mid=" + MID;
	data += "&fid=" + FID;
	data += "&Action=DeleteFavourite";
	httpReq.update(data,'POST');	
}


function listFavs(DIV,PG) {
	//getObj(DIV).innerHTML = "<img src='http://www.shape.gr/myimages/ajax-loadercat" + TYPE + ".gif' width='128' height='15' style='padding-top:210px; padding-left:350px;'>"; 
	var httpReq = new ajaxObject('http://www.shape.gr/myincludes/fav_model.php', function fin(responseTxt,responseStat) {
	getObj(DIV).innerHTML = responseTxt; 
}
);
	var data = "";
	data += "page=" + PG;
	data += "&Action=listFavs";
	httpReq.update(data,'POST');	
}
/* FAVOURITES */

/* MEMBERS */
function Register() {
	if (!document.MemFrm.terms.checked) {
		alert('Πρέπει να συμφωνήσετε με τους Όρους χρήσης...');	
	}
	else {
	getObj('RegRes').innerHTML = "<img src='http://www.shape.gr/myimages/ajax-loaderemail.gif' width='16' height='16'>"; 	
	var httpReq = new ajaxObject('http://www.shape.gr/myincludes/members_model.php', function fin(responseTxt,responseStat) {
	getObj('RegRes').innerHTML = responseTxt; 
}
);
	var data = "";
	data += "username=" + getObj('username1').value;
	data += "&password=" + getObj('password1').value;
	data += "&confirm=" + getObj('confirm').value;
	data += "&email=" + getObj('email1').value;
	data += "&newsletter=" + getObj('newsletter').value;	
	data += "&Action=Register";
	httpReq.update(data,'POST');		
	}
}

function Modify() {
	getObj('RegRes').innerHTML = "<img src='http://www.shape.gr/myimages/ajax-loaderemail.gif' width='16' height='16'>"; 	
	var httpReq = new ajaxObject('http://www.shape.gr/myincludes/members_model.php', function fin(responseTxt,responseStat) {
	getObj('RegRes').innerHTML = responseTxt; 
}
);
	var data = "";
	data += "username=" + getObj('username1').value;
	data += "&password=" + getObj('password1').value;
	data += "&confirm=" + getObj('confirm').value;
	data += "&email=" + getObj('email1').value;
	data += "&newsletter=" + getObj('newslet').value;	
	data += "&Action=Modify";
	httpReq.update(data,'POST');		
}

function ResetAvatar(MID) {
	var httpReq = new ajaxObject('http://www.shape.gr/myincludes/members_model.php', function fin(responseTxt,responseStat) {
	//getObj('avatar').innerHTML = responseTxt; 
	location.href='http://www.shape.gr/account';
}
);
	var data = "";
	data += "mid=" + MID;
	data += "&Action=ResetAvatar";
	httpReq.update(data,'POST');		
}

function Validate(ID) {
	var httpReq = new ajaxObject('http://www.shape.gr/myincludes/members_model.php', function fin(responseTxt,responseStat) {
	alert(responseTxt);
	location.href='http://www.shape.gr';
}
);
	var data = "";
	data += "id=" + ID;
	data += "&Action=Validate";
	httpReq.update(data,'POST');		
}

function getURLParam(strParamName){
  var strReturn = "";
  var strHref = window.location.href;
  if ( strHref.indexOf("?") > -1 ){
    var strQueryString = strHref.substr(strHref.indexOf("?"));
    var aQueryString = strQueryString.split("&");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
      if (
aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
        var aParam = aQueryString[iParam].split("=");
        strReturn = aParam[1];
        break;
      }
    }
  }
  return unescape(strReturn);
}

function Login() {
	getObj('LogRes').innerHTML = "<img src='http://www.shape.gr/myimages/ajax-loaderemail.gif' width='16' height='16'>"; 	
	var httpReq = new ajaxObject('http://www.shape.gr/myincludes/members_model.php', function fin(responseTxt,responseStat) {
	getObj('LogRes').innerHTML = '';
	if (responseTxt == '[OK]') {
		if (getURLParam('uri') != '') {
			location.href = getURLParam('uri');	
		}
		else {
			location.href = 'http://www.shape.gr/account';
		}		
	}
	else {
		getObj('LogRes').innerHTML = 'Λάθος στοιχεία...';
	}	
}
);
	var data = "";
	data += "username=" + getObj('username2').value;
	data += "&password=" + getObj('password2').value;
	if (getObj('remember').checked) {
  		data += "&remember=1";
  	}
	else {
    	data += "&remember=0";	  
  	} 
	data += "&Action=Login";
	httpReq.update(data,'POST');		
}

function IndexLoginShow() {
	getObj('LoginNew').innerHTML = "<img src='http://www.shape.gr/myimages/newsloader.gif' width='16' height='16' style='padding-top:70px; padding-left:100px;'>"; 	
	var httpReq = new ajaxObject('http://www.shape.gr/myincludes/login_model.php', function fin(responseTxt,responseStat) {
	getObj('LoginNew').innerHTML = responseTxt;	
}
);
	var data = "";
	data += "Action=IndexLoginShow";
	httpReq.update(data,'POST');		
}

function IndexLoginShow2() {
	getObj('LoginNew2').innerHTML = "<img src='http://www.shape.gr/myimages/newsloader.gif' width='16' height='16' style='padding-top:70px; padding-left:100px;'>"; 	
	var httpReq = new ajaxObject('http://www.shape.gr/myincludes/login_model.php', function fin(responseTxt,responseStat) {
	getObj('LoginNew2').innerHTML = responseTxt;	
}
);
	var data = "";
	data += "Action=IndexLoginShow";
	httpReq.update(data,'POST');		
}

function IndexLogin() {
	var httpReq = new ajaxObject('http://www.shape.gr/myincludes/login_model.php', function fin(responseTxt,responseStat) {
	if (responseTxt == '[OK]') {
		location.href = 'http://www.shape.gr/account';
	}
	else {
		alert('Λάθος στοιχεία...');
	}	
}
);
	var data = "";
	data += "username=" + getObj('usernameInd').value;
	data += "&password=" + getObj('passwordInd').value;
	if (getObj('rememberInd').checked) {
  		data += "&remember=1";
  	}
	else {
    	data += "&remember=0";	  
  	} 
	data += "&Action=IndexLogin";
	httpReq.update(data,'POST');		
}

function Remind() {
	getObj('RemRes').innerHTML = "<img src='http://www.shape.gr/myimages/ajax-loaderemail.gif' width='16' height='16'>"; 	
	var httpReq = new ajaxObject('http://www.shape.gr/myincludes/members_model.php', function fin(responseTxt,responseStat) {
	getObj('RemRes').innerHTML = responseTxt;
}
);
	var data = "";
	data += "email=" + getObj('email2').value;
	data += "&Action=Remind";
	httpReq.update(data,'POST');		
}

function Logout() {
	var httpReq = new ajaxObject('http://www.shape.gr/myincludes/members_model.php', function fin(responseTxt,responseStat) {	
	location.href='http://www.shape.gr/index.php';
}
);
	var data = "";
	data += "Action=Logout";
	httpReq.update(data,'POST');		
}

function MembersList() {
	getObj('List').innerHTML = "<img src='http://www.shape.gr/myimages/ajax-loaderemail.gif' width='16' height='16'>"; 	
	var httpReq = new ajaxObject('http://www.shape.gr/myincludes/memberslist_model.php', function fin(responseTxt,responseStat) {
	getObj('List').innerHTML = responseTxt;
}
);
	var data = "";
	data += "Action=MembersList";
	httpReq.update(data,'POST');		
}

/* COMMENTS */
function ValidComment(URI) {
var conf = 'Για την αποστολή σχολίου πρέπει να είστε συνδεδεμένο μέλος!\nΘέλετε να συνδεθείτε τώρα;';	
	if (confirm(conf)) {
		location.href='http://www.shape.gr/news/175?uri='+URI;	
	}	
}


function SendComment(AID,UID) {
	getObj('ComRes').innerHTML = "<img src='http://www.shape.gr/myimages/ajax-loaderemail.gif' width='16' height='16'>"; 	
	var httpReq = new ajaxObject('http://www.shape.gr/myincludes/article_model.php', function fin(responseTxt,responseStat) {
	if (responseTxt.indexOf("[OK]") != -1) {
		alert('Επιτυχής αποστολή σχολίου!');
		ComCounter(AID);
		ShowHideComment('Comment');
		getObj('ComRes').innerHTML = '';		
	}
	else {
		getObj('ComRes').innerHTML = responseTxt;		
	}
}
);
	var data = "";
	data += "aid=" + AID;
	data += "&uid=" + UID;
	data += "&text=" + getObj('text').value;
	data += "&Action=SendComment";
	httpReq.update(data,'POST');
}

function ComCounter(AID) {
	var httpReq = new ajaxObject('http://www.shape.gr/myincludes/article_model.php', function fin(responseTxt,responseStat) {
	getObj('ComCounter').innerHTML = responseTxt;
}
);
	var data = "";
	data += "aid=" + AID;
	data += "&Action=ComCounter";
	httpReq.update(data,'POST');
}


function relComments(AID,DIV,TYPE,PG) {	
	getObj(DIV).innerHTML = "<img src='http://www.shape.gr/myimages/ajax-loadercat" + TYPE + ".gif' width='128' height='15' style='padding-top:300px; padding-left:130px;'>"; 
	var httpReq = new ajaxObject('http://www.shape.gr/myincludes/comments_model.php', function fin(responseTxt,responseStat) {
	getObj(DIV).innerHTML = responseTxt; 
}
);
	var data = "";
	data += "aid=" + AID;
	data += "&type=" + TYPE;
	data += "&page=" + PG;		
	data += "&Action=relComments";
	httpReq.update(data,'POST');
}
/* COMMENTS */

/* MAGAZINE */
function MagArticle(CID,DIV,TYPE) {	
	getObj(DIV).innerHTML = "<img src='http://www.shape.gr/myimages/ajax-loadercat" + TYPE + ".gif' width='128' height='15' style='padding-top:60px; padding-left:350px;'>"; 
	var httpReq = new ajaxObject('http://www.shape.gr/myincludes/mag_model.php', function fin(responseTxt,responseStat) {
	getObj(DIV).innerHTML = responseTxt; 
}
);
	var data = "";
	data += "cid=" + CID;
	data += "&type=" + TYPE;
	data += "&Action=FeaturedMagArticle";
	httpReq.update(data,'POST');	
}

function relMagArticles(CID,DIV,TYPE) {
	getObj(DIV).innerHTML = "<img src='http://www.shape.gr/myimages/ajax-loadercat" + TYPE + ".gif' width='128' height='15' style='padding-top:210px; padding-left:350px;'>"; 
	var httpReq = new ajaxObject('http://www.shape.gr/myincludes/mag_model.php', function fin(responseTxt,responseStat) {
	getObj(DIV).innerHTML = responseTxt; 
}
);
	var data = "";
	data += "cid=" + CID;
	data += "&type=" + TYPE;
	data += "&Action=listMagArticles";
	httpReq.update(data,'POST');	
}
/* MAGAZINE */


/* CONTACTS */
function Contact(DIV) {	
	getObj(DIV).innerHTML = "<img src='http://www.shape.gr/myimages/ajax-loaderform.gif' width='16' height='16' style='padding-left:70px;'>"; 
	var httpReq = new ajaxObject('http://www.shape.gr/myincludes/contact_model.php', function fin(responseTxt,responseStat) {
	getObj(DIV).innerHTML = responseTxt; 
}
);
	var data = "";
	data += "to=" + document.contFrm.fTo.options[document.contFrm.fTo.selectedIndex].value;
	data += "&fullname=" + getObj('fFullname').value;
	data += "&email=" + getObj('fEmail').value;		
	data += "&message=" + getObj('fMessage').value;			
	data += "&Action=Contact";
	httpReq.update(data,'POST');
}

function AskShape(DIV,MID) {
	var conf = 'Για την αποστολή ερώτησης πρέπει να είσαι συνδεδεμένο μέλος..\nΘέλεις να συνδεθείς/εγγραφείς τώρα;';
	if (trimAll(MID) == '') {
		if (confirm(conf)) {
			location.href='http://www.shape.gr/news/175?uri=http://www.shape.gr/news/185';	
		}		
	}
	else {
	getObj(DIV).innerHTML = "<img src='http://www.shape.gr/myimages/ajax-loaderform.gif' width='16' height='16' style='padding-left:70px;'>"; 
	var httpReq = new ajaxObject('http://www.shape.gr/myincludes/contact_model.php', function fin(responseTxt,responseStat) {
	getObj(DIV).innerHTML = responseTxt; 
}
);
	var data = "";
	data += "username=" + getObj('fUsername').value;
	data += "&email=" + getObj('fEmail').value;		
	data += "&message=" + getObj('fMessage').value;			
	data += "&Action=AskShape";
	httpReq.update(data,'POST');
	}
}

function SuccessStories(DIV,MID) {
	var conf = 'Για την αποστολή ερώτησης πρέπει να είσαι συνδεδεμένο μέλος..\nΘέλεις να συνδεθείς/εγγραφείς τώρα;';
	if (trimAll(MID) == '') {
		if (confirm(conf)) {
			location.href='http://www.shape.gr/news/175?uri=http://www.shape.gr/news/188';	
		}		
	}
	else {
	getObj(DIV).innerHTML = "<img src='http://www.shape.gr/myimages/ajax-loaderform.gif' width='16' height='16' style='padding-left:70px;'>"; 
	var httpReq = new ajaxObject('http://www.shape.gr/myincludes/contact_model.php', function fin(responseTxt,responseStat) {
	getObj(DIV).innerHTML = responseTxt; 
}
);
	var data = "";
	data += "username=" + getObj('fUsername').value;
	data += "&email=" + getObj('fEmail').value;		
	data += "&message=" + getObj('fMessage').value;			
	data += "&Action=SuccessStories";
	httpReq.update(data,'POST');
	}
}

function SendSynt(DIV,MID) {
	var conf = 'Για την αποστολή ερώτησης πρέπει να είσαι συνδεδεμένο μέλος..\nΘέλεις να συνδεθείς/εγγραφείς τώρα;';
	if (trimAll(MID) == '') {
		if (confirm(conf)) {
			location.href='http://www.shape.gr/news/175';	
		}		
	}
	else {
	getObj(DIV).innerHTML = "<img src='http://www.shape.gr/myimages/ajax-loaderform.gif' width='16' height='16' style='padding-left:70px;'>"; 
	var httpReq = new ajaxObject('http://www.shape.gr/myincludes/contact_model.php', function fin(responseTxt,responseStat) {
	getObj(DIV).innerHTML = responseTxt; 
}
);
	var data = "";
	data += "username=" + getObj('fUsername').value;
	data += "&email=" + getObj('fEmail').value;		
	data += "&title=" + getObj('fTitle').value;			
	data += "&message=" + getObj('fMessage').value;			
	data += "&Action=SendSynt";
	httpReq.update(data,'POST');
	}
}

/* CONTACTS */

