/**
	CCR - Global Library (Projeto-global-lib) v: 0.1
	Developer(s):
		+ Diogo Silva (diogo.ferreira@hellointeractive.com.br)
*/

// Return GET params
function returnParam(url,paramName){
	for(var qs = url.split("&"), i=0; i < qs.length; i++)
		if(qs[i].indexOf(paramName)>=0)
			return qs[i].split("=")[1];
	return false;
}

// Flash Calls
function openLink(url) {
	if(!url.match('http')) {
		switch(url) {
			case "example": window.location = 'http://www.example.com.br/'; break;
			case "exampl2": doSomething(); return true; break;
			default: return false;
		}
	}else
		window.location = url;
	return true;
}

// Popup handler
function openPopup(u,n,w,h,o,c) {
	var l = t = 18;
	if (c) {
		l = (screen.availWidth-w) / 2;
		t = (screen.availHeight-h) / 2;
	}
	p = window.open(u,'pop_'+n,'left='+l+',top='+t+',width='+w+',height='+h+',scrollbars='+((o)?o:'1'));
}


var margin = 0;

function next(i) {
    var id = "fotos"+i;
    var thumbs=document.getElementById(id).getElementsByTagName('img').length;
    var deslocamento = parseInt(thumbs-4) * 111;
    if (margin >= -(deslocamento)) {
        margin -= 112;
        document.getElementById(id).style.left = margin + "px";
    }
}
 
function prev(i) {
    var id = "fotos"+i;
    if (margin != 0) {
        margin += 112;
        document.getElementById(id).style.left = margin + "px";
    }
}