function a(txt) { self.status = txt } function b() { self.status = "" }
function loadurl(dest) { try { xmlhttp = window.XMLHttpRequest?new XMLHttpRequest():
new ActiveXObject("Microsoft.XMLHTTP");}
catch (e) { }
xmlhttp.onreadystatechange = triggered; xmlhttp.open("GET", dest); xmlhttp.send(null);}
function triggered() { if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) { document.getElementById("rate").innerHTML = xmlhttp.responseText;}
}
if (document.images){ pic2 = new Image(25,75); pic2.src = "../../images/layout/icon/thumbsup.gif"; pic3 = new Image(25,75); pic3.src = "../../images/layout/icon/thumbsup2.gif";}
var xmlHttp
function GetXmlHttpObject(){ var xmlHttp = null; try { xmlHttp = new XMLHttpRequest();}
catch (e) { try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");}
catch (e){ xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");}
}
return xmlHttp;}
function rate(rating,id,show5,showPerc,showVotes){ xmlHttp = GetXmlHttpObject()
if(xmlHttp == null){ alert ("Your browser does not support AJAX!"); return;}
xmlHttp.onreadystatechange = function(){ var loader = document.getElementById('loading_'+id); var uldiv = document.getElementById('ul_'+id); if (xmlHttp.readyState == 4){ var res = xmlHttp.responseText; if(res == 'already_voted'){ loader.style.display = 'block';} else { loader.style.display = 'block'; if(show5 == true){ var out = document.getElementById('outOfFive_'+id); var calculate = res/20; out.innerHTML = Math.round(calculate*100)/100;}
if(showPerc == true){ var perc = document.getElementById('percentage_'+id); var newPerc = res; perc.innerHTML = newPerc+'%';}
else if(showPerc == false){ var newPerc = res;}
if(showVotes == true){ var votediv = document.getElementById('showvotes_'+id).firstChild.nodeValue; var splitted = votediv.split(' '); var newval = parseInt(splitted[0]) + 1; if(newval == 1){ document.getElementById('showvotes_'+id).innerHTML = newval+' Vote';} else { document.getElementById('showvotes_'+id).innerHTML = newval+' Votes';}
}
var ulRater = document.getElementById('rater_'+id); ulRater.className = 'star-rating2'; var all_li = ulRater.getElementsByTagName('li'); for(var i=1;i<all_li.length;i++){ all_li[i].getElementsByTagName('a')[0].onclick = 'return false;'; all_li[i].getElementsByTagName('a')[0].setAttribute('href','#');}
if(navigator.appName == 'Microsoft Internet Explorer'){ uldiv.style.setAttribute('width',newPerc+'%');} else { uldiv.setAttribute('style','width:'+newPerc+'%');}
}
} else { }
}
var url = "modules/rating/rating_process.php"; var params = "id="+id; xmlHttp.open("POST",url,true); xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlHttp.setRequestHeader("Content-length", params.length); xmlHttp.setRequestHeader("Connection", "close"); xmlHttp.send(params);}
var rootdomain="http://"+window.location.hostname
function ajaxinclude(url) { var page_request = false
if (window.XMLHttpRequest)
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ try { page_request = new ActiveXObject("Msxml2.XMLHTTP")
}
catch (e){ try{ page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
page_request.open('GET', url, false)
page_request.send(null)
writecontent(page_request)
}
function writecontent(page_request){ if (window.location.href.indexOf("http")==-1 || page_request.status==200)
document.write(page_request.responseText)
}
// crop
var img_main;
var selection;
var img_cover;

var thumb           = new Object();

var mouse           = new Object();
    mouse.xPos = 0;
    mouse.yPos = 0;
    mouse.isInSel = false;
    mouse.isInImg = false;

function initPage()
{
	img_main = document.getElementById('img_main');
	img_cover = document.getElementById('img_cover');
	selection = document.getElementById('selection');
	heightField = document.getElementById('thumbHeight');
	widthField = document.getElementById('thumbWidth');

    selection.style.cursor = 'move';
    selection.style.top    = 0;
    selection.style.left   = 0;
    selection.style.width  = 5;
    selection.style.height = 5;

    thumb.height    = heightField.value;
    thumb.width     = widthField.value;
    thumb.prop      = thumb.height/thumb.width;

    // Setup events
    document.onselectstart = selectStart;
    document.onmouseup     = mouseUp;
    window.onresize        = handleResize;

}
function changeHeight() {
	thumb.height = heightField.value;
    thumb.prop = thumb.height/thumb.width;
	resetSel();
}
function changeWidth() {
	thumb.width = widthField.value;
    thumb.prop      = thumb.height/thumb.width;
	resetSel();
}
function resetSel() {

    selection.style.top    = 0;
    selection.style.left   = 0;
    selection.style.width  = 5;
    selection.style.height = 5;

}
function selectStart(e)
{
    if( event )
    {
        event.cancelBubble = true;
    }

    return false;
}
function imageLoaded()
{
    img_main = document.getElementById('img_main');
    img_main.top  = getTop(img_main);
    img_main.left = getLeft(img_main);

	img_cover = document.getElementById('img_cover');
    img_cover.style.top    = img_main.top;
    img_cover.style.left   = img_main.left;
    img_cover.style.width  = img_main.width;
    img_cover.style.height = img_main.height;
}
function getLeft(obj)
{
	var curleft = 0;

    while(obj.offsetParent)
    {
        curleft += obj.offsetLeft;
        obj = obj.offsetParent;
    }

	return curleft;
}
function getTop(obj)
{
	var curtop = 0;

    while (obj.offsetParent)
    {
        curtop += obj.offsetTop;
        obj = obj.offsetParent;
    }

	return curtop;
}
function fillForm()
{
    document.thumbForm.selX.value      = parseInt(selection.style.left) - img_main.left;
    document.thumbForm.selY.value      = parseInt(selection.style.top) - img_main.top;
    document.thumbForm.selWidth.value  = parseInt(selection.style.width);
    document.thumbForm.selHeight.value = parseInt(selection.style.height);

    return true;
}
function moveSel(x, y)
{
    if( x < img_main.left ) x = img_main.left;
    else if( x + parseInt(selection.style.width) - img_main.left > img_main.width )
        x = img_main.width - parseInt(selection.style.width) + img_main.left;

    if( y < img_main.top ) y = img_main.top;
    else if( y + parseInt(selection.style.height) - img_main.top > img_main.height )
        y = img_main.height - parseInt(selection.style.height) + img_main.top;

    selection.style.left = parseInt(x);
    selection.style.top  = parseInt(y);
}
function resizeSel(width, height)
{
    if( height < 5 || width < 5 ) return;

    if (height/width > thumb.prop) width = (height/thumb.prop);
    else height = (thumb.prop * width);

    if( (parseInt(selection.style.top) - img_main.top) + height <= img_main.height && (parseInt(selection.style.left) - img_main.left) + width <= img_main.width )
    {
        selection.style.height   = height;
        selection.style.width    = width;
    }
}
function handleResize()
{
	img_main.top  = getTop(img_main);
	img_main.left = getLeft(img_main);

	img_cover.style.top    = img_main.top;
	img_cover.style.left   = img_main.left;
	img_cover.style.width  = img_main.width;
	img_cover.style.height = img_main.height;
}
function mouseUp()
{
    mouse.isInImg = false;
    mouse.isInSel = false;

    selection.style.cursor = 'move';
}
function mouseDownImg(e)
{
    if( !img_main.complete )
    {
        alert('Please wait for the image to load completely!');
        return;
    }


    if( !mouse.isInImg )
    {
        handleResize();

        mouse.isInImg = true;
        mouse.xPos = e.pageX ? e.pageX : e.offsetX + img_main.left;
        mouse.yPos = e.pageY ? e.pageY : e.offsetY + img_main.top;
      
        resizeSel(5, 5);
        moveSel(mouse.xPos, mouse.yPos);

        selection.style.visibility = 'visible';
        selection.style.cursor     = 'default';
    }
}
function mouseMoveImg(e)
{
    if( mouse.isInImg )
    {
        var new_x = e.pageX ? e.pageX : e.offsetX + img_main.left;
        var new_y = e.pageY ? e.pageY : e.offsetY + img_main.top;

        if( new_x > mouse.xPos && new_y > mouse.yPos )
        {
            resizeSel(new_x - mouse.xPos, new_y - mouse.yPos);
        }
    }
}
function mouseDownSel(e)
{
	mouse.isInSel = true;

	mouse.xPos = e.pageX ? e.pageX : e.x;
	mouse.yPos = e.pageY ? e.pageY : e.y;

	mouse.xPos -= parseInt(selection.style.left);
	mouse.yPos -= parseInt(selection.style.top);
}
function mouseMoveSel(e)
{
    if( mouse.isInImg )
    {
        img_cover.fireEvent('onmousemove', event);
		// mouseMoveImg(e);
    }
    else if( mouse.isInSel )
    {
        var destX = e.pageX ? e.pageX : e.x;
        var destY = e.pageY ? e.pageY : e.y;

        destX -= mouse.xPos;
        destY -= mouse.yPos;

        moveSel(destX, destY);
    }
}
//addthis
var  addthis_url   = '';
var  addthis_title = '';
var addthis_pub = 'K21X8ZQOYVPY72YV';
function addthis_click(obj, str){
 var aturl  = 'http://www.addthis.com/bookmark.php';
 aturl += '?v=10';
 aturl += '&pub='+addthis_pub;
 aturl += '&url='+encodeURIComponent(addthis_url);
 aturl += '&title='+encodeURIComponent(addthis_title);
 window.open(aturl,'addthis','scrollbars=yes,menubar=no,width=620,height=520,resizable=yes,toolbar=no,location=no,status=no,screenX=200,screenY=100,left=200,top=100');
 return false;
}

if (parent.frames.length > 0) {
    parent.location.href = self.document.location
}