function getPageScroll(){
	var xScroll, yScroll;
	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
		xScroll = document.body.scrollLeft;	
	}
	arrayPageScroll = new Array(xScroll,yScroll) 
	return arrayPageScroll;
}
/*---------------------------------------------------------------------------------------*/
function getPageSize(){
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}
/*---------------------------------------------------------------------------------------*/
var popTime;
function rmPop() {
   $('popUpList').style.display = 'none';
   $('sendEmail').style.display = 'none';
}
function removePopList() {
	popTime = setTimeout("rmPop()", 500);
}
function showPopList() {
   clearTimeout(popTime);	
   $('popUpList').style.display = 'block';
}

/*---------------------------------------------------------------------------------------*/

function BookMarkThis() {
 var title = 'Live Vote';
 var url = 'http:/www.book-this.com/index.php';
 if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite(url, title); 
	}
	else if(window.opera && window.print) { // Opera Hotlist
	  var mbm = document.createElement('a');
      mbm.setAttribute('rel','sidebar');
      mbm.setAttribute('href',url);
      mbm.setAttribute('title', title);
      mbm.click();
	}
}
/*---------------------------------------------------------------------------------------*/
function SendToFriends() {
   clearTimeout(popTime);
  $('popUpList').style.display = 'none';
  $('sendEmail').style.display = 'block';
}
/*---------------------------------------------------------------------------------------*/

function openLinks(serviceName) {
 var serviceName = serviceName;
 var destinationUrl = '';
 if ( serviceName == 'mySpace' ) {
	destinationUrl = 'http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.book-this.com%2F&t=Live-Vote+-+Social+Bookmarking+And+Sharing+Button&c=';
 }
 else if ( serviceName == 'faceBook' ) {
    destinationUrl = 'https://www.facebook.com/login.php?popup&next=http%253A%252F%252Fwww.facebook.com%252Fsharer.php%253Fu%253Dhttp%25253A%25252F%25252Fwww.book-this.com%25252F%2526t%253DSocial%252BBookmarking%252BAnd%252BSharing%252BButton'
 }
 else if ( serviceName == 'delicious' ) {
	destinationUrl = 'http://del.icio.us/post?url=http://www.book-this.com/&title=Social%20Bookmarking%20And%20Sharing+Button'; 
 }
 else if ( serviceName == 'digg' ) {
	destinationUrl = 'http://digg.com/submit?phase=2&url=http://www.book-this.com/'; 
 }
 else if ( serviceName == 'live' ) {
	destinationUrl = 'https://favorites.live.com/quickadd.aspx?marklet=1&mkt=en-us&url=http%3A%2F%2Fwww.book-this.com%2F&title=Social+Bookmarking+And+Sharing+Button&top=1';
 }
 else if ( serviceName == 'yahoo' ) {
	destinationUrl = 'http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://www.book-this.com&t=Social%20Bookmarking%20And%20Sharing+Button';
 }
 else if ( serviceName == 'all' ) {
	destinationUrl = 'http://www.book-this.com/bookmark.php?url=http://www.book-this.com&title=Social%20Bookmarking%20And%20Sharing+Button';
	//http://www.book-this.com/bookmark.php?Luser=abir&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)
 }
 window.open(destinationUrl,"live-vote","scrollbars=yes,menubar=no,width=620,height=500,resizable=yes,toolbar=no,location=no,status=no");
}

/*---------------------------------------------------------------------------------------*/
// get button page get-button.php
function showWhereToOption() {
  var val = $('where').value;
  ['blogginPlatForm','myspaceUser','Otherss'].each(function(e){$(e).hide();});
  if ( val == 'onblog' ) {
	 $('blogginPlatForm').show();
  }
  else if ( val == 'onmyspace' ) {
	 if ( $('btype').value == 'bookmarking')
	   $('myspaceUser').show();
	 else   
	   $('myspaceUser').hide();
  }
  else if ( val == 'ezine' ) {
	 if ( $('btype').value == 'bookmarking')
	    $('Otherss').show();
	 else   
	   $('Otherss').hide();
  }
}

/*---------------------------------------------------------------------------------------*/
// get button page get-button.php
function showFeedToOption() {
  var val = $('btype').value;
  if ( val == 'onfeed' ) { 
     $('showLookBookMark').hide();
	 $('showLookFeed').show();
	 $('forFeed').show();
  }
  else { 
     $('showLookBookMark').show();
	 $('showLookFeed').hide();
	 $('forFeed').hide();	 
  }
}
/*---------------------------------------------------------------------------------------*/

function sendEmail() {
  var to = $('sendTo').value;
  var from = $('sendFrom').value;
  var msg = $('sendMsg').value;
  if ( to.blank() || from.blank() || msg.blank() ) {
	 alert('Required Value Missing!!!');return false; 
  }
  var emailchar = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
  if (!emailchar.test(to)) {
	 alert('Invalid Email Address Given!!');return false;
  }
  $('processingEmail').style.display = 'inline';
  var parms = 'toEmail='+to+'&from='+from+'&msg='+msg;
  new Ajax.Request('./sendEmail.php', {method: 'post', parameters: parms, onComplete: function(e) {
	  if (e.responseText == 'success') { alert('Email Has Been Send Successfully'); }
	  else { alert('Could not send email. \nplease Try Later'); }
	   $('processingEmail').style.display = 'none';
	  removePopList();
  }});

}

/*---------------------------------------------------------------------------------------*/
function initialization() {
  Event.observe(document, 'mouseover', detectElm);
}
function detectElm(event) {
  var e = Event.findElement(event, 'div');
  if (typeof e != 'undefined') { 
     if(e.id != 'cont') {
       clearTimeout(popTime);
	   removePopList();
	 }
  }
}
document.observe('dom:loaded', initialization);
/*---------------------------------------------------------------------------------------*/











